Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

sudo does not work. I have installed Arch Linux onto a USB key formatted with BTRFS. The output of sudo is:

$ 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) +++
share|improve this question
    
What about ls -ld /etc? –  Ansgar Esztermann May 25 '12 at 11:48
    
Added in latest edit. –  Ross McDonald May 25 '12 at 11:52
3  
Show output of ls -l $(which sudo) , that's the source of problem –  warl0ck May 25 '12 at 12:43
    
Have you verified sudoers syntax has no problems? –  Tim May 25 '12 at 17:32
    
Added both in edits, no syntax errors... –  Ross McDonald May 26 '12 at 12:59

3 Answers 3

up vote 8 down vote accepted

Ok , you don't seem to have access for / (can't cd),

Can you try chmod 755 /

share|improve this answer
    
@UlrichDangel really ? I tried a simple program , with those calls , even if the program is suid-ed , the function will still return -1. ( I did chown root ./suid_test and chmod 4755 ./suid_test) , source code: pastebin.mozilla.org/1650215 –  warl0ck May 26 '12 at 5:30
    
'./suid_test': 0 setresuid: 0 0 –  Ross McDonald May 26 '12 at 13:00
    
Doesn't fix the issue –  Ross McDonald May 26 '12 at 13:03
    
"strace -uuli -f ./suid_test |& grep uid" produces nothing. –  Ross McDonald May 26 '12 at 13:08
    
"strace -f ./suid_test |& grep uid" produces: 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 –  Ross McDonald May 26 '12 at 13:09

The executable needs to be setuid and owned by root:

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

Your binary is missing one of those traits. Do this (as root):

# chown root /usr/bin/sudo
# chmod u+xs /usr/bin/sudo
share|improve this answer
    
I may be wrong but i don't think the suid bit is missing as the return value for setresuid32(0, -1, -1) and setresgid32(-1, 0, -1) is both time 0 which indicates that the program has the correct permissions –  Ulrich Dangel May 26 '12 at 8:43
    
Ulrich Dangel is right, sadly. That makes no difference (and I had already tried that). –  Ross McDonald May 26 '12 at 13:00

how did you install it? you have to mount the partition on the usb-stick as root for the installation. I don't know why but it worked for me only this way. Afterwards you can mount the partition as user and update it via rsync and no problem should appear (but I haven't tested this extensively).

There is most probably something broken in the user mount system.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.