You are not logged in.

#1 2011-09-16 10:52:34

bradomyn
Member
Registered: 2011-08-05
Posts: 15

[SOLVED] visudo doesn't grant NOPASSWD

Hi,

I'm using awesom and I'd like to have from the menu sth like

sudo pm-hibernate (or pm-suspend)

The point is that I modified the visudo like;

%power ALL=(ALL) NOPASSWD:/sbin/halt
%power ALL=(ALL) NOPASSWD:/sbin/reboot
%power ALL=(ALL) NOPASSWD:/usr/sbin/pm-suspend
%power ALL=(ALL) NOPASSWD:/usr/sbin/pm-hibernate
%power ALL=(ALL) NOPASSWD:/usr/sbin/pm-powersave

and halt and reboot work perfectly, but all the pm-* still needs the password... I cannot run this commnands from the awesom-menu since are lunch from a lua script (as well as halt and reboot).

WATCH OUT, according to the wiki:

**Note: These must come after any user privilege specifications, e.g., "username ALL=(ALL) ALL", or they will not work.

User_Permission_Method   

I think in my visudo is right.

I've been reading posts for a while and:

this one is flaged as solved but it's a botch, I tried out and it doesn't work

(SOLVED) sudo pm-suspend requires password (SOLVED)   (at least the guy asked why it worked out)

In this one the guy is satisfy not typing sudo

(SOLVED) Permissions to halt/reboot won't work

The issue is still (IHMO) open. I'm going to start reading the documentation of sudo, visudo etc.. and see why it doesn't work. Although,  if   someone  in the mean time offers a hint why the sudo/visudo grants the NOPASSWD to halt and reboot and not to pm-* it would be really helpful.

Cheers,

Last edited by bradomyn (2011-09-26 21:35:54)

Offline

#2 2011-09-16 11:59:22

bradomyn
Member
Registered: 2011-08-05
Posts: 15

Re: [SOLVED] visudo doesn't grant NOPASSWD

Update!!

I've forgotten to post the complete visudo:

root ALL=(ALL) ALL
bradomyn ALL=(ALL) ALL #(my user)

%power ALL=(ALL) NOPASSWD:/sbin/halt
%power ALL=(ALL) NOPASSWD:/sbin/reboot
%power ALL=(ALL) NOPASSWD:/usr/sbin/pm-suspend
%power ALL=(ALL) NOPASSWD:/usr/sbin/pm-hibernate
%power ALL=(ALL) NOPASSWD:/usr/sbin/pm-powersave

and it would make sense according to the note in the wiki:

**Note: These must come after any user privilege specifications, e.g., "username ALL=(ALL) ALL", or they will not work.

Now the first configuration in the file was:


root ALL=(ALL) ALL
bradomyn ALL=(ALL) ALL #(my user)

bradomyn ALL=(ALL) NOPASSWD:/sbin/halt
bradomyn ALL=(ALL) NOPASSWD:/sbin/reboot
bradomyn ALL=(ALL) NOPASSWD:/usr/sbin/pm-suspend
bradomyn ALL=(ALL) NOPASSWD:/usr/sbin/pm-hibernate
bradomyn ALL=(ALL) NOPASSWD:/usr/sbin/pm-powersave

the note in this case doesn't applies. So I have no freaking idea why it didn't work either.

But if organize the statements like this:

root ALL=(ALL) ALL

%power ALL=(ALL) NOPASSWD:/sbin/halt
%power ALL=(ALL) NOPASSWD:/sbin/reboot
%power ALL=(ALL) NOPASSWD:/usr/sbin/pm-suspend
%power ALL=(ALL) NOPASSWD:/usr/sbin/pm-hibernate
%power ALL=(ALL) NOPASSWD:/usr/sbin/pm-powersave

bradomyn ALL=(ALL) ALL #(my user)

Conclusion, the wiki, IHMO and this case is wrong, and the order of the NOPASSWD declaration matters. Why? Reading!

I tried also:


root ALL=(ALL) ALL

bradomyn ALL=(ALL) NOPASSWD:/sbin/halt
bradomyn ALL=(ALL) NOPASSWD:/sbin/reboot
bradomyn ALL=(ALL) NOPASSWD:/usr/sbin/pm-suspend
bradomyn ALL=(ALL) NOPASSWD:/usr/sbin/pm-hibernate
bradomyn ALL=(ALL) NOPASSWD:/usr/sbin/pm-powersave

bradomyn ALL=(ALL) ALL #(my user)

and  works....

I read that sudo reads the file top-down... and then what does it mean? if you grant NOPASSWD to the one user or group doesn't mean that the user with other commands could use sudo, and at the end the file granting sudo to the user... I don't get it... Keep reading 

Salud y Victoria!!

Last edited by bradomyn (2011-09-26 21:34:06)

Offline

Board footer

Powered by FluxBB