DNS Resolver: support both dnspython before and after 2.0.0
authorAlexander Bokovoy <ab@samba.org>
Sat, 24 Oct 2020 09:17:44 +0000 (12:17 +0300)
committerKarolin Seeger <kseeger@samba.org>
Fri, 30 Oct 2020 12:26:30 +0000 (12:26 +0000)
commite424e1d65e439460783bce4a32b723bc45fb5f2e
treeccca81e5407b36caf19fbef99869b71400835f18
parent6521b0ff5e23dea526f3c0cf9c5843bbb07adcec
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)
python/samba/dnsresolver.py [new file with mode: 0644]
source4/scripting/bin/samba_dnsupdate