From 9f8e5394199575634f6e8a68d5c1ed8c039d3268 Mon Sep 17 00:00:00 2001 From: Nicolas Iooss Date: Sat, 5 Aug 2017 18:37:49 +0200 Subject: [PATCH] sepolicy: support non-MCS policy in manpage This prevents the following exception to occur when using "sepolicy manpage": Traceback (most recent call last): File "/bin/sepolicy", line 699, in 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 --- 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 494c3431..35b3722d 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 ("""