我sudo
在Debian 8上遇到了一个很奇怪的问题。用户无法在中执行某些命令/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
#
为注释并作为指令的一部分,也是无视文件。有趣的是(激怒的)visudo -f some.file
没有警告说退出时很可能会忽略它。通过简单的投票就可以使信天翁信服。