From: Stefan Metzmacher Date: Wed, 20 May 2026 15:59:03 +0000 (+0200) Subject: s4:samba_dnsupdate: let update_file check for modified first X-Git-Tag: talloc-2.5.0~95 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7a478b5262178a4d7cf1a4e5a2b0a82af05bcad7;p=thirdparty%2Fsamba.git s4:samba_dnsupdate: let update_file check for modified first We only replace the file if it's modified. Signed-off-by: Stefan Metzmacher Reviewed-by: Jennifer Sutton Reviewed-by: Andreas Schneider --- diff --git a/source4/scripting/bin/samba_dnsupdate b/source4/scripting/bin/samba_dnsupdate index 8342b0ac547..dd9040a79bc 100755 --- a/source4/scripting/bin/samba_dnsupdate +++ b/source4/scripting/bin/samba_dnsupdate @@ -428,17 +428,29 @@ def update_file(write_file, d, op): (file_dir, file_name) = os.path.split(write_file) (tmp_fd, tmpfile) = tempfile.mkstemp(dir=file_dir, prefix=file_name, suffix="XXXXXX") wfile = os.fdopen(tmp_fd, 'a') + modified = False for line in rfile: + l = parse_dns_line(line, {}) + if str(l).lower() != str(d).lower(): + wfile.write(line) + continue if op == "delete": - l = parse_dns_line(line, {}) - if str(l).lower() == str(d).lower(): - continue - wfile.write(line) + modified = True + continue + if op == "add": + op = "skip_add" + wfile.write(line) + continue + continue if op == "add": wfile.write(str(d)+"\n") + modified = True rfile.close() wfile.close() - os.rename(tmpfile, write_file) + if modified: + os.rename(tmpfile, write_file) + else: + os.remove(tmpfile) return def call_nsupdate(d, op="add"):