All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH PR#394] semanage: list all ports even if not attributed with port_type
@ 2023-05-30 17:49 Topi Miettinen
  2023-06-02 12:13 ` Petr Lautrbach
  0 siblings, 1 reply; 2+ messages in thread
From: Topi Miettinen @ 2023-05-30 17:49 UTC (permalink / raw)
  To: selinux; +Cc: Topi Miettinen

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 <toiwoton@gmail.com>
---
 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 d82da494..72a2ec55 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
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-02 12:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-30 17:49 [PATCH PR#394] semanage: list all ports even if not attributed with port_type Topi Miettinen
2023-06-02 12:13 ` Petr Lautrbach

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.