VirtualBox

Changeset 1599

Show
Ignore:
Timestamp:
03/21/07 16:25:35 (2 years ago)
Author:
vboxsync
Message:

added RestrictAccess? key to allow to disable the policy that only VMs of the same user may attach to an internal network

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/VBox/intnet.h

    r1 r1599  
    215215    /** The size of the receive buffer. (input) */ 
    216216    uint32_t        cbRecv; 
     217    /** check access? */ 
     218    bool            fRestrictAccess; 
    217219    /** The handle to the network interface. (output) */ 
    218220    INTNETIFHANDLE  hIf; 
     
    325327 * @param   pIntNet     The 
    326328 */ 
    327 INTNETR0DECL(int) INTNETR0Open(PINTNET pIntNet, PSUPDRVSESSION pSession, const char *pszNetwork, unsigned cbSend, unsigned cbRecv, PINTNETIFHANDLE phIf); 
     329INTNETR0DECL(int) INTNETR0Open(PINTNET pIntNet, PSUPDRVSESSION pSession, const char *pszNetwork, unsigned cbSend, unsigned cbRecv, bool fRestrictAccess, PINTNETIFHANDLE phIf); 
    328330 
    329331/** 
  • trunk/src/VBox/Devices/Network/DrvIntNet.cpp

    r1005 r1599  
    618618     * Validate the config. 
    619619     */ 
    620     if (!CFGMR3AreValuesValid(pCfgHandle, "Network\0ReceiveBufferSize\0SendBufferSize\0")) 
     620    if (!CFGMR3AreValuesValid(pCfgHandle, "Network\0ReceiveBufferSize\0SendBufferSize\0RestrictAccess\0")) 
    621621        return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES; 
    622622 
     
    648648    rc = CFGMR3QueryString(pCfgHandle, "Network", OpenArgs.szNetwork, sizeof(OpenArgs.szNetwork)); 
    649649    if (VBOX_FAILURE(rc)) 
    650     { 
    651         AssertMsgFailed(("Configuration error: query for \"Network\" string return %Vra.\n", rc)); 
    652         return rc; 
    653     } 
     650        return PDMDRV_SET_ERROR(pDrvIns, rc, 
     651                                N_("Configuration error: Failed to get the \"Network\" value")); 
    654652    strcpy(pThis->szNetwork, OpenArgs.szNetwork); 
    655653 
     
    658656        OpenArgs.cbRecv = _256K; 
    659657    else if (VBOX_FAILURE(rc)) 
    660     { 
    661         AssertMsgFailed(("Configuration error: query for \"ReceiveBufferSize\" uint32_t return %Vra.\n", rc)); 
    662         return rc; 
    663     } 
     658        return PDMDRV_SET_ERROR(pDrvIns, rc, 
     659                                N_("Configuration error: Failed to get the \"ReceiveBufferSize\" value")); 
    664660 
    665661    rc = CFGMR3QueryU32(pCfgHandle, "SendBufferSize", &OpenArgs.cbSend); 
     
    667663        OpenArgs.cbSend = _4K; 
    668664    else if (VBOX_FAILURE(rc)) 
    669     { 
    670         AssertMsgFailed(("Configuration error: query for \"SendBufferSize\" uint32_t return %Vra.\n", rc)); 
    671         return rc; 
    672     } 
     665        return PDMDRV_SET_ERROR(pDrvIns, rc, 
     666                                N_("Configuration error: Failed to get the \"SendBufferSize\" value")); 
     667 
     668    rc = CFGMR3QueryBool(pCfgHandle, "RestrictAccess", &OpenArgs.fRestrictAccess); 
     669    if (rc == VERR_CFGM_VALUE_NOT_FOUND) 
     670        OpenArgs.fRestrictAccess = true; 
     671    else if (VBOX_FAILURE(rc)) 
     672        return PDMDRV_SET_ERROR(pDrvIns, rc, 
     673                                N_("Configuration error: Failed to get the \"RestrictAccess\" value")); 
    673674 
    674675    /* 
     
    688689    rc = pDrvIns->pDrvHlp->pfnSUPCallVMMR0Ex(pDrvIns, VMMR0_DO_INTNET_OPEN, &OpenArgs, sizeof(OpenArgs)); 
    689690    if (VBOX_FAILURE(rc)) 
    690     { 
    691         AssertMsgFailed(("Failed to open/create the network '%s', cbRecv=%RU32, cbSend=%RU32. rc=%Vrc\n", 
    692                          pThis->szNetwork, OpenArgs.cbRecv, OpenArgs.cbSend, rc)); 
    693         return rc; 
    694     } 
     691        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, 
     692                                   N_("Failed to open/create the internal network '%s'"), pThis->szNetwork); 
    695693    AssertRelease(OpenArgs.hIf != INTNET_HANDLE_INVALID); 
    696694    pThis->hIf = OpenArgs.hIf; 
     
    705703    rc = pDrvIns->pDrvHlp->pfnSUPCallVMMR0Ex(pDrvIns, VMMR0_DO_INTNET_IF_GET_RING3_BUFFER, &GetRing3BufferArgs, sizeof(GetRing3BufferArgs)); 
    706704    if (VBOX_FAILURE(rc)) 
    707     { 
    708         AssertMsgFailed(("Failed to get ring-3 buffer for the newly created interface to '%s'. rc=%Vrc\n", 
    709                          pThis->szNetwork, rc)); 
    710         return rc; 
    711     } 
     705        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, 
     706                                  N_("Failed to get ring-3 buffer for the newly created interface to '%s'"), pThis->szNetwork); 
    712707    AssertRelease(VALID_PTR(GetRing3BufferArgs.pRing3Buf)); 
    713708    pThis->pBuf = GetRing3BufferArgs.pRing3Buf; 
  • trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp

    r1482 r1599  
    103103    /** The SUPR0 object id. */ 
    104104    void                   *pvObj; 
     105    /**  Access restricted? */ 
     106    bool                    fRestrictAccess; 
    105107    /** The length of the network name. */ 
    106108    uint8_t                 cchName; 
     
    12011203static int INTNETOpenNetwork(PINTNET pIntNet, PSUPDRVSESSION pSession, const char *pszNetwork, PINTNETNETWORK *ppNetwork) 
    12021204{ 
    1203     LogFlow(("INTNETCreateNetwork: pIntNet=%p pSession=%p pszNetwork=%p:{%s} ppNetwork=%p\n", 
     1205    LogFlow(("INTNETOpenNetwork: pIntNet=%p pSession=%p pszNetwork=%p:{%s} ppNetwork=%p\n", 
    12041206             pIntNet, pSession, pszNetwork, pszNetwork, ppNetwork)); 
    12051207 
     
    12341236            if (VBOX_SUCCESS(rc)) 
    12351237            { 
    1236                 rc = SUPR0ObjVerifyAccess(pCur->pvObj, pSession, pCur->szName); 
     1238                if (pCur->fRestrictAccess) 
     1239                    rc = SUPR0ObjVerifyAccess(pCur->pvObj, pSession, pCur->szName); 
    12371240                if (VBOX_SUCCESS(rc)) 
    12381241                    *ppNetwork = pCur; 
     
    12691272 * @param   ppNetwork   Where to store the network. 
    12701273 */ 
    1271 static int INTNETCreateNetwork(PINTNET pIntNet, PSUPDRVSESSION pSession, const char *pszNetwork, PINTNETNETWORK *ppNetwork) 
     1274static int INTNETCreateNetwork(PINTNET pIntNet, PSUPDRVSESSION pSession, const char *pszNetwork, bool fRestrictAccess, PINTNETNETWORK *ppNetwork) 
    12721275{ 
    12731276    LogFlow(("INTNETCreateNetwork: pIntNet=%p pSession=%p pszNetwork=%p:{%s} ppNetwork=%p\n", 
     
    13081311        pNew->pIntNet = pIntNet; 
    13091312        pNew->cchName = cchName; 
     1313        pNew->fRestrictAccess = fRestrictAccess; 
    13101314        Assert(cchName && cchName < sizeof(pNew->szName));  /* caller's responsibility. */ 
    13111315        memcpy(pNew->szName, pszNetwork, cchName);          /* '\0' by alloc. */ 
     
    13661370 * @param   phIf        Where to store the handle to the network interface. 
    13671371 */ 
    1368 INTNETR0DECL(int) INTNETR0Open(PINTNET pIntNet, PSUPDRVSESSION pSession, const char *pszNetwork, unsigned cbSend, unsigned cbRecv, PINTNETIFHANDLE phIf) 
     1372INTNETR0DECL(int) INTNETR0Open(PINTNET pIntNet, PSUPDRVSESSION pSession, const char *pszNetwork, unsigned cbSend, unsigned cbRecv, bool fRestrictAccess, PINTNETIFHANDLE phIf) 
    13691373{ 
    13701374    LogFlow(("INTNETR0Open: pIntNet=%p pSession=%p pszNetwork=%p:{%s} cbSend=%u cbRecv=%u phIf=%p\n", 
     
    13951399    rc = INTNETOpenNetwork(pIntNet, pSession, pszNetwork, &pNetwork); 
    13961400    if (rc == VERR_FILE_NOT_FOUND) 
    1397         rc = INTNETCreateNetwork(pIntNet, pSession, pszNetwork, &pNetwork); 
     1401        rc = INTNETCreateNetwork(pIntNet, pSession, pszNetwork, fRestrictAccess, &pNetwork); 
    13981402    if (VBOX_SUCCESS(rc)) 
    13991403    { 
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r1348 r1599  
    614614                { 
    615615                    PINTNETOPENARGS pArgs = (PINTNETOPENARGS)pvArg; 
    616                     return INTNETR0Open(g_pIntNet, pVM->pSession, &pArgs->szNetwork[0], pArgs->cbSend, pArgs->cbRecv, &pArgs->hIf); 
     616                    return INTNETR0Open(g_pIntNet, pVM->pSession, &pArgs->szNetwork[0], pArgs->cbSend, pArgs->cbRecv, pArgs->fRestrictAccess, &pArgs->hIf); 
    617617                } 
    618618 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy