Blame SOURCES/0011-sepolicy-Another-small-optimization-for-mcs-types.patch

0cec52
From e54db76a3bff8e911ddd7c7ce834c024d634d9e1 Mon Sep 17 00:00:00 2001
0cec52
From: Petr Lautrbach <plautrba@redhat.com>
0cec52
Date: Tue, 28 Feb 2017 21:29:46 +0100
0cec52
Subject: [PATCH 11/20] sepolicy: Another small optimization for mcs types
0cec52
0cec52
---
0cec52
 python/sepolicy/sepolicy/manpage.py | 16 +++++++++++-----
0cec52
 1 file changed, 11 insertions(+), 5 deletions(-)
0cec52
0cec52
diff --git a/python/sepolicy/sepolicy/manpage.py b/python/sepolicy/sepolicy/manpage.py
0cec52
index f8a94fc0..67d39301 100755
0cec52
--- a/python/sepolicy/sepolicy/manpage.py
0cec52
+++ b/python/sepolicy/sepolicy/manpage.py
0cec52
@@ -142,6 +142,15 @@ def _gen_entry_types():
0cec52
         entry_types = next(sepolicy.info(sepolicy.ATTRIBUTE, "entry_type"))["types"]
0cec52
     return entry_types
0cec52
 
0cec52
+mcs_constrained_types = None
0cec52
+
0cec52
+def _gen_mcs_constrained_types():
0cec52
+    global mcs_constrained_types
0cec52
+    if mcs_constrained_types is None:
0cec52
+        mcs_constrained_types = next(sepolicy.info(sepolicy.ATTRIBUTE, "mcs_constrained_type"))
0cec52
+    return mcs_constrained_types
0cec52
+
0cec52
+
0cec52
 types = None
0cec52
 
0cec52
 def _gen_types():
0cec52
@@ -390,6 +399,7 @@ class ManPage:
0cec52
         self.types = _gen_types()
0cec52
         self.exec_types = _gen_exec_types()
0cec52
         self.entry_types = _gen_entry_types()
0cec52
+        self.mcs_constrained_types = _gen_mcs_constrained_types()
0cec52
 
0cec52
         if self.source_files:
0cec52
             self.fcpath = self.root + "file_contexts"
0cec52
@@ -944,11 +954,7 @@ All executeables with the default executable label, usually stored in /usr/bin a
0cec52
 %s""" % ", ".join(paths))
0cec52
 
0cec52
     def _mcs_types(self):
0cec52
-        try:
0cec52
-            mcs_constrained_type = next(sepolicy.info(sepolicy.ATTRIBUTE, "mcs_constrained_type"))
0cec52
-        except StopIteration:
0cec52
-            return
0cec52
-        if self.type not in mcs_constrained_type['types']:
0cec52
+        if self.type not in self.mcs_constrained_types['types']:
0cec52
             return
0cec52
         self.fd.write ("""
0cec52
 .SH "MCS Constrained"
0cec52
-- 
0cec52
2.21.0
0cec52