|
|
2fe7e5 |
From 9a33838407f244e481523fe643bc0626874e8b1a Mon Sep 17 00:00:00 2001
|
|
|
2fe7e5 |
From: Rafael Guterres Jeffman <rjeffman@redhat.com>
|
|
|
2fe7e5 |
Date: Mon, 19 Dec 2022 14:57:03 -0300
|
|
|
2fe7e5 |
Subject: [PATCH] Revert "DNSResolver: Fix use of nameservers with ports"
|
|
|
2fe7e5 |
|
|
|
2fe7e5 |
This reverts commit 5e2e4664aec641886923c2bec61ce25b96edb62a.
|
|
|
2fe7e5 |
---
|
|
|
2fe7e5 |
ipapython/dnsutil.py | 41 -------------------------
|
|
|
2fe7e5 |
ipatests/test_ipapython/test_dnsutil.py | 40 ------------------------
|
|
|
2fe7e5 |
2 files changed, 81 deletions(-)
|
|
|
2fe7e5 |
|
|
|
2fe7e5 |
diff --git a/ipapython/dnsutil.py b/ipapython/dnsutil.py
|
|
|
2fe7e5 |
index 58de365ab..4baeaf8cc 100644
|
|
|
2fe7e5 |
--- a/ipapython/dnsutil.py
|
|
|
2fe7e5 |
+++ b/ipapython/dnsutil.py
|
|
|
2fe7e5 |
@@ -144,47 +144,6 @@ class DNSResolver(dns.resolver.Resolver):
|
|
|
2fe7e5 |
nameservers.remove(ipv4_loopback)
|
|
|
2fe7e5 |
self.nameservers = nameservers
|
|
|
2fe7e5 |
|
|
|
2fe7e5 |
- @dns.resolver.Resolver.nameservers.setter
|
|
|
2fe7e5 |
- def nameservers(self, nameservers):
|
|
|
2fe7e5 |
- """
|
|
|
2fe7e5 |
- *nameservers*, a ``list`` of nameservers with optional ports:
|
|
|
2fe7e5 |
- "SERVER_IP port PORT_NUMBER".
|
|
|
2fe7e5 |
-
|
|
|
2fe7e5 |
- Overloads dns.resolver.Resolver.nameservers setter to split off ports
|
|
|
2fe7e5 |
- into nameserver_ports after setting nameservers successfully with the
|
|
|
2fe7e5 |
- setter in dns.resolver.Resolver.
|
|
|
2fe7e5 |
- """
|
|
|
2fe7e5 |
- # Get nameserver_ports if it is already set
|
|
|
2fe7e5 |
- if hasattr(self, "nameserver_ports"):
|
|
|
2fe7e5 |
- nameserver_ports = self.nameserver_ports
|
|
|
2fe7e5 |
- else:
|
|
|
2fe7e5 |
- nameserver_ports = {}
|
|
|
2fe7e5 |
-
|
|
|
2fe7e5 |
- # Check nameserver items in list and split out converted port number
|
|
|
2fe7e5 |
- # into nameserver_ports: { nameserver: port }
|
|
|
2fe7e5 |
- if isinstance(nameservers, list):
|
|
|
2fe7e5 |
- _nameservers = []
|
|
|
2fe7e5 |
- for nameserver in nameservers:
|
|
|
2fe7e5 |
- splits = nameserver.split()
|
|
|
2fe7e5 |
- if len(splits) == 3 and splits[1] == "port":
|
|
|
2fe7e5 |
- nameserver = splits[0]
|
|
|
2fe7e5 |
- try:
|
|
|
2fe7e5 |
- port = int(splits[2])
|
|
|
2fe7e5 |
- if port < 0 or port > 65535:
|
|
|
2fe7e5 |
- raise ValueError()
|
|
|
2fe7e5 |
- except ValueError:
|
|
|
2fe7e5 |
- raise ValueError(
|
|
|
2fe7e5 |
- "invalid nameserver: %s is not a valid port" %
|
|
|
2fe7e5 |
- splits[2])
|
|
|
2fe7e5 |
- nameserver_ports[nameserver] = port
|
|
|
2fe7e5 |
- _nameservers.append(nameserver)
|
|
|
2fe7e5 |
- nameservers = _nameservers
|
|
|
2fe7e5 |
-
|
|
|
2fe7e5 |
- # Call dns.resolver.Resolver.nameservers setter
|
|
|
2fe7e5 |
- dns.resolver.Resolver.nameservers.__set__(self, nameservers)
|
|
|
2fe7e5 |
- # Set nameserver_ports after successfull call to setter
|
|
|
2fe7e5 |
- self.nameserver_ports = nameserver_ports
|
|
|
2fe7e5 |
-
|
|
|
2fe7e5 |
|
|
|
2fe7e5 |
class DNSZoneAlreadyExists(dns.exception.DNSException):
|
|
|
2fe7e5 |
supp_kwargs = {'zone', 'ns'}
|
|
|
2fe7e5 |
diff --git a/ipatests/test_ipapython/test_dnsutil.py b/ipatests/test_ipapython/test_dnsutil.py
|
|
|
2fe7e5 |
index 09463c69d..5e7a46197 100644
|
|
|
2fe7e5 |
--- a/ipatests/test_ipapython/test_dnsutil.py
|
|
|
2fe7e5 |
+++ b/ipatests/test_ipapython/test_dnsutil.py
|
|
|
2fe7e5 |
@@ -101,43 +101,3 @@ class TestSortURI:
|
|
|
2fe7e5 |
assert dnsutil.sort_prio_weight([h3, h2, h1]) == [h1, h2, h3]
|
|
|
2fe7e5 |
assert dnsutil.sort_prio_weight([h3, h3, h3]) == [h3]
|
|
|
2fe7e5 |
assert dnsutil.sort_prio_weight([h2, h2, h1, h1]) == [h1, h2]
|
|
|
2fe7e5 |
-
|
|
|
2fe7e5 |
-
|
|
|
2fe7e5 |
-class TestDNSResolver:
|
|
|
2fe7e5 |
- def test_nameservers(self):
|
|
|
2fe7e5 |
- res = dnsutil.DNSResolver()
|
|
|
2fe7e5 |
- res.nameservers = ["4.4.4.4", "8.8.8.8"]
|
|
|
2fe7e5 |
- assert res.nameservers == ["4.4.4.4", "8.8.8.8"]
|
|
|
2fe7e5 |
-
|
|
|
2fe7e5 |
- def test_nameservers_with_ports(self):
|
|
|
2fe7e5 |
- res = dnsutil.DNSResolver()
|
|
|
2fe7e5 |
- res.nameservers = ["4.4.4.4 port 53", "8.8.8.8 port 8053"]
|
|
|
2fe7e5 |
- assert res.nameservers == ["4.4.4.4", "8.8.8.8"]
|
|
|
2fe7e5 |
- assert res.nameserver_ports == {"4.4.4.4": 53, "8.8.8.8": 8053}
|
|
|
2fe7e5 |
-
|
|
|
2fe7e5 |
- res.nameservers = ["4.4.4.4 port 53", "8.8.8.8 port 8053"]
|
|
|
2fe7e5 |
- assert res.nameservers == ["4.4.4.4", "8.8.8.8"]
|
|
|
2fe7e5 |
- assert res.nameserver_ports == {"4.4.4.4": 53, "8.8.8.8": 8053}
|
|
|
2fe7e5 |
-
|
|
|
2fe7e5 |
- def test_nameservers_with_bad_ports(self):
|
|
|
2fe7e5 |
- res = dnsutil.DNSResolver()
|
|
|
2fe7e5 |
- try:
|
|
|
2fe7e5 |
- res.nameservers = ["4.4.4.4 port a"]
|
|
|
2fe7e5 |
- except ValueError:
|
|
|
2fe7e5 |
- pass
|
|
|
2fe7e5 |
- else:
|
|
|
2fe7e5 |
- pytest.fail("No fail on bad port a")
|
|
|
2fe7e5 |
-
|
|
|
2fe7e5 |
- try:
|
|
|
2fe7e5 |
- res.nameservers = ["4.4.4.4 port -1"]
|
|
|
2fe7e5 |
- except ValueError:
|
|
|
2fe7e5 |
- pass
|
|
|
2fe7e5 |
- else:
|
|
|
2fe7e5 |
- pytest.fail("No fail on bad port -1")
|
|
|
2fe7e5 |
-
|
|
|
2fe7e5 |
- try:
|
|
|
2fe7e5 |
- res.nameservers = ["4.4.4.4 port 65536"]
|
|
|
2fe7e5 |
- except ValueError:
|
|
|
2fe7e5 |
- pass
|
|
|
2fe7e5 |
- else:
|
|
|
2fe7e5 |
- pytest.fail("No fail on bad port 65536")
|
|
|
2fe7e5 |
--
|
|
|
2fe7e5 |
2.38.1
|
|
|
2fe7e5 |
|