You are not logged in.

#1 2011-12-11 20:04:46

NOTtheMessiah
Member
Registered: 2011-12-11
Posts: 5

Sudo unable to open /etc/sudoers

Whenever I try to do anything at all with sudo on my fresh x86-64 Arch install, it prints out this error:

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

This is on a fresh Arch install from the core Image CD, packages initially installed from the CD and then upgraded with #pacman -Syu. I can edit sudoers just fine with visudo, and installing outdated versions of sudo produce the same error. File permissions on both /usr/bin/sudo and /etc/sudoers both look as they should be. Also, users and user groups don't seem to be an issue.

Found this related StackExchange thread and here are the outputs of strace and ltrace if anyone can interpret them: http://unix.stackexchange.com/questions … most-files
Ltrace:

# ltrace -u notthemessiah sudo true 2>&1 | egrep '(sudo|stat|set.*[ug].*id)'
bindtextdomain("sudo", "/usr/share/locale")      = "/usr/share/locale"
textdomain("sudo")                               = "sudo"
strlen("sudo")                                   = 4
memcpy(0x01c6f299, "sudo", 4)                    = 0x01c6f299
fopen("/etc/sudo.conf", "r")                     = 0
__xstat(1, "/usr/lib/sudoers.so", 0x7fff6b0913d0) = 0
dlopen("/usr/lib/sudoers.so", 257)               = 0x01c6f630
dlsym(0x01c6f630, "sudoers_policy")              = 0x7f33e2f96960
__xstat(1, "/usr/lib/sudoers.so", 0x7fff6b0913d0) = 0
dlopen("/usr/lib/sudoers.so", 257)               = 0x01c6f630
dlsym(0x01c6f630, "sudoers_io")                  = 0x7f33e2f969c0
fputs("sudo", 0x7f33e35296e0sudo)                    = 1
fputs("unable to open /etc/sudoers", 0x7f33e35296e0unable to open /etc/sudoers) = 1
fputs("sudo", 0x7f33e35296e0sudo)                    = 1
fputs("no valid sudoers sources found, "..., 0x7f33e35296e0no valid sudoers sources found, quitting) = 1
fputs("sudo", 0x7f33e35296e0sudo)                    = 1
+++ exited (status 1) +++

Strace:

# strace -u notthemessiah sudo true 2>&1 | egrep '(sudo|set.*[ug].*id)'
execve("/usr/bin/sudo", ["sudo", "true"], [/* 22 vars */]) = 0
open("/etc/sudo.conf", O_RDONLY)        = -1 ENOENT (No such file or directory)
stat("/usr/lib/sudoers.so", {st_mode=S_IFREG|0755, st_size=185352, ...}) = 0
open("/usr/lib/sudoers.so", O_RDONLY)   = 3
stat("/usr/lib/sudoers.so", {st_mode=S_IFREG|0755, st_size=185352, ...}) = 0
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/sudoers.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/sudoers.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/sudoers.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/sudoers.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/sudoers.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/sudoers.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
lstat("/etc/sudoers", {st_mode=S_IFREG|0440, st_size=2849, ...}) = 0
setresgid(4294967295, 0, 4294967295)    = 0
setresuid(0, 1, 4294967295)             = 0
open("/etc/sudoers", O_RDONLY)          = -1 EACCES (Permission denied)
setresuid(4294967295, 0, 4294967295)    = 0
write(2, "sudo", 4sudo)                     = 4
write(2, "unable to open /etc/sudoers", 27unable to open /etc/sudoers) = 27
setresuid(4294967295, 1, 4294967295)    = 0
setresgid(4294967295, 0, 4294967295)    = 0
setresuid(4294967295, 0, 4294967295)    = 0
setresuid(1000, 0, 4294967295)          = 0
setresgid(1000, 1000, 1000)             = 0
write(2, "sudo", 4sudo)                     = 4
write(2, "no valid sudoers sources found, "..., 40no valid sudoers sources found, quitting) = 40
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "sudo", 4sudo)                     = 4

Offline

#2 2011-12-11 20:21:35

kurych
Member
From: Saint-Petersburg, Russia
Registered: 2011-12-07
Posts: 27

Re: Sudo unable to open /etc/sudoers

show us output

# ls -l /etc/sudoers
# lsattr /etc/sudoers

Offline

#3 2011-12-11 20:43:08

NOTtheMessiah
Member
Registered: 2011-12-11
Posts: 5

Re: Sudo unable to open /etc/sudoers

kurych wrote:

show us output

# ls -l /etc/sudoers
# lsattr /etc/sudoers
-r--r----- 1 root root 2849 Oct 27 21:41 /etc/sudoers
-------------e- /etc/sudoers

Offline

#4 2011-12-12 09:53:47

kurych
Member
From: Saint-Petersburg, Russia
Registered: 2011-12-07
Posts: 27

Re: Sudo unable to open /etc/sudoers

It's OK. And can you open this file by "sudoedit /etc/sudoers" or "vim /etc/sudoers" if didn't work sudoedit?
I'm guessing that the file /etc/sudoers may contain a syntax error. You could try reinstall sudo package and edit rules only by sudoedit.
edit: and check whether executable file "/usr/bin/sudo" has SUID attribute

Last edited by kurych (2011-12-12 10:18:20)

Offline

#5 2011-12-12 11:50:14

SS4
Member
From: !Rochford, Essex
Registered: 2010-12-05
Posts: 699

Re: Sudo unable to open /etc/sudoers

OP wrote:

I can edit sudoers just fine with visudo

Which is the way you're meant to run it. If you don't know vim specify your favourite editor using the EDITOR variable

sudo EDITOR=nano visudo

Last edited by SS4 (2011-12-12 12:00:12)


Rauchen verboten

Offline

#6 2011-12-12 14:41:05

kurych
Member
From: Saint-Petersburg, Russia
Registered: 2011-12-07
Posts: 27

Re: Sudo unable to open /etc/sudoers

Sorry, of course, use  visudo for edit sudoers. I did mistake

Last edited by kurych (2011-12-12 17:13:45)

Offline

#7 2011-12-12 16:18:47

kyla
Member
From: Arlington, VA
Registered: 2011-03-12
Posts: 112
Website

Re: Sudo unable to open /etc/sudoers

I'm not sure if I'm misunderstanding, but are you trying to use sudo to edit sudoers for the first time? If so, you need to be logged in as root, visudo sudoers and add your normal user as a sudoer before you can use sudo to do anything.

Offline

#8 2011-12-20 21:19:05

NOTtheMessiah
Member
Registered: 2011-12-11
Posts: 5

Re: Sudo unable to open /etc/sudoers

No, I used visudoers and everything relating to that correctly. It's just probably something that happened while installing the core packages from the install CD that caused problems. As of now, I just reinstalled Arch on a new partition (this was a fairly fresh install) and it seems to work just fine. I was willing to continue to test the issue, but resizing the partition seems to have corrupted it somehow.

Offline

Board footer

Powered by FluxBB