VirtualBox

Changeset 57759 in vbox for trunk


Ignore:
Timestamp:
Sep 15, 2015 12:55:46 PM (9 years ago)
Author:
vboxsync
Message:

Guest Control/VBoxService: Use RTENV_DEFAULT when spawning new processes for a particular guest session.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r57753 r57759  
    19591959#endif
    19601960                                | RTPROC_FLAGS_HIDDEN; /** @todo More flags from startup info? */
    1961             /*
    1962              * Create the session process' environment block.
    1963              */
    1964             RTENV hEnv = NIL_RTENV;
    1965             if (RT_SUCCESS(rc))
    1966             {
    1967                 /** @todo At the moment a session process does not have the ability to use the
    1968                  *        per-session environment variables itself, only the session's guest
    1969                  *        processes do so. Implement that later, also needs tweaking of
    1970                  *        VbglR3GuestCtrlSessionGetOpen(). */
    1971                 rc = RTEnvClone(&hEnv, RTENV_DEFAULT);
    1972 
    1973                 if (g_cVerbosity > 3)
    1974                 {
    1975                     VBoxServiceVerbose(4, "Environment variables:\n");
    1976 
    1977                     uint32_t cVars = RTEnvCountEx(hEnv);
    1978                     for (uint32_t iVar = 0; iVar < cVars; iVar++)
    1979                     {
    1980                         char szVar[_1K];
    1981                         char szValue[_16K];
    1982                         rc2 = RTEnvGetByIndexEx(hEnv, iVar, szVar, sizeof(szVar), szValue, sizeof(szValue));
    1983                         if (RT_SUCCESS(rc2))
    1984                             VBoxServiceVerbose(4, "\t%s=%s\n", szVar, szValue);
    1985                         else if (rc2 == VERR_BUFFER_OVERFLOW)
    1986                             VBoxServiceVerbose(4, "\t%s=%s [VERR_BUFFER_OVERFLOW]\n", szVar, szValue);
    1987                         else
    1988                         {
    1989                             VBoxServiceVerbose(4, "\tUnable to enumerate environment variable #%RU32: %Rrc\n", iVar, rc2);
    1990                             /* Keep going. */
    1991                         }
    1992                     }
    1993                 }
    1994 
    1995 #ifdef RT_OS_WINDOWS
    1996                 if (RT_SUCCESS(rc))
    1997                 {
    1998                     /*
    1999                      * On Windows, when VBoxService was started as local service via SCM, the environment variable
    2000                      * USERPROFILE was set to point to LocalService's user directory.
    2001                      *
    2002                      * As we want to make sure that USERPROFILE actually points to the directory of the user we want
    2003                      * to spawn the guest process for, unset the variable here before handing the environment block over
    2004                      * to RTProcCreateEx().
    2005                      *
    2006                      * Note: RTProcCreateEx() in turn will *not* overwrite _any_ of already set
    2007                      *       environment variables by default! */
    2008                     RTEnvUnsetEx(hEnv, "USERPROFILE");
    2009                 }
    2010 #endif
    2011             }
    20121961
    20131962#if 0 /* Pipe handling not needed (yet). */
     
    20722021                    hStdOutAndErr.enmType = RTHANDLETYPE_FILE;
    20732022
    2074                         rc = RTProcCreateEx(pszExeName, papszArgs, hEnv, uProcFlags,
     2023                    rc = RTProcCreateEx(pszExeName, papszArgs, RTENV_DEFAULT, uProcFlags,
    20752024                                        &hStdIn, &hStdOutAndErr, &hStdOutAndErr,
    20762025                                        !fAnonymous ? pSessionThread->StartupInfo.szUser : NULL,
     
    20842033            }
    20852034#endif
    2086             if (hEnv != NIL_RTENV)
    2087                 RTEnvDestroy(hEnv);
    20882035        }
    20892036        else
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette