VirtualBox

Changeset 57780 in vbox


Ignore:
Timestamp:
Sep 16, 2015 11:27:17 AM (9 years ago)
Author:
vboxsync
Message:

HideSetUidRootFromAppKit: Documented it and dropped the long outdated 'snow leopard or later' check.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r57779 r57780  
    134134
    135135#ifdef Q_WS_MAC
    136 /** Mac OS X: Really ugly hack to prevent silly check in AppKit. */
     136/**
     137 * Mac OS X: Really ugly hack to bypass a set-uid check in AppKit.
     138 *
     139 * This will modify the issetugid() function to always return zero.  This must
     140 * be done _before_ AppKit is initialized, otherwise it will refuse to play ball
     141 * with us as it distrusts set-uid processes since Snow Leopard.  We, however,
     142 * have carefully dropped all root privileges at this point and there should be
     143 * no reason for any security concern here.
     144 */
    137145static void HideSetUidRootFromAppKit()
    138146{
    139     /* Check for Snow Leopard or higher: */
    140     char szInfo[64];
    141     int rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szInfo, sizeof(szInfo));
    142     if (RT_SUCCESS(rc) && szInfo[0] == '1') /* higher than 1x.x.x */
    143     {
    144         /* Find issetguid() and make it always return 0 by modifying the code: */
    145         void *pAddr = dlsym(RTLD_DEFAULT, "issetugid");
    146         int rc = mprotect((void *)((uintptr_t)pAddr & ~(uintptr_t)0xfff), 0x2000, PROT_WRITE|PROT_READ|PROT_EXEC);
    147         if (!rc)
    148             ASMAtomicWriteU32((volatile uint32_t *)pAddr, 0xccc3c031); /* xor eax, eax; ret; int3 */
    149     }
     147    /* Find issetguid() and make it always return 0 by modifying the code: */
     148    void *pvAddr = dlsym(RTLD_DEFAULT, "issetugid");
     149    int rc = mprotect((void *)((uintptr_t)pvAddr & ~(uintptr_t)0xfff), 0x2000, PROT_WRITE | PROT_READ | PROT_EXEC);
     150    if (!rc)
     151        ASMAtomicWriteU32((volatile uint32_t *)pvAddr, 0xccc3c031); /* xor eax, eax; ret; int3 */
    150152}
    151153#endif /* Q_WS_MAC */
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