From b84c6b6d6925b65801060923dc24bce8e0312fc9 Mon Sep 17 00:00:00 2001
From: Martin Basti <mbasti@redhat.com>
Date: Fri, 16 Jun 2017 13:49:06 +0200
Subject: [PATCH] python-netifaces: update to reflect upstream changes
python-netifaces now provides IPv6 netmask in format mask/prefix. It
breaks freeipa as it is unexpected format for python-netaddr. We must
split netmask and provide only prefix for netaddr.
https://pagure.io/freeipa/issue/7021
---
ipapython/ipautil.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index 968c14c97c2987d5a7397dc472d419bf54938c42..ff415e0d5093501db25431d7f4764c1a888acdba 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -188,9 +188,14 @@ class CheckedIPAddress(UnsafeIPAddress):
# errors in IPNetwork
ifaddr = ifdata['addr'].split(u'%', 1)[0]
+ # newer versions of netifaces provide IPv6 netmask in format
+ # 'ffff:ffff:ffff:ffff::/64'. We have to split and use prefix
+ # or the netmask with older versions
+ ifmask = ifdata['netmask'].split(u'/')[-1]
+
ifnet = netaddr.IPNetwork('{addr}/{netmask}'.format(
addr=ifaddr,
- netmask=ifdata['netmask']
+ netmask=ifmask
))
if ifnet == self._net or (
self._net is None and ifnet.ip == self):
--
2.9.4