RE: [PATCH] python/semanage: Use ipaddress module instead of IPy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: selinux-owner@xxxxxxxxxxxxxxx [mailto:selinux-owner@xxxxxxxxxxxxxxx]
> On Behalf Of Petr Lautrbach
> Sent: Friday, April 24, 2020 10:00 AM
> To: selinux@xxxxxxxxxxxxxxx
> Cc: Petr Lautrbach <plautrba@xxxxxxxxxx>
> Subject: [PATCH] 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@xxxxxxxxxx>
> ---
>  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

LGTM
<Reviewed-by: William.c.Roberts@xxxxxxxxx>

I can give it an acked by if you give me testing steps.




[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux