VirtualBox

Changeset 59134 in vbox for trunk/src/VBox/Additions/common


Ignore:
Timestamp:
Dec 15, 2015 2:55:18 PM (9 years ago)
Author:
vboxsync
Message:

Guest Control/VBoxService: Build up a UPN (User Principal Name) if a domain is given. Untested.

Location:
trunk/src/VBox/Additions/common/VBoxService
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.h

    r58029 r59134  
    209209    /** Password of specified user name (account). */
    210210    char szPassword[GUESTPROCESS_MAX_PASSWORD_LEN];
     211    /** Domain to be used for authenticating the specified user name (account). */
     212    char szDomain[GUESTPROCESS_MAX_DOMAIN_LEN];
    211213    /** Time limit (in ms) of the process' life time. */
    212214    uint32_t uTimeLimitMS;
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlProcess.cpp

    r59131 r59134  
    12041204 * @param   pszAsUser                   User name (account) to start the process under.
    12051205 * @param   pszPassword                 Password of the specified user.
     1206 * @param   pszDomain                   Domain to use for authentication.
    12061207 * @param   phProcess                   Pointer which will receive the process handle after
    12071208 *                                      successful process start.
     
    12091210static int vgsvcGstCtrlProcessCreateProcess(const char *pszExec, const char * const *papszArgs, RTENV hEnv, uint32_t fFlags,
    12101211                                            PCRTHANDLE phStdIn, PCRTHANDLE phStdOut, PCRTHANDLE phStdErr, const char *pszAsUser,
    1211                                             const char *pszPassword, PRTPROCESS phProcess)
     1212                                            const char *pszPassword, const char *pszDomain, PRTPROCESS phProcess)
    12121213{
    12131214    AssertPtrReturn(pszExec, VERR_INVALID_PARAMETER);
     
    13501351            VGSvcVerbose(3, "Starting process '%s' ...\n", szExecExp);
    13511352
     1353            const char *pszUser;
     1354#ifdef RT_OS_WINDOWS
     1355            /* If a domain name is given, construct an UPN (User Principle Name) with
     1356             * the domain name built-in, e.g. "[email protected]". */
     1357            char *pszUserUPN = NULL;
     1358            if (strlen(pszDomain))
     1359            {
     1360                int cbUserUPN = RTStrAPrintf(&pszUserUPN, "%s@%s", pszAsUser, pszDomain);
     1361                if (cbUserUPN > 0)
     1362                {
     1363                    pszUser = pszUserUPN;
     1364                    VGSvcVerbose(3, "Using UPN: %s\n", pszUserUPN);
     1365                }
     1366            }
     1367
     1368            if (!pszUserUPN) /* Fallback */
     1369#endif
     1370                pszUser = pszAsUser;
     1371
    13521372            /* Do normal execution. */
    13531373            rc = RTProcCreateEx(szExecExp, papszArgsExp, hEnv, uProcFlags,
    13541374                                phStdIn, phStdOut, phStdErr,
    1355                                 pszAsUser   && *pszAsUser   ? pszAsUser   : NULL,
     1375                                pszUser,
    13561376                                pszPassword && *pszPassword ? pszPassword : NULL,
    13571377                                phProcess);
    1358 
     1378#ifdef RT_OS_WINDOWS
     1379            if (pszUserUPN)
     1380                RTStrFree(pszUserUPN);
     1381#endif
    13591382            VGSvcVerbose(3, "Starting process '%s' returned rc=%Rrc\n", szExecExp, rc);
    13601383
     
    15751598                                                                 pProcess->StartupInfo.uFlags,
    15761599                                                                 phStdIn, phStdOut, phStdErr,
    1577                                                                  fNeedsImpersonation ? pProcess->StartupInfo.szUser : NULL,
     1600                                                                 fNeedsImpersonation ? pProcess->StartupInfo.szUser     : NULL,
    15781601                                                                 fNeedsImpersonation ? pProcess->StartupInfo.szPassword : NULL,
     1602                                                                 fNeedsImpersonation ? pProcess->StartupInfo.szDomain   : NULL,
    15791603                                                                 &pProcess->hProcess);
    15801604                                if (RT_FAILURE(rc))
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r58089 r59134  
    17121712            apszArgs[idxArg++] = "--user";
    17131713            apszArgs[idxArg++] = pSessionThread->StartupInfo.szUser;
     1714
     1715            if (strlen(pSessionThread->StartupInfo.szDomain))
     1716            {
     1717                apszArgs[idxArg++] = "--domain";
     1718                apszArgs[idxArg++] = pSessionThread->StartupInfo.szDomain;
     1719            }
    17141720        }
    17151721
     
    18361842                hStdOutAndErr.enmType = RTHANDLETYPE_FILE;
    18371843
     1844                const char *pszUser;
     1845#ifdef RT_OS_WINDOWS
     1846                /* If a domain name is given, construct an UPN (User Principle Name) with
     1847                 * the domain name built-in, e.g. "[email protected]". */
     1848                char *pszUserUPN = NULL;
     1849                if (strlen(pSessionThread->StartupInfo.szDomain))
     1850                {
     1851                    int cbUserUPN = RTStrAPrintf(&pszUserUPN, "%s@%s",
     1852                                                 pSessionThread->StartupInfo.szUser,
     1853                                                 pSessionThread->StartupInfo.szDomain);
     1854                    if (cbUserUPN > 0)
     1855                    {
     1856                        pszUser = pszUserUPN;
     1857                        VGSvcVerbose(3, "Using UPN: %s\n", pszUserUPN);
     1858                    }
     1859                }
     1860
     1861                if (!pszUserUPN) /* Fallback */
     1862#endif
     1863                    pszUser = pSessionThread->StartupInfo.szUser;
     1864
    18381865                rc = RTProcCreateEx(pszExeName, apszArgs, RTENV_DEFAULT, fProcCreate,
    18391866                                    &hStdIn, &hStdOutAndErr, &hStdOutAndErr,
    1840                                     !fAnonymous ? pSessionThread->StartupInfo.szUser : NULL,
     1867                                    !fAnonymous ? pszUser : NULL,
    18411868                                    !fAnonymous ? pSessionThread->StartupInfo.szPassword : NULL,
    18421869                                    &pSessionThread->hProcess);
    1843 
     1870# ifdef RT_OS_WINDOWS
     1871                if (pszUserUPN)
     1872                    RTStrFree(pszUserUPN);
     1873# endif
    18441874                RTFileClose(hStdOutAndErr.u.hFile);
    18451875            }
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