Tech Support > Operating Systems > Linux / Variants > Mount - as regular user?
Mount - as regular user?
Posted by Tobias Brox on November 17th, 2003


So I'm sitting as a regular user at a computer. We are allowed to mount
things, i.e. the floppy - /etc/fstab has this line:

/dev/floppy /mnt/floppy vfat noauto,rw,user,nosuid,nodev,sync 0 0

Well, nice enough. Except for that the floppy is formatted ext2, not fat.
I have ownership to the device:

brw-rw---- 1 tobias floppy 2, 0 Jan 30 2003 /dev/fd0

But anyway ...

$ mount -t ext2 /mnt/floppy/
mount: only root can do that

$ mount -t ext2 /dev/fd0 ~/floppy
mount: only root can do that

$ mount -o loop -t ext2 ~/floppy.img ~/floppy
mount: only root can do that

Why can't I do this? What problems are there to allow regular users doing
this?

--
Tobias Brox - +47 917 000 50 - http://www.cs.uit.no/~tobias/
Check our new Mobster game at http://mobster.td.org.uit.no/
(web game, updates every 4th hour, no payment, no commercials)

Posted by John Winters on November 17th, 2003


In article <bpb5re$216o$1@news.uit.no>,
Tobias Brox <tobias@stud.cs.uit.no> wrote:
None at all. Just create (or have your sysadmin create) another line
in /etc/fstab which reads:

/dev/floppy /mnt/ext2floppy ext2 noauto,rw,user,nosuid,nodev,sync 0 0

And then type:

mount /mnt/ext2floppy

HTH
John
--
The Linux Emporium - the source for Linux in the UK
See http://www.linuxemporium.co.uk/

We had a woodhenge here once but it rotted.

Posted by Lew Pitcher on November 17th, 2003


On Mon, 17 Nov 2003 18:59:58 +0000 (UTC), Tobias Brox <tobias@stud.cs.uit.no>
wrote:

Change the fstab entry to

/dev/floppy /mnt/floppy auto noauto,rw,user,nosuid,nodev,sync 0 0

and mount will automatically determine the filesystem type from the media.
The syntax for a user mount is...
mount /mount/point
as in (in your case)
mount /mnt/floppy

(The corresponding umount is
umount /mnt/floppy
)

Any other variation is taken as trying to use root user options, which is
forbidden to a non-root user.

--
Lew Pitcher
IT Consultant, Enterprise Technology Solutions
Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employers')

Posted by Robert Heller on November 17th, 2003


Tobias Brox <tobias@stud.cs.uit.no>,
In a message on Mon, 17 Nov 2003 18:59:58 +0000 (UTC), wrote :

TB> So I'm sitting as a regular user at a computer. We are allowed to mount
TB> things, i.e. the floppy - /etc/fstab has this line:
TB>
TB> /dev/floppy /mnt/floppy vfat noauto,rw,user,nosuid,nodev,sync 0 0
TB>
TB> Well, nice enough. Except for that the floppy is formatted ext2, not fat.
TB> I have ownership to the device:

Not relevant.

TB>
TB> brw-rw---- 1 tobias floppy 2, 0 Jan 30 2003 /dev/fd0
TB>
TB> But anyway ...
TB>
TB> $ mount -t ext2 /mnt/floppy/
TB> mount: only root can do that
TB>
TB> $ mount -t ext2 /dev/fd0 ~/floppy
TB> mount: only root can do that
TB>
TB> $ mount -o loop -t ext2 ~/floppy.img ~/floppy
TB> mount: only root can do that
TB>
TB> Why can't I do this? What problems are there to allow regular users doing
TB> this?

You need either another fstab entry (and make a new mount point):

/dev/floppy /mnt/floppye2 ext2 noauto,rw,user,nosuid,nodev,sync 0 0

OR change the existing fstab entry to:

/dev/floppy /mnt/floppy auto noauto,rw,user,nosuid,nodev,sync 0 0

There are no real issues with letting regular users mounting removable
media, such as floppies or Zip drives, so long as nosuid is included in
the mount options. It is unusual to format a *floppy* to be ext2
though. I do it all of the time with Zip (100meg) and Orb (2G) carts.
The FAT file system is actually ideal for floppies (1.44meg), since it
has a fairly low file system overhead. Fragmentation is generally not
an issue, one is generally not creating and deleting lots of files --
reformatting is a 'cheap' operation with a floppy.

