Page 1 of 1

VBoxManage 2.0.4 fails to start as a non-root on Ubuntu 8.04

Posted: 8. Nov 2008, 07:55
by rudy
Dear VirtualBox gurus:

I have a terrible problem that I tried to resolve to no avail. I have installed vbox 2.04 on Ubuntu 8.04 server. I run it using command line only. Everything works FINE when I run VBoxManage as ROOT. But it fails terribly when I try to run it as a different user that IS a member of the vboxusers group:

Create the user:

Code: Select all

adduser --system --ingroup vboxusers testvm
Assume his identity and run VBoxManage

Code: Select all

sudo -u testvm bash
cd ~testvm
VBoxManage list systemproperties
Error message:
VirtualBox Command Line Management Interface Version 2.0.4
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.

[!] FAILED calling com::Initialize() at line 8446!
[!] Primary RC = NS_ERROR_FAILURE (0x80004005) - Operation failed
I tried to search the net and even changed device permissions as described in the FAQ, but that was not the problem:
crw-rw---- 1 root vboxusers 10, 200 2008-08-15 01:12 /dev/net/tun
-rw-rw-r-- 1 root vboxusers 43 2008-11-08 10:56 /proc/bus/usb/001/001
-rw-rw-r-- 1 root vboxusers 43 2008-11-08 10:56 /proc/bus/usb/002/001
-rw-rw-r-- 1 root vboxusers 43 2008-11-08 10:56 /proc/bus/usb/003/001
-rw-rw-r-- 1 root vboxusers 43 2008-11-08 10:56 /proc/bus/usb/004/001
-rw-rw-r-- 1 root vboxusers 43 2008-11-08 10:56 /proc/bus/usb/005/001
-rw-rw-r-- 1 root vboxusers 43 2008-11-08 10:56 /proc/bus/usb/006/001
-rw-rw-r-- 1 root vboxusers 43 2008-11-08 10:56 /proc/bus/usb/007/001
-rw-rw-r-- 1 root vboxusers 43 2008-11-08 10:56 /proc/bus/usb/008/001
It may have something to do with utf-8 conversions as suggested in http://www.mail-archive.com/vbox-users@ ... 03473.html
I've found the problem using truss, virtualbox needs iconv for utf-8 support,
(solaris package SUNWuiu8) which isn't included in the minimal install.
But why would that fail for a non-root user only? Also, the iconv library seems to be installed...

I would greatly appreciate ANY advice as I seem to be seriously lost. I need to run virtual box as a couple of different users...

THANK YOU!!!
Rudy

Posted: 8. Nov 2008, 14:58
by diavolgr
Which version of Virtualbox do you use? Binaries package or OSE?

I remeber having the same problem with OSE but I fixed it installing the binaries package (dpkng -i)

Binaries

Posted: 8. Nov 2008, 16:39
by rudy
I am using the binary distribution (academical institution)...

Thanks for the note!
Rudy

Solved

Posted: 10. Nov 2008, 17:41
by rudy
The solution was found with the help of user erstazi on the vbox IRC. Thanks!!

Something changed in the way vbox determines the user's home directory --- before it used some procedure that resulted in the same value as "~username" in bash, but now it results in "~" which fails with the "sudo" command that I used. When sudo is used, "~" expands to the home of the user who ran the sudo command, not that of the user we changed to.

So, the solution is simple --- use su instead of sudo. The commands

Code: Select all

sudo -u testvm bash 
cd ~testvm 
VBoxManage list systemproperties 
should be

Code: Select all

su -s /bin/bash testvm
cd
VBoxManage list systemproperties 
Just a note: The -s option in su is needed because my user testvm does not have a shell specified in /etc/passwd.

Re: VBoxManage 2.0.4 fails to start as a non-root on Ubuntu 8.04

Posted: 6. Mar 2009, 17:35
by vnevoa
Found the same problem while running virtualbox-2.1 from an init script.
The problem is not in the vbox software, it is in the way "sudo" works.
You can still use sudo (and you should, it's simpler and safer), you just have to tell it to use the specific user's home directory (and environment, if desired).

Example:

Code: Select all

sudo -E -H -u $VM_OWNER VBoxManage showvminfo $VM_NAME
(see "man sudo") :)
This way the script (running as root) easily finds the $VM_OWNER's home dir, along with all the virtualbox files that reside there.

This was a tricky error to debug, because the account I created the VM in was also the account from where I called the script with sudo when I tested it, and it all seemed to work. However, when I rebooted the server, the VM would never start or stop and vbox would fail with the aforementioned error.
It turns out that doing "sudo" in the init scripts during host boot results in giving the root's home to the command that is executed by sudo, instead of the specified user's home, and so we have to use "sudo -H".

Enjoy! :)

Re: VBoxManage 2.0.4 fails to start as a non-root on Ubuntu 8.04

Posted: 8. Mar 2009, 06:34
by rudy
You are right, it works. I did read the man pages for "sudo" and tried various options, but never succeeded. Wow. Simple.

Thanks!
Rudy