My guess is that since you're running sudo, sudo itself is asking for a password *for the nobody/apache account*, where it's set up not to ask you for a password (which is bad mojo), or you already ran sudo once and you've got a valid ticket.
Paul Archer 11:38am, Andrew Gaffney wrote: > I'm designing a simplified user management interface, similar to Webmin's. Since I'm > using > mod_perl, I just allowed the 'apache' user to execute certain commands using sudo. > I've > written a command line version that works just fine: > > <code> > #!/usr/bin/perl > > use Expect; > > my $user = shift; > my $password = shift; > print "Running 'sudo passwd ${user}'\n"; > my $exp = Expect->spawn("sudo passwd ${user}") or die "Can't run 'sudo passwd > ${user}'\n"; > if($exp->expect(10, -re => 'New UNIX password: $')) { > print $exp "${password}\n"; > } > if($exp->expect(10, -re => 'Retype new UNIX password: $')) { > print $exp "${password}\n"; > } > </code> > > but when I change it to CGI, it doesn't: > > <code> > #!/usr/bin/perl > > use Expect; > use CGI; > > my $cgi = new CGI; > my $p = $cgi->Vars; > > print $cgi->header; > my $exp = Expect->spawn("sudo passwd $p->{user}") or die "Can't run 'sudo passwd > $p->{user}'\n"; > if($exp->expect(10, -re => '^New UNIX password: $')) { > print $exp "$p->{password}\n"; > } else { > print "Never saw first password prompt<br>"; > } > if ($exp->expect(10, -re => '^Retype new UNIX password: $')) { > print $exp "$p->{password}\n"; > } else { > print "Never saw second password prompt<br>"; > } > $exp->soft_close(); > </code> > > When I run the CGI will the same parameters as the command line version, I get: > > New UNIX password: New UNIX password: New UNIX password: passwd: Conversation error > Never > saw first password prompt > > where the command line version gives me: > > Running 'sudo passwd agaffney' > New UNIX password: > BAD PASSWORD: it is too short > Retype new UNIX password: > > and actually changes the password. Does anyone have any idea what's going on? > > -- > Andrew Gaffney > Network Administrator > Skyline Aeronautics, LLC. > 636-357-1548 > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > ------------------------------------------------------------------------ Jan Lewis, one of Microsoft's earliest employees, provides this helpful translation of Judge Jackson's 43-page opinion into "Windowese": You have performed an illegal operation and will be shut down. ------------------------------------------------------------------------ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>