VirtualBox

Changeset 93466 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Jan 27, 2022 8:26:16 PM (3 years ago)
Author:
vboxsync
Message:

Additions: Guest Library: Add interface to query if DRM IPC server socket access should be restricted, bugref:10134.

Access to IPC socket is restricted if /VirtualBox/GuestAdd/DRMIpcRestricted
guest property is set and is READ-ONLY for guest. This change is for Linux
Additions only.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibDrmClient.cpp

    r93331 r93466  
    3636
    3737#if defined(RT_OS_LINUX)
     38# include <VBox/HostServices/GuestPropertySvc.h>
    3839
    3940/** Defines the DRM client executable (image). */
     
    4647
    4748/**
    48  * Returns if the DRM resizing client is needed.
     49 * Check if specified guest property exist.
     50 *
     51 * @returns \c true if the property exists and its flags do match, \c false otherwise.
     52 * @param   pszPropName     Guest property name.
     53 * @param   fPropFlags      Guest property flags mask to verify if property exist.
     54 *                          If \p fPropFlags is 0, flags verification is omitted.
     55 */
     56static bool vbglR3DrmClientCheckProp(const char *pszPropName, uint32_t fPropFlags)
     57{
     58    bool fExist = false;
     59#if defined(RT_OS_LINUX) && defined(VBOX_WITH_GUEST_PROPS)
     60    uint32_t idClient;
     61
     62    int rc = VbglR3GuestPropConnect(&idClient);
     63    if (RT_SUCCESS(rc))
     64    {
     65        char *pcszFlags = NULL;
     66
     67        rc = VbglR3GuestPropReadEx(idClient, pszPropName, NULL /* ppszValue */, &pcszFlags, NULL);
     68        if (RT_SUCCESS(rc))
     69        {
     70            /* Check property flags match. */
     71            if (fPropFlags)
     72            {
     73                uint32_t fFlags = 0;
     74
     75                rc = GuestPropValidateFlags(pcszFlags, &fFlags);
     76                fExist = RT_SUCCESS(rc) && (fFlags & fPropFlags);
     77            }
     78            else
     79                fExist = true;
     80
     81            RTStrFree(pcszFlags);
     82        }
     83
     84        VbglR3GuestPropDisconnect(idClient);
     85    }
     86#endif /* RT_OS_LINUX */
     87    return fExist;
     88}
     89
     90/**
     91 * Returns true if the DRM resizing client is needed.
    4992 * This is achieved by querying existence of a guest property.
    5093 *
     
    5396VBGLR3DECL(bool) VbglR3DrmClientIsNeeded(void)
    5497{
    55 #if defined(RT_OS_LINUX)
    56     bool fStartClient = false;
    57 
    58 # ifdef VBOX_WITH_GUEST_PROPS
    59     uint32_t idClient;
    60     int rc = VbglR3GuestPropConnect(&idClient);
    61     if (RT_SUCCESS(rc))
    62     {
    63         fStartClient = VbglR3GuestPropExist(idClient, VBOX_DRMCLIENT_GUEST_PROP_RESIZE /*pszPropName*/);
    64         VbglR3GuestPropDisconnect(idClient);
    65     }
    66 # endif
    67     return fStartClient;
    68 
    69 #else /* !RT_OS_LINUX */
    70     return false;
    71 #endif
     98    return vbglR3DrmClientCheckProp(VBOX_DRMCLIENT_GUEST_PROP_RESIZE, 0);
    7299}
    73100
    74101/**
    75  * Returns if the DRM resizing client already is running.
     102 * Returns true if the DRM IPC server socket access should be restricted.
     103 *
     104 * Restricted access means that only users from a certain group should
     105 * be granted with read and write access permission to IPC socket. Check
     106 * is done by examining \c VBGLR3DRMIPCPROPRESTRICT guest property. Property
     107 * is only considered valid if is read-only for guest. I.e., the following
     108 * property should be set on the host side:
     109 *
     110 *  VBoxManage guestproperty set <VM> /VirtualBox/GuestAdd/DRMIpcRestricted 1 --flags RDONLYGUEST
     111 *
     112 * @returns \c true if restricted socket access is required, \c false otherwise.
     113 */
     114VBGLR3DECL(bool) VbglR3DrmRestrictedIpcAccessIsNeeded(void)
     115{
     116    return vbglR3DrmClientCheckProp(VBGLR3DRMIPCPROPRESTRICT, GUEST_PROP_F_RDONLYGUEST);
     117}
     118
     119/**
     120 * Returns true if the DRM resizing client already is running.
    76121 * This is achieved by querying existence of a guest property.
    77122 *
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