From: Matt S Trout Date: Sat, 2 Jun 2012 17:22:00 +0000 (+0000) Subject: password callback working X-Git-Tag: v0.001001~35 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FObject-Remote.git;a=commitdiff_plain;h=dac97b35627e705e87c7b9130b1c60d8ef217334;hp=7efea51f193cf42822232047403138ef98abcc32 password callback working --- diff --git a/lib/Object/Remote/Connector/LocalSudo.pm b/lib/Object/Remote/Connector/LocalSudo.pm index c6bad11..6eed5e6 100644 --- a/lib/Object/Remote/Connector/LocalSudo.pm +++ b/lib/Object/Remote/Connector/LocalSudo.pm @@ -36,6 +36,9 @@ sub _start_perl { unless $cb; print $foreign_stdin $cb->($line, @_), "\n"; chomp($line = <$sudo_stderr>); + die "sent password and expected newline from sudo, got ${line}" + if $line; + chomp($line = <$sudo_stderr>); die "sent password but next line was ${line}" unless $line eq "GO"; } else { diff --git a/xt/local-sudo.t b/xt/local-sudo.t index b1a7fa6..c1f3d3a 100644 --- a/xt/local-sudo.t +++ b/xt/local-sudo.t @@ -1,13 +1,24 @@ +use IO::Prompter; # dies, utterly, if loaded after strictures, no idea why use strictures 1; use Test::More; use lib 'xt/lib'; use Object::Remote; +use Object::Remote::Connector::LocalSudo; + my $user = $ENV{TEST_SUDOUSER} or plan skip_all => q{Requires TEST_SUDOUSER to be set}; -my $remote = TestFindUser->new::on($user . '@'); +my $pw; + +my $connector = Object::Remote::Connector::LocalSudo->new( + password_callback => sub { + $pw ||= prompt 'Sudo password', -echo => '*'; + } +); + +my $remote = TestFindUser->new::on($connector->connect($user)); my $remote_user = $remote->user; like $remote_user, qr/^\d+$/, 'returned an int'; isnt $remote_user, $<, 'ran as different user';