Mount shared folder (vbox) as another user

Well, while I was having another issue related with my shared folder, I ended up getting to this stackoverflow question: Shared folder in VirtualBox for Apache

It helped me in 2 ways, and seems that what I need are those uid and gid options.

So, to mount a shared folder as another user, I would run:

mount -t vboxsf SHARE_NAME /some/dir -o uid=48,gid=48

Also, to see what are your www-data's gid and uid, just run id www-data.

If you also need to change the permissions on the mounted files, just add "dmode" to the options, as:

sudo mount -t vboxsf SHARE_NAME-o rw,dmode=777,gid=GROUP_ID,uid=USER_ID /path/on/guest

The available options are (from mount's help):

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

And if you need it to run during the system init, just create a file on /etc/init/SOMETHING.conf, with something like this:

description     "SOME DESCRIPTION"

start on startup

task
exec mount -t vboxsf YOUR_SHARE_NAME /path/on/guest -o uid=1000,gid=33