apache user cannot execute useradd via sudo :(

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cuongvt
Forum Newbie
Posts: 11
Joined: Fri Aug 11, 2006 1:31 am

apache user cannot execute useradd via sudo :(

Post by cuongvt »

Hi all
My server is centos 5.1 with php 5.1.6.
In my app I want apache to add user through sudo.

My sudoers file is:

Code: Select all

 
%apache ALL=(ALL) NOPASSWD: ALL
%tony ALL=(ALL) NOPASSWD: ALL
 
My test.php í:

Code: Select all

 
<?php
$username="hixhix";
system("/usr/bin/sudo /usr/sbin/useradd -s /sbin/nologin -M $username",$returnvalue);
echo "return value: $returnvalue";
 
However, user 'hixhix' not created by apache at all, it always returned 1.
how can I make my apache tu add user using sudo?
Please help me. I need your help.
Thanks and regards.
Last edited by Benjamin on Fri May 22, 2009 9:39 am, edited 1 time in total.
Reason: Added [code] and [code=php] tags.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: apache user cannot execute useradd via sudo :(

Post by Benjamin »

:arrow: Moved to PHP - Code
Post Reply