Blame SOURCES/0030-python-semanage-Add-support-for-DCCP-and-SCTP-protoc.patch

9bbebd
From 7cbfcec89a6972f9c700687ed3cef25ff0846461 Mon Sep 17 00:00:00 2001
9bbebd
From: Vit Mojzis <vmojzis@redhat.com>
9bbebd
Date: Tue, 8 Oct 2019 14:22:13 +0200
9bbebd
Subject: [PATCH] python/semanage: Add support for DCCP and SCTP protocols
9bbebd
9bbebd
Fixes:
9bbebd
   # semanage port -a -p sctp -t port_t 1234
9bbebd
   ValueError: Protocol udp or tcp is required
9bbebd
   # semanage port -d -p sctp -t port_t 1234
9bbebd
   ValueError: Protocol udp or tcp is required
9bbebd
9bbebd
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
9bbebd
---
9bbebd
 python/semanage/seobject.py | 14 ++++++++------
9bbebd
 1 file changed, 8 insertions(+), 6 deletions(-)
9bbebd
9bbebd
diff --git a/python/semanage/seobject.py b/python/semanage/seobject.py
9bbebd
index 16edacaa..70ebfd08 100644
9bbebd
--- a/python/semanage/seobject.py
9bbebd
+++ b/python/semanage/seobject.py
9bbebd
@@ -1058,13 +1058,15 @@ class portRecords(semanageRecords):
9bbebd
             pass
9bbebd
 
9bbebd
     def __genkey(self, port, proto):
9bbebd
-        if proto == "tcp":
9bbebd
-            proto_d = SEMANAGE_PROTO_TCP
9bbebd
+        protocols = {"tcp": SEMANAGE_PROTO_TCP,
9bbebd
+                     "udp": SEMANAGE_PROTO_UDP,
9bbebd
+                     "sctp": SEMANAGE_PROTO_SCTP,
9bbebd
+                     "dccp": SEMANAGE_PROTO_DCCP}
9bbebd
+
9bbebd
+        if proto in protocols.keys():
9bbebd
+            proto_d = protocols[proto]
9bbebd
         else:
9bbebd
-            if proto == "udp":
9bbebd
-                proto_d = SEMANAGE_PROTO_UDP
9bbebd
-            else:
9bbebd
-                raise ValueError(_("Protocol udp or tcp is required"))
9bbebd
+            raise ValueError(_("Protocol has to be one of udp, tcp, dccp or sctp"))
9bbebd
         if port == "":
9bbebd
             raise ValueError(_("Port is required"))
9bbebd
 
9bbebd
-- 
9bbebd
2.21.0
9bbebd