fix LocalSudo, broken in 2012 by mst being an idiot
[scpubgit/Object-Remote.git] / lib / Object / Remote / Connector / LocalSudo.pm
index 044d106..47dead4 100644 (file)
@@ -1,5 +1,6 @@
 package Object::Remote::Connector::LocalSudo;
 
+use Object::Remote::Logging qw (:log :dlog);
 use Symbol qw(gensym);
 use Module::Runtime qw(use_module);
 use IPC::Open3;
@@ -24,11 +25,12 @@ has sudo_perl_command => (is => 'lazy');
 
 sub _build_sudo_perl_command {
   my ($self) = @_;
-  return
+  return [
     'sudo', '-S', '-u', $self->target_user, '-p', "[sudo] password please\n",
     'perl', '-MPOSIX=dup2',
             '-e', 'print STDERR "GO\n"; exec(@ARGV);',
-    $self->perl_command;
+    @{$self->perl_command},
+  ];
 }
 
 sub _start_perl {
@@ -64,14 +66,11 @@ sub _start_perl {
                 ->watch_io(
                     handle => $sudo_stderr,
                     on_read_ready => sub {
-  #TODO is there a specific reason sysread() and syswrite() aren't
-  #a part of ::MiniLoop? It's one spot to handle errors and other
-  #logic involving filehandles
                       Dlog_debug { "LocalSudo: Preparing to read data from $_" } $sudo_stderr;
                       if (sysread($sudo_stderr, my $buf, 32768) > 0) {
                         log_trace { "LocalSudo: successfully read data, printing it to STDERR" };
                         print STDERR $buf;
-                        log_trace { "LocalSudo: print() to STDERR is done" };                   
+                        log_trace { "LocalSudo: print() to STDERR is done" };
                       } else {
                         log_debug { "LocalSudo: received EOF or error on file handle, unwatching it" };
                         Object::Remote->current_loop