这行文字来自我的Ubuntu 14.04。
root ALL=(ALL:ALL) ALL
第三个ALL
的含义是什么?
上述行与root ALL=(ALL) ALL
有何区别?
root ALL=(ALL:ALL) ALL
第三个ALL
的含义是什么?
上述行与root ALL=(ALL) ALL
有何区别?
sudoers
manpage可能有点令人生畏,但其中提供了一些示例来帮助澄清事情:
我们可以推断,给定一个形式为dgb boulder = (operator) /bin/ls, (root) /bin/kill, /usr/bin/lprm
Then user
dgb
is now allowed to run/bin/ls
asoperator
, but/bin/kill
and/usr/bin/lprm
asroot
.We can extend this to allow
dgb
to run/bin/ls
with either the user or group set tooperator
:dgb boulder = (operator : operator) /bin/ls, (root) /bin/kill,\ /usr/bin/lprm
sudoers
的行:A B = (C:D) E
D
指的是可以使用的组。
因此,第三个ALL
表示用户可以在任何组下运行该命令。
(ALL)
而不是 (ALL:ALL)
,那么该用户不能在那些命令中使用 sudo -g
。Runas_Spec
A Runas_Spec determines the user and/or the group that a command may
be run as. ... The second defines a list of groups that
can be specified via `sudo`'s `-g` option. If both Runas_Lists are
specified, the command may be run with any combination of users and
groups listed in their respective Runas_Lists. If only the first is
specified, the command may be run as any user in the list but no `-g`
option may be specified.
boulder
是一个主机名。在大多数常见的情况下,你只需要使用ALL
来匹配所有的主机。 - muru