Blame SOURCES/0010-sepolicy-Drop-old-interface-file_type_is_executable-.patch

0cec52
From ef0f54ffc6d691d10e66a0793204edd159cd45d0 Mon Sep 17 00:00:00 2001
0cec52
From: Petr Lautrbach <plautrba@redhat.com>
0cec52
Date: Mon, 27 Feb 2017 17:12:39 +0100
0cec52
Subject: [PATCH 10/20] sepolicy: Drop old interface file_type_is_executable(f)
0cec52
 and file_type_is_entrypoint(f)
0cec52
0cec52
- use direct queries
0cec52
- load exec_types and entry_types only once
0cec52
---
0cec52
 python/sepolicy/sepolicy/manpage.py | 22 ++++++++++++++++++++--
0cec52
 1 file changed, 20 insertions(+), 2 deletions(-)
0cec52
0cec52
diff --git a/python/sepolicy/sepolicy/manpage.py b/python/sepolicy/sepolicy/manpage.py
0cec52
index de8184d8..f8a94fc0 100755
0cec52
--- a/python/sepolicy/sepolicy/manpage.py
0cec52
+++ b/python/sepolicy/sepolicy/manpage.py
0cec52
@@ -125,8 +125,24 @@ def gen_domains():
0cec52
     domains.sort()
0cec52
     return domains
0cec52
 
0cec52
-types = None
0cec52
 
0cec52
+exec_types = None
0cec52
+
0cec52
+def _gen_exec_types():
0cec52
+    global exec_types
0cec52
+    if exec_types is None:
0cec52
+        exec_types = next(sepolicy.info(sepolicy.ATTRIBUTE, "exec_type"))["types"]
0cec52
+    return exec_types
0cec52
+
0cec52
+entry_types = None
0cec52
+
0cec52
+def _gen_entry_types():
0cec52
+    global entry_types
0cec52
+    if entry_types is None:
0cec52
+        entry_types = next(sepolicy.info(sepolicy.ATTRIBUTE, "entry_type"))["types"]
0cec52
+    return entry_types
0cec52
+
0cec52
+types = None
0cec52
 
0cec52
 def _gen_types():
0cec52
     global types
0cec52
@@ -372,6 +388,8 @@ class ManPage:
0cec52
         self.all_file_types = sepolicy.get_all_file_types()
0cec52
         self.role_allows = sepolicy.get_all_role_allows()
0cec52
         self.types = _gen_types()
0cec52
+        self.exec_types = _gen_exec_types()
0cec52
+        self.entry_types = _gen_entry_types()
0cec52
 
0cec52
         if self.source_files:
0cec52
             self.fcpath = self.root + "file_contexts"
0cec52
@@ -689,7 +707,7 @@ Default Defined Ports:""")
0cec52
         for f in self.all_file_types:
0cec52
             if f.startswith(self.domainname):
0cec52
                 flist.append(f)
0cec52
-                if not file_type_is_executable(f) or not file_type_is_entrypoint(f):
0cec52
+                if not f in self.exec_types or not f in self.entry_types:
0cec52
                     flist_non_exec.append(f)
0cec52
                 if f in self.fcdict:
0cec52
                     mpaths = mpaths + self.fcdict[f]["regex"]
0cec52
-- 
0cec52
2.21.0
0cec52