mirror of
https://github.com/SELinuxProject/selinux
synced 2024-12-27 16:32:05 +00:00
python/semanage: Use ipaddress module instead of IPy
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>
This commit is contained in:
parent
4465a807c7
commit
79f69a3ca1
@ -32,7 +32,7 @@ from semanage import *
|
||||
PROGNAME = "policycoreutils"
|
||||
import sepolicy
|
||||
import setools
|
||||
from IPy import IP
|
||||
import ipaddress
|
||||
|
||||
try:
|
||||
import gettext
|
||||
@ -1858,15 +1858,12 @@ class nodeRecords(semanageRecords):
|
||||
if addr == "":
|
||||
raise ValueError(_("Node Address is required"))
|
||||
|
||||
# verify valid combination
|
||||
# verify that (addr, mask) is either a IP address (without a mask) or a valid network mask
|
||||
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:
|
||||
newmask = "::"
|
||||
|
||||
protocol = "ipv%d" % i.version()
|
||||
i = ipaddress.ip_network(addr + mask)
|
||||
newaddr = str(i.network_address)
|
||||
newmask = str(i.netmask)
|
||||
protocol = "ipv%d" % i.version
|
||||
|
||||
try:
|
||||
newprotocol = self.protocol.index(protocol)
|
||||
|
Loading…
Reference in New Issue
Block a user