From f8dd80d13bb5313a11b38b280f8ad3e22f0a6300 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 6 Aug 2008 15:26:24 -0700 Subject: Replace dixLookupResource by dixLookupResourceBy{Type,Class} dixLookupResource attempted to automatically detect whether the caller wanted a lookup by-type or by-class, unfortunately, it guessed wrong for RT_NONE. Instead of trying to make the guess better, this patch just reverts the unification and creates separate functions for each operation. --- dix/resource.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'dix/resource.c') diff --git a/dix/resource.c b/dix/resource.c index ec1d8cf4c..dc6945dd1 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -844,11 +844,10 @@ LegalNewID(XID id, ClientPtr client) } int -dixLookupResource(pointer *result, XID id, RESTYPE rtype, - ClientPtr client, Mask mode) +dixLookupResourceByType(pointer *result, XID id, RESTYPE rtype, + ClientPtr client, Mask mode) { int cid = CLIENT_ID(id); - int istype = (rtype & TypeMask) && (rtype != RC_ANY); ResourcePtr res = NULL; *result = NULL; @@ -857,8 +856,38 @@ dixLookupResource(pointer *result, XID id, RESTYPE rtype, res = clientTable[cid].resources[Hash(cid, id)]; for (; res; res = res->next) - if ((res->id == id) && ((istype && res->type == rtype) || - (!istype && res->type & rtype))) + if (res->id == id && res->type == rtype) + break; + } + if (!res) + return BadValue; + + if (client) { + client->errorValue = id; + cid = XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type, + res->value, RT_NONE, NULL, mode); + if (cid != Success) + return cid; + } + + *result = res->value; + return Success; +} + +int +dixLookupResourceByClass(pointer *result, XID id, RESTYPE rclass, + ClientPtr client, Mask mode) +{ + int cid = CLIENT_ID(id); + ResourcePtr res = NULL; + + *result = NULL; + + if ((cid < MAXCLIENTS) && clientTable[cid].buckets) { + res = clientTable[cid].resources[Hash(cid, id)]; + + for (; res; res = res->next) + if (res->id == id && (res->type & rclass)) break; } if (!res) -- cgit v1.2.3