From 9138d5a51e411f598bc0e75a3e73d2c16187a518 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 3 Aug 2006 18:24:04 -0400 Subject: [PATCH] Make SecurityLookupIDBy* part of the base functionality. --- dix/resource.c | 61 +++----------------------------------- hw/xfree86/loader/dixsym.c | 2 -- include/resource.h | 11 ------- 3 files changed, 4 insertions(+), 70 deletions(-) diff --git a/dix/resource.c b/dix/resource.c index abe79dee6..669739e45 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -824,8 +824,6 @@ LegalNewID(XID id, register ClientPtr client) !LookupIDByClass(id, RC_ANY))); } -#ifdef XACE - /* SecurityLookupIDByType and SecurityLookupIDByClass: * These are the heart of the resource ID security system. They take * two additional arguments compared to the old LookupID functions: @@ -841,10 +839,6 @@ SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask mode) register ResourcePtr res; pointer retval = NULL; - assert(client == NullClient || - (client->index <= currentMaxClients && clients[client->index] == client)); - assert( (rtype & TypeMask) <= lastResourceType); - if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) { @@ -857,9 +851,11 @@ SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask mode) break; } } +#ifdef XACE if (retval && client && !XaceHook(XACE_RESOURCE_ACCESS, client, id, rtype, mode, retval)) retval = NULL; +#endif return retval; } @@ -871,10 +867,6 @@ SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask mode) register ResourcePtr res = NULL; pointer retval = NULL; - assert(client == NullClient || - (client->index <= currentMaxClients && clients[client->index] == client)); - assert (classes >= lastResourceClass); - if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) { @@ -887,9 +879,11 @@ SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask mode) break; } } +#ifdef XACE if (retval && client && !XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type, mode, retval)) retval = NULL; +#endif return retval; } @@ -910,50 +904,3 @@ LookupIDByClass(XID id, RESTYPE classes) return SecurityLookupIDByClass(NullClient, id, classes, SecurityUnknownAccess); } - -#else /* not XACE */ - -/* - * LookupIDByType returns the object with the given id and type, else NULL. - */ -pointer -LookupIDByType(XID id, RESTYPE rtype) -{ - int cid; - register ResourcePtr res; - - if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && - clientTable[cid].buckets) - { - res = clientTable[cid].resources[Hash(cid, id)]; - - for (; res; res = res->next) - if ((res->id == id) && (res->type == rtype)) - return res->value; - } - return (pointer)NULL; -} - -/* - * LookupIDByClass returns the object with the given id and any one of the - * given classes, else NULL. - */ -pointer -LookupIDByClass(XID id, RESTYPE classes) -{ - int cid; - register ResourcePtr res; - - if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && - clientTable[cid].buckets) - { - res = clientTable[cid].resources[Hash(cid, id)]; - - for (; res; res = res->next) - if ((res->id == id) && (res->type & classes)) - return res->value; - } - return (pointer)NULL; -} - -#endif /* XACE */ diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c index dba2cc4de..d30848a50 100644 --- a/hw/xfree86/loader/dixsym.c +++ b/hw/xfree86/loader/dixsym.c @@ -285,10 +285,8 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(LookupIDByType) SYMFUNC(LookupIDByClass) SYMFUNC(LegalNewID) -#ifdef XACE SYMFUNC(SecurityLookupIDByClass) SYMFUNC(SecurityLookupIDByType) -#endif SYMFUNC(FindClientResourcesByType) SYMFUNC(FindAllClientResources) SYMVAR(lastResourceType) diff --git a/include/resource.h b/include/resource.h index c08998c9f..613b50a72 100644 --- a/include/resource.h +++ b/include/resource.h @@ -227,8 +227,6 @@ extern pointer LookupClientResourceComplex( #define SecurityWriteAccess (1<<1) /* changing the object */ #define SecurityDestroyAccess (1<<2) /* destroying the object */ -#ifdef XACE - extern pointer SecurityLookupIDByType( ClientPtr /*client*/, XID /*id*/, @@ -241,15 +239,6 @@ extern pointer SecurityLookupIDByClass( RESTYPE /*classes*/, Mask /*access_mode*/); -#else /* not XACE */ - -#define SecurityLookupIDByType(client, id, rtype, access_mode) \ - LookupIDByType(id, rtype) - -#define SecurityLookupIDByClass(client, id, classes, access_mode) \ - LookupIDByClass(id, classes) - -#endif /* XACE */ extern void GetXIDRange( int /*client*/,