diff --git a/samples/vboxwrapper/vbox_vboxmanage.cpp b/samples/vboxwrapper/vbox_vboxmanage.cpp index 89a96dbceb7236dab93ef123ef1ab33184bd6cfd..8a775db260bd3a90305002509555328a8f0e7326 100644 --- a/samples/vboxwrapper/vbox_vboxmanage.cpp +++ b/samples/vboxwrapper/vbox_vboxmanage.cpp @@ -86,8 +86,6 @@ int VBOX_VM::initialize() { // Prep the environment so we can execute the vboxmanage application // - // TODO: Fix for non-Windows environments if we ever find another platform - // where vboxmanage is not already in the search path #ifdef _WIN32 if (!virtualbox_install_directory.empty()) { @@ -98,6 +96,18 @@ int VBOX_VM::initialize() { vboxlog_msg("Failed to modify the search path."); } } +#else + old_path = getenv("PATH"); + if(boinc_file_exists("/usr/local/bin/VboxManage")) { + new_path = "/usr/local/bin/:" + old_path; + } + if(boinc_file_exists("/usr/bin/VboxManage")) { + new_path = "/usr/bin/:" + old_path; + } + // putenv does not copy its input buffer, so we must use setenv + if (setenv("PATH", const_cast<char*>(new_path.c_str()), 1)) { + vboxlog_msg("Failed to modify the search path."); + } #endif // Determine the VirtualBox home directory. Overwrite as needed.