Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vboxwrapper: create the 'virtualbox home directory' in the project dir #6018

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions samples/vboxwrapper/vbox_vboxmanage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,38 @@ int VBOX_VM::initialize() {
#endif

// Determine the 'VirtualBox home directory'.
// NOTE: I'm not sure this is relevant; see
// We run VboxSVC.exe here, and look for its log file here.
//
// See
// https://docs.oracle.com/en/virtualization/virtualbox/6.1/admin/TechnicalBackground.html#3.1.3.-Summary-of-Configuration-Data-Locations

// Check if specified by environment variable
//
if (getenv("VBOX_USER_HOME")) {
virtualbox_home_directory = getenv("VBOX_USER_HOME");
char *p = getenv("VBOX_USER_HOME");
if (p) {
virtualbox_home_directory = p;
} else {
// If the override environment variable isn't specified then
// it is based of the current users HOME directory.
const char *home;
// If not then make one in the BOINC data directory.
// Note: in a sandboxed config we're running as user 'boinc_project'.
// This user doesn't have write access to the (real user) home dir.
//
virtualbox_home_directory = aid.boinc_dir;
virtualbox_home_directory += "/.VirtualBox";

// create if not there already
boinc_mkdir(virtualbox_home_directory.c_str());

// set env var telling VBox where to put log file
#ifdef _WIN32
home = getenv("USERPROFILE");
if (home == NULL) {
vboxlog_msg("no USERPROFILE - exiting");
exit(1);
if (!SetEnvironmentVariable("VBOX_USER_HOME", const_cast<char*>(virtualbox_home_directory.c_str()))) {
vboxlog_msg("Failed to modify the search path.");
}
#elif __APPLE__
home = "/Library/Application Support/BOINC Data";
#else
home = getenv("HOME");
if (home == NULL) {
home = getpwuid(getuid())->pw_dir;
// putenv does not copy its input buffer, so we must use setenv
if (setenv("VBOX_USER_HOME", const_cast<char*>(virtualbox_home_directory.c_str()), 1)) {
vboxlog_msg("Failed to modify the VBOX_USER_HOME path.");
}
#endif
virtualbox_home_directory = home;
virtualbox_home_directory += "/.VirtualBox";
}

#ifdef _WIN32
Expand Down
Loading