* 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. */
| 294 | * object class. If not found, create a new cache entry. |
| 295 | */ |
| 296 | static avc_cache * |
| 297 | sepgsql_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) |
no test coverage detected