Can't run useradd command through php script in RHEL 7
Red HatThis forum is for the discussion of Red Hat Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Can't run useradd command through php script in RHEL 7
I am making a college project which is on Web Hosting and I have made up a php page in which I have added useradd command. I have given root privileges to apache entered in /etc/sudoers file but it's still not working.
script
-----------------------
<?php>
$p="mayank";
$i=`sudo useradd $p`;
?>
------------------------
Last edited by mayank4aug; 04-06-2015 at 12:33 PM.
Does apache user has got /usr/sbin/useradd in the search path, if not then you have to use to run the command as: sudo /usr/sbin/useradd. In sudoers file also specify full path to useradd to be used with sudo.
You did not answer the other question I asked. Did you give full path for useradd in your php script? If not did you try giving full path? Did it work?
When you run su - apache and then run "which useradd" without quotes what do you get?
You are using a service account. When it says this account is not available check in /etc/passwd and see if it set to /sbin/nologin or /bin/false. Not sure why you need apache account to do the password reset, you can link any other account in the backend to do that. It is not a good idea to provide shell access to service account, still you want to do it for testing purpose you can do but not at all advisable in production
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.