Changeset 40531 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Mar 19, 2012 11:13:32 AM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 76918
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlThread.cpp
r40529 r40531 1131 1131 * 1132 1132 * @return IPRT status code. 1133 * @param pszFileName File name to reso vle.1133 * @param pszFileName File name to resolve. 1134 1134 * @param pszResolved Pointer to a string where the resolved file name will be stored. 1135 1135 * @param cbResolved Size (in bytes) of resolved file name string. … … 1138 1138 char *pszResolved, size_t cbResolved) 1139 1139 { 1140 AssertPtrReturn(pszFileName, VERR_INVALID_POINTER); 1141 AssertPtrReturn(pszResolved, VERR_INVALID_POINTER); 1142 AssertReturn(cbResolved, VERR_INVALID_PARAMETER); 1143 1140 1144 int rc = VINF_SUCCESS; 1141 1145 1142 /* Search the path of our executable. */ 1143 char szVBoxService[RTPATH_MAX]; 1144 if (RTProcGetExecutablePath(szVBoxService, sizeof(szVBoxService))) 1145 { 1146 char *pszExecResolved = NULL; 1147 if ( (g_pszProgName && RTStrICmp(pszFileName, g_pszProgName) == 0) 1148 || !RTStrICmp(pszFileName, VBOXSERVICE_NAME)) 1149 { 1150 /* We just want to execute VBoxService (no toolbox). */ 1151 pszExecResolved = RTStrDup(szVBoxService); 1152 } 1153 else /* Nothing to resolve, copy original. */ 1154 pszExecResolved = RTStrDup(pszFileName); 1155 AssertPtr(pszExecResolved); 1156 1157 rc = VBoxServiceControlThreadMakeFullPath(pszExecResolved, pszResolved, cbResolved); 1158 #ifdef DEBUG 1159 VBoxServiceVerbose(3, "ControlThread: VBoxServiceControlExecResolveExecutable: %s -> %s\n", 1160 pszFileName, pszResolved); 1161 #endif 1162 RTStrFree(pszExecResolved); 1163 } 1146 char szPathToResolve[RTPATH_MAX]; 1147 if ( (g_pszProgName && (RTStrICmp(pszFileName, g_pszProgName) == 0)) 1148 || !RTStrICmp(pszFileName, VBOXSERVICE_NAME)) 1149 { 1150 /* Resolve executable name of this process. */ 1151 if (!RTProcGetExecutablePath(szPathToResolve, sizeof(szPathToResolve))) 1152 rc = VERR_FILE_NOT_FOUND; 1153 } 1154 else 1155 { 1156 /* Take the raw argument to resolve. */ 1157 rc = RTStrCopy(szPathToResolve, sizeof(szPathToResolve), pszFileName); 1158 } 1159 1160 if (RT_SUCCESS(rc)) 1161 { 1162 rc = VBoxServiceControlThreadMakeFullPath(szPathToResolve, pszResolved, cbResolved); 1163 if (RT_SUCCESS(rc)) 1164 VBoxServiceVerbose(3, "Looked up executable: %s -> %s\n", 1165 pszFileName, pszResolved); 1166 } 1167 1168 if (RT_FAILURE(rc)) 1169 VBoxServiceError("Failed to lookup executable \"%s\" with rc=%Rrc\n", 1170 pszFileName, rc); 1164 1171 return rc; 1165 1172 } … … 1253 1260 * won't be shown (doesn't have a desktop). 1254 1261 */ 1255 if ( RTStrICmp(pszExec, "sysprep") == 0)1262 if (!RTStrICmp(pszExec, "sysprep")) 1256 1263 { 1257 1264 /* Use a predefined sysprep path as default. */ … … 1286 1293 } 1287 1294 } 1295 1296 if (RT_FAILURE(rc)) 1297 VBoxServiceVerbose(3, "Starting sysprep returned rc=%Rrc\n", rc); 1298 1288 1299 return rc; 1289 1300 } … … 1312 1323 rc = VBoxServiceControlThreadPrepareArgv(pszExec /* Always use the unmodified executable name as argv0. */, 1313 1324 papszArgs /* Append the rest of the argument vector (if any). */, &papszArgsExp); 1314 if (RT_SUCCESS(rc)) 1325 if (RT_FAILURE(rc)) 1326 { 1327 /* Don't print any arguments -- may contain passwords or other sensible data! */ 1328 VBoxServiceError("Could not prepare arguments, rc=%Rrc\n", rc); 1329 } 1330 else 1315 1331 { 1316 1332 uint32_t uProcFlags = 0; … … 1336 1352 VBoxServiceVerbose(3, "\targv[%ld]: %s\n", i, papszArgsExp[i]); 1337 1353 #endif 1354 VBoxServiceVerbose(3, "Starting process \"%s\" ...\n", szExecExp); 1355 1338 1356 /* Do normal execution. */ 1339 1357 rc = RTProcCreateEx(szExecExp, papszArgsExp, hEnv, uProcFlags, … … 1342 1360 *pszPassword ? pszPassword : NULL, 1343 1361 phProcess); 1362 1363 VBoxServiceVerbose(3, "Starting process \"%s\" returned rc=%Rrc\n", 1364 szExecExp, rc); 1365 1344 1366 RTGetOptArgvFree(papszArgsExp); 1345 1367 }
Note:
See TracChangeset
for help on using the changeset viewer.