这种组合合法吗:
username ALL=(ALL) NOPASSWD: /usr/bin/foo, PASSWD:ALL
或者它们是否相互冲突或相互抵消?
答案1
看着sudoers
手册页我想说你可以一起做:
Tag_Spec
A command may have zero or more tags associated with it. There are eight
possible tag values, NOPASSWD, PASSWD, NOEXEC, EXEC, SETENV, NOSETENV,
LOG_INPUT, NOLOG_INPUT, LOG_OUTPUT and NOLOG_OUTPUT. Once a tag is set on
a Cmnd, subsequent Cmnds in the Cmnd_Spec_List, inherit the tag unless it
is overridden by the opposite tag (i.e.: PASSWD overrides NOPASSWD and
NOEXEC overrides EXEC).
将会PASSWD:ALL
覆盖NOPASSWD
之后的。手册页中甚至还有一个示例显示了您正在尝试的内容。
默认情况下,sudo 要求用户在运行命令之前对自己进行身份验证。可以通过 NOPASSWD 标签修改此行为。与 Runas_Spec 类似,NOPASSWD 标记为 Cmnd_Spec_List 中跟随它的命令设置默认值。相反,PASSWD 标签可用于逆转事情。例如:
ray rushmore = NOPASSWD: /bin/kill, PASSWD: /bin/ls, /usr/bin/lprm