forked from lix-project/lix
SSH.pm: Print a friendlier message if connecting fails
"got EOF while expecting 8 bytes from remote side" is not very helpful.
This commit is contained in:
parent
087581a642
commit
d436e44ae3
|
@ -57,6 +57,7 @@ sub copyTo {
|
||||||
if ($@) {
|
if ($@) {
|
||||||
chomp $@;
|
chomp $@;
|
||||||
warn "$@; falling back to old closure copying method\n";
|
warn "$@; falling back to old closure copying method\n";
|
||||||
|
$@ = "";
|
||||||
return oldCopyTo(@_);
|
return oldCopyTo(@_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package Nix::SSH;
|
package Nix::SSH;
|
||||||
|
|
||||||
|
use utf8;
|
||||||
use strict;
|
use strict;
|
||||||
use File::Temp qw(tempdir);
|
use File::Temp qw(tempdir);
|
||||||
use IPC::Open2;
|
use IPC::Open2;
|
||||||
|
@ -89,10 +90,16 @@ sub connectToRemoteNix {
|
||||||
my $pid = open2($from, $to, "exec ssh -x -a $sshHost @globalSshOpts @{$sshOpts} nix-store --serve --write $extraFlags");
|
my $pid = open2($from, $to, "exec ssh -x -a $sshHost @globalSshOpts @{$sshOpts} nix-store --serve --write $extraFlags");
|
||||||
|
|
||||||
# Do the handshake.
|
# Do the handshake.
|
||||||
|
my $magic;
|
||||||
|
eval {
|
||||||
my $SERVE_MAGIC_1 = 0x390c9deb; # FIXME
|
my $SERVE_MAGIC_1 = 0x390c9deb; # FIXME
|
||||||
my $clientVersion = 0x200;
|
my $clientVersion = 0x200;
|
||||||
syswrite($to, pack("L<x4L<x4", $SERVE_MAGIC_1, $clientVersion)) or die;
|
syswrite($to, pack("L<x4L<x4", $SERVE_MAGIC_1, $clientVersion)) or die;
|
||||||
die "did not get valid handshake from remote host\n" if readInt($from) != 0x5452eecb;
|
$magic = readInt($from);
|
||||||
|
};
|
||||||
|
die "unable to connect to ‘$sshHost’\n" if $@;
|
||||||
|
die "did not get valid handshake from remote host\n" if $magic != 0x5452eecb;
|
||||||
|
|
||||||
my $serverVersion = readInt($from);
|
my $serverVersion = readInt($from);
|
||||||
die "unsupported server version\n" if $serverVersion < 0x200 || $serverVersion >= 0x300;
|
die "unsupported server version\n" if $serverVersion < 0x200 || $serverVersion >= 0x300;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue