is possible the line "apache ALL=(root) NOPASSWD:ALL" into [/etc/sudoers.d/file.test] ?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
thanks, same result:1
about apache LOG bingo!, new info (but I not understand):
Code:
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
sudo: no tty present and no askpass program specified
sh: /sys/class/gpio/gpio18/direction: Permission denied
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
sudo: no tty present and no askpass program specified
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
sudo: no tty present and no askpass program specified
sh: /sys/class/gpio/gpio18/direction: Permission denied
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
sudo: no tty present and no askpass program specified
You can try adding the apache user to the gpio group.
I do not know the difference between CentOS running on a Pi and a regular desktop. Make sure the file in the /etc/sudoers.d directory has permission 0440.
You can try the non-interactive option -n but its just a guess.
I've seen one thread where the OP created the gpio group and added their user but I don't know if this will work.
What groups does your regular user belong?
Then your PHP code ("exec('sudo /sbin/reboot');" )
...will work.
Beyond that, you are doing a *HUGELY BAD THING* by doing this. The number of attack vectors you are opening up on your system is enormous, for no really good reason. There are LOADS of ways to do what you're after that are far better. And if all you want to do is reboot the machine over the network, why on earth aren't you using SNMP???
Essentially you are trying to run a cgi command with that php script.
Is your system (web server) set up to allow cgi scripts to execute from the directory where that file is located? Is it also set up to allow commands with root permissions to execute from that directory?
I think this may have no bearing on the php script, but may instead be a feature of security built into the web server to protect the system from potential hackers. We would need to look at this type of security to see if executing a command as root from the web page is even possible. I know that script execution is restricted except as specifically authorized and even then scripts are limited.
One workaround may be to have that script write to a specific file (which would only require the normal user permissions for the apache user), then have something such as a cron job that frequently checks if the file exists. If it does then delete the file & reboot and if not do nothing.
Then your PHP code ("exec('sudo /sbin/reboot');" )
...will work.
thanks master.
When I try save file with TWO options:
1// the same THREE columns but ADD the text "!requiretty":
Code:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
pp ALL=(ALL) NOPASSWD:ALL
apache !requiretty ALL=(ALL) NOPASSWD:ALL
php ALL=(ALL) NOPASSWD:ALL
2// FOUR columns:
Code:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
pp ALL=(ALL) NOPASSWD:ALL
apache !requiretty ALL=(ALL) NOPASSWD:ALL
php ALL=(ALL) NOPASSWD:ALL
in both cases when I try save file the result is:
Code:
[root@localhost ~]# visudo
>>> /etc/sudoers: syntax error near line 102 <<<
What now? cat /var/log/httpd/error.log
Options are:
(e)dit sudoers file again
e(x)it without saving changes to sudoers file
(Q)uit and save changes to sudoers file (DANGER!)
What now? e
>>> /etc/sudoers: syntax error near line 102 <<<
What now?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.