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

其它类软件,非上述版软件
回复
qyecst
帖子: 1
注册时间: 2015-03-06 14:26
系统: Ubuntu

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

#1

帖子 qyecst » 2015-08-18 16:33

我以root修改/etc/sudoers,添加一用户,使其获得sudo权限,但是我要禁止该用户使用useradd/adduser命令
即在/etc/sudoers添加:[用户名] ALL=(ALL) ALL,!/usr/sbin/adduser,!/usr/sbin/adduser
但是我发现该用户可以使用sudo修改/etc/sudoers,使得上述限制失效,请问如何禁止sudo用户修改/etc/sudoers
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

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

#2

帖子 vickycq » 2015-08-18 18:51

代码: 全选

[用户名] ALL=(ALL) ALL
这样配置,相当于狗窦大开,用户总能找到办法执行被禁止的命令。比如,他可以 sudo cp /usr/sbin/useradd /usr/sbin/hehehe,然后执行sudo hehehe即可。也可以从其它应用程序中fork一个shell出来随意执行。
hehehe.png
hehehe.png (14.45 KiB) 查看 7055 次
参考:
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/
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

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

#3

帖子 poloshiao » 2015-08-18 20:54

我以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
onlylove
论坛版主
帖子: 5230
注册时间: 2007-01-14 16:23

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

#4

帖子 onlylove » 2015-08-18 21:42

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
可是人的问题是如何避免修改,而不是可不可以直接修改
#include <stdio.h>
void main()
{
double world;
unsigned letter;
short stay;
long memories;
printf("I miss you.\n");
}
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

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

#5

帖子 vickycq » 2015-08-18 23:54

-
上次由 vickycq 在 2015-08-19 8:23,总共编辑 1 次。
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
头像
自由建客
帖子: 13468
注册时间: 2008-07-30 23:21
系统: Debian stable AMD64

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

#6

帖子 自由建客 » 2015-08-19 0:20

sudo 是用来设置白名单的,不应该用来设置黑名单。
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

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

#7

帖子 poloshiao » 2015-08-19 7:23

我要禁止该用户使用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?
回复