This prevents the following exception to occur when using "sepolicy
manpage":

    Traceback (most recent call last):
      File "/bin/sepolicy", line 699, in <module>
        args.func(args)
      File "/bin/sepolicy", line 359, in manpage
        m = ManPage(domain, path, args.root, args.source_files, args.web)
      File "/usr/lib/python3.6/site-packages/sepolicy/manpage.py", line 459, in 
__init__
        self.__gen_man_page()
      File "/usr/lib/python3.6/site-packages/sepolicy/manpage.py", line 548, in 
__gen_man_page
        self._mcs_types()
      File "/usr/lib/python3.6/site-packages/sepolicy/manpage.py", line 978, in 
_mcs_types
        mcs_constrained_type = next(sepolicy.info(sepolicy.ATTRIBUTE, 
"mcs_constrained_type"))
    StopIteration

Signed-off-by: Nicolas Iooss <nicolas.io...@m4x.org>
---
 python/sepolicy/sepolicy/manpage.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/python/sepolicy/sepolicy/manpage.py 
b/python/sepolicy/sepolicy/manpage.py
index 494c34319c26..35b3722dbe45 100755
--- a/python/sepolicy/sepolicy/manpage.py
+++ b/python/sepolicy/sepolicy/manpage.py
@@ -975,7 +975,10 @@ All executeables with the default executable label, 
usually stored in /usr/bin a
 %s""" % ", ".join(paths))
 
     def _mcs_types(self):
-        mcs_constrained_type = next(sepolicy.info(sepolicy.ATTRIBUTE, 
"mcs_constrained_type"))
+        try:
+            mcs_constrained_type = next(sepolicy.info(sepolicy.ATTRIBUTE, 
"mcs_constrained_type"))
+        except StopIteration:
+            return
         if self.type not in mcs_constrained_type['types']:
             return
         self.fd.write ("""
-- 
2.13.3

Reply via email to