[PATCH 23/31] samba_dnsupdate: Always fill out the nameservers of a dns object.
Andreas Schneider
asn at samba.org
Wed Dec 3 07:45:19 MST 2014
Signed-off-by: Andreas Schneider <asn at samba.org>
---
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 c8d110a..7f94067 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)
@@ -211,9 +212,12 @@ def check_dns_name(d):
resolv_conf = '/etc/resolv.conf'
resolver = dns.resolver.Resolver(filename=resolv_conf, configure=True)
+ 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:
@@ -360,7 +364,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.1.3
More information about the samba-technical
mailing list