The RedHat login scripts make sure that several devices (like floppy
belong to the console user. I'd like to use autofs for floppy drives and
it would be nice if the floppy would be mounted with the owner permissions
(rather than root).
(I also sent this request to Peter Alvin.)
Created attachment 21385 [details]
Automount script that copies the device permissions
I just attached a script ``auto.mnt" that works with autofs
to mount the removable devices under ./mnt.
The script scans the fstab file for entries with
a matching mount point and options "user" and "noauto".
It also understand option "owner" and interprets it by
adding a "uid=" and "gid=" in such a way that
the filesystem owner matches the device owner.
% ls -l /mnt/floppy
-rw-r--r-- 1 leonb floppy 46194 Jun 19 17:24 arbib.tgz
-rw-r--r-- 1 leonb floppy 252 Jun 19 18:03 auto.master
-rw-r--r-- 1 leonb floppy 1561 Jun 20 06:26 auto.mnt
Created attachment 21386 [details]
Fixed version (previous had garbage after the doc)
I currently use Take/GiveConsole to do a similar thing:
MYUID=`id -u $USER`
MYGID=`id -g $USER`
sed "s/uid=[0-9]*/uid=$MYUID/g;s/gid=[0-9]*/gid=$MYGID/g" /etc/auto.mnt >
mv -f /etc/auto.mnt. /etc/auto.mnt
> I currently use Take/GiveConsole to do a similar thing.
My auto.mnt is not a data file but an executable script.
There is no need to replicate the list of removable devices.
It only uses the usual fstab entries to determine the mount
line and make everything happens. That includes the insertion
of the uid= and gid= option (when option "owner" is specified).
For instance, inserting /etc/auto.mnt and the corresponding
/etc/auto.master line in the autofs-xxx.rpm would make linux mount
all removeable devices listed in fstab on demand, with the
proper uid/gid options. No configuration necessary.
Created attachment 21850 [details]
Autofs script that automounts devices with correct ownership
Just attached an improved version of the script.
This version relies less on bash oddities
and works properly when the user does not own
I think the proper way to solve this is by adding an option to
mount which causes the fs to be mounted with the permissions of
the device. See #45166