Changeset 55531 in vbox
- Timestamp:
- Apr 29, 2015 6:06:09 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 99890
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/HostServices/GuestControlSvc.h
r49349 r55531 106 106 }; 107 107 108 /** @todo r=bird: Most defines in this file needs to be scoped a little 109 * better! For instance INPUT_FLAG_NONE is very generic. */ 110 108 111 /** 109 112 * Input flags, set by the host. This is needed for … … 133 136 #define DIRREMOVE_FLAG_VALID_MASK UINT32_C(0x00000003) 134 137 135 /** 136 * Guest process creation flags. 137 * Note: Has to match Main's ProcessCreateFlag_* flags! 138 */ 139 #define EXECUTEPROCESSFLAG_NONE 0x0 138 /** @name EXECUTEPROCESSFLAG_XXX Guest process creation flags. 139 * @note Has to match Main's ProcessCreateFlag_* flags! 140 */ 141 #define EXECUTEPROCESSFLAG_NONE UINT32_C(0x0) 140 142 #define EXECUTEPROCESSFLAG_WAIT_START RT_BIT(0) 141 143 #define EXECUTEPROCESSFLAG_IGNORE_ORPHANED RT_BIT(1) … … 145 147 #define EXECUTEPROCESSFLAG_WAIT_STDERR RT_BIT(5) 146 148 #define EXECUTEPROCESSFLAG_EXPAND_ARGUMENTS RT_BIT(6) 149 #define EXECUTEPROCESSFLAG_UNQUOTED_ARGS RT_BIT(7) 150 /** @} */ 147 151 148 152 /** -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlProcess.cpp
r51205 r55531 1065 1065 * @param pszArgv0 First argument (argv0), either original or modified version. Optional. 1066 1066 * @param papszArgs Original argv command line from the host, starting at argv[1]. 1067 * @param fFlags The process creation flags pass to us from the host. 1067 1068 * @param ppapszArgv Pointer to a pointer with the new argv command line. 1068 1069 * Needs to be freed with RTGetOptArgvFree. 1069 1070 */ 1070 static int gstcntlProcessAllocateArgv(const char *pszArgv0, 1071 const char * const *papszArgs, 1072 bool fExpandArgs, char ***ppapszArgv) 1071 static int gstcntlProcessAllocateArgv(const char *pszArgv0, const char * const *papszArgs, uint32_t fFlags, 1072 char ***ppapszArgv) 1073 1073 { 1074 1074 AssertPtrReturn(ppapszArgv, VERR_INVALID_POINTER); 1075 1075 1076 VBoxServiceVerbose(3, "GstCntlProcessPrepareArgv: pszArgv0=%p, papszArgs=%p, f ExpandArgs=%RTbool, ppapszArgv=%p\n",1077 pszArgv0, papszArgs, f ExpandArgs, ppapszArgv);1076 VBoxServiceVerbose(3, "GstCntlProcessPrepareArgv: pszArgv0=%p, papszArgs=%p, fFlags=%#x, ppapszArgv=%p\n", 1077 pszArgv0, papszArgs, fFlags, ppapszArgv); 1078 1078 1079 1079 int rc = VINF_SUCCESS; … … 1096 1096 #endif 1097 1097 1098 size_t i = 0; /* Keep the argument counter in scope for cleaning up on failure. */ 1099 1100 rc = RTStrDupEx(&papszNewArgv[0], pszArgv0); 1098 1099 /* HACK ALERT! Since we still don't allow the user to really specify the first 1100 argument separately from the executable image, we have to fudge 1101 a little in the unquoted argument case to deal with executables 1102 containing spaces. */ 1103 /** @todo Fix the stupid host/guest protocol so the user can do this for us! */ 1104 if ( !(fFlags & EXECUTEPROCESSFLAG_UNQUOTED_ARGS) 1105 || !strpbrk(pszArgv0, " \t\n\r") 1106 || pszArgv0[0] == '"') 1107 rc = RTStrDupEx(&papszNewArgv[0], pszArgv0); 1108 else 1109 { 1110 size_t cchArgv0 = strlen(pszArgv0); 1111 rc = RTStrAllocEx(&papszNewArgv[0], 1 + cchArgv0 + 1 + 1); 1112 if (RT_SUCCESS(rc)) 1113 { 1114 char *pszDst = papszNewArgv[0]; 1115 *pszDst++ = '"'; 1116 memcpy(pszDst, pszArgv0, cchArgv0); 1117 pszDst += cchArgv0; 1118 *pszDst++ = '"'; 1119 *pszDst = '\0'; 1120 } 1121 } 1101 1122 if (RT_SUCCESS(rc)) 1102 1123 { 1103 for (; i < cArgs; i++) 1124 size_t i; 1125 for (i = 0; i < cArgs; i++) 1104 1126 { 1105 1127 char *pszArg; 1106 1128 #if 0 /* Arguments expansion -- untested. */ 1107 if (fExpandArgs) 1108 { 1129 if (fFlags & EXECUTEPROCESSFLAG_EXPAND_ARGUMENTS) 1130 { 1131 /** @todo r=bird: If you want this, we need a generic implementation, preferably in RTEnv or somewhere like that. The marking 1132 * up of the variables must be the same on all platforms. */ 1109 1133 /* According to MSDN the limit on older Windows version is 32K, whereas 1110 1134 * Vista+ there are no limits anymore. We still stick to 4K. */ … … 1136 1160 1137 1161 *ppapszArgv = papszNewArgv; 1138 } 1139 } 1140 1141 if (RT_FAILURE(rc)) 1142 { 1143 for (i; i > 0; i--) 1162 return VINF_SUCCESS; 1163 } 1164 1165 /* Failed, bail out. */ 1166 for (; i > 0; i--) 1144 1167 RTStrFree(papszNewArgv[i]); 1145 RTMemFree(papszNewArgv); 1146 } 1147 1168 } 1169 RTMemFree(papszNewArgv); 1148 1170 return rc; 1149 1171 } … … 1239 1261 char szExecExp[RTPATH_MAX]; 1240 1262 1241 /* Do we need to expand environment variables in arguments? */1242 bool fExpandArgs = (fFlags & EXECUTEPROCESSFLAG_EXPAND_ARGUMENTS) ? true : false;1243 1244 1263 #ifdef RT_OS_WINDOWS 1245 1264 /* … … 1295 1314 { 1296 1315 char **papszArgsExp; 1297 rc = gstcntlProcessAllocateArgv(szSysprepCmd /* argv0 */, papszArgs, 1298 fExpandArgs, &papszArgsExp); 1316 rc = gstcntlProcessAllocateArgv(szSysprepCmd /* argv0 */, papszArgs, fFlags, &papszArgsExp); 1299 1317 if (RT_SUCCESS(rc)) 1300 1318 { … … 1336 1354 { 1337 1355 char **papszArgsExp; 1356 /** @todo r-bird: pszExec != argv[0]! When are you going to get that?!? How many 1357 * times does this need to be pointed out? HOST/GUEST INTERFACE IS MISDESIGNED! */ 1338 1358 rc = gstcntlProcessAllocateArgv(pszExec /* Always use the unmodified executable name as argv0. */, 1339 1359 papszArgs /* Append the rest of the argument vector (if any). */, 1340 f ExpandArgs, &papszArgsExp);1360 fFlags, &papszArgsExp); 1341 1361 if (RT_FAILURE(rc)) 1342 1362 { … … 1353 1373 if (fFlags & EXECUTEPROCESSFLAG_NO_PROFILE) 1354 1374 uProcFlags |= RTPROC_FLAGS_NO_PROFILE; 1375 if (fFlags & EXECUTEPROCESSFLAG_UNQUOTED_ARGS) 1376 uProcFlags |= RTPROC_FLAGS_UNQUOTED_ARGS; 1355 1377 } 1356 1378 … … 1591 1613 bool fNeedsImpersonation = !(pProcess->pSession->uFlags & VBOXSERVICECTRLSESSION_FLAG_FORK); 1592 1614 1593 rc = gstcntlProcessCreateProcess(pProcess->StartupInfo.szCmd, papszArgs, hEnv, pProcess->StartupInfo.uFlags, 1615 rc = gstcntlProcessCreateProcess(pProcess->StartupInfo.szCmd, papszArgs, hEnv, 1616 pProcess->StartupInfo.uFlags, 1594 1617 phStdIn, phStdOut, phStdErr, 1595 1618 fNeedsImpersonation ? pProcess->StartupInfo.szUser : NULL, -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r55528 r55531 10217 10217 <desc> 10218 10218 Guest process execution flags. 10219 <note>The values are passed to the guest additions, so its not possible 10220 to change (move) or reuse values.here. See EXECUTEPROCESSFLAG_XXX 10221 in GuestControlSvc.h.</note> 10219 10222 </desc> 10220 10223 … … 10243 10246 <const name="ExpandArguments" value="64"> 10244 10247 <desc>Expands environment variables in process arguments.</desc> 10248 </const> 10249 <const name="UnquotedArguments" value="128"> 10250 <desc>Work around for Windows and OS/2 applications not following normal 10251 argument quoting and escaping rules. The arguments are passed to the 10252 application without any extra quoting, just a single space between each. 10253 <note>Present since VirtualBox 4.3.28 and 5.0 beta 3.</note> 10254 </desc> 10245 10255 </const> 10246 10256 </enum>
Note:
See TracChangeset
for help on using the changeset viewer.