summaryrefslogtreecommitdiff
path: root/source4/scripting/bin
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-09-26 10:02:43 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-09-26 05:48:25 +0200
commit3c4d0ce46995f82921f538757783fa7a678a7fc1 (patch)
tree0dcb67aebca6fa102bf68e245928c0b069cfcf29 /source4/scripting/bin
parent6d7c651f2f61b481c1e1ade1e2e0e756ccef2210 (diff)
downloadsamba-3c4d0ce46995f82921f538757783fa7a678a7fc1.tar.gz
samba-3c4d0ce46995f82921f538757783fa7a678a7fc1.tar.bz2
samba-3c4d0ce46995f82921f538757783fa7a678a7fc1.zip
samba_dnsupdate: Safely update/create names for Samba3 targets as well
This avoids unlocked writes to the dns_hosts_file, and may fix some of our issues on the build farm where large numbers of tests fail due to failed name resolution. Andrew Bartlett Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Sep 26 05:48:25 CEST 2012 on sn-devel-104
Diffstat (limited to 'source4/scripting/bin')
-rwxr-xr-xsource4/scripting/bin/samba_dnsupdate18
1 files changed, 14 insertions, 4 deletions
diff --git a/source4/scripting/bin/samba_dnsupdate b/source4/scripting/bin/samba_dnsupdate
index ab87356484..2f2c7b562a 100755
--- a/source4/scripting/bin/samba_dnsupdate
+++ b/source4/scripting/bin/samba_dnsupdate
@@ -65,6 +65,7 @@ parser.add_option("--use-file", type="string", help="Use a file, rather than rea
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")
parser.add_option("--no-credentials", dest='nocreds', action='store_true', help="don't try and get credentials")
+parser.add_option("--no-substiutions", dest='nosubs', action='store_true', help="don't try and expands variables in file specified by --update-list")
creds = None
ccachename = None
@@ -278,7 +279,13 @@ def call_nsupdate(d):
print "Calling nsupdate for %s" % d
if opts.use_file is not None:
- rfile = open(opts.use_file, 'r+')
+ try:
+ rfile = open(opts.use_file, 'r+')
+ except IOError:
+ # Perhaps create it
+ rfile = open(opts.use_file, 'w+')
+ # Open it for reading again, in case someone else got to it first
+ rfile = open(opts.use_file, 'r+')
fcntl.lockf(rfile, fcntl.LOCK_EX)
(file_dir, file_name) = os.path.split(opts.use_file)
(tmp_fd, tmpfile) = tempfile.mkstemp(dir=file_dir, prefix=file_name, suffix="XXXXXX")
@@ -432,10 +439,13 @@ os.environ['KRB5_CONFIG'] = krb5conf
file = open(dns_update_list, "r")
-samdb = SamDB(url=lp.samdb_url(), session_info=system_session(), lp=lp)
+if opts.nosubs:
+ sub_vars = {}
+else:
+ samdb = SamDB(url=lp.samdb_url(), session_info=system_session(), lp=lp)
-# get the substitution dictionary
-sub_vars = get_subst_vars(samdb)
+ # get the substitution dictionary
+ sub_vars = get_subst_vars(samdb)
# build up a list of update commands to pass to nsupdate
update_list = []