pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0125-Fix-parse-errors-with-link-local-addresses.patch

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