TB>
TB> --
TB> Tobias Brox - +47 917 000 50 - http://www.cs.uit.no/~tobias/
TB> Check our new Mobster game at http://mobster.td.org.uit.no/
TB> (web game, updates every 4th hour, no payment, no commercials)
TB>

\/
Robert Heller ||InterNet: heller@cs.umass.edu
http://vis-www.cs.umass.edu/~heller || heller@deepsoft.com
http://www.deepsoft.com /\FidoNet: 1:321/153







Posted by Baard Ove Kopperud on November 18th, 2003



"Lew Pitcher" <Lew.Pitcher@td.com> wrote in message
news:3fb92158.27159471@news21.on.aibn.com...
Just a little warning here...

I'm don't know if this is still a problem, but if you *both*
have 'vfat' (long filenames) and old-fascioned 8+3
filename supported filesystem ('fat' or was it
'umsdos' filesystem?) available for MS-DOS/Win
floppies, then 'auto' may not be able to decide which
of the two (vfat or the other one) to use, and thus
refuse to mount the floppy.

-Koppe




Posted by Tobias Brox on November 19th, 2003


John Winters <newstmp@sinodun.org.uk> wrote:
I didn't phrase my question good enough:

Why cannot Linux allow me, as a regular user, to get access to files on
non-mounted filesystems that I own, without the sysadmin explicitly telling
the system exactly what I can mount and where it can be mounted? I.e., I
may have an image (ISO, ext2 or whatever) at $HOME, how to read the files?

--
Tobias Brox - +47 917 000 50 - http://www.cs.uit.no/~tobias/
Check our new Mobster game at http://mobster.td.org.uit.no/
(web game, updates every 4th hour, no payment, no commercials)

Posted by P.T. Breuer on November 19th, 2003


Tobias Brox <tobias@stud.cs.uit.no> wrote:
False. You don't own them. They just happen to be lying around in the
environment. They may be yours. They may be your uncles. Who can tell?
Your sysadmin will know, as the person responsible for the system.

You can read the files by using an application that does a loopback
mount for you. Or you can read them byte by byte off the file system
image.

Peter

Posted by P.T. Breuer on November 19th, 2003


