in class policy, ports is usually initialized with the result of
get_all_ports(), which is a dict. If this function failed, the error was
not fatal but ports was left initialized as a list, which would trigger
other errors when accessing it.

Initialize ports as an empty dict in order to fix this issue.

Signed-off-by: Nicolas Iooss <nicolas.io...@m4x.org>
---
 python/sepolicy/sepolicy/generate.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python/sepolicy/sepolicy/generate.py 
b/python/sepolicy/sepolicy/generate.py
index 35623a01acfe..f885425806f1 100644
--- a/python/sepolicy/sepolicy/generate.py
+++ b/python/sepolicy/sepolicy/generate.py
@@ -198,7 +198,7 @@ class policy:
 
     def __init__(self, name, type):
         self.rpms = []
-        self.ports = []
+        self.ports = {}
         self.all_roles = get_all_roles()
         self.types = []
 
-- 
2.16.0


Reply via email to