[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v4 02/11] osstest: add routine to execute ssh with password



On Wed, 2015-02-18 at 17:18 +0100, Roger Pau Monne wrote:
> This is needed when bootstrapping FreeBSD, since the installer has ssh
> enabled with the root password set to 'root' by default.

I think the commit message should mention the refactoring done WRT
$stdout vs $child_sub (i.e. you are replacing the boolean with a hook,
where the current invocations do the same thing as the old boolean used
to cause).

I also think the trick with SSH_ASKPASS deserves a brief mention.

> @@ -585,9 +585,42 @@ sub tcmd { # $tcmd will be put between '' but not escaped
>  sub target_cmd ($$;$) { tcmd(undef,'osstest',@_); }
>  sub target_cmd_root ($$;$$) { tcmd(undef,'root',@_); }
>  
> +sub target_cmd_root_with_password {
> +    my ($ho,$tcmd,$timeout,$password, $disable_hosts) = @_;
> +    my $temp_name = "tmp/t.ssh-password-helper.$flight.$job";
> +
> +    open(my $temp_fh, '>', $temp_name)
> +      or die "Cannot open $temp_name: $!";
> +    print $temp_fh "#!/bin/sh\n\necho \"$password\"\n"
> +      or die "Cannot write to $temp_name: $!";
> +    chmod 0755, $temp_name
> +      or die "Cannot chmod $temp_name: $!";
> +    close $temp_fh
> +      or die "Cannot close $temp_name: $!";
> +
> +    my $child_sub = sub {
> +                           $ENV{DISPLAY} = ":0";

? This seems like it must be pretty magic, in some terribly scary way...

> +                           $ENV{SSH_ASKPASS} = 
> "tmp/t.ssh-password-helper.$flight.$job";
> +                           setsid or die "Can't start a new session: $!";
> +                        };
> +
> +    my $ssh_opts = [qw(-o BatchMode=no
> +                       -o PasswordAuthentication=yes
> +                       -o ChallengeResponseAuthentication=yes),
> +                    @{ sshopts($disable_hosts) }];
> +
> +    tcmdex($timeout,$child_sub,
> +           'ssh', $ssh_opts,
> +           sshuho("root",$ho), $tcmd);
> +
> +    unlink $temp_fh;
> +}
> +
>  sub tcmdout {
>      my $stdout= IO::File::new_tmpfile();
> -    tcmd($stdout,@_);
> +    my $stdout_sub = sub { open STDOUT, '>&', $stdout
> +                              or die "STDOUT $stdout $!"; };
> +    tcmd($stdout_sub,@_);
>      $stdout->seek(0,0) or die "$stdout $!";
>      my $r;
>      { local ($/) = undef;



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.