summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2015-08-13 11:34:36 +1200
committerGarming Sam <garming@samba.org>2016-06-16 04:40:14 +0200
commit26b475fb3239e5669a38a054fb42007654898bdf (patch)
treedb1d6bc0002121faa4fc4848ec87b75a7d82d421 /source4/scripting
parent8f1659e540e661326791c3ca25789d9c50d85298 (diff)
downloadsamba-26b475fb3239e5669a38a054fb42007654898bdf.tar.gz
samba_dnsupdate: Give the administrator more detail when DNS lookups fail
This avoids treating server errors identically to name-not-present status values Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'source4/scripting')
-rwxr-xr-xsource4/scripting/bin/samba_dnsupdate19
1 files changed, 16 insertions, 3 deletions
diff --git a/source4/scripting/bin/samba_dnsupdate b/source4/scripting/bin/samba_dnsupdate
index 8b39c426b3d..6565b5aef5b 100755
--- a/source4/scripting/bin/samba_dnsupdate
+++ b/source4/scripting/bin/samba_dnsupdate
@@ -273,10 +273,20 @@ def check_dns_name(d):
try:
ans = check_one_dns_name(normalised_name, d.type, d)
- except dns.exception.DNSException:
+ except dns.exception.Timeout:
+ raise Exception("Timeout while waiting to contact a working DNS server while looking for %s as %s" % (d, normalised_name))
+ except dns.resolver.NoNameservers:
+ raise Exception("Unable to contact a working DNS server while looking for %s as %s" % (d, normalised_name))
+ except dns.resolver.NXDOMAIN:
+ if opts.verbose:
+ print "The DNS entry %s, queried as %s does not exist" % (d, normalised_name)
+ return False
+ except dns.resolver.NoAnswer:
if opts.verbose:
- print "Failed to find DNS entry %s" % d
+ print "The DNS entry %s, queried as %s does not hold this record type" % (d, normalised_name)
return False
+ except dns.exception.DNSException:
+ raise Exception("Failure while trying to resolve %s as %s" % (d, normalised_name))
if d.type in ['A', 'AAAA']:
# we need to be sure that our IP is there
for rdata in ans:
@@ -304,7 +314,7 @@ def check_dns_name(d):
d.existing_weight = str(rdata.weight)
if opts.verbose:
- print "Failed to find matching DNS entry %s" % d
+ print "Lookup of %s succeeded, but we failed to find a matching DNS entry for %s" % (normalised_name, d)
return False
@@ -836,10 +846,13 @@ for d in update_list:
call_nsupdate(d)
if rebuild_cache:
+ print "Rebuilding cache at %s" % dns_update_cache
(file_dir, file_name) = os.path.split(dns_update_cache)
(tmp_fd, tmpfile) = tempfile.mkstemp(dir=file_dir, prefix=file_name, suffix="XXXXXX")
wfile = os.fdopen(tmp_fd, 'a')
for d in dns_list:
+ if opts.verbose:
+ print "Adding %s to %s" % (str(d), file_name)
wfile.write(str(d)+"\n")
os.rename(tmpfile, dns_update_cache)
fcntl.lockf(cfile, fcntl.LOCK_UN)