P.T. Breuer <ptb@oboe.it.uc3m.es> wrote:
Well, if they are in your environment, yes they are yours (but not
what's in them! - you own the medium but not the content). The real
point is that mounting them on the system affects the system, and so
is a sysadmin decision. He can delegate it to you if he wishes.

I was going to remind you that other people files may lie in a
directory of yours. Consider that too.

Peter

Posted by Ed Blackman on November 19th, 2003


Tobias Brox wrote:
The filesystem images could contain setuid binaries, so allowing users
to mount arbitrary images would allow them to run arbitrary programs
as root.

The filesystem images could contain device files with less restrictive
permissions. There's nothing special about the name "/dev/hda", for
instance: it's the fact that it's a device file with a certain major
and minor that tells the kernel that accessing that file should access
the first IDE device. So if a malicious user created an image that
had a device file equivalent to /dev/hda on it with 777 permissions,
and was able to mount that image, they could format the hard disk.

That's why the mount option "user" implies the options noexec, nosuid,
and nodev.

Ed


Posted by Serguei Miridonov on December 10th, 2003


Robert Heller <heller@deepsoft.com> wrote in message news:

Well, another problem: I've downloaded ISO image and want to see what's inside using

mount -o loop,nodev,nosuid,ro image.iso mnt-in-my-home-directory/

However, mount does not allow me to do that...

Any idea?

Posted by Pascal Bourguignon on December 10th, 2003


ebenONE@tampabay.ARE-ARE.com.unmunge (Hactar) writes:


The important point in these fstab entries is the "user" keyword!

To be able to use mount as a user, there must be an entry in
/etc/fstab that allows the users to do it. Of course the problem with
looping mounts, is that no twice you mount the same file at the same
place!

You could try:

/home/hactar/image.iso /home/hactar/mnt auto loop,noauto,ro,user,nosuid,nodev,async 0 0

but of course, this would work only for you, and for predetermined
image and mount point.

As a user, you could still rename your images when you want to mount them.

Seems to me simplier to have a sudo account and do the mount as root.


--
__Pascal_Bourguignon__ . * * . * .* .
http://www.informatimago.com/ . * . .*
There is no worse tyranny than to force * . . /\ () . *
a man to pay for what he does not . . / .\ . * .
want merely because you think it .*. / * \ . .
would be good for him. -- Robert Heinlein . /* o \ .
http://www.theadvocates.org/ * '''||''' .
SCO Spam-magnet: postmaster@sco.com ******************

Posted by Pascal Bourguignon on December 10th, 2003


ebenONE@tampabay.ARE-ARE.com.unmunge (Hactar) writes:

That would be hard link. It seems that symlinks are followed before
mounting, so if the mount point is a symlink, the destination will
have to be speficied in /etc/fstab.

--
__Pascal_Bourguignon__ . * * . * .* .
http://www.informatimago.com/ . * . .*
There is no worse tyranny than to force * . . /\ () . *
a man to pay for what he does not . . / .\ . * .
want merely because you think it .*. / * \ . .
would be good for him. -- Robert Heinlein . /* o \ .
http://www.theadvocates.org/ * '''||''' .
SCO Spam-magnet: postmaster@sco.com ******************

Posted by Serguei Miridonov on December 10th, 2003


Pascal Bourguignon <spam@thalassa.informatimago.com> wrote in message news:<87wu95t8oa.fsf@thalassa.informatimago.com>.. .
So, it seems there is no simple way to allow users to inspect iso
image files. /etc/fstab may have only a few records with predefined
names of iso files and mount points, and if there are many users
logged in, it's difficult to tell them which mount points are already
in use... Also, when user logs out, there must be a script which
unmounts the user files...

For using sudo, it seems the system administrator has to write a
script which does the actual mount. I'll think about that. Thanks.

Posted by John-Paul Stewart on December 10th, 2003


Serguei Miridonov wrote:
[snip]

No script needed. The admin needs to edit /etc/sudoers to allow the
designated user(s) to use 'mount'. Then the user does 'sudo mount
<whatever>'. That's all there is to it (once you figure out the format
of /etc/sudoers). The system sees the mount command as if root had
entered it on the command line.

Posted by Serguei Miridonov on December 11th, 2003


John-Paul Stewart <jpstewart@sympatico.ca> wrote in message news:<3FD760FD.F8E8121D@sympatico.ca>...
No so simple, I think. Users must be denied to mount anything with
working suid executables, device files, etc. So, nodev,nosuid options
are mandatory. Also, if users are able to mount they also need umount.
Now, if umount runs with root priveleges, how to disable unmounting
the system volumes and some other required stuff?

Does anyone have working sudoers file wich enables mount/umount for
users and still provides strict security?

Posted by Chris F.A. Johnson on December 11th, 2003


On Thu, 11 Dec 2003 at 17:06 GMT, Serguei Miridonov wrote:

I don't have one, but it's simple to do: just write scripts with
the commands that are to be allowed, and put those in the sudoers
file.

The scripts should check that the item being mounted or unmounted
is a file, not a partition.


--
Chris F.A. Johnson http://cfaj.freeshell.org
================================================== =================
My code (if any) in this post is copyright 2003, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License

Posted by LEE Sau Dan on December 16th, 2003


Chris> On Thu, 11 Dec 2003 at 17:06 GMT, Serguei Miridonov wrote:
Chris> I don't have one, but it's simple to do: just write
Chris> scripts with the commands that are to be allowed, and put
Chris> those in the sudoers file.

Read what Chris had said before. He was "complaining" that sudo is
not easy for the task because he needs to write scripts to confine
what and how the users can mount and umount.


Chris> The scripts should check that the item being mounted
Chris> or unmounted is a file, not a partition.

So, it involves scripting, which was what Chris was "complaining"
about, and what John counter Chris.


--
Lee Sau Dan +Z05biGVm-(Big5) ~{@nJX6X~}(HZ)

E-mail: danlee@informatik.uni-freiburg.de
Home page: http://www.informatik.uni-freiburg.de/~danlee

Posted by Noi on December 17th, 2003


On Tue, 16 Dec 2003 22:45:57 +0100, LEE Sau Dan thoughtfully wrote:

When he updates the sudoers file he can define a group and assign specific
mount commands available to that group or those users can use.

# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom







Similar Posts