Letting Users Mount


Pleng

Well-Known Member
Joined
Dec 28, 2006
Messages
3,030
OK so here's the deal. I'm really not too worried about the security of my Pandora. In the highly unlikely scenario that anybody wants to try and hack into it and mount things here there and everywhere, then so be it.

I've written a script to mount my shares. I want to be able to run this script from a menu option. Which means I need to make a PND wrapper. Only root can run mount. Therefore the scripts won't run without being run with sudo.

I've tried chmod 777 on /bin/mount and /usr/sbin/mount.cifs but even then when I run my 'netmount' script, or try to mount anything, I get the message 'Only root can do that'

How can I give users the mount privilege?
 
chown USERNAME /YOURMOUNTPOINT

Chmod only works on files AFAIK.

the_more_you_know2.jpg
 
yes but it's the mount COMMAND I need to have access to. Because presently whenever I try and mount anything it just says "mount: only root can do that"
 
You already have access to the mount command by default. Setting it to 777 just makes it writable for everyone, making it easier to hose the system by overwriting an essential command. What you're missing is sufficient privileges to actually mount anything.

If you have shares that regularly need to be mounted, put them in /etc/fstab, optionally with the "user" option in order to allow regular users to mount them. You shouldn't need a script for this; if set up correctly you can just do "mount /path/to/mountpoint" or set up automount to do it for you when you attempt to access the directory.
 
OK so I've added the mount points to fstab and now the Pandora hangs while booting. I can't do ANYTHING :(

I presume that this is due to the fact it's trying to mount before the network has been started??

Is a reflash my only option? :(
 
you didn't need to change the permissions on the mount command. It is executing, otherwise you would be getting a different error.
The problem is that it's looking at some permission list somewhere and preventing non-root users from mounting.
Try modifying your sudoers file (/etc/sudoers) to include the following:
After the #aliases line, add
Code:
Cmnd_Alias      MOUNT         =/bin/mount, /bin/umount
and after the #users line, add
Code:
user_name ALL=NOPASSWD: MOUNT
replacing user_name with your name, of course.
Then you can just call "sudo mount ..." and it will elevate you to super user without asking for a password. Can even be called from a script.
 
Pleng said:
Is a reflash my only option? :(
D'oh, apparently I am too late with my advice :(
It's probably trying to mount non-existent points and getting all confused. Don't know how to help.
This is where a "liveSD" card would come in handy, so you could boot from that and just fix the file you broke.
If you had a breakout board, you could get to the UART and log in that way.
 
Last edited by a moderator:
For the reference: "chmod +s /bin/mount" gives anyone the right to do anything with mount. That at least gives *that* executable all rights; there might still be other security features preventing an user to mount stuff (E.g. on my computer, it's SELinux)
 
I have a similar problem, every time I try to mount my girlfriend I find access is denied. Apparently I don't have the privelage. It's very frustrating and I'm reluctant to let anyone else have a go.

EDIT: Forgot to mention, I've tried different slots, all without success.
 
Pleng said:
OK so I've added the mount points to fstab and now the Pandora hangs while booting. I can't do ANYTHING :(

I presume that this is due to the fact it's trying to mount before the network has been started??

Is a reflash my only option? :(
Yes, you should have included the options "users,noauto" in fstab. "users" to allow any user to mount it, and "noauto" to stop "mount -a" from mounting it at boot!

No, it should be extremely possible to boot from a prepared SD-card. If you have access to an empty SD-card and a computer with a SD-slot, you should be able to use a simple bootable Linux operating system to revert your changes via the terminal!
 
Last edited by a moderator:
WizardStan said:
you didn't need to change the permissions on the mount command. It is executing, otherwise you would be getting a different error.
The problem is that it's looking at some permission list somewhere and preventing non-root users from mounting.
Try modifying your sudoers file (/etc/sudoers) to include the following:
After the #aliases line, add
Code:
Cmnd_Alias      MOUNT         =/bin/mount, /bin/umount
and after the #users line, add
Code:
user_name ALL=NOPASSWD: MOUNT
replacing user_name with your name, of course.

hmm sudoers doesn't have those lines. It has:

#Host alias specification

#User alias specification

#Cmd alias specification

#Defaults specification

#User alias specification
root ALL=(ALL) ALL

#Uncomment to allow people in a group wheel to run all commands
#%wheel ALL=(ALL) NOPASSWD: ALL

#Samples
#%users ALL=/sbin/mount /cdrom,/sbin/umout /cdrom
#%users localhost=/sbin/shutdown -h now

#Add support for a system include dir for sudo rules
#includedir /etc/sudoers.d

at the beginning there are also comments saying that the file must be edited with the 'visudo' command as root. I was using mouepad as root.
 
Last edited by a moderator:
Make your sudoers file look like this:
Code:
#Host alias specification

#User alias specification

#Cmd alias specification 
Cmnd_Alias      MOUNT         =/bin/mount, /bin/umount

#Defaults specification

#User alias specification
root ALL=(ALL) ALL
pleng ALL=NOPASSWD: MOUNT

#Uncomment to allow people in a group wheel to run all commands
#%wheel ALL=(ALL) NOPASSWD: ALL

#Samples
#%users ALL=/sbin/mount /cdrom,/sbin/umout /cdrom
#%users localhost=/sbin/shutdown -h now

#Add support for a system include dir for sudo rules
#includedir /etc/sudoers.d

I added the relevant lines after the "#cmd aliases" and "#user aliases" lines. Really they could have gone anywhere, but it's good to keep them organized.
And yes, to edit the file, type the command
"sudo visudo"
 
hmm and how do I use visudo? It's performance is pretty erratic!! Sometimes the cursor keys move the cursor as expected, sometimes down produces a line feed (something 'enter' never does) and sometimes they produce the letters A B C and D. Backspace doesn't remove characters and neither does delete, and space doesn't insert spaces.

Then there's the issue of saving (not that I'd want to save the mangled file that i've produced so far!)

Any little tips..?
 
Have you never used vi before? Sorry, my arrogance. Quick crash course!
vi has two modes: command mode and insert mode. When you start, you are in command mode. Use the cursor keys to move around.
When you are ready to insert something, press "i" to enter insert mode. Everything you type gets added at that point, including the special characters for the cursor keys, so don't press them while in insert mode. When you're done inserting, hit escape, move to the next spot, and hit "i" to go into insert again.
When you're done and ready to save, type ":wq". That's colon (command), write, and quit.
If you make a mistake, pressing "dd" (d twice) in command mode will erase the entire line. Pressing "x" will just erase one character.
If you've made such a mess that you just want to quit and start over, type ":q!", that's command, quit, yes-I'm-really-sure. Without the ! it warns you you haven't saved yet.
 
Thanks. No I've never used vi. I've always been a Pico person (well not always, you know, just when I had to do Linux at uni for a while). Ill give that a try now
 
Ok, I've also done some looking, and you can use any editor you want to edit the file, visudo just has additional features that make it safer.
 
bill-joy1.jpg


The inventor of Vi. In every photo I've seen he looks... crazy. I like crazy people mind you. B)
 
Ok Stan. I've made the changes. I'm afraid it hasn't really made a difference :(
 
Back
Top