Changeset 80824 in vbox for trunk/src/VBox/Main/src-all
- Timestamp:
- Sep 16, 2019 1:18:44 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 133393
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-all/MachineLaunchVMCommonWorker.cpp
r80614 r80824 75 75 const Utf8Str &aComment, 76 76 const Utf8Str &aFrontend, 77 const Utf8Str &aEnvironment,77 const std::vector<com::Utf8Str> &aEnvironmentChanges, 78 78 const Utf8Str &aExtraArg, 79 79 const Utf8Str &aFilename, … … 105 105 106 106 RTENV hEnv = RTENV_DEFAULT; 107 if (!aEnvironment.isEmpty()) 108 { 109 Utf8Str strEnvCopy(aEnvironment); /* auto release trick */ 110 107 if (!aEnvironmentChanges.empty()) 108 { 111 109 #ifdef IN_VBOXSVC 112 110 /* VBoxSVC: clone the current environment */ … … 120 118 AssertRCReturn(vrc, vrc); 121 119 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); 155 127 } 156 128 }
Note:
See TracChangeset
for help on using the changeset viewer.