Remove need for sudo for mount/umount


 
Thread Tools Search this Thread
Special Forums Cybersecurity Remove need for sudo for mount/umount
# 1  
Old 02-17-2010
Remove need for sudo for mount/umount

Hello,

I'm trying to remove the need to use sudo to mount (in particular, binding).

Modifying /etc/sudoers using visudo, I have tried:
Code:
%admin ALL=NOPASSWD: /usr/bin/mount
%admin ALL=NOPASSWD: /usr/bin/umount

and
Code:
%admin ALL=(ALL) NOPASSWD: /usr/bin/mount
%admin ALL=(ALL) NOPASSWD: /usr/bin/umount

Both return

Code:
$ mount --bind /home/woodnt/Dir1 /home/woodnt/Dir2
mount: only root can do that

I have logged out and in (and even rebooted) to no avail.

What am I missing here?

With thanks,
Narnie
# 2  
Old 02-17-2010
You're missing the invocation of sudo. The sudoers file is only read by sudo, not by the shell.
# 3  
Old 02-17-2010
If you're not using sudo, its configuration isn't relevant. sudo options are sudo's alone and don't matter when you don't use it.

If these things are being mounted by hand, could you just alias mount to sudo mount in their .bashrc? Users could thus run 'mount' and the shell would run 'sudo mount'. This is a lot safer than the alternative, i.e. setting the mount binary setuid so it always runs as root!
# 4  
Old 02-17-2010
Quote:
Originally Posted by Corona688
If you're not using sudo, its configuration isn't relevant. sudo options are sudo's alone and don't matter when you don't use it.

If these things are being mounted by hand, could you just alias mount to sudo mount in their .bashrc? Users could thus run 'mount' and the shell would run 'sudo mount'. This is a lot safer than the alternative, i.e. setting the mount binary setuid so it always runs as root!
Ultimately, I want to have this in a script.

As far as not using sudo, I'm confused then. In looking for how to run truecrypt without needing a password, I read that if this is added to the /etc/sudoers

Code:
%admin ALL=NOPASSWD: /usr/bin/truecrypt

then one can run truecrypt without having to type sudo.

This is in fact the case in my setup. If I have this line in sudoers then I can run truecrypt without prefixing it with sudo. If I don't have this line, then truecrypt asks for admin privileges.

To show truecrypt is not aliased :
Code:
$ type truecrypt
truecrypt is hashed (/usr/bin/truecrypt)

Is truecrypt itself calling sudo to mount? If that is the case, then this makes a little more sense. The more I think of it, the more I feel it is likely this way. But still, truecrypt isn't needing a sudo prefix so how can modifying sudoers affect the truecrypt script? Can someone explain? Why don't I have to have sudo in from of truecrypt as in:

Code:
sudo truecrypt -d ; # to dismount all volumes

as evidenced by this result:

Code:
$ truecrypt -t -v -d
Volume "/home/woodnt/.vol/xj9" has been dismounted.
Volume "/home/woodnt/.vol/i5yq" has been dismounted.

Furthermore, why wouldn't it require mount in sudoers rather than truecrypt if truecrypt is using "sudo mount ..."

Bewildered but enjoying learning,
Narnie

---------- Post updated at 06:15 PM ---------- Previous update was at 05:42 PM ----------

BTW, if I have either of the 2 mount/umount combos I listed in my first post in place I get this when trying to run sudo mount ...

Code:
$ sudo mount --bind Dir1 Dir2
[sudo] password for woodnt:

It still wants a password if I prefix it with sudo even though I've tried:

Code:
%admin ALL=NOPASSWD: /usr/bin/mount

and
Code:
%admin ALL=(ALL) NOPASSWD: /usr/bin/mount

Narnie

This shows I'm in admin group:

Code:
$ groups
woodnt adm disk dialout cdrom audio video plugdev lpadmin admin sambashare vboxusers


Last edited by Narnie; 02-17-2010 at 07:53 PM..
# 5  
Old 02-17-2010
Quote:
Originally Posted by Narnie
Ultimately, I want to have this in a script.
You can put sudo in scripts.
Quote:
As far as not using sudo, I'm confused then. In looking for how to run truecrypt without needing a password, I read that if this is added to the /etc/sudoers

Code:
%admin ALL=NOPASSWD: /usr/bin/truecrypt

then one can run truecrypt without having to type sudo.
truecrypt is smart enough to call sudo by itself. It's a fairly friendly program.
Quote:
Is truecrypt itself calling sudo to mount? If that is the case, then this makes a little more sense. The more I think of it, the more I feel it is likely this way.
Yes, truecrypt is calling sudo.
Quote:
But still, truecrypt isn't needing a sudo prefix so how can modifying sudoers affect the truecrypt script?
Because it calls sudo itself. it's not a "prefix". You're actually running a command named 'sudo'. Imagine you made a script that called 'sudo umount'.

As for the proper syntax, I have this line in my sudoers:

Code:
%wheel          ALL=NOPASSWD: /usr/bin/powertop

