VirtualBox

Changeset 47915 in vbox


Ignore:
Timestamp:
Aug 20, 2013 2:00:58 PM (11 years ago)
Author:
vboxsync
Message:

Main/Machine: add a way to safely override the VM app, OSX specific

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r47776 r47915  
    40714071    /* Check whether the flag to allow silent storage attachment reconfiguration is set. */
    40724072    strReconfig = getExtraData(Utf8Str("VBoxInternal2/SilentReconfigureWhilePaused"));
    4073     if (FAILED(rc))
    4074         return rc;
    40754073    if (   mData->mMachineState == MachineState_Paused
    40764074        && strReconfig == "1")
     
    46354633    /* Check whether the flag to allow silent storage attachment reconfiguration is set. */
    46364634    strReconfig = getExtraData(Utf8Str("VBoxInternal2/SilentReconfigureWhilePaused"));
    4637     if (FAILED(rc))
    4638         return rc;
    46394635    if (   mData->mMachineState == MachineState_Paused
    46404636        && strReconfig == "1")
     
    79357931    szPath[sz] = 0;
    79367932    char *cmd = szPath + sz;
    7937     sz = RTPATH_MAX - sz;
     7933    sz = sizeof(szPath) - sz;
    79387934
    79397935    int vrc = VINF_SUCCESS;
     
    79957991    {
    79967992# ifdef RT_OS_DARWIN /* Avoid Launch Services confusing this with the selector by using a helper app. */
    7997         const char VirtualBox_exe[] = "../Resources/VirtualBoxVM.app/Contents/MacOS/VirtualBoxVM";
     7993        /* Modify the base path so that we don't need to use ".." below. */
     7994        RTPathStripTrailingSlash(szPath);
     7995        RTPathStripFilename(szPath);
     7996        sz = strlen(szPath);
     7997        cmd = szPath + sz;
     7998        sz = sizeof(szPath) - sz;
     7999
     8000#define OSX_APP_NAME "VirtualBoxVM"
     8001#define OSX_APP_PATH_FMT "/Resources/%s.app/Contents/MacOS/VirtualBoxVM"
     8002
     8003        Utf8Str strAppOverride = getExtraData(Utf8Str("VBoxInternal2/VirtualBoxVMAppOverride"));
     8004        if (   strAppOverride.contains(".")
     8005            || strAppOverride.contains("/")
     8006            || strAppOverride.contains("\\")
     8007            || strAppOverride.contains(":"))
     8008            strAppOverride.setNull();
     8009        Utf8Str strAppPath;
     8010        if (!strAppOverride.isEmpty())
     8011        {
     8012            strAppPath = Utf8StrFmt(OSX_APP_PATH_FMT, strAppOverride.c_str());
     8013            Utf8Str strFullPath(szPath);
     8014            strFullPath.append(strAppPath);
     8015            /* there is a race, but people using this deserve the failure */
     8016            if (!RTFileExists(strFullPath.c_str()))
     8017                strAppOverride.setNull();
     8018        }
     8019        if (strAppOverride.isEmpty())
     8020            strAppPath = Utf8StrFmt(OSX_APP_PATH_FMT, OSX_APP_NAME);
     8021        const char *VirtualBox_exe = strAppPath.c_str();
     8022        AssertReturn(sz >= strlen(VirtualBox_exe), E_UNEXPECTED);
    79988023# else
    79998024        const char VirtualBox_exe[] = "VirtualBox" HOSTSUFF_EXE;
     8025        Assert(sz >= sizeof(VirtualBox_exe));
    80008026# endif
    8001         Assert(sz >= sizeof(VirtualBox_exe));
    80028027        strcpy(cmd, VirtualBox_exe);
    80038028
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette