分页: 1 / 1

请问如何禁止sudo用户修改/etc/sudoers的问题?

发表于 : 2015-08-18 16:33
qyecst
我以root修改/etc/sudoers,添加一用户,使其获得sudo权限,但是我要禁止该用户使用useradd/adduser命令
即在/etc/sudoers添加:[用户名] ALL=(ALL) ALL,!/usr/sbin/adduser,!/usr/sbin/adduser
但是我发现该用户可以使用sudo修改/etc/sudoers,使得上述限制失效,请问如何禁止sudo用户修改/etc/sudoers

Re: 请问如何禁止sudo用户修改/etc/sudoers的问题?

发表于 : 2015-08-18 18:51
vickycq

代码: 全选

[用户名] ALL=(ALL) ALL
这样配置,相当于狗窦大开,用户总能找到办法执行被禁止的命令。比如,他可以 sudo cp /usr/sbin/useradd /usr/sbin/hehehe,然后执行sudo hehehe即可。也可以从其它应用程序中fork一个shell出来随意执行。
hehehe.png
hehehe.png (14.45 KiB) 查看 7298 次
参考:
http://www.unix.com/unix-for-advanced-a ... mands.html
http://askubuntu.com/questions/500679/b ... -sudo-user
http://serverfault.com/questions/308198 ... doers-file
http://blog.siphos.be/2013/12/limiting- ... nux-alone/

Re: 请问如何禁止sudo用户修改/etc/sudoers的问题?

发表于 : 2015-08-18 20:54
poloshiao
我以root修改/etc/sudoers,添加一用户,使其获得sudo权限
sudo cat /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.

/etc/sudoers 檔案前面幾行 已經說明 不要直接修改/etc/sudoers

Re: 请问如何禁止sudo用户修改/etc/sudoers的问题?

发表于 : 2015-08-18 21:42
onlylove
poloshiao 写了:
我以root修改/etc/sudoers,添加一用户,使其获得sudo权限
sudo cat /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.

/etc/sudoers 檔案前面幾行 已經說明 不要直接修改/etc/sudoers
可是人的问题是如何避免修改,而不是可不可以直接修改

Re: 请问如何禁止sudo用户修改/etc/sudoers的问题?

发表于 : 2015-08-18 23:54
vickycq
-

Re: 请问如何禁止sudo用户修改/etc/sudoers的问题?

发表于 : 2015-08-19 0:20
自由建客
sudo 是用来设置白名单的,不应该用来设置黑名单。

Re: 请问如何禁止sudo用户修改/etc/sudoers的问题?

发表于 : 2015-08-19 7:23
poloshiao
我要禁止该用户使用useradd/adduser命令
[用户名] ALL=(ALL) ALL,!/usr/sbin/adduser,!/usr/sbin/adduser
http://superuser.com/questions/735172/h ... c-commands
How to prevent sudo users from running specific commands?