I want to restart a linux service from a shell CGI script, which obviously requires root rights. I'm kind of out of options that I know of:
setuid
on my CGI script doesn't work and people say it's generally a bad idea What are the best practices of doing something like that?
Another option is to use a sudoer . As a best practice always provide the apache user as little rights as it needs.
Edit the sudoers file with sudo visudo
and add a line
apache ALL = NOPASSWD: /usr/sbin/service /usr/local/myapp *
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.