VirtualBox

Changeset 83405 in vbox


Ignore:
Timestamp:
Mar 25, 2020 12:45:01 PM (5 years ago)
Author:
vboxsync
Message:

Guest Control/Main + VBoxService: Resolved another @todo: Added ability for guest processes to use argv[0] independently of the actual execution command. bugref:9320

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/HostServices/GuestControlSvc.h

    r82968 r83405  
    139139     * The host wants to execute something in the guest. This can be a command
    140140     * line or starting a program.
    141      * @note Legacy (VBox < 4.3) message.
    142141     */
    143142    HOST_MSG_EXEC_CMD = 100,
    144143    /**
    145144     * Sends input data for stdin to a running process executed by HOST_EXEC_CMD.
    146      * @note Legacy (VBox < 4.3) message.
    147145     */
    148146    HOST_MSG_EXEC_SET_INPUT = 101,
     
    150148     * Gets the current status of a running process, e.g.
    151149     * new data on stdout/stderr, process terminated etc.
    152      * @note Legacy (VBox < 4.3) message.
    153150     */
    154151    HOST_MSG_EXEC_GET_OUTPUT = 102,
     
    692689 * @{ */
    693690/** Supports HOST_MSG_FILE_SET_SIZE. */
    694 #define VBOX_GUESTCTRL_GF_0_SET_SIZE     RT_BIT_64(0)
     691#define VBOX_GUESTCTRL_GF_0_SET_SIZE                RT_BIT_64(0)
     692/** Supports (fixes) treating argv[0] separately from the actual execution command.
     693 *  Without this flag the actual execution command is taken as argv[0]. */
     694#define VBOX_GUESTCTRL_GF_0_PROCESS_ARGV0           RT_BIT_64(1)
    695695/** Bit that must be set in the 2nd parameter, will be cleared if the host reponds
    696696 * correctly (old hosts might not). */
    697 #define VBOX_GUESTCTRL_GF_1_MUST_BE_ONE RT_BIT_64(63)
     697#define VBOX_GUESTCTRL_GF_1_MUST_BE_ONE             RT_BIT_64(63)
    698698/** @} */
    699699
     
    704704 *  GUEST_FILE_NOTIFYTYPE_WRITE_OFFSET notification types. */
    705705#define VBOX_GUESTCTRL_HF_0_NOTIFY_RDWR_OFFSET      RT_BIT_64(0)
     706/** Host supports sending (treating) argv[0] separately from the actual execution command.
     707 *  Needed when newer Guest Additions which support VBOX_GUESTCTRL_GF_0_PROCESS_ARGV0 run on an older
     708 *  host which doesn't in turn support VBOX_GUESTCTRL_HF_0_PROCESS_ARGV0. */
     709#define VBOX_GUESTCTRL_HF_0_PROCESS_ARGV0           RT_BIT_64(1)
    706710/** @} */
    707711
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp

    r82968 r83405  
    216216             * Report features to the host.
    217217             */
    218             rc = VbglR3GuestCtrlReportFeatures(g_idControlSvcClient, VBOX_GUESTCTRL_GF_0_SET_SIZE, &g_fControlHostFeatures0);
     218            const uint64_t fGuestFeatures = VBOX_GUESTCTRL_GF_0_SET_SIZE
     219                                          | VBOX_GUESTCTRL_GF_0_PROCESS_ARGV0;
     220
     221            rc = VbglR3GuestCtrlReportFeatures(g_idControlSvcClient, fGuestFeatures, &g_fControlHostFeatures0);
    219222            if (RT_SUCCESS(rc))
    220223                VGSvcVerbose(3, "Host features: %#RX64\n", g_fControlHostFeatures0);
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlProcess.cpp

    r83400 r83405  
    10711071#endif
    10721072
    1073     /* HACK ALERT! Since we still don't allow the user to really specify the first
    1074                    argument separately from the executable image, we have to fudge
     1073    /* HACK ALERT! Older hosts (< VBox 6.1.x) did not allow the user to really specify the first
     1074                   argument separately from the executable image, so we have to fudge
    10751075                   a little in the unquoted argument case to deal with executables
    10761076                   containing spaces. */
    1077     /** @todo Fix the stupid host/guest protocol so the user can do this for us! */
    10781077    if (   !(fFlags & EXECUTEPROCESSFLAG_UNQUOTED_ARGS)
    10791078        || !strpbrk(pszArgv0, " \t\n\r")
     
    10941093        }
    10951094    }
     1095
    10961096    if (RT_SUCCESS(rc))
    10971097    {
     
    13421342    if (RT_SUCCESS(rc))
    13431343    {
     1344        const char *pszArgv0 = RT_BOOL(g_fControlHostFeatures0 & VBOX_GUESTCTRL_HF_0_PROCESS_ARGV0)
     1345                             ? papszArgs[0] : pszExec;
    13441346        char **papszArgsExp;
    1345         /** @todo r-bird: pszExec != argv[0]! When are you going to get that?!? How many
    1346          * times does this need to be pointed out?  HOST/GUEST INTERFACE IS MISDESIGNED! */
    1347         rc = vgsvcGstCtrlProcessAllocateArgv(pszExec /* Always use the unmodified executable name as argv0. */,
    1348                                              papszArgs /* Append the rest of the argument vector (if any). */,
     1347        rc = vgsvcGstCtrlProcessAllocateArgv(pszArgv0, papszArgs,
    13491348                                             fFlags, &papszArgsExp);
    13501349        if (RT_FAILURE(rc))
  • trunk/src/VBox/HostServices/GuestControl/VBoxGuestControlSvc.cpp

    r82968 r83405  
    934934
    935935/** Host feature mask for GUEST_MSG_REPORT_FEATURES/GUEST_MSG_QUERY_FEATURES. */
    936 static uint64_t const g_fGstCtrlHostFeatures0 = VBOX_GUESTCTRL_HF_0_NOTIFY_RDWR_OFFSET;
    937 
     936static uint64_t const g_fGstCtrlHostFeatures0 = VBOX_GUESTCTRL_HF_0_NOTIFY_RDWR_OFFSET
     937                                              | VBOX_GUESTCTRL_HF_0_PROCESS_ARGV0;
    938938
    939939
  • trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp

    r82968 r83405  
    3535# error "VBOX_WITH_GUEST_CONTROL must defined in this file"
    3636#endif
     37#include "GuestImpl.h"
    3738#include "GuestProcessImpl.h"
    3839#include "GuestSessionImpl.h"
     
    10771078        papszArgv[cArgs] = NULL;
    10781079
    1079         if (uProtocol < UINT32_C(0xdeadbeef) ) /** @todo implement a way of sending argv[0], best idea is a new command. */
     1080        Guest *pGuest = mSession->i_getParent();
     1081        AssertPtr(pGuest);
     1082
     1083        /* If the Guest Additions don't support using argv[0] correctly (< 6.1.x), don't supply it. */
     1084        if (!RT_BOOL(pGuest->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_PROCESS_ARGV0))
    10801085            vrc = RTGetOptArgvToString(&pszArgs, papszArgv + 1, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH);
    1081         else
     1086        else /* ... else send the whole argv, including argv[0]. */
    10821087            vrc = RTGetOptArgvToString(&pszArgs, papszArgv, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH);
    10831088
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