sudo 无法打开 /etc/sudoers

sudo 无法打开 /etc/sudoers

sudo不起作用。我将 Arch Linux 安装在使用 BTRFS 格式化的 USB 闪存盘上。这是我运行“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) +++

答案1

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

你能试一下吗chmod 755 /

答案2

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

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

您的二进制文件缺少其中一个特征。执行此操作(以 root 身份):

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

答案3

你是怎么安装的?您必须以 root 身份将分区挂载到 U 盘上才能进行安装。我不知道为什么,但它只对我有用。之后,您可以以用户身份挂载分区并通过 rsync 更新它,并且不会出现问题(但我还没有对此进行广泛测试)。

用户挂载系统很可能出现问题。

答案4

按着这些次序:

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

相关内容