From db55bde15dd83a0ed29205a127cefabe691e81b1 Mon Sep 17 00:00:00 2001 From: Martin Basti Date: Mon, 5 Sep 2016 14:33:58 +0200 Subject: [PATCH] Fix parse errors with link-local addresses Link-local addresses received from netifaces contains '%suffix' that causes parse error in IPNetwork class. We must remove %suffix before it us used in IPNetwork objects. https://fedorahosted.org/freeipa/ticket/6296 Reviewed-By: Tomas Krizek --- ipapython/ipautil.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 953654355..8de9acfb0 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -173,8 +173,13 @@ class CheckedIPAddress(UnsafeIPAddress): iface = None for interface in netifaces.interfaces(): for ifdata in netifaces.ifaddresses(interface).get(family, []): + + # link-local addresses contain '%suffix' that causes parse + # errors in IPNetwork + ifaddr = ifdata['addr'].split(u'%', 1)[0] + ifnet = netaddr.IPNetwork('{addr}/{netmask}'.format( - addr=ifdata['addr'], + addr=ifaddr, netmask=ifdata['netmask'] )) if ifnet == self._net or (