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

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