It lets anyone in the wheel group run powertop as root with no password. If you updated your users' groups recently, try logging out then back in.
# 6  
Old 02-18-2010
Quote:
Originally Posted by Corona688
You can put sudo in scripts. truecrypt is smart enough to call sudo by itself. It's a fairly friendly program. Yes, truecrypt is calling sudo. Because it calls sudo itself. it's not a "prefix". You're actually running a command named 'sudo'. Imagine you made a script that called 'sudo umount'.

As for the proper syntax, I have this line in my sudoers:

Code:
%wheel          ALL=NOPASSWD: /usr/bin/powertop

It lets anyone in the wheel group run powertop as root with no password. If you updated your users' groups recently, try logging out then back in.
Perhaps I shouldn't have said "prefix" in this context. I was not meaning test.txt as test is the prefix and txt is the suffix, just that you have to have "sudo something" to run something if something requires root access.

So I'm still puzzled why I don't have to put sudo in front of truecrypt when I run it.

Why doesn't the sudoers require mount to be mentioned and not truecrypt since sudo is elevating the privies of mount, not really truecrypt?

Also, why does "sudo mount --binding foo.bar foobar2" ask for the password even when I have mount set up as I have posted above which is identical to the code you have in the wheel line again?

The only difference is "admin" is in wheels place and /bin/mount is in /usr/bin/powertop's place.

Is mount "special?" If so, why does this work for truecrypt?

I'm sure I'm just being thick, but I really want to "get this."

With thanks for all the patience,
Narnie

---------- Post updated at 11:29 PM ---------- Previous update was at 10:48 PM ----------

OK, as far as why mount and umount are still requiring password was because I was blinded by the truecrypt line before it.

It should be /bin/mount or unmount not /usr/bin/mount.

Stupid mistake.

Err!!!

Narnie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Test cases for file system mount/umount performance in HP

Hi Folks, Could anyone please assist me with the what could be the scenarios to test the file system mount/umount performance check in HPUX. Thanks in advance, Vaishey (5 Replies)
Discussion started by: Vaishey
5 Replies

2. AIX

how to remove sudo access from a user ?

Hello Folks, I need help on removing sudo access on one id but first of all, can i confirm that the user below is having sudo access ? if he did have sudo access, how to remove ? thanks alrsprd3:root-/etc> more sudoers | grep fzcx0l fzcx0l ALL=(ALL) ALL alrsprd3:root-/etc> (2 Replies)
Discussion started by: wingcross
2 Replies

3. Fedora

What is the right way to mount and umount a usb driver?

I have some questions: 1, I successfully mounted my usb drive with "sudo mount /dev/sdb1 /mnt", but I can't wirte, It says "read-only file system". But I can write it in windows. 2, After I umounted the usb drive the led of it still on, but not blinking. Is it safe to unplug it? How to let it's... (17 Replies)
Discussion started by: vistastar
17 Replies

4. UNIX for Dummies Questions & Answers

Simple way to umount NFS mount in linux

Hello... I've mounted a share using standard nomenclature for the NFS mount command with the following command line: mount -t nfs -o rw {IP address1}:/ /mnt_for_70 / {IP address2}(rw) mnt_for_70 is a mount point I created on {IP address2} I'm confuse and want to be sure I use the... (1 Reply)
Discussion started by: blaine.miller
1 Replies

5. Shell Programming and Scripting

shell script problem , sudo mount command

cat test.sh sudo mount -t vfat /dev/sda7 /media/Ddrive If i double click the test.sh file and select run in terminal then the terminal prompts for password. How can i avoid typing password? Or if i double click test.sh file and select run then nothing happens. What i'm trying "Double... (3 Replies)
Discussion started by: cola
3 Replies

6. Solaris

mount & umount in sigle-user mode

In Solaris 8, when I boot to single user mode, mount a device and then reboot or init 0, the system unmount it automatically. However, in Solaris 10 it does not seem to do the same. Here is what I did: {0} ok boot -s # format Searching for disks...done AVAILABLE DISK SELECTIONS: 0.... (11 Replies)
Discussion started by: StarSol
11 Replies

7. Linux

How to mount/umount disk from a non-root account

Is it possible to mount a disk from a non-root account? I'm developing a Java application which executes commands in the shell using the java.lang.Runtime.exec api, which runs fine for commands ls, df, etc., but for commands mount and umount, i have problems as I need to be root to eecute these.... (8 Replies)
Discussion started by: brendan76
8 Replies

8. Solaris

How to remove sudo program

How to completely uninstall sudo program? Thank u in advance (1 Reply)
Discussion started by: unitipon
1 Replies

9. UNIX for Dummies Questions & Answers

solaris 8 admin I text ambiguities on mount and umount

i'm prepping for my midterm, which i will bomb. i am scurrying to finish reading the final chapter before i get down into the review. however, i came across something in chapter 8 - "mounting file systems" that has me really confused. the text says the following: then it goes on to... (2 Replies)
Discussion started by: xyyz
2 Replies

10. UNIX for Dummies Questions & Answers

Writing a script to mount and umount a drive in Linux

I have a 1 GB jazz drive. The jazz disk is used daily, both at home and at work on my Win 98 Server. So, I have to keep it in vfat format, which is fine because Linux rocks and will read it no problem. :-) However, I can't just stick the disk in the drive and open up the jazz folder in my mnt... (2 Replies)
Discussion started by: wizkid
2 Replies
Login or Register to Ask a Question