summaryrefslogtreecommitdiff
path: root/dix/resource.c
diff options
context:
space:
mode:
authorEamon Walsh <ewalsh@tycho.nsa.gov>2007-04-04 12:00:15 -0400
committerEamon Walsh <ewalsh@moss-uranus.epoch.ncsc.mil>2007-04-04 16:00:15 -0400
commited75b056511ccb429c48c6c55d14dc7ae79e75a3 (patch)
tree2bce240f5c998b371895bdb4dd94a6e679067f35 /dix/resource.c
parent63e46e4fc3e98751f2edbed9c79ef3d5dc2dadc6 (diff)
dix: add new, combined resource lookup function. Move all dix lookup API
deprecated so far to a new file dix/deprecated.c. Remove the deprecation warnings for the time being.
Diffstat (limited to 'dix/resource.c')
-rw-r--r--dix/resource.c88
1 files changed, 19 insertions, 69 deletions
diff --git a/dix/resource.c b/dix/resource.c
index 81269c3b2..7530e8665 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -899,81 +899,31 @@ LegalNewID(XID id, ClientPtr client)
!LookupIDByClass(id, RC_ANY)));
}
-/* SecurityLookupIDByType and SecurityLookupIDByClass:
- * These are the heart of the resource ID security system. They take
- * two additional arguments compared to the old LookupID functions:
- * the client doing the lookup, and the access mode (see resource.h).
- * The resource is returned if it exists and the client is allowed access,
- * else NULL is returned.
- */
-
-_X_EXPORT pointer
-SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask mode)
-{
- int cid;
- ResourcePtr res;
- pointer retval = NULL;
-
- 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))
- {
- retval = res->value;
- break;
- }
- }
- if (retval && client &&
- !XaceHook(XACE_RESOURCE_ACCESS, client, id, rtype, mode, retval))
- retval = NULL;
-
- return retval;
-}
-
-
-_X_EXPORT pointer
-SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask mode)
+_X_EXPORT int
+dixLookupResource(pointer *result, XID id, RESTYPE rtype,
+ ClientPtr client, Mask mode)
{
- int cid;
+ int cid = CLIENT_ID(id);
+ int istype = (rtype & TypeMask) && (rtype != RC_ANY);
ResourcePtr res = NULL;
- pointer retval = NULL;
- if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
- clientTable[cid].buckets)
- {
+ *result = NULL;
+ client->errorValue = id;
+
+ if ((cid < MAXCLIENTS) && clientTable[cid].buckets) {
res = clientTable[cid].resources[Hash(cid, id)];
for (; res; res = res->next)
- if ((res->id == id) && (res->type & classes))
- {
- retval = res->value;
+ if ((res->id == id) && ((istype && res->type == rtype) ||
+ (!istype && res->type & rtype)))
break;
- }
}
- if (retval && client &&
- !XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type, mode, retval))
- retval = NULL;
-
- return retval;
-}
-
-/* We can't replace the LookupIDByType and LookupIDByClass functions with
- * macros because of compatibility with loadable servers.
- */
-
-_X_EXPORT pointer
-LookupIDByType(XID id, RESTYPE rtype)
-{
- return SecurityLookupIDByType(NullClient, id, rtype,
- DixUnknownAccess);
-}
-
-_X_EXPORT pointer
-LookupIDByClass(XID id, RESTYPE classes)
-{
- return SecurityLookupIDByClass(NullClient, id, classes,
- DixUnknownAccess);
+ if (res) {
+ if (client && !XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type,
+ mode, res->value))
+ return BadAccess;
+ *result = res->value;
+ return Success;
+ }
+ return BadValue;
}