VirtualBox

Ignore:
Timestamp:
Jan 19, 2016 1:37:10 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
105119
Message:

VBoxHeadless: hack

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r55867 r59409  
    4444
    4545#ifdef VBOX_WITH_VPX
    46 #include <cstdlib>
    47 #include <cerrno>
    48 #include <iprt/process.h>
     46# include <cstdlib>
     47# include <cerrno>
     48# include <iprt/process.h>
     49#endif
     50
     51#ifdef RT_OS_DARWIN
     52# include <dlfcn.h>
     53# include <sys/mman.h>
    4954#endif
    5055
     
    586591static CComModule _Module;
    587592#endif
     593
     594#ifdef RT_OS_DARWIN
     595/**
     596 * Mac OS X: Really ugly hack to bypass a set-uid check in AppKit.
     597 *
     598 * This will modify the issetugid() function to always return zero.  This must
     599 * be done _before_ AppKit is initialized, otherwise it will refuse to play ball
     600 * with us as it distrusts set-uid processes since Snow Leopard.  We, however,
     601 * have carefully dropped all root privileges at this point and there should be
     602 * no reason for any security concern here.
     603 */
     604static void hideSetUidRootFromAppKit()
     605{
     606    /* Find issetguid() and make it always return 0 by modifying the code: */
     607    void *pvAddr = dlsym(RTLD_DEFAULT, "issetugid");
     608    int rc = mprotect((void *)((uintptr_t)pvAddr & ~(uintptr_t)0xfff), 0x2000, PROT_WRITE | PROT_READ | PROT_EXEC);
     609    if (!rc)
     610        ASMAtomicWriteU32((volatile uint32_t *)pvAddr, 0xccc3c031); /* xor eax, eax; ret; int3 */
     611}
     612#endif /* RT_OS_DARWIN */
    588613
    589614/**
     
    685710    const char *pcszNameOrUUID = NULL;
    686711
     712#ifdef RT_OS_DARWIN
     713    hideSetUidRootFromAppKit();
     714#endif
     715
    687716    // parse the command line
    688717    int ch;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette