You are not logged in.

#1 2019-07-04 13:09:40

riri
Member
Registered: 2007-05-21
Posts: 28

[FIXED] Can't use sudo as user on host

I installed arch in a virtualbox VM. I am a seasoned user of arch, and that issue plays with my nerves.

It's a basic install, I have added Xorg, Firefox, openbox, rxvt-unicode.
I like to use sudo, and get that problem I never had before. It says my user is not allowed to use sudo, while I have added access to wheel group and my user is in this group.

I created a /etc/sudoers.d/10-wheel.conf containing

%wheel ALL=(ALL) ALL

to avoid modifying /etc/sudoers (content written with visudo -f /etc/sudoers.d/10-wheel.conf).

Perms for sudoers files are correct:

# ls -l /etc/sudoers*
-r--r----- 1 root root 3174 13 janv. 13:40 /etc/sudoers

/etc/sudoers.d:
total 4
-r--r----- 1 root root 21  4 juil. 13:32 10-wheel.conf

My user arch (uid 1000, gid) is in wheel group:

$ groups
ftp http users wheel adm arch

When I want to use sudo, I get this error:

$ sudo -s
[sudo] password for arch: 
arch is not in the sudoers file. This incident will be reported.

(the real command is LANG=C sudo -s to get message in english, my locale is french)

Trying to list rights from root:

# sudo -l -U arch
User arch is not allowed to run sudo on archvm.

My /etc/hosts

# Static table lookup for hostnames.
# See hosts(5) for details.

127.0.0.1	localhost archvm
::1		localhost
#127.0.0.1	archvm.localdomain archvm

The commented line is what I had before testing different things to make sudo working.

I suspect there is something with hostname resolution or something like that, as I don't see why sudoers rules are not processed.
Any idea?

Edit the drop-in file extension was the issue, because sudo does not process a file containing dots.

Last edited by riri (2019-07-04 14:32:34)

Offline

#2 2019-07-04 13:17:22

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,702
Website

Re: [FIXED] Can't use sudo as user on host

How does your /etc/sudoers file look?
Do you have other drop-in files in /etc/sudoers.d?


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#3 2019-07-04 13:38:26

riri
Member
Registered: 2007-05-21
Posts: 28

Re: [FIXED] Can't use sudo as user on host

I didn't touch to /etc/sudoers at all, it's the one installed.
It contains at the end the statement #includedir /etc/sudoers.d
No other drop-in files in sudoers.d
To be sure I use the default sudoers, I uninstalled/reinstalled sudo, after I tried to uncomment the line with %wheel in /etc/sudoers (no better)

Offline

#4 2019-07-04 13:47:35

riri
Member
Registered: 2007-05-21
Posts: 28

Re: [FIXED] Can't use sudo as user on host

2ManyDogs wrote:

Does it work if you remove the # from in front of the "include" directive?

The # is part of the #includedir statement. Changing directly sudoers does not help either

Offline

#5 2019-07-04 13:52:05

riri
Member
Registered: 2007-05-21
Posts: 28

Re: [FIXED] Can't use sudo as user on host

Ok now it works, but I will never know why it didn't before.

To try again following 2ManyDogs comment, I have uncommented again the line for wheel group... and it worked.
So I have uncommented it again to use my sudoers.d/10-wheel.conf, killed my sudo timestamp with sudo -k and tried again... it worked!

I have not made any other change, but used tmux in my urxvt. If I try directly from urxvt or a tty, it works too.
If ever I get the idea of why it didn't want to work, I will update here.

Offline

#6 2019-07-04 13:52:41

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,702
Website

Re: [FIXED] Can't use sudo as user on host

Can you give us the outputs of

sha256sum /etc/sudoers /etc/sudoers.d/10-wheel.conf

Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#7 2019-07-04 13:59:05

riri
Member
Registered: 2007-05-21
Posts: 28

Re: [FIXED] Can't use sudo as user on host

Ha, I was still in visudo when I wanted to do my last test, so commenting %wheel was not taken in account.
So it works when I put the rule in /etc/sudoers, not when I use the drop-in file /etc/sudoers.d/10-wheel.conf

# cat /etc/sudoers.d/10-wheel.conf 
%wheel ALL=(ALL) ALL
# sha256sum /etc/sudoers.d/10-wheel.conf 
9db7f67e68218e51ee549cba0949aae86b6c14a48ac40b851cf76aba951f70a7  /etc/sudoers.d/10-wheel.conf

Last edited by riri (2019-07-04 14:00:32)

Offline

#8 2019-07-04 14:04:56

riri
Member
Registered: 2007-05-21
Posts: 28

Re: [FIXED] Can't use sudo as user on host

My /etc/sudoers file with

# cat /etc/sudoers | curl -F 'f:1=<-' ix.io
http://ix.io/1NGI

And /etc/sudoers.d/10-wheel.conf with

cat /etc/sudoers.d/10-wheel.conf | curl -F 'f:1=<-' ix.io
http://ix.io/1NGJ

Offline

#9 2019-07-04 14:13:24

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,702
Website

Re: [FIXED] Can't use sudo as user on host

The .conf suffix is the problem.

man sudoers wrote:

sudo will suspend processing of the current file and read each file in /etc/sudoers.d, skipping file names that end in ‘~’ or contain a ‘.’ character to avoid causing problems with package manager or
     editor temporary/backup files.

Last edited by schard (2019-07-04 14:13:38)


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#10 2019-07-04 14:30:51

riri
Member
Registered: 2007-05-21
Posts: 28

Re: [FIXED] Can't use sudo as user on host

schard wrote:

The .conf suffix is the problem.

Exactly, I renamed the file and it works. Thank you schard!

Offline

Board footer

Powered by FluxBB