You are not logged in.

#1 2017-04-11 17:42:05

Maniaxx
Member
Registered: 2014-05-14
Posts: 761

[SOLVED] Sudo -g asks for password

Hi,
my user is in 'wheel' group and its enabled like this in /etc/sudoers:

%wheel ALL=(ALL) NOPASSWD: ALL

So no password prompt when using 'sudo echo test'.

But when i use 'sudo -g no-internet echo test' it asks for password again. Why?

This is my '/etc/sudoers.d/no-internet' (chmod 640) drop-in:

Defaults      editor=/usr/bin/nano, !env_editor
%no-internet ALL=(ALL) NOPASSWD: ALL
myuser ALL=(ALL) NOPASSWD: ALL

The group 'no-internet' has been added by 'groupadd no-internet'. The user spawning 'sudo' is not in that group.

Edit:
I also get this when entering the password. That's wrong as well.

Sorry, user {user} is not allowed to execute '/usr/bin/echo test' as {user}:no-internet on {host}.

Injecting the lines directly into '/etc/sudoers' and logging out (or restart) doesn't help either.

Edit2:
I guess its because the specified group (%no-internet) is just a placeholder for its members/users. As the group doesn't hold any users its just placebo here.
Looks like this guy is wrong (he claims to not join the group) even though his link/reference explicitly tells to join the group (or i misunderstand him).

Last edited by Maniaxx (2017-04-11 21:34:34)


sys2064

Offline

#2 2017-04-11 19:53:11

oliver
Member
Registered: 2007-12-12
Posts: 448

Re: [SOLVED] Sudo -g asks for password

what is the output from sudo -l

$ sudo -l

Offline

#3 2017-04-11 19:54:31

c00ter
Member
From: Alaskan in Washington State
Registered: 2014-08-28
Posts: 421

Re: [SOLVED] Sudo -g asks for password

Have you tried

 sudo gpasswd -a username wheel 

UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things. -- Doug Gwyn

Offline

#4 2017-04-11 21:25:48

Maniaxx
Member
Registered: 2014-05-14
Posts: 761

Re: [SOLVED] Sudo -g asks for password

oliver wrote:

what is the output from sudo -l

$ sudo -l
Matching Defaults entries for {user} on {host}:
    env_reset, editor=/usr/bin/nano, !env_editor, editor=/usr/bin/nano, !env_editor

User {user} may run the following commands on {host}:
    (ALL) NOPASSWD: ALL
    (ALL) NOPASSWD: ALL
    (ALL : ALL) NOPASSWD: ALL

In the meantime i've added the last line (ALL : ALL) to allow execution for all groups. Otherwise permission is denied to execute anything (from different group). But it didn't help to suppress the password prompt. The trick was to add myself to the group. The linked post above (that confused me) explicitly tells to not join the group. That's wrong.
It works now properly. I can block internet access (without local subnet) app/command-based on-demand with

sudo iptables -A OUTPUT -m owner --gid-owner no-internet ! -d 192.168.0.0/16 -j DROP
sudo -g no-internet YOURCOMMAND

And thanks for the 'sudo -l'. Didn't know that. smile

c00ter wrote:

Have you tried

 sudo gpasswd -a username wheel 

I'm already member of 'wheel'.

Last edited by Maniaxx (2017-04-11 21:33:03)


sys2064

Offline

#5 2017-04-12 13:39:48

oliver
Member
Registered: 2007-12-12
Posts: 448

Re: [SOLVED] Sudo -g asks for password

Maniaxx wrote:

And thanks for the 'sudo -l'. Didn't know that. smile

No worries - it's often helpful since sudoers is read top-down with the last match applying.

Offline

Board footer

Powered by FluxBB