summaryrefslogtreecommitdiff
path: root/source4/scripting/bin/samba_dnsupdate
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-11-15 19:09:14 +1100
committerAndrew Tridgell <tridge@samba.org>2010-11-15 21:47:38 +1100
commite409db9da170ae24e3806ccf87d411b42e582945 (patch)
tree5ffaebd269804e7369362fa51f34edbc7a4e5d2b /source4/scripting/bin/samba_dnsupdate
parentdeaf7e5995c5120a8009dcd90e17f7e0678d1206 (diff)
downloadsamba-e409db9da170ae24e3806ccf87d411b42e582945.tar.gz
samba-e409db9da170ae24e3806ccf87d411b42e582945.tar.bz2
samba-e409db9da170ae24e3806ccf87d411b42e582945.zip
s4-dns: added --fail-immediately option to samba_dnsupdate
this is useful for manual testing
Diffstat (limited to 'source4/scripting/bin/samba_dnsupdate')
-rwxr-xr-xsource4/scripting/bin/samba_dnsupdate14
1 files changed, 13 insertions, 1 deletions
diff --git a/source4/scripting/bin/samba_dnsupdate b/source4/scripting/bin/samba_dnsupdate
index 6a20173a14..9911c6ae26 100755
--- a/source4/scripting/bin/samba_dnsupdate
+++ b/source4/scripting/bin/samba_dnsupdate
@@ -22,6 +22,7 @@ import os
import fcntl
import sys
import tempfile
+import subprocess
# ensure we get messages out immediately, so they get in the samba logs,
# and don't get swallowed by a timeout
@@ -49,6 +50,7 @@ import dns.resolver as resolver
default_ttl = 900
am_rodc = False
+error_count = 0
parser = optparse.OptionParser("samba_dnsupdate")
sambaopts = options.SambaOptions(parser)
@@ -59,6 +61,7 @@ parser.add_option("--all-names", action="store_true")
parser.add_option("--all-interfaces", action="store_true")
parser.add_option("--use-file", type="string", help="Use a file, rather than real DNS calls")
parser.add_option("--update-list", type="string", help="Add DNS names from the given file")
+parser.add_option("--fail-immediately", action='store_true', help="Exit on first failure")
creds = None
ccachename = None
@@ -253,7 +256,14 @@ def call_nsupdate(d):
f.close()
os.putenv("KRB5CCNAME", ccachename)
- os.system("%s %s" % (nsupdate_cmd, tmpfile))
+ try:
+ cmd = "%s %s" % (nsupdate_cmd, tmpfile)
+ subprocess.check_call(cmd, shell=True)
+ except subprocess.CalledProcessError:
+ global error_count
+ if opts.fail_immediately:
+ sys.exit(1)
+ error_count = error_count + 1
os.unlink(tmpfile)
@@ -392,3 +402,5 @@ for d in update_list:
# delete the ccache if we created it
if ccachename is not None:
os.unlink(ccachename)
+
+sys.exit(error_count)