[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Coercing sane file permissions -- site specific



On Mon, Nov 21, 2016 at 08:18:39AM -0500, Greg Wooledge wrote:
On Sat, Nov 19, 2016 at 12:51:58PM -0600, Richard Owlett wrote:
I use fat16 and fat32 formatted USB flash drives

When I plug one into my Debian machine I want totally unfettered
read/write access.
[when logged in as root or *ANY* user ID]

You can't.

You have to be root to mount one of these things, or to edit the
/etc/fstab file to give an ordinary user the permission to mount one of
these things.

Let me restate this another way. Greg said "You have to be root to mount ...". Another way to say this is "Only root can mount ...".

What's the difference? If you want to mount you can EITHER switch to root and issue a mount command as root, OR you can install something which runs AS ROOT and mounts the device automatically.

Now, I believe pmount was mentioned in this thread, as was udisks. These demons can be considered brokers. You ask them to mount the disk and they, running as root, mount the disk and set the appropriate permissions to your user.

There is another alternative that I just found, though. With a little hacking, you can get udev itself to mount the drive.

https://www.axllent.org/docs/view/auto-mounting-usb-storage/ shows a set of udev rules that will mount a vfat or ntfs USB stick to "/media/${File System ID or Label}", AND set the user permissions appropriately.

Pay appropriate attention to the line with "ENV{mount_options}=" in, though. Use the information elsewhere in this thread to set a sensible uid, gid and umask to get the permissions you require.


Didn't we tell you this multiple times over the last several weeks?
Yes, we did.

AS ROOT, you can determine the device name (which is dynamically
generated every time you plug it in), and then mount it with some
commands like:

mkdir -p /usb
mount -o uid=richard /dev/sdb1 /usb

Where /dev/sdb1 is the partition you want to mount, and /usb is a
directory you create specifically for the purpose of mounting the
device onto.  And "richard" is the username you want the files to
appear to be owned by.

ONCE IT IS MOUNTED, then user "richard" can read and write to the
files and directories.

To unmount it, you have to be root again.  And then it's simply:

umount /usb


--
For more information, please reread.


Reply to: