From e85ef1dbfef4b16c35cac80c0efc563d8cd1ba3e Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 7 Oct 2014 15:35:34 +0200 Subject: [PATCH] samba_dnsupdate: Always fill out the nameservers of a dns object. Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- source4/scripting/bin/samba_dnsupdate | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source4/scripting/bin/samba_dnsupdate b/source4/scripting/bin/samba_dnsupdate index c2ee3ecb7fb..427b5dc869f 100755 --- a/source4/scripting/bin/samba_dnsupdate +++ b/source4/scripting/bin/samba_dnsupdate @@ -139,6 +139,7 @@ class dnsobj(object): self.existing_weight = None self.type = list[0] self.name = list[1] + self.nameservers = [] if self.type == 'SRV': if len(list) < 4: raise Exception("Invalid DNS entry %r" % string_form) @@ -208,9 +209,12 @@ def check_dns_name(d): resolver = dns.resolver.Resolver() + if d.nameservers != []: + resolver.nameservers = d.nameservers + else: + d.nameservers = resolver.nameservers + try: - if getattr(d, 'nameservers', None): - resolver.nameservers = list(d.nameservers) ans = resolver.query(normalised_name, d.type) except dns.exception.DNSException: if opts.verbose: @@ -357,7 +361,7 @@ def call_nsupdate(d, op="add"): (tmp_fd, tmpfile) = tempfile.mkstemp() f = os.fdopen(tmp_fd, 'w') - if getattr(d, 'nameservers', None): + if d.nameservers != []: f.write('server %s\n' % d.nameservers[0]) if d.type == "A": f.write("update %s %s %u A %s\n" % (op, normalised_name, default_ttl, d.ip)) -- 2.11.4.GIT