cuongvt Posted May 22, 2009 Share Posted May 22, 2009 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: %apache ALL=(ALL) NOPASSWD: ALL %tony ALL=(ALL) NOPASSWD: ALL My test.php í: <?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. Quote Link to comment https://forums.phpfreaks.com/topic/159238-apache-user-cannot-execute-useradd-via-sudo/ Share on other sites More sharing options...
Axeia Posted May 22, 2009 Share Posted May 22, 2009 Check your existing users, the user isn't apache it's iirc wwwrun. Quote Link to comment https://forums.phpfreaks.com/topic/159238-apache-user-cannot-execute-useradd-via-sudo/#findComment-839939 Share on other sites More sharing options...
cuongvt Posted May 23, 2009 Author Share Posted May 23, 2009 >Check your existing users, the user isn't apache it's iirc wwwrun. Are you sure it is wwwrun, not apache in centos? AFAIK, the user is wwwrun in SUSE, apache in centos/redhat and www-data in debian/ubuntu. anyway I added wwwrun ALL=(ALL) NOPASSWD: ALL into /etc/sudoers but still not works. any idea? thanks and regards Quote Link to comment https://forums.phpfreaks.com/topic/159238-apache-user-cannot-execute-useradd-via-sudo/#findComment-840474 Share on other sites More sharing options...
trq Posted May 23, 2009 Share Posted May 23, 2009 Why don't you check what user apache is actually running as? grep User /etc/apache/httpd.conf Quote Link to comment https://forums.phpfreaks.com/topic/159238-apache-user-cannot-execute-useradd-via-sudo/#findComment-840478 Share on other sites More sharing options...
cuongvt Posted May 23, 2009 Author Share Posted May 23, 2009 ok. I'll check now (your specified path /etc/apache/httpd.conf is not correct). Thanks for the reply. I'm working overtime on this sartuday (and sunday maybe) for solving this so do not leave me alone. I'll report you back Quote Link to comment https://forums.phpfreaks.com/topic/159238-apache-user-cannot-execute-useradd-via-sudo/#findComment-840482 Share on other sites More sharing options...
cuongvt Posted May 23, 2009 Author Share Posted May 23, 2009 i checked. As I expected, User is apache, group is apache. Could you give me some other hints? (If I run above php script via shell by another user assigned executing sudo in sudoers, this script ran fine) thanks and regards Quote Link to comment https://forums.phpfreaks.com/topic/159238-apache-user-cannot-execute-useradd-via-sudo/#findComment-840485 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.