LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   automount vfat partition with rw access for any user (https://www.linuxquestions.org/questions/red-hat-31/automount-vfat-partition-with-rw-access-for-any-user-325869/)

Simon Bridge 05-22-2005 02:31 AM

automount vfat partition with rw access for any user
 
This is for RH9 with 2.4.20-6 kernel as dual boot (via GRUB) with win98SE on an 800MHz celeron aged machine.

I'd like users to be able to access the win98 vfat partition from their desktop. I can get fstab to mount it and an icon appears - however, since the mount user is "root" there is read only access (despite "rw" option in fstab)

The fstab entry goes something like this:

/dev/hda1 /mnt/c: user,rw 0 0

I realise I could set "noauto,users,rw", thus allowing usrs to mount and unmount at whim... but:
windows users are going to be logged in and I don't want to have to teach them about mounting and all. Presumably I need to be able to set the uid and gid for the filesystem. Or create a "windows" group perhaps?

Anyone tried this?

jschiwal 05-22-2005 07:03 PM

If the users are members of the "users" group, then you can use the "gid=users" option, and use a fmask of 0117 and dmask of 0007. This will allow reading and writing on this partition. If you want to give them read access to the win98 parition but not write access use "fmask=0137,dmask=0030".
If what you want to do is give anyone access to the partition, then use "fmask=0111,dmask=0000" for read/write access and "fmask=0333,dmask=0000".

As you probaby noticed, I didn't give "eXecution" rights on the fmask, but did on the dmask. That is because on a world writable partition, you don't want programs executed. However the 'x' bit is needed for directories. It allows you to enter directories, which you need to do to read files inside.
This precaution is even more important if someone has added ./ to their $PATH variable.

Simon Bridge 05-23-2005 06:47 AM

OK: I tried putting the following in fstab

/dev/hda1 /mnt/c: vfat gid=users,fmask=0660,dmask=0770 0 0

It didn't mount at all this time ... what if I said: uid=users,rw ??

I note from the "fat options" section in the mount manpage that the fmask and dmask numbers are the bitmask of permissions not present. So shouldn't that be: fmask=7117,dmask=7007 ?

(When I had the user,rw fstab entry, the mountpoint appeared on the desktop ... but with the one above, the mountpoint didn't. That's what got me confused. Anyway, the mount was fine, but the permissions (read and execute on files and folders) were weird! So there are two questions implicit in there ...)

jschiwal 05-24-2005 05:53 PM

What is the name of the directory you are trying to mount to?

Get rid of that stupid colon!

Simon Bridge 05-24-2005 08:17 PM

The directory is called "c:" because "c:\" it didn't like :)
It does the same if I call the directory "fubar".
jschiwal:
Quote:

Get rid of that stupid colon!
<gasp>! Are you a registered proctologist?

Simon Bridge 05-25-2005 05:15 AM

Update:
The masks are for the permissions not present: so to set permissions to 0660 (-rw-rw---) I must set the mask to 7117.

I've been experimenting with mount -o options since I can do this many times without rebooting. Just to see what happens.

The mount command dosn't seem to see the dmask and fmask options, though umask works nicely. gid works, but only if suid is also set.

It would be desirable if I could set the permissions to
drwxr-x--- and -rwxrw---- (0750 and 0760, masks 7027 and 7017).

For now, I set umask=7007 (-rwxrwx---) since that allows the user to do what they want there. There are no linux executables native to the partition and the system does not have wine installed.

Not great.

Interestingly - noauto,user,rw still sets the x bit for owner (-rwxr-xr-x) for most files ... a few files have different permissions. Now I'm getting confused.

BTW: mounting at /mnt/win98 dosn't change anything.

Thinks: setting the first 3 bits to 000, dosn't activate the suid,sgid, and sticky thingys. If I make this a 6 (mask 1) then the suid and sgid bits are set. Does this make a difference? <checking> Nope...

options: users,suid,gid=users,dmask=1027,fmask=1017
mounts everything rwxr-xr-x ...

jschiwal 05-25-2005 05:39 AM

A colon character shouldn't be used because it can have a special meaning in a shell. Plus it is one of the seperation characters in various configuration files. Simply call it "c" if you want.

Also, "users" is a group and not a user. You can use the "gid=users" option. If you are the only person using the partition, then you can use "uid=<yourusername>" also.

Simon Bridge 05-25-2005 06:01 AM

1. The colon character dosn't make any difference in this case (same trouble mounting to /mnt/win98 - it looks nicer though.)
2. I know users is not a user but a group and I did use gid=users. (that was a typo... "users" is also a mount option allowing anybody to mount/unmount a file system. See, I do read the man pages!) uid=<myname> does work to gain access - permission bits still set to rwxr-xr-x though. dmask and fmask still don't change permissions...

Is this something you've tried yourself? If so, please paste your fstab line here (either one of us can make the name changes required.)

Simon Bridge 05-25-2005 06:06 AM

perhaps I should allow it to mount under defaults somewhere else, then shift it and it's bitmasks via --bind or ...

jschiwal 05-26-2005 01:29 AM

You are right. I got my umask and fmask values negated. I've since changed them. Sorry for the confusion.

I don't know if on your system, the other users are members of the "users" group.
An option of 'users' (not gid=users) means that it is possible for an ordinary user to use the mount command to mount the device. If the device is a fixed hard-drive and not a key-pen usb drive, then you would probably want to mount it when the machine boots up. The 'noauto' option means that this partition will NOT be mounted automatically during boot. You would use the 'noauto' and 'users' option for a CDROM or floppy device. Because they are removable, and may not have media present when you bootup.
The sticky bit would protect group writable files from deletion but not modification. It is used for the /tmp partition to protect temporary lock files. The other extended bits like suid and sgid bits you don't want to use. They would elevate a persons rights when using the partition.

The 0 in front of the number in fmask=0666 for example indicates that the number is octal. Using fmask=666 may be the same as fmask=1232 but I'm not certain about that. It also may depend on the version of the mount program used. In any case, since it is an octal number, precede it with a '0'.

I just plugged a pen drive into my laptop. It uses the fat32 filesystem so it is similar as yours. Since it was automounted, I su'ed to root and unmounted it before my little experiment.
I used the mount command:rw
mount -t vfat /dev/sda1 /mnt -o rw,noexec,nosuid,fmask=0111,dmask=0,gid=users,iocharset=utf8
In an fstab entry, you would want to include the option auto for a fixed drive. As a regular user I was able to read and write to the drive. The directories have permissions of 'rwxrwxrwx' and the files have permissions of 'rw-rw-rw'. With the owner of root and group of users.

These options should work for you. I would still give the mount location a better name. Perhaps /mnt/windows_c. When the c:\ drive on a windows computer is mounted on a network, it is often given the name "c_drive" or "drive_c" But the colon isn't part of the name, it is part of the msdos command indicating that it is a device.

jschiwal 05-26-2005 01:44 AM

I should of mentioned earlier that giving anyone but yourself access to the partition that contains the WINDOWS system directory would be a bad idea. Anyone could write a virus into your system (if you give them write access) or read your email messages ( messages read in windows ).

Simon Bridge 05-26-2005 03:27 AM

Yeah, I've been thinking about this (below) only yesterday and figured that it would be better only to mount the "My Documents" tree from the windows partition.

Quote:

I should of mentioned earlier that giving anyone but yourself access to the partition that contains the WINDOWS system directory would be a bad idea. Anyone could write a virus into your system (if you give them write access) or read your email messages ( messages read in windows ).
Trying the mount options a bit later.

Simon Bridge 05-26-2005 08:37 AM

Great - thanks, this will help clear things up... this is what I did:
Code:

[root@hauora3 guest]# mount -t vfat /dev/hda1 /mnt/win98 -o rw,noexec,nosuid,fmask=0111,dmask=0,gid=users,iocharset=utf8
[root@hauora3 guest]# ls -l /mnt/win98
total 4496
-rwxr-xr-x    1 root    users          7 May 14  2001 autoexec.bat
-rwxr-xr-x    1 root    users          0 Oct 30  2001 autoexec.bit
-rwxr-xr-x    1 root    users          0 Oct 19  2001 autoexec.via
drwxr-xr-x    6 root    users        8192 May 14  2001 bitware
-rwxr-xr-x    1 root    users      44337 Oct 19  2001 bootlog.prv
-rwxr-xr-x    1 root    users      45109 Oct 19  2001 bootlog.txt
-rwxr-xr-x    1 root    users      93890 Apr 23  1999 command.com
-rwxr-xr-x    1 root    users          30 May 14 17:15 config.sys

As you can see ... I did not get the same as you.
However, I did try the same mount command for a virgin (unsullied by windows) vfat partition. And it worked for that one, exactly the way you said it would and the way that the man pages say.

So this would appear to be a windows thing ... could win98 have something in the fat32 partition which could effect this? note, this partition was not formatted as fat32, but as fat16. This shouldn't make a difference to the fat fs mount-options, at least, not according to "man mount".

Or maybe this is a quirk of the windows root filesystem - and I should mount /dev/hda1 somewhere like /usr/win98 under defaults and then mount a subtree where the users can easily get to it?

To change track slightly: to my mind, the options... noauto,user,rw ...should disallow automount, but allow the user to mount the filesystem via the user mount tool, and the file system will be mounted read/wrote (x bit not set except for directories).

However, in practise, while users can mount OK, the owner is set to the username, and the permissions are unaltered from the above code section. Again, this behavior is unique to the win98 partition. Normal win32 partitions behave themselves.


All times are GMT -5. The time now is 12:29 AM.