我的sudoers.d/nginx
文件中有以下内容:
deployer ALL=NOPASSWD: /etc/init.d/nginx reload
Run Code Online (Sandbox Code Playgroud)
如果我以 sudo 身份运行命令,这会起作用:
$ sudo /etc/init.d/nginx start
[sudo] password for deployer:
Sorry, user deployer is not allowed to execute '/etc/init.d/nginx start' as root on graduation.
Run Code Online (Sandbox Code Playgroud)
但是,当我以非 sudo运行命令时,似乎 sudoers 被通过了。该命令仍然不起作用,但这是因为其他所有权错误,而不是 sudoers 中的限制:
$ /etc/init.d/nginx start
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2012/12/30 20:59:49 [warn] 30054#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:12
2012/12/30 20:59:49 …
Run Code Online (Sandbox Code Playgroud)