diff options
author | Alexander Bokovoy <ab@samba.org> | 2020-10-24 12:17:44 +0300 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2020-10-30 12:26:30 +0000 |
commit | e424e1d65e439460783bce4a32b723bc45fb5f2e (patch) | |
tree | ccca81e5407b36caf19fbef99869b71400835f18 /source4 | |
parent | 6521b0ff5e23dea526f3c0cf9c5843bbb07adcec (diff) | |
download | samba-e424e1d65e439460783bce4a32b723bc45fb5f2e.tar.gz |
DNS Resolver: support both dnspython before and after 2.0.0
`dnspython` 2.0.0 has many changes and several deprecations like:
```
> dns.resolver.resolve() has been added, allowing control of whether
search lists are used. dns.resolver.query() is retained for backwards
compatibility, but deprecated. The default for search list behavior can
be set at in the resolver object with the use_search_by_default
parameter. The default is False.
> dns.resolver.resolve_address() has been added, allowing easy
address-to-name lookups.
```
The new class `DNSResolver`:
- provides the compatibility layer
- defaults the previous behavior (the search list configured in the
system's resolver configuration is used for relative names)
- defaults lifetime to 15sec (determines the number of seconds
to spend trying to get an answer to the question)
The compatibility shim was developed by Stanislav Levin for FreeIPA and
adopted for Samba by Alexander Bokovoy.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14553
Signed-off-by: Stanislav Levin <slev@altlinux.org>
Signed-off-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 183d5d63f4b40accda3b3ffc980fea391612f964)
Diffstat (limited to 'source4')
-rwxr-xr-x | source4/scripting/bin/samba_dnsupdate | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/source4/scripting/bin/samba_dnsupdate b/source4/scripting/bin/samba_dnsupdate index 44eb1cadd27..fe04ce71338 100755 --- a/source4/scripting/bin/samba_dnsupdate +++ b/source4/scripting/bin/samba_dnsupdate @@ -53,6 +53,7 @@ from samba.compat import get_string from samba.compat import text_type import ldb +from samba.dnsresolver import DNSResolver import dns.resolver import dns.exception @@ -259,7 +260,7 @@ def hostname_match(h1, h2): def get_resolver(d=None): resolv_conf = os.getenv('RESOLV_CONF', default='/etc/resolv.conf') - resolver = dns.resolver.Resolver(filename=resolv_conf, configure=True) + resolver = DNSResolver(filename=resolv_conf, configure=True) if d is not None and d.nameservers != []: resolver.nameservers = d.nameservers @@ -271,7 +272,7 @@ def check_one_dns_name(name, name_type, d=None): if d and not d.nameservers: d.nameservers = resolver.nameservers # dns.resolver.Answer - return resolver.query(name, name_type) + return resolver.resolve(name, name_type) def check_dns_name(d): """check that a DNS entry exists.""" |