简体   繁体   中英

How to execute a privileged action from a CGI script

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:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM