0

Well, title says it all, but to be more clear:

To mount a share in a local mount point I need to do something like

sudo mount -t cifs //location/to-share /home/<user>/some/destination -o gid=<gid>,uid=<uid>,username=<username>

Conversely, doing this:

mount -t cifs <all the other arguments>

will result in mount: only root can do that. Why? Why do I need to be superuser? I am adding something to my home directory. Then why do I need to superuser? I'm sure there is a valid reason, but it just strikes me as odd.

7
  • If you read through the mount documentation man mount, you will find information on how to mark the mount point as being user mountable. Jun 16, 2014 at 22:24
  • That's not answering WHY this is the default behavior.
    – Gx1sptDTDa
    Jun 16, 2014 at 22:33
  • True, but it's a comment rather than an answer. Jun 16, 2014 at 22:34
  • 1
    Other than the plug in USB type devices, I'm not sure that you can. This is probably a hold over from earlier days in Unix, to prevent casual insertion of disks where they don't belong. Jun 16, 2014 at 22:40
  • 1
    You can mount shares in your home without root access. However, I know only graphical way how to do it. But after mounting, you can access those shares through .gvfs directory. This is fuseblk, user-space driver functionality.
    – Danatela
    Jun 17, 2014 at 3:00

2 Answers 2

0

I believe the answer to WHY can't a normal user mount something anywhere would be that a mount can be mounted OVER an existing directory, completely hiding the existing directory. If you do this with a directory containing binaries than the user would be able to alter the binaries that get executed.

Now if you own the directory (like your home directory) then perhaps it would not as big of a deal. But I think root would want to know if a new drive got mounted before he or she trusted the content of that mount point. Thus you can specifically allow a user to mount to a particular mount point, but the default is to disallow.

0

If what you mounted contains a setuid root program, and your mount options enabled it, you can effectively gain root. Thus, irrespective of where you're mounting stuff, allowing users to mount without requiring root is a security risk.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .