Skip Menu |

This queue is for tickets about the POE CPAN distribution.

Report information
The Basics
Id: 49380
Status: rejected
Priority: 0/
Queue: POE

People
Owner: Nobody in particular
Requestors: brad [...] divisionbyzero.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 1.007
  • 1.020
Fixed in: (no value)



Subject: Use of sudo in POE::Wheel::Run causes a stall.
See Attached sample program.. Using sudo to execute a command via the Program argument to POE::Wheel::Run causes the program to stall. Simply removing sudo, fixes the problem. Suspecting a subshell issue, I created a script which called bash as a login shell and executed the command. Calling that script in POE runs fine. Apparently there is something not successfully happening with POE::Wheel::Run and sudo.. also tried playing with NoSetSid and NoSetPgrp to no avail. Verified on #poe@irc.perl.org to be reproducible. Tested with 1.007 and 1.021 on CentOS 5.3 with Perl 5.8.8.
Subject: POE-sudo.pl
#!/usr/bin/perl use strict; use warnings; use POE qw( Wheel::Run Filter::Line );; POE::Session->create( inline_states => { _start => \&processor_start, _stop => sub { }, run_lsof => \&processor_run_lsof, lsof_line => \&processor_show_line, lsof_close => \&processor_lsof_close, }); POE::Kernel->run(); sub processor_start { my ($kernel,$heap) = @_[KERNEL,HEAP]; $kernel->alias_set( 'processor' ); $kernel->yield( 'run_lsof' ); } sub processor_run_lsof { my ($kernel,$heap) = @_[KERNEL,HEAP]; my @CMD = qw(/usr/bin/sudo /usr/sbin/lsof -i -n); print "Running @CMD\n"; $heap->{lsof_job} = POE::Wheel::Run->new( Conduit => 'pty-pipe', Program => \@CMD, StdioFilter => POE::Filter::Line->new(), StderrFilter => POE::Filter::Line->new(), StdoutEvent => 'lsof_line', StderrEvent => 'lsof_line', CloseEvent => 'lsof_close', ); print " + Job Started.\n"; } sub processor_show_line { my ($kernel,$heap,$line) = @_[KERNEL,HEAP,ARG0]; print "got: $line\n"; } sub processor_lsof_close { my ($kernel,$heap) = @_[KERNEL,HEAP]; print "Job Done\n"; $kernel->delay_add( 'run_lsof', 60 ); }
Sorry, but this isn't a POE problem. Change POE::Filter::Line->new() to POE::Filter::Stream->new(), and you will see that the program is waiting for sudo's password prompt: % perl rt49380.pl Running /usr/bin/sudo /usr/sbin/lsof -i -n + Job Started. got: Password: ^C POE::Filter::Line returns complete lines, which means that the newline must be present before a line is returned. The password prompt doesn't end with a newline, so it's waiting in POE::Filter::Line's buffer. POE::Filter::Stream is not line-buffered, so it returns data right away. You may be able to configure sudo not to ask for a password when running lsof. In that case, POE::Wheel::Run with POE::Filter::Line should work as expected.
It's not a sudo problem either, it appears to be a problem with perl's fork(). Add this to /etc/sudoers: %group_im_in ALL=NOPASSWD:/usr/sbin/lsof Then run 'sudo lsof' to ensure there's no sudo config problems. Create test.pl: #!/usr/bin/perl exec(qw(/usr/bin/sudo /usr/sbin/lsof -i -n)); Run, and it works.. Now add a fork(): #!/usr/bin/perl my $pid = fork; unless ($pid ) { exec(qw(/usr/bin/sudo /usr/sbin/lsof -i -n)); } And you're prompted for a password.. I'm not sure I'm smart enough to understand why this is happening. $<, $>, $(, and $) are all correct.. On Thu Sep 03 19:47:28 2009, RCAPUTO wrote: Show quoted text
> Sorry, but this isn't a POE problem. > > Change POE::Filter::Line->new() to POE::Filter::Stream->new(), and you > will see that the program is waiting for sudo's password prompt: > > % perl rt49380.pl > Running /usr/bin/sudo /usr/sbin/lsof -i -n > + Job Started. > got: Password: > ^C > > POE::Filter::Line returns complete lines, which means that the newline > must be present before a line is returned. The password prompt doesn't > end with a newline, so it's waiting in POE::Filter::Line's buffer. > > POE::Filter::Stream is not line-buffered, so it returns data right away. > > You may be able to configure sudo not to ask for a password when running > lsof. In that case, POE::Wheel::Run with POE::Filter::Line should work > as expected.
Attempted to recreate on another system and was unable to. closing.. sorry for the noise..