From fec3b75e4bba045178bfb4b9ba1e2aa8c55447f5 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 25 Apr 2014 17:04:51 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20=E2=80=98nixos-container=20run=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default, socat only waits 0.5s for the remote side to finish after getting EOF on the local side. So don't close the local side, instead wait for socat to exit when the remote side finishes. http://hydra.nixos.org/build/10663282 --- nixos/modules/virtualisation/nixos-container.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nixos/modules/virtualisation/nixos-container.pl b/nixos/modules/virtualisation/nixos-container.pl index 2fd41a340962..8a1e6f927b30 100644 --- a/nixos/modules/virtualisation/nixos-container.pl +++ b/nixos/modules/virtualisation/nixos-container.pl @@ -212,18 +212,22 @@ elsif ($action eq "root-login") { elsif ($action eq "run") { shift @ARGV; shift @ARGV; - open(SOCAT, "|-", $socat, "unix:$root/var/lib/run-command.socket", "-"); + my $pid = open(SOCAT, "|-", $socat, "-t0", "-", "unix:$root/var/lib/run-command.socket") or die "$0: cannot start $socat: $!\n"; print SOCAT join(' ', map { "'$_'" } @ARGV), "\n"; + flush SOCAT; + waitpid($pid, 0); close(SOCAT); } elsif ($action eq "set-root-password") { # FIXME: don't get password from the command line. my $password = $ARGV[2] or die "$0: no password given\n"; - open(SOCAT, "|-", $socat, "unix:$root/var/lib/run-command.socket", "-"); + my $pid = open(SOCAT, "|-", $socat, "-t0", "-", "unix:$root/var/lib/run-command.socket") or die "$0: cannot start $socat: $!\n"; print SOCAT "passwd\n"; print SOCAT "$password\n"; print SOCAT "$password\n"; + flush SOCAT; + waitpid($pid, 0); close(SOCAT); }