Page 1 of 2
VirtualBox changes user privileges - other users can't open
Posted: 14. Aug 2011, 08:27
by bcw787
I hope this specific issue has not been delt with previously, I have searched far and wide but to no avail. I am new to both Mac and VB, so a dummies explanation would be great if anyone knows the answer.
Host: Mac OS X Lion
Virtual Box: 4.1.0
Guest: Windows XP
I have multiple users on the mac, and want all users to be able to use the one virtual disk/guest OS. After trawling as many forums and related posts as I could find, I have installed VB in the "/Users/Shared" folder and changed the default machine folder to "/Users/Shared/VirtualBox VMs". I have ensured all folder and file privileges related to VB inside of "/Users/Shared" are set so "everyone" can "read & write". From there any user can open VB and run the guest OS(in my case Windows XP). The problem arises as soon as I shut down the guest OS and quit VB. From then only that user can run the guest OS in VB unless I go and reset the privileges again.
When I open VB with another user I get the message that Windows XP is inaccessible and following error message is present:
Runtime error opening '/Users/Shared/VirtualBox VMs/Windows XP/Windows XP.vbox' for reading: -38 (Access denied.).
/Users/vbox/tinderbox/mac-rel/src/VBox/Main/src-server/MachineImpl.cpp[685] (nsresult Machine::registeredInit()).
Result Code:
NS_ERROR_FAILURE (0x80004005)
Component:
VirtualBox
Interface:
IVirtualBox {c28be65f-1a8f-43b4-81f1-eb60cb516e66}
I have tried adding all users to the privileges but that does not help. It just dumps all the other users and changes "everyone" to "read only". There are only two files that I can see that these privilege changes are being made to which is affecting the other users. They are "Users/Shared/VirtualBox VMs/Windows XP/Windows XP.vbox" and "Users/Shared/VirtualBox VMs/Windows XP/Logs/VBox.log"
If any one has a solution I would really appreciate the help. This is driving me crazy!
Thanks
Re: VirtualBox changes user privileges - other users can't open
Posted: 14. Aug 2011, 11:38
by Sasquatch
This has been noted before in another topic describing your situation for multiple users on OSX and a single VM. The solution was that the user who last ran a VM will run a script once he's done with VB or logs off to restore the permissions. It does a simple chmod on the files. Something like this should do the trick:
Code: Select all
#!/bin/bash
find /Users/Shared/ -type f -exec chmod 666 {} \;
This changes the file permission to read/write for everyone on all files in /Users/Shared.
Re: VirtualBox changes user privileges - other users can't open
Posted: 14. Aug 2011, 14:38
by bcw787
Hi Sasquatch,
Thanks so much for your prompt reply. I know this may sound a bit stupid, but as an amateur is there any chance you could step me through the process to run the script. I opened applescript editor and copied in your script and hit run, but it did not work.
Also, does this script only need to be run once, or each time each user has finished with VB?
Sincere Thanks!
Re: VirtualBox changes user privileges - other users can't open
Posted: 14. Aug 2011, 15:26
by Sasquatch
The script needs to be made executable first. The application you used creates apple script files and I'm not familiar with that scripting language, so what I wrote will probably not work from there. If you past it in text editor and save it somewhere, then modify the bits with Finder to make it executable, you can run it. It has to be run every time a user has used VB, as that's when the files are changed. Just running VB alone, without a VM, will require this script, because it will change the main XML file. That is the file that holds all the VM registrations.
You might have to look for some other help in to make scripts like these work on your Mac. I only have Linux scripting experience, mostly shell/bash.
Re: VirtualBox changes user privileges - other users can't open
Posted: 15. Aug 2011, 02:27
by bcw787
Thanks for your help Sasquatch, I really appreciate it. I'll see what I can find to make it work.
If anyone has any idea's on how to do it in Mac OS X?
Re: VirtualBox changes user privileges - other users can't open
Posted: 15. Aug 2011, 11:45
by reaperboy
Hi @all,
is there anyone who can help us out starting this script automatically after the VM has been shutdown?????
the script for changing file permissions itself is not the issue, but i have no idea how to start it automatically.
this is more for my wife
Thanks
Re: VirtualBox changes user privileges - other users can't open
Posted: 15. Aug 2011, 20:21
by Sasquatch
You can make a desktop shortcut for it or just put it on the desktop and instruct the user to start the script once he/she is done with the VMs. Another option is to make a separate shortcut that will run a script to start the VB Manager or specific VM and have it so that once the process is done, it will run the last part of the script to set the permissions. On Linux, it would be like this, so you have to change it to make it compatible for Apple Mac OSX.
Code: Select all
#!/bin/bash
VirtualBox
find /Users/Shared -type f -exec chmod 666 {} \;
Re: VirtualBox changes user privileges - other users can't open
Posted: 5. Sep 2011, 23:06
by reaperboy
Hi,
so here is my solution which works find on MAC OS X Lion:
the VMfiles have to be in a directory which is accessible for all users (e.g. /Users/Shared/ ...)
1) create a shell script like this ... anyVM.sh
Code: Select all
#! /bin/sh
echo Starting VirtualMachine
VirtualBox --startvm /Users/Shared/VirtualBox/anyVM/anyVM.vbox &
wait
sleep 5
echo OK
chmod -R 777 /Users/Shared/VirtualBox/
this works quite good, but the user interaction is quite annoying
So lets dig deeper ...
2) create a little apple-script which launches the shell script without user interaction
Code: Select all
do shell script "/Users/Shared/VirtualBox/anyVM.sh"
now save the script as program and verify, that the checkbox "Startdialog" is NOT checked ..
that´s it
BUT ... (there is always a but ...)
you might have problems with the chmod as VirtualBox changes the user of the files, so here is some sudo magic.
3) edit the sudoers file to be able to change mod without problem
for each user who should run this VM add this:
Code: Select all
myuser ALL=NOPASSWD: /Users/Shared/VirtualBox
That´s it.
Hope that helps.
Happy VMing ...
ps: the shell-script and the apple-script should also be located in the /Users/Shared/VirtualBox directory
Re: VirtualBox changes user privileges - other users can't o
Posted: 11. Sep 2011, 17:18
by Sasquatch
If you remove the '&' from the start VM command, then the script will pause as long as the VM is running (well, it should, check by manually starting the command and see if you're returned to your prompt). Then you won't need the wait command. Sleep is fine, it gives things time to finish.
I do find it odd that sudo (or administrative) privileges are required for a folder that should have read/write for everyone. Or full permissions. Maybe you can change that with Finder.
Re: VirtualBox changes user privileges - other users can't o
Posted: 15. Sep 2011, 10:01
by bcw787
Thanks sasquatch and reaperboy! I'll see if we can get it to work...
Re: VirtualBox changes user privileges - other users can't o
Posted: 15. Sep 2011, 16:32
by iroctw
I was annoyed by this issue also.
There are four users on my Mac mini running Lion, and the guest is Windows Vista.
My solution is as follows:
First, I created the guest VM for user A(me) by my account and followed the standard procedure of VB.
I installed the guest disk image in user A and chmod this image file to 666, also shared the directory.
(only disk image file was changed to 666, .vbox file will be reset each time even you change this file to 666)
Then, for every user on my mini, I created the .vbox file and Logs directory by using the standard 'new'
function of VB for users B,C and D, respectively. The disk image file is referenced to the file in user A,
not creating a new one. To create VM for others you have to login their account, respectively.
That's it. One disk image file for everyone and every user needs one VM in their own directory.
No shell script needed before or after VB startups.
I did not install the guest in /users/Shared/, because I did not sense this issue before I did it.
Hope this will do some help.
Re: VirtualBox changes user privileges - other users can't o
Posted: 15. Sep 2011, 23:14
by Sasquatch
That may work at first, but it will cause problems in the long run. Let's say user A changes a setting. User B doesn't have that change. Then user C creates a snapshot, installs some software the others want as well, but that won't be available because it's in the snapshot file. Then user A and B do something else in the Guest and suddenly user C can no longer use the VM because his snapshot tree got borked due to the changes of the parent VDI that should not have been made.
Using the above method of sharing the entire VM with it's settings is the one and only proper way to do it.
Re: VirtualBox changes user privileges - other users can't o
Posted: 16. Sep 2011, 14:20
by iroctw
Hi all,
I am sorry to provide a solution with serious flaws.
Hope no one will adopt it.
Thanks
Re: VirtualBox changes user privileges - other users can't o
Posted: 16. Sep 2011, 20:18
by Sasquatch
No worries. Better be warned than to face the consequences first hand

.
Re: VirtualBox changes user privileges - other users can't o
Posted: 24. Sep 2011, 01:21
by iroctw
Hi all,
To dodge the snapshot tree breakage issue, maybe we can change the disk image write mode from "normal images (the default setting)" mode to
"write-through hard disks" mode as specified in user manual page 79 of version 4.1.2.
Then, snapshot will take no effect to the disk image file and multi-VMs can safely share the disk image file.
Of course, the side effect is no snapshot protection for wrong-doing.
Just for reference.
Thanks