我在 Debian 8 上有一个相当奇怪的问题sudo
。用户无法在/etc/sudoers.d
. 我使用 Chef 来分发配置,因此所有文件都是自动生成的。
例子:
此配置工作正常
root@server:~# cat /etc/sudoers.d/nginx
# This file is managed by Chef.
# Do NOT modify this file directly.
user ALL=(root) NOPASSWD:/usr/sbin/nginx
这失败了:
root@server:~# cat /etc/sudoers.d/update-rc.d
# This file is managed by Chef.
# Do NOT modify this file directly.
user ALL=(root) NOPASSWD:/usr/sbin/update-rc.d
user@www42:~$ sudo update-rc.d
[sudo] password for user:
Sorry, user user is not allowed to execute '/usr/sbin/update-rc.d' as root on server.
有什么问题?
诊断:
Mar 5 12:12:51 server sudo: user : command not allowed ; TTY=pts/0 ; PWD=/home/user ; USER=root ; COMMAND=/usr/sbin/update-rc.d
Mar 5 12:14:25 www42 su[1209]: pam_unix(su:session): session closed for user user
root@server:~# sudo --version
Sudo version 1.8.10p3
Configure options: --prefix=/usr -v --with-all-insults --with-pam --with-fqdn --with-logging=syslog --with-logfac=authpriv --with-env-editor --with-editor=/usr/bin/editor --with-timeout=15 --with-password-timeout=0 --with-passprompt=[sudo] password for %p: --disable-root-mailer --with-sendmail=/usr/sbin/sendmail --with-rundir=/var/lib/sudo --mandir=/usr/share/man --libexecdir=/usr/lib/sudo --with-sssd --with-sssd-lib=/usr/lib/x86_64-linux-gnu --with-selinux --with-linux-audit
Sudoers policy plugin version 1.8.10p3
Sudoers file grammar version 43