Changeset 92674 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Dec 1, 2021 12:48:34 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r92662 r92674 2406 2406 * Flags. 2407 2407 */ 2408 uint32_t fProcCreate = RTPROC_FLAGS_PROFILE2408 uint32_t const fProcCreate = RTPROC_FLAGS_PROFILE 2409 2409 #ifdef RT_OS_WINDOWS 2410 | RTPROC_FLAGS_SERVICE2411 | RTPROC_FLAGS_HIDDEN2410 | RTPROC_FLAGS_SERVICE 2411 | RTPROC_FLAGS_HIDDEN 2412 2412 #endif 2413 | VBOXSERVICE_PROC_F_UTF8_ARGV;2413 | VBOXSERVICE_PROC_F_UTF8_ARGV; 2414 2414 2415 2415 /* … … 2451 2451 #endif 2452 2452 { 2453 RTENV hEnvSession = RTENV_DEFAULT;2454 2455 /*2456 * If we start a new guest session with RTPROC_FLAGS_PROFILE (the default, means another user),2457 * process the initial session's environment and search for important env vars we also need in2458 * the new guest session and apply those to the new environment block we're going to use for that2459 * new guest session then.2460 *2461 * This is needed in order to make different locales on POSIX OSes work. See @bugref{10153}.2462 */2463 if (fProcCreate & RTPROC_FLAGS_PROFILE)2464 {2465 RTENV hEnv;2466 int rc2 = RTEnvClone(&hEnv, RTENV_DEFAULT);2467 if (RT_SUCCESS(rc2))2468 {2469 rc2 = RTEnvCreate(&hEnvSession);2470 if (RT_SUCCESS(rc2))2471 {2472 size_t cbVar = 128; /* Start with a conservative size, as we might grow this down below. */2473 char *pszVar = RTStrAlloc(cbVar);2474 if (pszVar)2475 {2476 size_t cbValue = cbVar;2477 char *pszValue = RTStrAlloc(cbValue);2478 if (pszValue)2479 {2480 for (uint32_t iVar = 0; iVar < RTEnvCountEx(hEnv); iVar++)2481 {2482 for (unsigned cTries = 0; cTries < 10; cTries++)2483 {2484 rc2 = RTEnvGetByIndexEx(hEnv, iVar, pszVar, cbVar, pszValue, cbValue);2485 if (RT_SUCCESS(rc2))2486 break;2487 if (rc2 == VERR_BUFFER_OVERFLOW)2488 {2489 cbVar *= 2;2490 rc2 = RTStrRealloc(&pszVar, cbVar);2491 AssertRCBreak(rc2);2492 2493 cbValue *= 2;2494 rc2 = RTStrRealloc(&pszValue, cbValue);2495 AssertRCBreak(rc2);2496 }2497 else2498 break;2499 }2500 2501 if (RT_FAILURE(rc2))2502 break;2503 2504 if ( RTStrSimplePatternMatch("LANG", pszVar)2505 || RTStrSimplePatternMatch("LC_*", pszVar))2506 {2507 #ifdef DEBUG2508 /* Don't log this in release mode -- might contain sensitive data! */2509 VGSvcVerbose(2, "Adding %s=%s to guest session environment\n", pszVar, pszValue);2510 #endif2511 rc2 = RTEnvSetEx(hEnvSession, pszVar, pszValue);2512 }2513 2514 if (RT_FAILURE(rc2))2515 break;2516 }2517 2518 RTStrFree(pszValue);2519 }2520 else2521 rc2 = VERR_NO_MEMORY;2522 2523 RTStrFree(pszVar);2524 }2525 else2526 rc2 = VERR_NO_MEMORY;2527 2528 if (RT_SUCCESS(rc2))2529 fProcCreate |= RTPROC_FLAGS_ENV_CHANGE_RECORD;2530 }2531 2532 RTEnvDestroy(hEnv);2533 }2534 2535 if (RT_FAILURE(rc2))2536 VGSvcError("Creating session environment block failed with %Rrc\n", rc2);2537 /* Consider this as not being fatal. Just stay witht the default environment and hope for the best. */2538 }2539 2540 2453 /* 2541 2454 * Finally, create the process. 2542 2455 */ 2543 rc = RTProcCreateEx(pszExeName, apszArgs, hEnvSession, fProcCreate,2456 rc = RTProcCreateEx(pszExeName, apszArgs, RTENV_DEFAULT, fProcCreate, 2544 2457 &hStdIn, &hStdOutAndErr, &hStdOutAndErr, 2545 2458 !fAnonymous ? pszUser : NULL, … … 2547 2460 NULL /*pvExtraData*/, 2548 2461 &pSessionThread->hProcess); 2549 2550 if (hEnvSession != RTENV_DEFAULT)2551 {2552 RTEnvDestroy(hEnvSession);2553 hEnvSession = NIL_RTENV;2554 }2555 2462 } 2556 2463 #ifdef RT_OS_WINDOWS
Note:
See TracChangeset
for help on using the changeset viewer.