LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-28-2011, 06:02 PM   #1
segmentation_fault
Member
 
Registered: Sep 2008
Location: Ioannina, Greece
Distribution: Gentoo
Posts: 332

Rep: Reputation: 55
sudo passwordless commands


What I'm trying to do is to grant my regular user to locally mount partitions and shutdown the machine without a password. Here is what I've done to /etc/sudoers:
Code:
Host_Alias LOCAL = localhost

Cmnd_Alias SHUTDOWN = /sbin/shutdown
Cmnd_Alias MOUNT = /bin/mount, /bin/umount

<my_username> LOCAL=(root) NOPASSWD: SHUTDOWN, MOUNT

%wheel ALL=(ALL) ALL
My user is a member of wheel group and I want to type the password for each sudo command except for shutdown and mount.
However I am asked for a password whenever I execute "sudo mount [...]" or "sudo shutdown [...]".
Am I missing something?
 
Old 05-28-2011, 07:43 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 476Reputation: 476Reputation: 476Reputation: 476Reputation: 476
@ Reply

Hi there,

Try adding this to your sudoers file:

<my_username> LOCAL=(root) NOPASSWD: /sbin/shutdown
<my_username> LOCAL=(root) NOPASSWD: /sbin/mount
 
Old 05-28-2011, 07:56 PM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Does gentoo use PolicyKit. You can add a policy allowing GUI users to have removable media mounted.
Look at "polkit-auth". If it lists policies, is "org.freedesktop.hal.storage.mount-removable" listed?
 
Old 05-28-2011, 09:42 PM   #4
segmentation_fault
Member
 
Registered: Sep 2008
Location: Ioannina, Greece
Distribution: Gentoo
Posts: 332

Original Poster
Rep: Reputation: 55
Well, there are some entries under /etc/polkit-1/ and /var/lib/polkit-1/ so I suppose it does. However this should only resolve the mount issue, not the shutdown.
And I'm not actually a GUI user. The default login is in terminal from which I invoke blackbox WM (through startx). I don't have either KDE or Gnome or any other WM/DE installed. That's why I'm trying to make these two commands work without password (just to avoid typing it so frequently). And of course to understand further how sudo works.
Is it possible that wheel group rule "overwrites" somehow the NOPASSWD rule for the user?

Last edited by segmentation_fault; 05-28-2011 at 10:09 PM.
 
Old 05-28-2011, 10:07 PM   #5
segmentation_fault
Member
 
Registered: Sep 2008
Location: Ioannina, Greece
Distribution: Gentoo
Posts: 332

Original Poster
Rep: Reputation: 55
Looks like it is solved. First of all, instead of "localhost", I put the hostname of the machine.
Secondly, I put the user rule after the group rule
Code:
 %wheel ALL=(ALL) ALL
<my_username> <hostname> = (root) NOPASSWD: MOUNT, SHUTDOWN
and it seems that did the trick. Now I can mount/unmount and shutdown without a password and for any other sudo operation I am asked for a password.
Thanks for the replies.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Allow commands without SUDO Touch Linux - Newbie 6 01-05-2011 09:33 AM
passwordless sudo to restart dhcpd psychobyte Linux - Security 1 01-12-2010 05:24 PM
sudo not giving me all commands, I have to su. Romanus81 Slackware 6 03-14-2008 10:26 AM
Limited 'sudo' commands Casket Linux - Security 1 10-23-2007 03:05 AM
sudo and at commands ulto Programming 2 05-01-2004 09:36 AM


All times are GMT -5. The time now is 10:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration