Changeset 27512 in vbox for trunk/src/VBox
- Timestamp:
- Mar 19, 2010 1:37:58 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/process-win.cpp
r27491 r27512 51 51 #include <iprt/pipe.h> 52 52 #include <iprt/string.h> 53 #include <iprt/socket.h> 53 54 54 55 … … 186 187 const char *pszPassword, PRTPROCESS phProcess) 187 188 { 188 #if 1 /* needs more work... dinner time. */189 189 int rc; 190 190 … … 220 220 PCRTHANDLE paHandles[3] = { phStdIn, phStdOut, phStdErr }; 221 221 HANDLE *aphStds[3] = { &StartupInfo.hStdInput, &StartupInfo.hStdOutput, &StartupInfo.hStdError }; 222 DWORD afInhStds[3] = { 0xffffffff, 0xffffffff, 0xffffffff }; 222 223 for (int i = 0; i < 3; i++) 223 224 { … … 239 240 break; 240 241 241 //case RTHANDLETYPE_SOCKET:242 //*aphStds[i] = paHandles[i]->u.hSocket != NIL_RTSOCKET243 // ? (HANDLE)RTTcpToNative(paHandles[i]->u.hSocket)244 //: INVALID_HANDLE_VALUE;245 //break;242 case RTHANDLETYPE_SOCKET: 243 *aphStds[i] = paHandles[i]->u.hSocket != NIL_RTSOCKET 244 ? (HANDLE)RTSocketToNative(paHandles[i]->u.hSocket) 245 : INVALID_HANDLE_VALUE; 246 break; 246 247 247 248 default: 248 249 AssertMsgFailedReturn(("%d: %d\n", i, paHandles[i]->enmType), VERR_INVALID_PARAMETER); 249 250 } 251 252 /* Get the inheritability of the handle. */ 253 if (*aphStds[i] != INVALID_HANDLE_VALUE) 254 { 255 if (!GetHandleInformation(*aphStds[i], &afInhStds[i])) 256 { 257 rc = RTErrConvertFromWin32(GetLastError()); 258 AssertMsgFailedReturn(("%Rrc %p\n", rc, *aphStds[i]), rc); 259 } 260 } 250 261 } 251 262 } 252 263 253 264 /* 265 * Set the inheritability any handles we're handing the child. 266 */ 267 rc = VINF_SUCCESS; 268 for (int i = 0; i < 3; i++) 269 if ( (afInhStds[i] != 0xffffffff) 270 && !(afInhStds[i] & HANDLE_FLAG_INHERIT)) 271 { 272 if (!SetHandleInformation(*aphStds[i], HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) 273 { 274 rc = RTErrConvertFromWin32(GetLastError()); 275 AssertMsgFailedBreak(("%Rrc %p\n", rc, *aphStds[i])); 276 } 277 } 278 279 /* 254 280 * Create the environment block, command line and convert the executable 255 281 * name. 256 282 */ 257 283 PRTUTF16 pwszzBlock; 258 rc = RTEnvQueryUtf16Block(hEnv, &pwszzBlock); 284 if (RT_SUCCESS(rc)) 285 rc = RTEnvQueryUtf16Block(hEnv, &pwszzBlock); 259 286 if (RT_SUCCESS(rc)) 260 287 { … … 289 316 PRTUTF16 pwszUser; 290 317 291 rc = RTStrToUtf16(pszAsUser, &pwszUser); 318 rc = RTStrToUtf16(pszAsUser, &pwszUser); 292 319 if (RT_SUCCESS(rc)) 293 320 { 294 321 PRTUTF16 pwszPassword; 295 rc = RTStrToUtf16(pszPassword, &pwszPassword); 322 rc = RTStrToUtf16(pszPassword, &pwszPassword); 296 323 if (RT_SUCCESS(rc)) 297 324 { 298 /* 325 /* 299 326 * User needs to be specified in UPN format because we 300 * don't fill a domain name. 327 * don't fill a domain name. 301 328 */ 302 329 … … 337 364 { 338 365 DWORD dwErr = GetLastError(); 339 366 340 367 /* 341 368 * If we don't hold enough priviledges to spawn a new 342 * process with different credentials we have to use 369 * process with different credentials we have to use 343 370 * CreateProcessWithLogonW here. 344 371 * … … 402 429 } 403 430 431 /* Undo any handle inherit changes. */ 432 for (int i = 0; i < 3; i++) 433 if ( (afInhStds[i] != 0xffffffff) 434 && !(afInhStds[i] & HANDLE_FLAG_INHERIT)) 435 { 436 if (!SetHandleInformation(*aphStds[i], HANDLE_FLAG_INHERIT, 0)) 437 AssertMsgFailed(("%Rrc %p\n", RTErrConvertFromWin32(GetLastError()), *aphStds[i])); 438 } 439 404 440 return rc; 405 #else406 return VERR_NOT_IMPLEMENTED;407 #endif408 441 } 409 442
Note:
See TracChangeset
for help on using the changeset viewer.