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 read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
rustleg
Level 2
Level 2
Posts: 73
Joined: Mon Sep 13, 2010 12:37 pm

Sudo in launcher ?

Post by rustleg »

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)
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
veggen

Re: Sudo in launcher ?

Post by veggen »

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.
rustleg
Level 2
Level 2
Posts: 73
Joined: Mon Sep 13, 2010 12:37 pm

Re: Sudo in launcher ?

Post by rustleg »

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.
Locked

Return to “Other topics”