summaryrefslogtreecommitdiff
path: root/source4/scripting/bin/samba_dnsupdate
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-09-26 09:48:48 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-09-26 04:08:26 +0200
commit6d7c651f2f61b481c1e1ade1e2e0e756ccef2210 (patch)
tree8d9f57091e36bbb72d4f1add9ad1421debf9feb7 /source4/scripting/bin/samba_dnsupdate
parentb320e7f93b5905558efa879992c125af66f0043c (diff)
downloadsamba-6d7c651f2f61b481c1e1ade1e2e0e756ccef2210.tar.gz
samba-6d7c651f2f61b481c1e1ade1e2e0e756ccef2210.tar.bz2
samba-6d7c651f2f61b481c1e1ade1e2e0e756ccef2210.zip
samba_dnsupdate: Move to using tmpfile/rename to keep the dns_hosts_file consistent
This may be the cause of some of the large failure modes on the build farm. Andrew Bartlett
Diffstat (limited to 'source4/scripting/bin/samba_dnsupdate')
-rwxr-xr-xsource4/scripting/bin/samba_dnsupdate13
1 files changed, 10 insertions, 3 deletions
diff --git a/source4/scripting/bin/samba_dnsupdate b/source4/scripting/bin/samba_dnsupdate
index d21496ca21..ab87356484 100755
--- a/source4/scripting/bin/samba_dnsupdate
+++ b/source4/scripting/bin/samba_dnsupdate
@@ -278,10 +278,17 @@ def call_nsupdate(d):
print "Calling nsupdate for %s" % d
if opts.use_file is not None:
- wfile = open(opts.use_file, 'a')
- fcntl.lockf(wfile, fcntl.LOCK_EX)
+ 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")
+ wfile = os.fdopen(tmp_fd, 'a')
+ rfile.seek(0)
+ for line in rfile:
+ wfile.write(line)
wfile.write(str(d)+"\n")
- fcntl.lockf(wfile, fcntl.LOCK_UN)
+ os.rename(tmpfile, opts.use_file)
+ fcntl.lockf(rfile, fcntl.LOCK_UN)
return
normalised_name = d.name.rstrip('.') + '.'