mirror of
https://github.com/SELinuxProject/setools
synced 2025-03-29 23:06:19 +00:00
User: Cache users.
This commit is contained in:
parent
8156e809b8
commit
40b9f2473e
@ -18,6 +18,9 @@
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
cdef dict _user_cache = {}
|
||||
|
||||
|
||||
cdef class User(PolicySymbol):
|
||||
|
||||
"""A user."""
|
||||
@ -32,7 +35,12 @@ cdef class User(PolicySymbol):
|
||||
@staticmethod
|
||||
cdef inline User factory(SELinuxPolicy policy, sepol.user_datum_t *symbol):
|
||||
"""Factory function for constructing User objects."""
|
||||
cdef User u = User.__new__(User)
|
||||
cdef User u
|
||||
try:
|
||||
return _user_cache[<uintptr_t>symbol]
|
||||
except KeyError:
|
||||
u = User.__new__(User)
|
||||
_user_cache[<uintptr_t>symbol] = u
|
||||
u.policy = policy
|
||||
u.key = <uintptr_t>symbol
|
||||
u.name = policy.user_value_to_name(symbol.s.value - 1)
|
||||
|
Loading…
Reference in New Issue
Block a user