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.

  • If you read through the mount documentation man mount, you will find information on how to mark the mount point as being user mountable. – Charles Green Jun 16 '14 at 22:24
  • That's not answering WHY this is the default behavior. – Gx1sptDTDa Jun 16 '14 at 22:33
  • True, but it's a comment rather than an answer. – Charles Green Jun 16 '14 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. – Charles Green Jun 16 '14 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 '14 at 3:00
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.

| improve this answer | |
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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.