Link to home
Start Free TrialLog in
Avatar of iqula
iqula

asked on

sudo not working for apache in php

I am trying tp get php to add a system user using sudo on redhat 9.  
Apache is running under user apache, the PHP and sudo command (sudo /usr/sbin/useradd -gpods -d/home/test11 -m test11 -p q) is correct I have edited the visudo for both users apache and steve, when I type in the command (under user steve) it works, but not when running it from php

$output = system("sudo /usr/sbin/useradd -gpods -d/home/test11 -m test11 -p q", $result1);

$result1 comes out as 127

any clues as it runs fine on suse 9.1
Avatar of veedar
veedar
Flag of United States of America image

I assume it works by hand when you try it.

As a test replace useradd with /usr/bin/id
Does it say your root?
Avatar of iqula
iqula

ASKER

Thanks for that I have discovered that a 127 is some sort of PHP system error code, I tryed what you suggested and a few other non (root/sudo) commands like whoami and get the same result 127.  I think it has something to do with with PHP running the system command, I get the same result with exec and passthru.

any ideas would be appreciated
ASKER CERTIFIED SOLUTION
Avatar of manav_mathur
manav_mathur

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of iqula

ASKER

I had to add the ini file so apache could run it.