ipa/0003-python-netifaces-update-to-reflect-upstream-changes.patch
Tomas Krizek 71dac404bd
fix ip address checks and python-netifaces
Important patches that will be part of 4.5.3 release.

Signed-off-by: Tomas Krizek <tkrizek@redhat.com>
2017-06-20 14:33:05 +02:00

57 lines
2.1 KiB
Diff

From 56d04b3dccc967630d869006dfbd0003fcfedabe Mon Sep 17 00:00:00 2001
From: Martin Basti <mbasti@redhat.com>
Date: Fri, 16 Jun 2017 13:42:53 +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
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
---
ipapython/ipautil.py | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index 5a6bf5a..1bb48d4 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -197,6 +197,7 @@ class CheckedIPAddress(UnsafeIPAddress):
:return: InterfaceDetails named tuple or None if no interface has
this address
"""
+ root_logger.debug("Searching for an interface of IP address: %s", self)
if self.version == 4:
family = netifaces.AF_INET
elif self.version == 6:
@@ -213,10 +214,20 @@ class CheckedIPAddress(UnsafeIPAddress):
# errors in IPNetwork
ifaddr = ifdata['addr'].split(u'%', 1)[0]
- ifnet = netaddr.IPNetwork('{addr}/{netmask}'.format(
+ # 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]
+
+ ifaddrmask = '{addr}/{netmask}'.format(
addr=ifaddr,
- netmask=ifdata['netmask']
- ))
+ netmask=ifmask
+ )
+ root_logger.debug(
+ "Testing local IP address: %s (interface: %s)",
+ ifaddrmask, interface)
+
+ ifnet = netaddr.IPNetwork(ifaddrmask)
if ifnet.ip == self:
return InterfaceDetails(interface, ifnet)
--
2.9.4