From ec49029999bf324e293bbcafebc13e4ef3c25808 Mon Sep 17 00:00:00 2001 From: cbh34680 Date: Wed, 21 Feb 2024 13:47:45 +0900 Subject: [PATCH] Initialized _pol I get an exception when I run the following > python3 -c 'import sepolicy; sepolicy.get_init_entrypoints_str()' AttributeError: 'NoneType' object has no attribute 'lookup_class' > python3 -c 'import sepolicy; sepolicy.get_all_role_allows()' AttributeError: 'NoneType' object has no attribute 'rbacrules' > python3 -c 'import sepolicy; sepolicy.get_all_bool_rules()' python3 -c 'import sepolicy; sepolicy.get_all_bool_rules()' Signed-off-by: cbh34680 --- python/sepolicy/sepolicy/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/python/sepolicy/sepolicy/__init__.py b/python/sepolicy/sepolicy/__init__.py index 2d526c94a0..0013be6a39 100644 --- a/python/sepolicy/sepolicy/__init__.py +++ b/python/sepolicy/sepolicy/__init__.py @@ -771,6 +771,10 @@ def get_init_entrypoint(transtype): return entrypoints def get_init_entrypoints_str(): + global _pol + if not _pol: + init_policy() + q = TERuleQuery(_pol, ruletype=["type_transition"], source="init_t", @@ -849,6 +853,10 @@ def get_user_types(): def get_all_role_allows(): + global _pol + if not _pol: + init_policy() + global role_allows if role_allows: return role_allows @@ -1138,6 +1146,10 @@ def get_all_allow_rules(): return all_allow_rules def get_all_bool_rules(): + global _pol + if not _pol: + init_policy() + global all_bool_rules if not all_bool_rules: q = TERuleQuery(_pol, boolean=".*", boolean_regex=True,