sudo无法打开/ etc / sudoers


15

sudo不起作用。我在用BTRFS格式化的USB密钥上安装了Arch Linux。这是我运行“ sudo”时的输出:

$ sudo
sudo: unable to stat /etc/sudoers: Permission denied
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

$ ls -l /etc/sudoers
-r--r----- 1 root root 2849 May 18 15:00 /etc/sudoers

$ lsattr /etc/sudoers
--------------- /etc/sudoers

$ ls -ld /etc
drwxr-xr-x 1 root root 2476 May 25 13:45 /etc

$ ls -ld /
drwx------ 1 root root 142 May 25 06:51 /

$ ls -l $(which sudo)
---s--x--x 2 root root 123995 May 25 13:10 /usr/bin/sudo

$ strace -u ross sudo true 2>&1 | egrep '(sudo|set.*[ug].*id)'
execve("/usr/bin/sudo", ["sudo", "true"], [/* 30 vars */]) = 0
read(3, "31799 (sudo) R 31796 31796 31754"..., 1024) = 223
lstat64("/etc/sudo.conf", 0xbfcddeb0)   = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudoers.so", {st_mode=S_IFREG|0755, st_size=235092, ...}) = 0
open("/usr/lib/sudoers.so", O_RDONLY|O_CLOEXEC) = 3
stat64("/usr/lib/sudoers.so", {st_mode=S_IFREG|0755, st_size=235092, ...}) = 0
setresuid32(0, -1, -1)                  = 0
setresgid32(-1, 0, -1)                  = 0
setresuid32(-1, 1, -1)                  = 0
lstat64("/etc/sudoers", 0xbfcddd60)     = -1 EACCES (Permission denied)
setresuid32(-1, 0, -1)                  = 0
write(2, "sudo", 4sudo)                     = 4
write(2, "unable to stat /etc/sudoers", 27unable to stat /etc/sudoers) = 27
setresuid32(-1, 1, -1)                  = 0
setresgid32(-1, -1, -1)                 = 0
setresuid32(-1, 0, -1)                  = 0
setresuid32(-1, 0, -1)                  = 0
setresgid32(-1, 1000, -1)               = 0
write(2, "sudo", 4sudo)                     = 4
write(2, "no valid sudoers sources found, "..., 40no valid sudoers sources found, quitting) = 40
write(2, "sudo", 4sudo)                     = 4


$ ltrace -u ross sudo true 2>&1 | egrep '(sudo|stat|set.*[ug].*id)'
bindtextdomain("sudo", "/usr/share/locale")      = "/usr/share/locale"
textdomain("sudo")                               = "sudo"
fopen("/proc/31813/stat", "r")                   = 0x9e51d40
__xstat(3, "/dev/console", 0xbffd6074)           = 0
__xstat(3, "/dev/wscons", 0xbffd6074)            = -1
__xstat(3, "/dev/pts/4", 0xbffd6074)             = 0
__lxstat64(3, "/etc/sudo.conf", 0xbffd9040)      = -1
strlen("sudo")                                   = 4
memcpy(0x09e51e71, "sudo", 4)                    = 0x09e51e71
__xstat64(3, "/usr/lib/sudoers.so", 0xbffd810c)  = 0
dlopen("/usr/lib/sudoers.so", 257 <unfinished ...>
dlsym(0x09e51ef8, "sudoers_policy")              = 0xb75af520
__xstat64(3, "/usr/lib/sudoers.so", 0xbffd810c)  = 0
dlopen("/usr/lib/sudoers.so", 257)               = 0x09e51ef8
dlsym(0x09e51ef8, "sudoers_io")                  = 0xb75af560
fputs("sudo", 0xb7760920sudo)                        = 1
fputs("unable to stat /etc/sudoers", 0xb7760920unable to stat /etc/sudoers) = 1
fputs("sudo", 0xb7760920sudo)                        = 1
fputs("no valid sudoers sources found, "..., 0xb7760920no valid sudoers sources found, quitting) = 1
fputs("sudo", 0xb7760920sudo)                        = 1
+++ exited (status 1) +++

ls -ld /etc
Ansgar Esztermann'5

在最新编辑中添加。
Chipuba

3
显示的输出ls -l $(which sudo),这是问题的根源
雏菊2012年

您是否已验证sudoers语法没有问题?
蒂姆(Tim)

在编辑中添加了两者,没有语法错误...
Chipuba

Answers:


19

好的,您似乎无权访问/(无法cd),

你能试一下吗 chmod 755 /


@UlrichDangel真的吗?我尝试了一个简单的程序,通过这些调用,即使该程序是suid-ed,该函数仍将返回-1。(我做了chown root ./suid_testchmod 4755 ./suid_test),源代码: pastebin.mozilla.org/1650215
雏菊

'./suid_test':0 setresuid:0 0
Chipuba

无法解决问题
Chipuba

“ strace -uuli -f ./suid_test |&grep uid”不会产生任何结果。
Chipuba

“ strace -f ./suid_test |&grep uid”产生:execve(“ ./ suid_test”,[“ ./suid_test”],[/ * 22 vars * /])= 0 geteuid32()= 0 setresuid32(0, -1,-1)= 0 geteuid32()= 0 write(1,“ 0 \ nsetresuid:0 \ n0 \ n”,170 setresuid:0
Chipuba

1

可执行文件需要设置为setuid并由root拥有:

$ ls -la /usr/bin/sudo
---s--x--x 2 root root 173154 Oct 19  2010 /usr/bin/sudo

您的二进制文件缺少这些特征之一。执行此操作(作为根用户):

# chown root /usr/bin/sudo
# chmod u+xs /usr/bin/sudo

我可能是错的,但我不认为suid位会作为返回值丢失,setresuid32(0, -1, -1)并且setresgid32(-1, 0, -1)都为0,这表示程序具有正确的权限
Ulrich Dangel,2012年

不幸的是,乌尔里希·丹格尔(Ulrich Dangel)是对的。没什么区别(我已经尝试过了)。
Chipuba

0

您是如何安装的?您必须将分区作为根安装在USB记忆棒上。我不知道为什么,但是它只对我有用。之后,您可以以用户身份挂载分区并通过rsync更新它,应该没有问题出现(但是我还没有对此进行广泛的测试)。

用户安装系统中最有可能损坏的东西。


-2

按着这些次序:

~# chmod 440 /etc/sudoers
~# chmod -R 755 /root
~# chmod -R 755 /etc
~# chmod 755 /etc/phpmyadmin/config.inc.php

-1:这是非常糟糕的建议。您不应该盲目地破坏/root和中所有内容的权限/etc。这些文件的安装权限不同是有原因的。盲目地对所有这些文件设置可执行权限的建议是虚假的。这些树中很少有文件需要它。并建议给予世界的读取和-execute权限的一切/root,并/etc是令人惊讶的糟糕; 您最好将root密码通过电子邮件发送给可以在该系统上登录该系统的每个用户,因为这样做已经使他们获得了完整的使用权限。
沃伦·杨
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.