VirtualBox

Changeset 5703 in vbox


Ignore:
Timestamp:
Nov 12, 2007 1:01:48 PM (17 years ago)
Author:
vboxsync
Message:

Solaris setuid wrapper, in progress.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Config.kmk

    r5689 r5703  
    245245# Enable Crossbow support for Solaris.
    246246#VBOX_WITH_CROSSBOW = 1
     247# Enable setuid wrapper for Solaris.
     248#VBOX_WITH_SUID_WRAPPER = 1
    247249
    248250
  • trunk/src/VBox/Devices/Makefile.kmk

    r5698 r5703  
    139139 ifdef VBOX_WITH_CROSSBOW
    140140  VBoxDD_LIBS          += dladm # or maybe try libdladm.so.1 ?
     141 endif
     142 ifdef VBOX_WITH_SUID_WRAPPER
     143  VBoxDD_LIBS          += secdb
    141144 endif
    142145endif
     
    527530        Network/solaris
    528531 endif
     532 ifdef VBOX_WITH_SUID_WRAPPER
     533  Drivers_DEFS += VBOX_WITH_SUID_WRAPPER
     534 endif
    529535endif
    530536
  • trunk/src/VBox/Devices/Storage/DrvHostBase.cpp

    r5215 r5703  
    948948static int drvHostBaseOpen(PDRVHOSTBASE pThis, PRTFILE pFileBlockDevice, PRTFILE pFileRawDevice, bool fReadOnly)
    949949{
    950     unsigned fFlags = (pThis->fReadOnlyConfig ? RTFILE_O_READ : RTFILE_O_READWRITE) | RTFILE_O_NON_BLOCK;
     950    unsigned fFlags = (fReadOnly ? RTFILE_O_READ : RTFILE_O_READWRITE) | RTFILE_O_NON_BLOCK;
    951951    int rc = RTFileOpen(pFileBlockDevice, pThis->pszDeviceOpen, fFlags);
    952952    if (RT_SUCCESS(rc))
     
    954954        rc = RTFileOpen(pFileRawDevice, pThis->pszRawDeviceOpen, fFlags);
    955955        if (RT_FAILURE(rc))
     956        {
     957            LogRel(("DVD: failed to open device %s\n", pThis->pszRawDeviceOpen));
    956958            RTFileClose(*pFileBlockDevice);
    957     }
     959        }
     960    }
     961    else
     962        LogRel(("DVD: failed to open device %s\n", pThis->pszRawDeviceOpen));
    958963    return rc;
    959964}
  • trunk/src/VBox/Devices/Storage/DrvHostDVD.cpp

    r5212 r5703  
    5858# include <pwd.h>
    5959# include <unistd.h>
    60 # include <auth_attr.h>
     60# include <syslog.h>
     61# ifdef VBOX_WITH_SUID_WRAPPER
     62#  include <auth_attr.h>
     63# endif
    6164# include <sys/dkio.h>
    6265# include <sys/sockio.h>
     
    8992
    9093static DECLCALLBACK(int) drvHostDvdDoLock(PDRVHOSTBASE pThis, bool fLock);
     94#ifdef VBOX_WITH_SUID_WRAPPER
     95static int solarisCheckUserAuth();
     96static int solarisEnterRootMode(uid_t *pEffUserID);
     97static int solarisExitRootMode(uid_t *pEffUserID);
     98#endif
    9199
    92100
     
    508516
    509517    /* We need root privileges for user-SCSI under Solaris. */
     518#ifdef VBOX_WITH_SUID_WRAPPER
     519    uid_t effUserID = geteuid();
     520    solarisEnterRootMode(&effUserID); /** @todo check return code when this really works. */
     521#endif
    510522    rc = ioctl(pThis->FileRawDevice, USCSICMD, &usc);
     523#ifdef VBOX_WITH_SUID_WRAPPER
     524    solarisExitRootMode(&effUserID);
     525#endif
    511526    if (rc < 0)
    512527    {
     
    589604}
    590605
    591 #if 0
     606#ifdef VBOX_WITH_SUID_WRAPPER
    592607/* These functions would have to go into a seperate solaris binary with
    593608 * the setuid permission set, which would run the user-SCSI ioctl and
     
    616631 *
    617632 * @returns VBox error code.
    618  * @param   pUserID        Pointer to user ID.
    619633 * @param   pEffUserID     Pointer to effective user ID.
    620634 */
    621 static int solarisEnterRootMode(uid_t *pUserID, uid_t *pEffUserID)
     635static int solarisEnterRootMode(uid_t *pEffUserID)
    622636{
    623637    /* Increase privilege if required */
    624     if (*pEffUserID == 0)
    625         return VINF_SUCCESS;
    626     else
     638    if (*pEffUserID != 0)
    627639    {
    628640        if (seteuid(0) == 0)
     
    631643            return VINF_SUCCESS;
    632644        }
    633         else
    634             return VERR_PERMISSION_DENIED;
    635     }
     645        return VERR_PERMISSION_DENIED;
     646    }
     647    return VINF_SUCCESS;
    636648}
    637649
     
    640652 *
    641653 * @returns VBox error code.
    642  * @param   pUserID        Pointer to user ID.
    643654 * @param   pEffUserID     Pointer to effective user ID.
    644655 */
    645 static int solarisExitRootMode(uid_t *pUserID, uid_t *pEffUserID)
     656static int solarisExitRootMode(uid_t *pEffUserID)
    646657{
    647658    /* Get back to user mode. */
    648659    if (*pEffUserID == 0)
    649660    {
    650         if (seteuid(*pUserID) == 0)
     661        uid_t realID = getuid();
     662        if (seteuid(realID) == 0)
    651663        {
    652             *pEffUserID = *pUserID;
    653             return VINF_SUCCESS;
    654         }
    655         else
    656             return VERR_PERMISSION_DENIED;
    657     }
    658     return VINF_SUCCESS;
    659 }
    660 
    661 /**
    662  * Setuid wrapper to gain root access.
    663  *
    664  * @returns VBox error code.
    665  * @param   pUserID        Pointer to user ID.
    666  * @param   pEffUserID     Pointer to effective user ID.
    667  */
    668 static int solarisEnterRootMode(uid_t *pUserID, uid_t *pEffUserID)
    669 {
    670     /* Increase privilege if required */
    671     if (*pEffUserID == 0)
    672         return VINF_SUCCESS;
    673     if (seteuid(0) == 0)
    674     {
    675         *pEffUserID = 0;
    676         return VINF_SUCCESS;
    677     }
    678     return VERR_PERMISSION_DENIED;
    679 }
    680 
    681 /**
    682  * Setuid wrapper to relinquish root access.
    683  *
    684  * @returns VBox error code.
    685  * @param   pUserID        Pointer to user ID.
    686  * @param   pEffUserID     Pointer to effective user ID.
    687  */
    688 static int solarisExitRootMode(uid_t *pUserID, uid_t *pEffUserID)
    689 {
    690     /* Get back to user mode. */
    691     if (*pEffUserID == 0)
    692     {
    693         if (seteuid(*pUserID) == 0)
    694         {
    695             *pEffUserID = *pUserID;
     664            *pEffUserID = realID;
    696665            return VINF_SUCCESS;
    697666        }
     
    746715            /* Passthrough requires opening the device in R/W mode. */
    747716            pThis->fReadOnlyConfig = false;
     717# ifdef VBOX_WITH_SUID_WRAPPER  /* Solaris setuid for Passthrough mode. */
     718            rc = solarisCheckUserAuth();
     719            if (VBOX_FAILURE(rc))
     720            {
     721                Log(("DVD: solarisCheckUserAuth failed. Permission denied!\n"));
     722                return rc;
     723            }
     724# endif /* VBOX_WITH_SUID_WRAPPER */
    748725        }
    749726#endif /* !RT_OS_L4 */
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