What is happening is that the files created, when the machine state is saved, are given the permissions based on the current user. Therefore, all other users will be disallowed from using these new files.
To fix it, you need to make sure all users are in the same group, and set additional bits on the folder, which will cause all children folders/files inherit the same permissions.
(1) Create a Group for users to share:
Add a group, e.g.:
sudo groupadd vboxsharing
(Note, there is a "vboxusers" group already installed by VirtualBox. It has a specific use, but you can user this existing group rather than adding a new one.)
(2) Add users to the group:
The users who will need access to the shared VMs, need to be added to the group:
sudo usermod -a -G vboxsharing <user1>
sudo usermod -a -G vboxsharing <user2>
# ... etc.
NOTE: You can alternatively set the group as primary for all these users (sudo usermod -g vboxsharing <userXYZ>
), which means you can skip step #3 below. However, doing so is a security risk and should be avoided.
(3) New VirtualBox files to be accessible to the group:
Change the folder's group ownership:
sudo chgrp -R vboxsharing /Users/shared_folder
And, set bits setuid and setgid, as necessary, to ensure future files are created for the group.
Therefore, for your folder, do the following:
sudo chmod -R 6770 /Users/shared_folder
The 6, at the start of the permission bits, is the combination of setuid and setgid:
Technically, you DO NOT need setuid. Therefore, it is enough to have:
sudo chmod -R 2770 /Users/shared_folder
..
Note:
And, you don't need that long find
command, it is a command to apply a different set of permissions to files, and a different set to folders.
Thank you man. Unfortunately, the same problem still occurs: VirtualBox still set permissions to the current user only. I'm thinking in the workaround of a script that changes the permissions right before executing VirtualBox. It would be ugly and the users will have to introduce their admin passwords every time though... – chelder – 2016-07-03T13:30:50.800
1If you SETGID the folders and everyone has group write (via
umask
) then the owners of the files won't matter. – chicks – 2016-07-04T13:04:16.770@chicks, thanks for pointing out the redundancy. I've modified my answer, to highlight the unnecessary setting of setuid, and expand to ensure group is set (I may have incorrectly assumed that it is obvious). I will experiment later today when I have some time, to make sure my answer works on my machine... so apologies, my answer may still be incorrect. – jehad – 2016-07-04T13:47:32.517