How to give not-root user ability to mount devices to any mount point???
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to give not-root user ability to mount devices to any mount point???
How do I allow any user or specific users to mount specific devices at a mount point they specify?
I see that fstab can be edited with an entry like so:
/dev/fd0 /media/floppy auto user,noauto
That would allow any user to
# mount /dev/fd0
and have it be mounted to /media/floppy
But if the user tried
# mount /dev/fd0 ~/mymounts/floppy
The mount would fail. The entry in fstab limits the mount to the mount point specified.
Specifically I need to be able to allow non-root users the ability to mount filesystems using the loop feature, as in
# mount -o loop some.fs.image /some/mount/point
Even if the user has read/write access to the /dev/loop(n) device nodes, it appears only root can mount. It seems to me that if a user has read/write access to a device, and read/write access to a mount point, they should be able to use mount regardless of what it says in fstab.
If you REALLY require this feature you could
add a line per user into /etc/fstab, and tell them
to mount the devices not using the /dev entry
but rather the mountpoint to execute it, e.g.
mount ~/mymounts/floppy
Cheers,
Tink
P.S.: I don't think that rw to a loop from several mountpoints
would be a good idea.
jdupre, this is a very very bad idea. Let's say you give me rights to use mount and allow me to mount .iso's via loop to any directory that I can write to. (phrasing what you mention at the start of the thread). This is _ASKING_ to be hacked. All I would need to do is upload an .iso image of whatever I wanted...say my own personal executables that I built on my personal server. I could then mount that iso in say, /var. Suddenly I have all the programs/files in that iso at my disposal.
Might not sound like much, but if the user can write to /etc, that means with 1 .iso, I can overmap your /etc to be my /etc...which I know the root password for and have different config files for. Boom, your machine is mine.
This is just a taste of why mount is a root only program and why it is STRONGLY discouraged to do exactly what you are trying to do. Please take my post seriously and try to think of another idea for your problem. I would hate to hear later your machine has been hijacked or worse.
Thanks for the advices. My requirements are that of a developer, not a system administrator. This is not a public machine, and "root" and myself are the only users on the system. I just hate having to su all the time just to mount/umount a filesystem I happen to be working on at the moment. (I am working with filesystem images that I mount as a loop device.) Apparently this can only be done as root.
I thought that by simply adding myself to the group that owns the /dev/loop devices I could overcome this limitation of mount.
Of course I could just always login as root, but that has it's drawbacks as well!
I'd rather say you should setup a line in your /etc/fstab for the images. I am setup much like how your setup. I typically have 1 console window that's left logged in as root. Yes, bad. Yes, convenient.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.