MCPcopy Create free account
hub / github.com/apache/cloudberry / sepgsql_avc_lookup

Function sepgsql_avc_lookup

contrib/sepgsql/uavc.c:296–322  ·  view source on GitHub ↗

* sepgsql_avc_lookup * * Look up a cache entry that matches the supplied security contexts and * object class. If not found, create a new cache entry. */

Source from the content-addressed store, hash-verified

294 * object class. If not found, create a new cache entry.
295 */
296static avc_cache *
297sepgsql_avc_lookup(const char *scontext, const char *tcontext, uint16 tclass)
298{
299 avc_cache *cache;
300 ListCell *cell;
301 uint32 hash;
302 int index;
303
304 hash = sepgsql_avc_hash(scontext, tcontext, tclass);
305 index = hash % AVC_NUM_SLOTS;
306
307 foreach(cell, avc_slots[index])
308 {
309 cache = lfirst(cell);
310
311 if (cache->hash == hash &&
312 cache->tclass == tclass &&
313 strcmp(cache->tcontext, tcontext) == 0 &&
314 strcmp(cache->scontext, scontext) == 0)
315 {
316 cache->hot_cache = true;
317 return cache;
318 }
319 }
320 /* not found, so insert a new cache */
321 return sepgsql_avc_compute(scontext, tcontext, tclass);
322}
323
324/*
325 * sepgsql_avc_check_perms(_label)

Callers 2

sepgsql_avc_trusted_procFunction · 0.85

Calls 3

sepgsql_avc_hashFunction · 0.85
sepgsql_avc_computeFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected