VirtualBox

Changeset 80824 in vbox for trunk/src/VBox/Main/src-all


Ignore:
Timestamp:
Sep 16, 2019 1:18:44 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
133393
Message:

Main: bugref:9341: The "environment" parameter in the IMachine::launchVMProcess renamed to "environmentChanges" and changed the type from wstring to "safearray of wstrings"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-all/MachineLaunchVMCommonWorker.cpp

    r80614 r80824  
    7575                                const Utf8Str &aComment,
    7676                                const Utf8Str &aFrontend,
    77                                 const Utf8Str &aEnvironment,
     77                                const std::vector<com::Utf8Str> &aEnvironmentChanges,
    7878                                const Utf8Str &aExtraArg,
    7979                                const Utf8Str &aFilename,
     
    105105
    106106    RTENV hEnv = RTENV_DEFAULT;
    107     if (!aEnvironment.isEmpty())
    108     {
    109         Utf8Str strEnvCopy(aEnvironment); /* auto release trick */
    110 
     107    if (!aEnvironmentChanges.empty())
     108    {
    111109#ifdef IN_VBOXSVC
    112110        /* VBoxSVC: clone the current environment */
     
    120118        AssertRCReturn(vrc, vrc);
    121119
    122         /* Apply the specified environment changes (ignoring empty variable names
    123            as RTEnv intentionally does not support that). */
    124         char *pszEnvMutable = strEnvCopy.mutableRaw();
    125         char *pszVar = pszEnvMutable;
    126         for (char *psz = pszEnvMutable; ; ++psz)
    127         {
    128             /** @todo r=bird: Broken escaping rule, how to end a variable with '\\'?
    129               * E.g. TMP=C:\\TEMP\\  */
    130             char const ch = *psz;
    131             if (   (ch == '\n' && (psz == pszEnvMutable || psz[-1] != '\\'))
    132                 || ch == '\0')
    133             {
    134                 *psz = '\0';
    135                 if (*pszVar)
    136                 {
    137                     char *val = strchr(pszVar, '=');
    138                     if (val)
    139                     {
    140                         *val++ = '\0';
    141                         vrc = RTEnvSetEx(hEnv, pszVar, val);
    142                     }
    143                     else
    144                         vrc = RTEnvUnsetEx(hEnv, pszVar);
    145                     if (RT_FAILURE(vrc))
    146                     {
    147                         RTEnvDestroy(hEnv);
    148                         return vrc;
    149                     }
    150                 }
    151                 if (!ch)
    152                     break;
    153                 pszVar = psz + 1;
    154             }
     120        /* Apply the specified environment changes. */
     121        for (std::vector<com::Utf8Str>::const_iterator itEnv = aEnvironmentChanges.begin();
     122             itEnv != aEnvironmentChanges.end();
     123             ++itEnv)
     124        {
     125            vrc = RTEnvPutEx(hEnv, itEnv->c_str());
     126            AssertRCReturnStmt(vrc, RTEnvDestroy(hEnv), vrc);
    155127        }
    156128    }
Note: See TracChangeset for help on using the changeset viewer.

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