VirtualBox

Changeset 70727 in vbox for trunk/src/VBox/HostServices


Ignore:
Timestamp:
Jan 24, 2018 2:01:03 PM (7 years ago)
Author:
vboxsync
Message:

Enforce that host-side configuration guest properties are read-only-guest.
bugref:9047: Clean up Linux guest vboxuser device
We use certain guest properties for passing configuration information to the
Guest Additions, and these are not intended to be set or changed from inside
the guest. Enforce this.

Location:
trunk/src/VBox/HostServices/GuestProperties
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/GuestProperties/service.cpp

    r70221 r70727  
    268268
    269269    /**
     270     * Check whether the property name is reserved for host changes only.
     271     *
     272     * @returns Boolean true (host reserved) or false (available to guest).
     273     *
     274     * @param   pszName  The property name to check.
     275     */
     276    bool checkHostReserved(const char *pszName)
     277    {
     278        if (RTStrStartsWith(pszName, "/VirtualBox/GuestAdd/"))
     279            return true;
     280        if (RTStrStartsWith(pszName, "/VirtualBox/HostInfo/"))
     281            return true;
     282        return false;
     283    }
     284
     285    /**
    270286     * Gets a property.
    271287     *
     
    539555                rc = GuestPropValidateFlags(papszFlags[i], &fFlags);
    540556                AssertRCBreak(rc);
     557                /*
     558                 * Handle names which are read-only for the guest.
     559                 */
     560                if (checkHostReserved(papszNames[i]))
     561                    fFlags |= GUEST_PROP_F_RDONLYGUEST;
    541562
    542563                Property *pProp = getPropertyInternal(papszNames[i]);
     
    715736    Property *pProp = getPropertyInternal(pcszName);
    716737    rc = checkPermission(pProp ? pProp->mFlags : GUEST_PROP_F_NILFLAG, isGuest);
     738    /*
     739     * Handle names which are read-only for the guest.
     740     */
     741    if (rc == VINF_SUCCESS && checkHostReserved(pcszName))
     742    {
     743        if (isGuest)
     744            rc = VERR_PERMISSION_DENIED;
     745        else
     746            fFlags |= GUEST_PROP_F_RDONLYGUEST;
     747    }
    717748    if (rc == VINF_SUCCESS)
    718749    {
  • trunk/src/VBox/HostServices/GuestProperties/testcase/tstGuestPropSvc.cpp

    r70221 r70727  
    464464        { "Green", "gone out...", "", false, false, false },
    465465        { "Green", "gone out...", "", true, false, false },
     466        { "/VirtualBox/GuestAdd/SharedFolders/MountDir", "test", "", false, true, false },
     467        { "/VirtualBox/HostInfo/VRDP/Client/1/Name", "test", "", false, false, false },
     468        { "/VirtualBox/GuestAdd/SharedFolders/MountDir", "test", "", true, true, true },
     469        { "/VirtualBox/HostInfo/VRDP/Client/1/Name", "test", "TRANSRESET", true, true, true },
    466470    };
    467471
     
    662666    { "Green\0Go!\0READONLY", sizeof("Green\0Go!\0READONLY") },
    663667    { "Blue\0What on earth...?\0", sizeof("Blue\0What on earth...?\0") },
     668    { "/VirtualBox/GuestAdd/SharedFolders/MountDir\0test\0RDONLYGUEST",
     669      sizeof("/VirtualBox/GuestAdd/SharedFolders/MountDir\0test\0RDONLYGUEST") },
     670    { "/VirtualBox/HostInfo/VRDP/Client/1/Name\0test\0TRANSIENT, RDONLYGUEST, TRANSRESET",
     671      sizeof("/VirtualBox/HostInfo/VRDP/Client/1/Name\0test\0TRANSIENT, RDONLYGUEST, TRANSRESET") },
    664672    { "Red\0\0", sizeof("Red\0\0") },
    665673    { "Amber\0\0", sizeof("Amber\0\0") },
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