From ac90929618c0054e732474adbb91e8df1ca6b2a8 Mon Sep 17 00:00:00 2001 From: Topi Miettinen Date: Sun, 28 May 2023 21:56:27 +0300 Subject: [PATCH] semanage: list all ports even if not attributed with port_type Show also ports which are not attributed with `port_type`. Such ports may exist in custom policies and even the attribute `port_type` may not be defined. This fixes the following error: Traceback (most recent call last): File "/usr/sbin/semanage", line 975, in do_parser() File "/usr/sbin/semanage", line 947, in do_parser args.func(args) File "/usr/sbin/semanage", line 441, in handlePort OBJECT = object_dict['port'](args) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/seobject.py", line 1057, in __init__ self.valid_types = list(list(sepolicy.info(sepolicy.ATTRIBUTE, "port_type"))[0]["types"]) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^ IndexError: list index out of range Signed-off-by: Topi Miettinen --- python/semanage/seobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/semanage/seobject.py b/python/semanage/seobject.py index d82da49429..72a2ec55c8 100644 --- a/python/semanage/seobject.py +++ b/python/semanage/seobject.py @@ -1055,7 +1055,7 @@ class portRecords(semanageRecords): def __init__(self, args = None): semanageRecords.__init__(self, args) try: - self.valid_types = list(list(sepolicy.info(sepolicy.ATTRIBUTE, "port_type"))[0]["types"]) + self.valid_types = list(list(sepolicy.info(sepolicy.PORT))[0]["type"]) except RuntimeError: pass