The Identity, Policy and Audit system
CentOS Sources
2016-11-03 403b09ab980c02ef36095973349a13e0181c794a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From fd11c06c34a45688c7609872b93413823f9ccb4d Mon Sep 17 00:00:00 2001
From: Martin Basti <mbasti@redhat.com>
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 <tkrizek@redhat.com>
---
 ipapython/ipautil.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
 
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index fdfebb65ecb8b62108852f6517b5ffb22fd7eedc..a099ea45747100946aa97bb5010ae58c49a089ba 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 (
-- 
2.7.4