|
|
ac7d03 |
From c4482f0441e610c077d550c10b9525f97ea2f984 Mon Sep 17 00:00:00 2001
|
|
|
ac7d03 |
From: Martin Basti <mbasti@redhat.com>
|
|
|
ac7d03 |
Date: Wed, 14 Jun 2017 14:54:43 +0200
|
|
|
ac7d03 |
Subject: [PATCH] CheckedIPAddress: remove match_local param
|
|
|
ac7d03 |
|
|
|
ac7d03 |
This parameter is unused in code. We are no longer testing if IP address
|
|
|
ac7d03 |
matches an interface in constructor.
|
|
|
ac7d03 |
|
|
|
ac7d03 |
https://pagure.io/freeipa/issue/4317
|
|
|
ac7d03 |
|
|
|
ac7d03 |
Reviewed-By: David Kupka <dkupka@redhat.com>
|
|
|
ac7d03 |
---
|
|
|
ac7d03 |
ipapython/config.py | 5 ++---
|
|
|
ac7d03 |
ipapython/ipautil.py | 10 +---------
|
|
|
ac7d03 |
ipaserver/install/installutils.py | 2 +-
|
|
|
ac7d03 |
ipaserver/plugins/dns.py | 4 ++--
|
|
|
ac7d03 |
ipaserver/plugins/host.py | 2 +-
|
|
|
ac7d03 |
ipatests/test_ipapython/test_ipautil.py | 3 +--
|
|
|
ac7d03 |
6 files changed, 8 insertions(+), 18 deletions(-)
|
|
|
ac7d03 |
|
|
|
ac7d03 |
diff --git a/ipapython/config.py b/ipapython/config.py
|
|
|
ac7d03 |
index 9db2dcd4dbf3ed0fbe3e3166c3f0c5bae0f1716b..6349892fe88757629129f464401efce64e30f058 100644
|
|
|
ac7d03 |
--- a/ipapython/config.py
|
|
|
ac7d03 |
+++ b/ipapython/config.py
|
|
|
ac7d03 |
@@ -68,10 +68,9 @@ class IPAFormatter(IndentedHelpFormatter):
|
|
|
ac7d03 |
def check_ip_option(option, opt, value):
|
|
|
ac7d03 |
from ipapython.ipautil import CheckedIPAddress
|
|
|
ac7d03 |
|
|
|
ac7d03 |
- ip_local = option.ip_local is True
|
|
|
ac7d03 |
ip_netmask = option.ip_netmask is True
|
|
|
ac7d03 |
try:
|
|
|
ac7d03 |
- return CheckedIPAddress(value, parse_netmask=ip_netmask, match_local=ip_local)
|
|
|
ac7d03 |
+ return CheckedIPAddress(value, parse_netmask=ip_netmask)
|
|
|
ac7d03 |
except Exception as e:
|
|
|
ac7d03 |
raise OptionValueError("option %s: invalid IP address %s: %s" % (opt, value, e))
|
|
|
ac7d03 |
|
|
|
ac7d03 |
@@ -86,7 +85,7 @@ class IPAOption(Option):
|
|
|
ac7d03 |
optparse.Option subclass with support of options labeled as
|
|
|
ac7d03 |
security-sensitive such as passwords.
|
|
|
ac7d03 |
"""
|
|
|
ac7d03 |
- ATTRS = Option.ATTRS + ["sensitive", "ip_local", "ip_netmask"]
|
|
|
ac7d03 |
+ ATTRS = Option.ATTRS + ["sensitive", "ip_netmask"]
|
|
|
ac7d03 |
TYPES = Option.TYPES + ("ip", "dn")
|
|
|
ac7d03 |
TYPE_CHECKER = copy(Option.TYPE_CHECKER)
|
|
|
ac7d03 |
TYPE_CHECKER["ip"] = check_ip_option
|
|
|
ac7d03 |
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
|
|
|
ac7d03 |
index 2c020e3ecbf4d8b969511a6dd9b36ee955ba1f15..5a6bf5a27d5a6e25c51fbaa6e2b1167652e2735d 100644
|
|
|
ac7d03 |
--- a/ipapython/ipautil.py
|
|
|
ac7d03 |
+++ b/ipapython/ipautil.py
|
|
|
ac7d03 |
@@ -135,7 +135,7 @@ class CheckedIPAddress(UnsafeIPAddress):
|
|
|
ac7d03 |
|
|
|
ac7d03 |
Reserved or link-local addresses are never accepted.
|
|
|
ac7d03 |
"""
|
|
|
ac7d03 |
- def __init__(self, addr, match_local=False, parse_netmask=True,
|
|
|
ac7d03 |
+ def __init__(self, addr, parse_netmask=True,
|
|
|
ac7d03 |
allow_loopback=False, allow_multicast=False):
|
|
|
ac7d03 |
try:
|
|
|
ac7d03 |
super(CheckedIPAddress, self).__init__(addr)
|
|
|
ac7d03 |
@@ -166,14 +166,6 @@ class CheckedIPAddress(UnsafeIPAddress):
|
|
|
ac7d03 |
if not allow_multicast and self.is_multicast():
|
|
|
ac7d03 |
raise ValueError("cannot use multicast IP address {}".format(addr))
|
|
|
ac7d03 |
|
|
|
ac7d03 |
- if match_local:
|
|
|
ac7d03 |
- intf_details = self.get_matching_interface()
|
|
|
ac7d03 |
- if not intf_details:
|
|
|
ac7d03 |
- raise ValueError('no network interface matches the IP address '
|
|
|
ac7d03 |
- 'and netmask {}'.format(addr))
|
|
|
ac7d03 |
- else:
|
|
|
ac7d03 |
- self.set_ip_net(intf_details.ifnet)
|
|
|
ac7d03 |
-
|
|
|
ac7d03 |
if self._net is None:
|
|
|
ac7d03 |
if self.version == 4:
|
|
|
ac7d03 |
self._net = netaddr.IPNetwork(
|
|
|
ac7d03 |
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
|
|
|
ac7d03 |
index 3521d555914714351160213df60ed9167ac6e370..01930c4de6f0edd16b31aeba1c926fe581e9635b 100644
|
|
|
ac7d03 |
--- a/ipaserver/install/installutils.py
|
|
|
ac7d03 |
+++ b/ipaserver/install/installutils.py
|
|
|
ac7d03 |
@@ -585,7 +585,7 @@ def get_server_ip_address(host_name, unattended, setup_dns, ip_addresses):
|
|
|
ac7d03 |
if len(hostaddr):
|
|
|
ac7d03 |
for ha in hostaddr:
|
|
|
ac7d03 |
try:
|
|
|
ac7d03 |
- ips.append(ipautil.CheckedIPAddress(ha, match_local=False))
|
|
|
ac7d03 |
+ ips.append(ipautil.CheckedIPAddress(ha))
|
|
|
ac7d03 |
except ValueError as e:
|
|
|
ac7d03 |
root_logger.warning("Invalid IP address %s for %s: %s", ha, host_name, unicode(e))
|
|
|
ac7d03 |
|
|
|
ac7d03 |
diff --git a/ipaserver/plugins/dns.py b/ipaserver/plugins/dns.py
|
|
|
ac7d03 |
index f0e6c48f06313def57cdd6a4c7114357c9d8de8a..f01baf515525c43824eddf06abc7af9fef228efe 100644
|
|
|
ac7d03 |
--- a/ipaserver/plugins/dns.py
|
|
|
ac7d03 |
+++ b/ipaserver/plugins/dns.py
|
|
|
ac7d03 |
@@ -567,7 +567,7 @@ def add_records_for_host_validation(option_name, host, domain, ip_addresses, che
|
|
|
ac7d03 |
for ip_address in ip_addresses:
|
|
|
ac7d03 |
try:
|
|
|
ac7d03 |
ip = CheckedIPAddress(
|
|
|
ac7d03 |
- ip_address, match_local=False, allow_multicast=True)
|
|
|
ac7d03 |
+ ip_address, allow_multicast=True)
|
|
|
ac7d03 |
except Exception as e:
|
|
|
ac7d03 |
raise errors.ValidationError(name=option_name, error=unicode(e))
|
|
|
ac7d03 |
|
|
|
ac7d03 |
@@ -599,7 +599,7 @@ def add_records_for_host(host, domain, ip_addresses, add_forward=True, add_rever
|
|
|
ac7d03 |
|
|
|
ac7d03 |
for ip_address in ip_addresses:
|
|
|
ac7d03 |
ip = CheckedIPAddress(
|
|
|
ac7d03 |
- ip_address, match_local=False, allow_multicast=True)
|
|
|
ac7d03 |
+ ip_address, allow_multicast=True)
|
|
|
ac7d03 |
|
|
|
ac7d03 |
if add_forward:
|
|
|
ac7d03 |
add_forward_record(domain, host, unicode(ip))
|
|
|
ac7d03 |
diff --git a/ipaserver/plugins/host.py b/ipaserver/plugins/host.py
|
|
|
ac7d03 |
index 1e1f9d82dfdfcf9e7fef65ce729cd8ee7b76e605..364e5be6002eeb9c5e6b4c594b71f38169598227 100644
|
|
|
ac7d03 |
--- a/ipaserver/plugins/host.py
|
|
|
ac7d03 |
+++ b/ipaserver/plugins/host.py
|
|
|
ac7d03 |
@@ -245,7 +245,7 @@ def validate_ipaddr(ugettext, ipaddr):
|
|
|
ac7d03 |
Verify that we have either an IPv4 or IPv6 address.
|
|
|
ac7d03 |
"""
|
|
|
ac7d03 |
try:
|
|
|
ac7d03 |
- CheckedIPAddress(ipaddr, match_local=False)
|
|
|
ac7d03 |
+ CheckedIPAddress(ipaddr)
|
|
|
ac7d03 |
except Exception as e:
|
|
|
ac7d03 |
return unicode(e)
|
|
|
ac7d03 |
return None
|
|
|
ac7d03 |
diff --git a/ipatests/test_ipapython/test_ipautil.py b/ipatests/test_ipapython/test_ipautil.py
|
|
|
ac7d03 |
index 6427935b162b087c55e069cb2a576a7379cbe7a7..9c351bd0ed9cd96488ac74deadf97996668a75d2 100644
|
|
|
ac7d03 |
--- a/ipatests/test_ipapython/test_ipautil.py
|
|
|
ac7d03 |
+++ b/ipatests/test_ipapython/test_ipautil.py
|
|
|
ac7d03 |
@@ -30,11 +30,10 @@ from ipapython import ipautil
|
|
|
ac7d03 |
|
|
|
ac7d03 |
pytestmark = pytest.mark.tier0
|
|
|
ac7d03 |
|
|
|
ac7d03 |
-
|
|
|
ac7d03 |
def make_ipaddress_checker(addr, words=None, prefixlen=None):
|
|
|
ac7d03 |
def check_ipaddress():
|
|
|
ac7d03 |
try:
|
|
|
ac7d03 |
- ip = ipautil.CheckedIPAddress(addr, match_local=False)
|
|
|
ac7d03 |
+ ip = ipautil.CheckedIPAddress(addr)
|
|
|
ac7d03 |
assert ip.words == words and ip.prefixlen == prefixlen
|
|
|
ac7d03 |
except Exception:
|
|
|
ac7d03 |
assert words is None and prefixlen is None
|
|
|
ac7d03 |
--
|
|
|
ac7d03 |
2.9.4
|
|
|
ac7d03 |
|