Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

semanage: list all ports even if not attributed with port_type #394

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Jul 2, 2023

  1. semanage, sepolicy: list also ports not attributed with port_type

    For `semanage port -l` and `sepolicy network -t 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 with `semanage port -l` (and similar
    error with `sepolicy network -t type`):
    
    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]>
    
    ---
    v5: fix from Petr Lautrbach
    v4: keep types found with attribute port_type for compatibility with types
        which are not portcons
    v3: use even better version, thanks to Petr Lautrbach
    v2: fix other cases and use better version courtesy of Petr Lautrbach
    topimiettinen committed Jul 2, 2023
    Configuration menu
    Copy the full SHA
    9bc150a View commit details
    Browse the repository at this point in the history