Skip to content

Commit

Permalink
semanage: list all ports even if not attributed with port_type
Browse files Browse the repository at this point in the history
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 <module>
    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 <[email protected]>
  • Loading branch information
topimiettinen committed May 28, 2023
1 parent 820f019 commit ac90929
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/semanage/seobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ac90929

Please sign in to comment.