On linux host, when runnin virtualbox as root and then as regular user, the following error emerges:
Wrong owner (0) of '/tmp/.vbox-mkudlvasr-ipc'
When virtualbox is not run from command line, the error is more cryptic:
Callee RC: NS_ERROR_FACTORY_NOT_REGISTERED
0x80040154
This is because the tmpdir is not deleted. I understand from the sources, that it is not deleted for security reasons. Ok, but why not to name the dir .vbox-root-ipc, when vbox is run by root?
Fix - prefer username (as in getpwuid) instead of trusting just the env variables.
Patch attached.
The patch doesn't include proper #ifdefs for non-unix systems. I just don't understand the various macros well enough.