]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:samba_dnsupdate: add --sync-file option
authorStefan Metzmacher <metze@samba.org>
Wed, 20 May 2026 15:59:47 +0000 (17:59 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 21 Jul 2026 09:32:37 +0000 (09:32 +0000)
This can be used similar to the --use-file option,
but the --sync-file option only mirrors the real dns
updates into the file.

It means the dns records on the server are still created,
this is needed for more useful testing.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
source4/scripting/bin/samba_dnsupdate

index dd9040a79bcfedaee2224c3e026ab1bd0dca3b66..07d985f0c4f44e3507573d94f3fcdbcc1ccfe852 100755 (executable)
@@ -72,6 +72,7 @@ parser.add_option("--all-interfaces", action="store_true")
 parser.add_option("--current-ip", action="append", help="IP address to update DNS to match (helpful if behind NAT, valid multiple times, defaults to values from interfaces=)")
 parser.add_option("--rpc-server-ip", type="string", help="IP address of server to use with samba-tool (defaults to first --current-ip)")
 parser.add_option("--use-file", type="string", help="Use a file, rather than real DNS calls")
+parser.add_option("--sync-file", type="string", help="sync to a file, in addition to real DNS calls")
 parser.add_option("--update-list", type="string", help="Add DNS names from the given file")
 parser.add_option("--update-cache", type="string", help="Cache database of already registered records")
 parser.add_option("--fail-immediately", action='store_true', help="Exit on first failure")
@@ -976,6 +977,16 @@ if rebuild_cache:
     wfile.close()
     os.rename(tmpfile, dns_update_cache)
 
+if opts.sync_file is not None:
+    for d in delete_list:
+        if opts.verbose:
+            print("delete (sync file): %s" % d)
+        update_file(opts.sync_file, d, op="delete")
+    for d in dns_list:
+        if opts.verbose:
+            print("Add (sync file): %s" % d)
+        update_file(opts.sync_file, d, op="add")
+
 # delete the ccache if we created it
 if ccachename is not None:
     os.unlink(ccachename)