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`; ?> ------------------------ |
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.
|
my sudoers entry is like this..
apache ALL = (ALL) NOPASSWD:ALL |
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? |
Yes, I have appended the /usr/sbin/useradd path in sudoers like this.
apache ALL=NOPASSWD: /usr/sbin/useradd but still not working. when I run su - apache it says "This account is currently not available" echo,touch commands are working through php but systemctl,useradd like are not working. |
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
|
I want to make it for my college project.
-Ok I have added a user named mayank shell /bin/bash -Entered path for mayank in sudoers -Created a php script <?php> $p="mayank"; $i=`sudo useradd $p`; ?> -still not working. I have changed the user in httpd.conf as mayank Same configuration works in RHEL 4 but not in RHEL 7. |
Selinux is enforcing in rhel 7 by default. That might require some tweaking.
|
All times are GMT -5. The time now is 12:16 AM. |