Sudo in launcher ?

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post please read this

Sudo in launcher ?

Postby rustleg on Thu Jun 14, 2012 4:25 pm

I want a launcher to mount my NAS without having to put in my sudo password. I have added the ability to do this by adding a line to sudoers
as follows:
Code: Select all
me ALL = NOPASSWD: /bin/mount
(me stands for my user name)

I have a script in /home/me/bin. If I open a terminal and invoke this, the script is recognised and executed with no password being necessary. This is the script - very simple.

Code: Select all
#!/bin/bash
# mountnas
if [ 0 = `sudo mount |grep -c nasbox` ]
   then
      sudo mount -a
fi

But when I use a launcher from the desktop it doesn't obey the sudoers line and asks for the password. If I give the password it works. So it knows I am the correct user. Why doesn't it obey the command in sudoers?

(this is in Mint13Mate 64bit)
rustleg
Level 1
Level 1
 
Posts: 36
Joined: Mon Sep 13, 2010 12:37 pm

Linux Mint is funded by ads and donations.
 

Re: Sudo in launcher ?

Postby veggen on Thu Jun 14, 2012 4:48 pm

I remember doing something similar by adding the mount command to /etc/rc.local. Executed on startup and doesn't require sudo (IIRC).
Not exactly your answer, but you might want to check it out.
User avatar
veggen
Level 4
Level 4
 
Posts: 401
Joined: Mon May 09, 2011 4:54 am

Re: Sudo in launcher ?

Postby rustleg on Thu Jun 14, 2012 5:05 pm

The problem is that i may not start the NAS running soon enough to be able to be mounted at startup which is why I need the script. Normally if the NAS is up and running the lines in fstab will cause it to be mounted without any problem. Sometimes I leave the NAS off until I want files on it then switch it on. I'm not going for a reboot then.

Of course it's not a big issue to type my password in. It's just that I like to set things up that allow easy operation and this almost gets there - and solving it will also increase my understanding.
rustleg
Level 1
Level 1
 
Posts: 36
Joined: Mon Sep 13, 2010 12:37 pm


Return to Other topics

Who is online

Users browsing this forum: No registered users and 3 guests