VirtualBox

Changeset 99120 in vbox


Ignore:
Timestamp:
Mar 22, 2023 5:30:14 PM (21 months ago)
Author:
vboxsync
Message:

Guest Control: Added ability of specifying an optional current working directory to started guest processes. This needs Guest Additions which support this. bugref:8053

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/en_US/man_VBoxManage-guestcontrol.xml

    r98330 r99120  
    7878      <arg>--unquoted-args</arg>
    7979      <arg>--username=<replaceable>username</replaceable></arg>
     80      <arg>--cwd=<replaceable>directory</replaceable></arg>
    8081      <arg>--verbose</arg>
    8182      <arg choice="req">-- <replaceable>program/arg0</replaceable> <arg rep="repeat"><replaceable>argument</replaceable></arg></arg>
     
    102103      <arg>--unquoted-args</arg>
    103104      <arg>--username=<replaceable>username</replaceable></arg>
     105      <arg>--cwd=<replaceable>directory</replaceable></arg>
    104106      <arg>--verbose</arg>
    105107      <arg choice="req">-- <replaceable>program/arg0</replaceable> <arg rep="repeat"><replaceable>argument</replaceable></arg></arg>
     
    502504              run on the guest VM. For example:
    503505              <filename>C:\Windows\System32\calc.exe</filename>.
     506            </para></listitem>
     507        </varlistentry>
     508        <varlistentry>
     509          <term><option>--cwd=<replaceable>path-to-directory</replaceable></option></term>
     510          <listitem><para>
     511              Specifies the absolute path of a directory in which
     512              to start the program. Optional. The directory must
     513              exist and be accessible to the guest user. For example:
     514              <filename>C:\Users\production\work_area</filename>.
     515            </para><para>
     516              The short form of this option is <option>-C</option>.
    504517            </para></listitem>
    505518        </varlistentry>
  • trunk/include/VBox/GuestHost/GuestControl.h

    r99085 r99120  
    194194 */
    195195#define GUEST_PROC_DEF_CMD_LEN        _1K
     196#define GUEST_PROC_DEF_CWD_LEN        _1K
    196197#define GUEST_PROC_DEF_ARGS_LEN       _1K
    197198#define GUEST_PROC_DEF_ENV_LEN        _1K
     
    205206 */
    206207#define GUEST_PROC_MAX_CMD_LEN            _1M
     208#define GUEST_PROC_MAX_CWD_LEN            RTPATH_MAX
    207209#define GUEST_PROC_MAX_ARGS_LEN           _2M
    208210#define GUEST_PROC_MAX_ENV_LEN            _4M
  • trunk/include/VBox/HostServices/GuestControlSvc.h

    r99088 r99120  
    814814 * The toolbox commands now are being marked as deprecated.
    815815 * @since 7.1 */
    816 # define VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS        RT_BIT_64(4)
     816#define VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS         RT_BIT_64(4)
     817/** Supports specifying the working directory for run / start. */
     818#define VBOX_GUESTCTRL_GF_0_PROCESS_CWD             RT_BIT_64(5)
    817819/** Bit that must be set in the 2nd parameter, will be cleared if the host reponds
    818820 * correctly (old hosts might not). */
     
    830832 * @since 6.1.6  */
    831833#define VBOX_GUESTCTRL_HF_0_PROCESS_ARGV0           RT_BIT_64(1)
     834/** Host sends the working directory for run / start, if guest
     835 * reports VBOX_GUESTCTRL_GF_0_PROCESS_CWD.
     836 * @since 6.1.20 ??  */
     837#define VBOX_GUESTCTRL_HF_0_PROCESS_CWD             RT_BIT_64(2)
    832838/** @} */
    833839
     
    12101216            /** Pointer to process affinity blocks (uint64_t). */
    12111217            HGCMFunctionParameter affinity;
     1218            /** Working directory request, filled if guest
     1219             *  reports VBOX_GUESTCTRL_GF_0_PROCESS_CWD. */
     1220            HGCMFunctionParameter cwd;
    12121221        } v2;
    12131222    } u;
  • trunk/include/VBox/VBoxGuestLib.h

    r99085 r99120  
    10291029    /** Number of environment variables specified in pszEnv. */
    10301030    uint32_t cEnvVars;
     1031    /** Optional working directory. */
     1032    char *pszCwd;
     1033    /** Size (in bytes) of optional working directory string. */
     1034    uint32_t cbCwd;
    10311035    /** User name (account) to start the process under. */
    10321036    char *pszUser;
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibGuestCtrl.cpp

    r99088 r99120  
    13911391 * @param   pStartupInfo        Process startup info to initializes.
    13921392 * @param   cbCmd               Size (in bytes) to use for the command buffer.
     1393 * @param   cbCwd               Size (in bytes) to use for the current working directory.
    13931394 * @param   cbUser              Size (in bytes) to use for the user name buffer.
    13941395 * @param   cbPassword          Size (in bytes) to use for the password buffer.
     
    13991400VBGLR3DECL(int) VbglR3GuestCtrlProcStartupInfoInitEx(PVBGLR3GUESTCTRLPROCSTARTUPINFO pStartupInfo,
    14001401                                                     size_t cbCmd,
     1402                                                     size_t cbCwd,
    14011403                                                     size_t cbUser, size_t cbPassword, size_t cbDomain,
    14021404                                                     size_t cbArgs, size_t cbEnv)
     
    14041406    AssertPtrReturn(pStartupInfo, VERR_INVALID_POINTER);
    14051407    AssertReturn(cbCmd,           VERR_INVALID_PARAMETER);
     1408    AssertReturn(cbCwd,           VERR_INVALID_PARAMETER);
    14061409    AssertReturn(cbUser,          VERR_INVALID_PARAMETER);
    14071410    AssertReturn(cbPassword,      VERR_INVALID_PARAMETER);
     
    14231426    {
    14241427        ALLOC_STR(Cmd,      cbCmd);
     1428        ALLOC_STR(Cwd,      cbCwd);
    14251429        ALLOC_STR(Args,     cbArgs);
    14261430        ALLOC_STR(Env,      cbEnv);
     
    14481452    return VbglR3GuestCtrlProcStartupInfoInitEx(pStartupInfo,
    14491453                                                GUEST_PROC_DEF_CMD_LEN,
     1454                                                GUEST_PROC_DEF_CWD_LEN,
    14501455                                                GUEST_PROC_DEF_USER_LEN     /* Deprecated, now handled via session creation. */,
    14511456                                                GUEST_PROC_DEF_PASSWORD_LEN /* Ditto. */,
     
    14651470
    14661471    RTStrFree(pStartupInfo->pszCmd);
     1472    RTStrFree(pStartupInfo->pszCwd);
    14671473    RTStrFree(pStartupInfo->pszArgs);
    14681474    RTStrFree(pStartupInfo->pszEnv);
     
    16051611            VbglHGCMParmUInt32Set(&Msg.u.v2.num_affinity, 0);
    16061612            VbglHGCMParmPtrSet(&Msg.u.v2.affinity, pStartupInfo->uAffinity, sizeof(pStartupInfo->uAffinity));
     1613            /* v2.cwd was added in 7.1.  If the host is older, the Msg struct it sends is
     1614             * shorter and these fields are zero-filled, which equals 'no cwd requested'. */
     1615            VbglHGCMParmPtrSet(&Msg.u.v2.cwd, pStartupInfo->pszCwd, pStartupInfo->cbCwd);
    16071616        }
    16081617
     
    16101619        if (RT_FAILURE(rc))
    16111620        {
    1612             LogRel(("VbglR3GuestCtrlProcGetStart: 1 - %Rrc (retry %u, cbCmd=%RU32, cbArgs=%RU32, cbEnv=%RU32)\n",
    1613                     rc, cRetries, pStartupInfo->cbCmd, pStartupInfo->cbArgs, pStartupInfo->cbEnv));
     1621            LogRel(("VbglR3GuestCtrlProcGetStart: 1 - %Rrc (retry %u, cbCmd=%RU32, cbCwd=%RU32, cbArgs=%RU32, cbEnv=%RU32)\n",
     1622                    rc, cRetries, pStartupInfo->cbCmd, pStartupInfo->cbCwd, pStartupInfo->cbArgs, pStartupInfo->cbEnv));
    16141623
    16151624            if (   rc == VERR_BUFFER_OVERFLOW
     
    16241633                /* We can't tell which parameter doesn't fit, so we have to resize all. */
    16251634                GROW_STR(Cmd , GUEST_PROC_MAX_CMD_LEN);
     1635                GROW_STR(Cwd,  GUEST_PROC_MAX_CWD_LEN);
    16261636                GROW_STR(Args, GUEST_PROC_MAX_ARGS_LEN);
    16271637                GROW_STR(Env,  GUEST_PROC_MAX_ENV_LEN);
    16281638
    16291639#undef GROW_STR
    1630                 LogRel(("VbglR3GuestCtrlProcGetStart: 2 - %Rrc (retry %u, cbCmd=%RU32, cbArgs=%RU32, cbEnv=%RU32)\n",
    1631                         rc, cRetries, pStartupInfo->cbCmd, pStartupInfo->cbArgs, pStartupInfo->cbEnv));
     1640                LogRel(("VbglR3GuestCtrlProcGetStart: 2 - %Rrc (retry %u, cbCmd=%RU32, cbCwd=%RU32, cbArgs=%RU32, cbEnv=%RU32)\n",
     1641                        rc, cRetries, pStartupInfo->cbCmd, pStartupInfo->cbCwd, pStartupInfo->cbArgs, pStartupInfo->cbEnv));
    16321642                LogRel(("g_fVbglR3GuestCtrlHavePeekGetCancel=%RTbool\n", RT_BOOL(g_fVbglR3GuestCtrlHavePeekGetCancel)));
    16331643            }
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp

    r98526 r99120  
    258258                                      | VBOX_GUESTCTRL_GF_0_PROCESS_ARGV0
    259259                                      | VBOX_GUESTCTRL_GF_0_PROCESS_DYNAMIC_SIZES
     260                                      | VBOX_GUESTCTRL_GF_0_PROCESS_CWD
    260261#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
    261262                                      | VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlProcess.cpp

    r98103 r99120  
    12541254 * @param   pszPassword                 Password of the specified user.
    12551255 * @param   pszDomain                   Domain to use for authentication.
     1256 * @param   pszCwd                      Current working directory to use for the created process.
     1257 *                                      Set to NULL if not being used.
    12561258 * @param   phProcess                   Pointer which will receive the process handle after
    12571259 *                                      successful process start.
     
    12601262                                            PCRTHANDLE phStdIn, PCRTHANDLE phStdOut, PCRTHANDLE phStdErr,
    12611263                                            const char *pszAsUser, const char *pszPassword, const char *pszDomain,
    1262                                             PRTPROCESS phProcess)
     1264                                            const char *pszCwd, PRTPROCESS phProcess)
    12631265{
    12641266#ifndef RT_OS_WINDOWS
     
    12721274    /* pszPassword is optional. */
    12731275    /* pszDomain is optional. */
     1276    /* pszCwd is optional. */
    12741277    AssertPtrReturn(phProcess, VERR_INVALID_PARAMETER);
    12751278
     
    14111414                    fProcCreateFlags |= RTPROC_FLAGS_UNQUOTED_ARGS;
    14121415            }
     1416            if (pszCwd && *pszCwd)
     1417                fProcCreateFlags |= RTPROC_FLAGS_CWD;
     1418            else
     1419                pszCwd = NULL;
    14131420
    14141421            /* If no user name specified run with current credentials (e.g.
     
    14471454                                    pszAsUser,
    14481455                                    pszPassword && *pszPassword ? pszPassword : NULL,
    1449                                     NULL /*pvExtraData*/,
     1456                                    (void *)pszCwd /*pvExtraData*/,
    14501457                                    phProcess);
    14511458
     
    15451552    VGSvcVerbose(3, "vgsvcGstCtrlProcessProcessWorker: fHostFeatures0       = %#x\n",     g_fControlHostFeatures0);
    15461553    VGSvcVerbose(3, "vgsvcGstCtrlProcessProcessWorker: StartupInfo.szCmd    = '%s'\n",    pProcess->pStartupInfo->pszCmd);
     1554    VGSvcVerbose(3, "vgsvcGstCtrlProcessProcessWorker: StartupInfo.szCwd    = '%s'\n",    pProcess->pStartupInfo->pszCwd
     1555                                                                                        ? pProcess->pStartupInfo->pszCwd : "<None>");
    15471556    VGSvcVerbose(3, "vgsvcGstCtrlProcessProcessWorker: StartupInfo.uNumArgs = '%RU32'\n", pProcess->pStartupInfo->cArgs);
    15481557#ifdef DEBUG /* Never log this stuff in release mode! */
     
    16781687                                                                     fNeedsImpersonation ? pProcess->pStartupInfo->pszPassword : NULL,
    16791688                                                                     fNeedsImpersonation ? pProcess->pStartupInfo->pszDomain   : NULL,
    1680                                                                      &pProcess->hProcess);
     1689                                                                     pProcess->pStartupInfo->pszCwd, &pProcess->hProcess);
    16811690                                    if (RT_FAILURE(rc))
    16821691                                        VGSvcError("Error starting process, rc=%Rrc\n", rc);
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r99087 r99120  
    16921692    if (RT_SUCCESS(rc))
    16931693    {
    1694         VGSvcVerbose(3, "Request to start process szCmd=%s, fFlags=0x%x, szArgs=%s, szEnv=%s, uTimeout=%RU32\n",
     1694        VGSvcVerbose(3, "Request to start process szCmd=%s, fFlags=0x%x, szArgs=%s, szEnv=%s, szCwd=%s, uTimeout=%RU32\n",
    16951695                     pStartupInfo->pszCmd, pStartupInfo->fFlags,
    16961696                     pStartupInfo->cArgs    ? pStartupInfo->pszArgs : "<None>",
    16971697                     pStartupInfo->cEnvVars ? pStartupInfo->pszEnv  : "<None>",
     1698                     pStartupInfo->cbCwd    ? pStartupInfo->pszCwd  : "<None>",
    16981699                     pStartupInfo->uTimeLimitMS);
    16991700
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp

    r98665 r99120  
    11701170    {
    11711171        GCTLCMD_COMMON_OPTION_DEFS()
     1172        { "--cwd",                          'C',                                      RTGETOPT_REQ_STRING  },
    11721173        { "--putenv",                       'E',                                      RTGETOPT_REQ_STRING  },
    11731174        { "--exe",                          'e',                                      RTGETOPT_REQ_STRING  },
     
    12001201    com::SafeArray<IN_BSTR>                 aEnv;
    12011202    const char *                            pszImage            = NULL;
     1203    const char *                            pszCwd              = NULL;
    12021204    bool                                    fWaitForStdOut      = fRunCmd;
    12031205    bool                                    fWaitForStdErr      = fRunCmd;
     
    12391241                case kGstCtrlRunOpt_Profile:
    12401242                    aCreateFlags.push_back(ProcessCreateFlag_Profile);
     1243                    break;
     1244
     1245                case 'C':
     1246                    pszCwd = ValueUnion.psz;
    12411247                    break;
    12421248
     
    13581364            ComPtr<IGuestProcess> pProcess;
    13591365            CHECK_ERROR_BREAK(pCtx->pGuestSession, ProcessCreate(Bstr(pszImage).raw(),
     1366                                                                 Bstr(pszCwd).raw(),
    13601367                                                                 ComSafeArrayAsInParam(aArgs),
    13611368                                                                 ComSafeArrayAsInParam(aEnv),
  • trunk/src/VBox/HostServices/GuestControl/VBoxGuestControlSvc.cpp

    r98665 r99120  
    952952/** Host feature mask for GUEST_MSG_REPORT_FEATURES/GUEST_MSG_QUERY_FEATURES. */
    953953static uint64_t const g_fGstCtrlHostFeatures0 = VBOX_GUESTCTRL_HF_0_NOTIFY_RDWR_OFFSET
     954                                              | VBOX_GUESTCTRL_HF_0_PROCESS_CWD
    954955                                              | VBOX_GUESTCTRL_HF_0_PROCESS_ARGV0;
    955956
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r99085 r99120  
    1481414814  <interface
    1481514815    name="IGuestSession" extends="$unknown"
    14816     uuid="234f0627-866d-48c2-91a5-4c9d50f04928"
     14816    uuid="5591bead-9c1d-4cbd-9669-2d0b04fac0a8"
    1481714817    wsmap="managed"
    1481814818    reservedMethods="8" reservedAttributes="12"
     
    1594715947          If ProcessCreateFlag_WaitForStdOut and/or ProcessCreateFlag_WaitForStdErr
    1594815948          are set, the guest process will not enter the terminated state until
    15949           all data from the specified streams have been read read.
     15949          all data from the specified streams have been read.
    1595015950        </note>
    1595115951
     
    1596115961        <desc>
    1596215962          Full path to the file to execute in the guest.  The file has to
    15963           exists in the guest VM with executable right to the session user in
     15963          exist in the guest VM with executable right to the session user in
    1596415964          order to succeed.  If empty/null, the first entry in the
    1596515965          @a arguments array will be used instead (i.e. argv[0]).
     15966        </desc>
     15967      </param>
     15968      <param name="cwd" type="wstring" dir="in">
     15969        <desc>
     15970          Path to the directory in which to execute in the guest.  The
     15971          directory has to exist in the guest VM with search rights to the
     15972          session user in order to succeed.  If empty/null, the session
     15973          user's default (typically 'home') directory is used.  If not a
     15974          full path, it is interpreted relative to the default directory;
     15975          e.g. 'work' means '$HOME/work' (according to the guest's '$HOME'-
     15976          like concept).
    1596615977        </desc>
    1596715978      </param>
     
    1601716028        See <link to="IGuestSession::processCreate"/> for more information.
    1601816029      </desc>
     16030      <param name="cwd" type="wstring" dir="in">
     16031        <desc>
     16032          Path to the directory in which to execute in the guest.  The
     16033          directory has to exist in the guest VM with search rights to the
     16034          session user in order to succeed.  If empty/null, the session
     16035          user's default (typically 'home') directory is used.  If not a
     16036          full path, it is interpreted relative to the default directory;
     16037          e.g. 'work' means '$HOME/work' (according to the guest's '$HOME'-
     16038          like concept).
     16039        </desc>
     16040      </param>
    1601916041      <param name="executable" type="wstring" dir="in">
    1602016042        <desc>
    1602116043          Full path to the file to execute in the guest.  The file has to
    16022           exists in the guest VM with executable right to the session user in
     16044          exist in the guest VM with executable right to the session user in
    1602316045          order to succeed.  If empty/null, the first entry in the
    1602416046          @a arguments array will be used instead (i.e. argv[0]).
  • trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h

    r99085 r99120  
    945945    /** The executable. */
    946946    Utf8Str                     mExecutable;
     947    /** The working directory. Optional, can be empty if not used. */
     948    Utf8Str                     mCwd;
    947949    /** Arguments vector (starting with argument \#0). */
    948950    ProcessArguments            mArguments;
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r98713 r99120  
    212212                        ULONG aMode);
    213213    HRESULT processCreate(const com::Utf8Str &aCommand,
     214                          const com::Utf8Str &aCwd,
    214215                          const std::vector<com::Utf8Str> &aArguments,
    215216                          const std::vector<com::Utf8Str> &aEnvironment,
     
    218219                          ComPtr<IGuestProcess> &aGuestProcess);
    219220    HRESULT processCreateEx(const com::Utf8Str &aCommand,
     221                            const com::Utf8Str &aCwd,
    220222                            const std::vector<com::Utf8Str> &aArguments,
    221223                            const std::vector<com::Utf8Str> &aEnvironment,
  • trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp

    r98666 r99120  
    11581158int GuestProcess::i_startProcess(uint32_t cMsTimeout, int *pvrcGuest)
    11591159{
    1160     LogFlowThisFunc(("cMsTimeout=%RU32, procExe=%s, procTimeoutMS=%RU32, procFlags=%x, sessionID=%RU32\n",
    1161                      cMsTimeout, mData.mProcess.mExecutable.c_str(), mData.mProcess.mTimeoutMS, mData.mProcess.mFlags,
    1162                      mSession->i_getId()));
     1160    LogFlowThisFunc(("cMsTimeout=%RU32, procExe=%s, cwd=%s, procTimeoutMS=%RU32, procFlags=%x, sessionID=%RU32\n",
     1161                     cMsTimeout, mData.mProcess.mExecutable.c_str(), mData.mProcess.mCwd.c_str(),
     1162                     mData.mProcess.mTimeoutMS, mData.mProcess.mFlags, mSession->i_getId()));
    11631163
    11641164    /* Wait until the caller function (if kicked off by a thread)
     
    12151215        return VERR_BUFFER_OVERFLOW;
    12161216
     1217    Guest *pGuest = mSession->i_getParent();
     1218    AssertPtr(pGuest);
     1219    const uint64_t fGuestControlFeatures0 = pGuest->i_getGuestControlFeatures0();
     1220
     1221    /* Check if the Guest Additions support setting the current working directory for the new process
     1222     * if the caller wants to set one, and bail out early if it doesn't. */
     1223    if (   !mData.mProcess.mCwd.isEmpty()
     1224        && (   uProtocol < 2
     1225            || !(fGuestControlFeatures0 & VBOX_GUESTCTRL_GF_0_PROCESS_CWD)))
     1226    {
     1227        LogRel2(("Guest Control: Installed Guest Addtions don't support setting the current working directory to '%s'!\n",
     1228                 mData.mProcess.mCwd.c_str()));
     1229        return VERR_NOT_SUPPORTED;
     1230    }
     1231
    12171232    size_t cbArgs = 0;
    12181233    char *pszArgs = NULL;
    12191234    int vrc = VINF_SUCCESS;
     1235
    12201236    if (cArgs)
    12211237    {
     
    12291245        }
    12301246        papszArgv[cArgs] = NULL;
    1231 
    1232         Guest *pGuest = mSession->i_getParent();
    1233         AssertPtr(pGuest);
    1234 
    1235         const uint64_t fGuestControlFeatures0 = pGuest->i_getGuestControlFeatures0();
    12361247
    12371248        /* If the Guest Additions don't support using argv[0] correctly (< 6.1.x), don't supply it. */
     
    12991310            /* The actual CPU affinity blocks. */
    13001311            HGCMSvcSetPv(&paParms[i++], (void *)&mData.mProcess.mAffinity, sizeof(mData.mProcess.mAffinity));
     1312            /* Supply working directory, if guest supports it. */
     1313            if (fGuestControlFeatures0 & VBOX_GUESTCTRL_GF_0_PROCESS_CWD)
     1314                HGCMSvcSetRTCStr(&paParms[i++], mData.mProcess.mCwd);
    13011315        }
    13021316
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r98813 r99120  
    49434943
    49444944
    4945 HRESULT GuestSession::processCreate(const com::Utf8Str &aExecutable, const std::vector<com::Utf8Str> &aArguments,
     4945HRESULT GuestSession::processCreate(const com::Utf8Str &aExecutable, const com::Utf8Str &aCwd,
     4946                                    const std::vector<com::Utf8Str> &aArguments,
    49464947                                    const std::vector<com::Utf8Str> &aEnvironment,
    49474948                                    const std::vector<ProcessCreateFlag_T> &aFlags,
     
    49514952
    49524953    std::vector<LONG> affinityIgnored;
    4953     return processCreateEx(aExecutable, aArguments, aEnvironment, aFlags, aTimeoutMS, ProcessPriority_Default,
    4954                            affinityIgnored, aGuestProcess);
    4955 }
    4956 
    4957 HRESULT GuestSession::processCreateEx(const com::Utf8Str &aExecutable, const std::vector<com::Utf8Str> &aArguments,
     4954    return processCreateEx(aExecutable, aCwd, aArguments, aEnvironment, aFlags, aTimeoutMS,
     4955                           ProcessPriority_Default, affinityIgnored, aGuestProcess);
     4956}
     4957
     4958HRESULT GuestSession::processCreateEx(const com::Utf8Str &aExecutable, const com::Utf8Str &aCwd,
     4959                                      const std::vector<com::Utf8Str> &aArguments,
    49584960                                      const std::vector<com::Utf8Str> &aEnvironment,
    49594961                                      const std::vector<ProcessCreateFlag_T> &aFlags, ULONG aTimeoutMS,
     
    49784980    }
    49794981
     4982    uint32_t const uProtocol              = i_getProtocolVersion();
     4983    uint64_t const fGuestControlFeatures0 = mParent->i_getGuestControlFeatures0();
     4984
     4985    /* If a current working directory (CWD) is set, make sure that the installed Guest Additions actually
     4986     * support this before doing anything else. */
     4987    if (   !aCwd.isEmpty()
     4988        && (   uProtocol < 2
     4989            || !(fGuestControlFeatures0 & VBOX_GUESTCTRL_GF_0_PROCESS_CWD)))
     4990        return setError(VBOX_E_NOT_SUPPORTED,
     4991                        tr("Setting the current working directory is not supported by the installed Guest Addtions!"));
     4992
    49804993    /* The rest of the input is being validated in i_processCreateEx(). */
    49814994
     
    49965009    else /* If no arguments were given, add the executable as argv[0] by default. */
    49975010        procInfo.mArguments.push_back(procInfo.mExecutable);
     5011
     5012    /* Optional working directory */
     5013    procInfo.mCwd = aCwd;
    49985014
    49995015    /* Combine the environment changes associated with the ones passed in by
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