2

I am trying to set a VirtualBox shared folder mountable by any user, so this is the line I put in /etc/fstab:

# mint shared folder
mint /media/sf_mint vboxsf defaults,user,uid=1000,gid=999 0 0

However, I get this error message:

juanlu@minted ~ $ mount mint
Only root can mount shared folders from the host.
juanlu@minted ~ $ sudo !!
sudo mount mint
unknown mount option `user'
valid options:
  rw         mount read write (default)
  ro         mount read only
  uid       =<arg> default file owner user id
  gid       =<arg> default file owner group id
  ttl       =<arg> time to live for dentry
  iocharset =<arg> i/o charset (default utf8)
  convertcp =<arg> convert share name from given charset to utf8
  dmode     =<arg> mode of all directories
  fmode     =<arg> mode of all regular files
  umask     =<arg> umask of directories and regular files
  dmask     =<arg> umask of directories
  fmask     =<arg> umask of regular files

If I remove the user option, then I am forced to use sudo but at least the owner of the mount point is assigned properly. What am I doing wrong here?

Notice that this might be duplicate to Mounting a VBox shared folder as user, but I actually tried an option it was supposed to work.

3 Answers3

1

As kindly answered in the VirtualBox user support forums, vbox shared folders are not actually devices (if they were, they would be under /dev/) and therefore the "user" option among others is not applicable. Consequently it's not possible to allow non-admin users to manually mount the shared folder.

However, there's still the possibility to automatically mount the vboxsf from /etc/rc.local and customize the mount options. This is similar to automount but allowing to set proper masks and permissions to the folder, as explained here. Notice though that this page is incomplete in that it points to the mount man page to list the available list of options but, as a matter of fact, some of them are not applicable, as seen above.

0

This looks like a bug in the program file mount.vboxsf.c, which is part of the VirtualBox Guest Additions for Linux, and I believe that you are doing nothing wrong.

The check for being executed under the root account is done immediately in main() at the start of the program, and before the parameters were processed, so before the user parameter was detected or processed.

The check should have been done much later, after the effective user ID of the process (or its fork) was changed to the specified user account.

You should signal this bug to the VirtualBox developers.
The right forum seems to be VirtualBox on Linux Hosts (login required).

harrymc
  • 498,455
0

You don't necessarily need the user option in /etc/fstab to allow ordinary users to mount a filesystem.

Another option is to configure sudo to allow this action, either with or without asking for the executing user's password.

From man sudoers:

Authentication and logging

The sudoers security policy requires that most users authenticate themselves before they can use sudo. A password is not required if the invoking user is root, if the target user is the same as the invoking user, or if the policy has disabled authentication for the user or command.

Tag_Spec

[...]

NOPASSWD and PASSWD

By default, sudo requires that a user authenticate him or herself before running a command. This behavior can be modified via the NOPASSWD tag. Like a Runas_Spec, the NOPASSWD tag sets a default for the commands that follow it in the Cmnd_Spec_List. Conversely, the PASSWD tag can be used to reverse things. For example:

ray rushmore = NOPASSWD: /bin/kill, /bin/ls, /usr/bin/lprm

would allow the user ray to run /bin/kill, /bin/ls, and /usr/bin/lprm as root on the machine rushmore without authenticating himself.

So a line like this in /etc/sudoers will allow any user to mount the specified file system without entering any password:

ALL ALL = NOPASSWD: /bin/mount mint

Then sudo mount mint should work as an ordinary user.