Skip to contentSkip to conversation

Non-root mount of a FS?

DISCUSSION Paul Furness 2 participants 3 messages Oct 28, 2002

lore
Share & tools
lore
#0 lore raw

Good afternoon.

Can anyone help me out with something that's been annoying me for at least a year? I'm currently using RH 7.3 and Gnome, with Ximian on top, but I think that is probably not all that relevant to this:

If I log in as me (not root) and I put a CD in, I can mount it by device like this:

mount /dev/cdrom

or by mount point like this:

mount /mnt/cdrom

This all works fine because I have this in my /etc/fstab:

/dev/cdrom /mnt/cdrom iso9660 noauto,owner,kudzu,ro 0 0

So far, so good.

I can also do this with a floppy (mount /dev/fd0 or mount
/mnt/floppy) because I also have this in /etc/fstab:

/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0

So I want to do this with another device (in this case a USB Flash HD which appears as sda1) so I do this:

/dev/sda1 /mnt/ezdrive vfat noauto,owner,kudzu 0 0

The problem is that, as root, can do what I want (mount /dev/sda1) and it works just fine. But if I try this as the user, I get this:

mount: only root can mount /dev/sda1 on /mnt/ezdrive

So it's a permission thing, right? This is where I get lost. "ls -l /dev/cdrom" shows that it's a pointer to /dev/scd0. "ls -l /dev/scd0 shows that the file is owned by me. If I log into the machine as someone else, the file is owned by them.
However, /dev/sda1 is persistently owned by root.

So something is changing the ownership of the device files to enable the user to mount those devices?

What?

How can I set it up to do this for other devices (or even NFS mounts but not using AMD)? I'm having a real hard time finding any documentation for this. Oh, and I _don't_ have autofs running.

Somebody must know what's going on...

Thanks

Paul.

Signature · 5 lines
Paul Furness

Systems Manager

Steepness is an illusion caused by flat things leaning over.
#1 lore raw
Quoted 10 lines · Paul Furness

So it's a permission thing, right? This is where I get lost. "ls -l /dev/cdrom" shows that it's a pointer to /dev/scd0. "ls -l /dev/scd0 shows that the file is owned by me. If I log into the machine as someone else, the file is owned by them.
However, /dev/sda1 is persistently owned by root.

So something is changing the ownership of the device files to enable the user to mount those devices?

What?

AFAICT, the display manager (xdm, gdm, kdm, ...) is configured to use the pam_console module, which sets the permissions of various devices as specified by /etc/security/console.perms.

Signature · 1 line
Glynn Clements <[email protected]>
#2 lore raw

Hurrah! That got it! Thanks, Glynn.

Just in case anyone else is trying to get this to work, here's what I did:

In order for users to mount devices, they need to have perms to the device file. The display manager knows who's just logged into the console, and therefore should have rights to change this permissions, and it is configured in /etc/security/console.perms (man console.perms helps here).

Basically, the device you want to make available must have some appropriate entries in here, and then the ownership of the device files gets changed when you log in.

To get USB Flash drive to work, the simplest way is to use an already existing entry in this config file - ie, create a link in /dev to the device which youre flash drive comes up as (sda1 or sdb1, probably) and call the link "flash" something (eg flash, flash1 or flash01).

Then create a mount point for it under /mnt which is also called flash* (/mnt/flash or /mnt/flash1 and so on).

Finally, create an entry in /etc/fstab which maps the device to the mount point. The easiest is to copy the cdrom or floppy entry, and make sure it doesn't have "ro" in the options.

Then it works.

Paul.

Quoted 25 lines · Glynn Clements
Quoted 10 lines · Paul Furness

So it's a permission thing, right? This is where I get lost. "ls -l /dev/cdrom" shows that it's a pointer to /dev/scd0. "ls -l /dev/scd0 shows that the file is owned by me. If I log into the machine as someone else, the file is owned by them.
However, /dev/sda1 is persistently owned by root.

So something is changing the ownership of the device files to enable the user to mount those devices?

What?

AFAICT, the display manager (xdm, gdm, kdm, ...) is configured to use the pam_console module, which sets the permissions of various devices as specified by /etc/security/console.perms.

Signature · 5 lines
Glynn Clements <[email protected]>
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 5 lines
Paul Furness

Systems Manager

Steepness is an illusion caused by flat things leaning over.