Subject: | A couple of t/Net-SSH2.t bugs (Win32) |
Hi,
When I build Net-SSH2-0.18 (and earlier) on Win32 I find I need to make
the following changes to t/Net-SSH2.t:
1) Replace:
# (3) authentication methods
unless ($user) {
my $def_user = getpwuid $<;
print "\nEnter username [$def_user]: ";
chomp($user = <STDIN>);
$user ||= $def_user;
}
with:
# (3) authentication methods
unless ($user) {
my $def_user;
$def_user = getpwuid $< if $^O !~ /mswin/i;
print $def_user ? "\nEnter username [$def_user]: " : "\nEnter
username: ";
chomp($user = <STDIN>);
$user ||= $def_user;
}
2) Replace:
# (2) authenticate
@auth = $pass ? (password => $pass) : (interact => 1);
my $type = $ssh2->auth(username => $user, @auth);
ok($type, "authenticated via: $type");
SKIP: { # SKIP-auth
skip '- failed to authenticate with server', 37 unless $ssh2->auth_ok;
pass('authenticated successfully');
with:
# (2) authenticate
@auth = $pass ? (password => $pass) : (interact => 1);
#'interact => 1' not currently working on win32.
if($^O =~ /mswin/i && !$pass) {
print "\nEnter password (NOTE: Your password will be printed to the
console in plain text - for all to see !!!)... or hit 'Ctrl-C' to abort
the test: ";
chomp($pass = <STDIN>);
@auth = (password => $pass);
}
I believe both amendments are portable - though, admittedly, the second
fix is a little agricultural, and could well be refined somewhat. I
suppose that a better fix would be to get "interact => 1" working on
Win32.
Cheers,
Rob