1.1 --- a/core/systems/HandleSys.cpp Thu Feb 22 02:20:15 2007 +0000
1.2 +++ b/core/systems/HandleSys.cpp Mon Feb 26 02:47:03 2007 +0000
1.3 @@ -283,6 +283,7 @@
1.4 pHandle->serial = m_HSerial;
1.5 pHandle->owner = owner;
1.6 pHandle->ch_next = 0;
1.7 + pHandle->access_special = false;
1.8
1.9 /* Create the hash value */
1.10 Handle_t hash = pHandle->serial;
1.11 @@ -336,8 +337,25 @@
1.12 m_Types[type].typeSec.ident = pToken;
1.13 }
1.14
1.15 -Handle_t HandleSystem::CreateHandleEx(HandleType_t type, void *object, IdentityToken_t *owner, IdentityToken_t *ident, HandleError *err, bool identity)
1.16 +Handle_t HandleSystem::CreateHandleInt(HandleType_t type,
1.17 + void *object,
1.18 + const HandleSecurity *pSec,
1.19 + HandleError *err,
1.20 + const HandleAccess *pAccess,
1.21 + bool identity)
1.22 {
1.23 + IdentityToken_t *ident;
1.24 + IdentityToken_t *owner;
1.25 +
1.26 + if (pSec)
1.27 + {
1.28 + ident = pSec->pIdentity;
1.29 + owner = pSec->pOwner;
1.30 + } else {
1.31 + ident = NULL;
1.32 + owner = NULL;
1.33 + }
1.34 +
1.35 if (!type
1.36 || type >= HANDLESYS_TYPEARRAY_SIZE
1.37 || m_Types[type].dispatch == NULL)
1.38 @@ -376,15 +394,31 @@
1.39 return 0;
1.40 }
1.41
1.42 + if (pAccess)
1.43 + {
1.44 + pHandle->access_special = true;
1.45 + pHandle->sec = *pAccess;
1.46 + }
1.47 +
1.48 pHandle->object = object;
1.49 pHandle->clone = 0;
1.50
1.51 return handle;
1.52 }
1.53
1.54 +Handle_t HandleSystem::CreateHandleEx(HandleType_t type, void *object, const HandleSecurity *pSec, const HandleAccess *pAccess, HandleError *err)
1.55 +{
1.56 + return CreateHandleInt(type, object, pSec, err, pAccess, false);
1.57 +}
1.58 +
1.59 Handle_t HandleSystem::CreateHandle(HandleType_t type, void *object, IdentityToken_t *owner, IdentityToken_t *ident, HandleError *err)
1.60 {
1.61 - return CreateHandleEx(type, object, owner, ident, err, false);
1.62 + HandleSecurity sec;
1.63 +
1.64 + sec.pIdentity = ident;
1.65 + sec.pOwner = owner;
1.66 +
1.67 + return CreateHandleEx(type, object, &sec, NULL, err);
1.68 }
1.69
1.70 bool HandleSystem::TypeCheck(HandleType_t intype, HandleType_t outtype)
1.71 @@ -447,7 +481,14 @@
1.72 bool HandleSystem::CheckAccess(QHandle *pHandle, HandleAccessRight right, const HandleSecurity *pSecurity)
1.73 {
1.74 QHandleType *pType = &m_Types[pHandle->type];
1.75 - unsigned int access = pType->hndlSec.access[right];
1.76 + unsigned int access;
1.77 +
1.78 + if (pHandle->access_special)
1.79 + {
1.80 + access = pHandle->sec.access[right];
1.81 + } else {
1.82 + access = pType->hndlSec.access[right];
1.83 + }
1.84
1.85 /* Check if the type's identity matches */
1.86 if (access & HANDLE_RESTRICT_IDENTITY)
1.87 @@ -487,6 +528,13 @@
1.88 return err;
1.89 }
1.90
1.91 + /* Assign permissions from parent */
1.92 + if (pHandle->access_special)
1.93 + {
1.94 + pNewHandle->access_special = true;
1.95 + pNewHandle->sec = pHandle->sec;
1.96 + }
1.97 +
1.98 pNewHandle->clone = index;
1.99 pHandle->refcount++;
1.100