Fix ‘nixos-container run’
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
This commit is contained in:
parent
abe9fb340e
commit
fec3b75e4b
1 changed files with 6 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue