selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] python/semanage: Use ipaddress module instead of IPy
@ 2020-04-24 14:59 Petr Lautrbach
  2020-04-24 19:46 ` Roberts, William C
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Lautrbach @ 2020-04-24 14:59 UTC (permalink / raw)
  To: selinux; +Cc: Petr Lautrbach

ipaddress python module was added to standard library in Python 3.3 -
https://docs.python.org/3/library/ipaddress.html

seobject.py was the only consumer of IPy module so this dependency is not needed
anymore.

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
---
 python/semanage/seobject.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/python/semanage/seobject.py b/python/semanage/seobject.py
index f2a139c970bd..c89c67e491b6 100644
--- a/python/semanage/seobject.py
+++ b/python/semanage/seobject.py
@@ -32,7 +32,7 @@ from semanage import *
 PROGNAME = "policycoreutils"
 import sepolicy
 import setools
-from IPy import IP
+import ipaddress
 
 try:
     import gettext
@@ -1860,13 +1860,13 @@ class nodeRecords(semanageRecords):
 
         # verify valid combination
         if len(mask) == 0 or mask[0] == "/":
-            i = IP(addr + mask)
-            newaddr = i.strNormal(0)
-            newmask = str(i.netmask())
-            if newmask == "0.0.0.0" and i.version() == 6:
+            i = ipaddress.ip_network(addr + mask)
+            newaddr = str(i.network_address)
+            newmask = str(i.netmask)
+            if newmask == "0.0.0.0" and i.version == 6:
                 newmask = "::"
 
-            protocol = "ipv%d" % i.version()
+            protocol = "ipv%d" % i.version
 
         try:
             newprotocol = self.protocol.index(protocol)
-- 
2.26.0


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

end of thread, other threads:[~2020-05-01  7:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24 14:59 [PATCH] python/semanage: Use ipaddress module instead of IPy Petr Lautrbach
2020-04-24 19:46 ` Roberts, William C
2020-04-25  6:52   ` Nicolas Iooss
2020-04-27 15:34     ` [PATCH v2] " Petr Lautrbach
2020-04-28 21:28       ` Nicolas Iooss
2020-05-01  7:47         ` Nicolas Iooss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).