dns: update tool changed for scavenging
authorAaron Haslett <aaronhaslett@catalyst.net.nz>
Tue, 10 Jul 2018 01:14:18 +0000 (13:14 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 Jul 2018 02:31:55 +0000 (04:31 +0200)
Now that scavenging is implemented, the DNS update tool needs to be changed so
that it always updates every name required by the DC.  Otherwise, the records
might be scavenged.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=10812

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/blackbox/samba_dnsupdate.py
selftest/knownfail.d/dns
source4/scripting/bin/samba_dnsupdate

index e6cad3bbaba651fc6618441ba4ccd67f9c48f4b6..c4f14b319dca42ec16021b2122c1a09784c7adbb 100644 (file)
@@ -23,6 +23,7 @@ from samba.credentials import Credentials
 from samba.auth import system_session
 from samba.samdb import SamDB
 import ldb
+import shutil, os
 
 class SambaDnsUpdateTests(samba.tests.BlackboxTestCase):
     """Blackbox test case for samba_dnsupdate."""
@@ -37,7 +38,10 @@ class SambaDnsUpdateTests(samba.tests.BlackboxTestCase):
             pass
 
     def test_samba_dnsupate_no_change(self):
-        out = self.check_output("samba_dnsupdate --verbose")
+        try:
+            out = self.check_output("samba_dnsupdate --verbose")
+        except samba.tests.BlackboxProcessError as e:
+            self.fail("Error calling samba_dnsupdate: %s" % e)
         self.assertTrue("No DNS updates needed" in out, out)
 
     def test_samba_dnsupate_set_ip(self):
@@ -83,6 +87,9 @@ class SambaDnsUpdateTests(samba.tests.BlackboxTestCase):
         self.creds = Credentials()
         self.creds.guess(self.lp)
         self.session = system_session()
+        uc_fn = self.lp.private_path('dns_update_cache')
+        tmp_uc = uc_fn + '_tmp'
+        shutil.copyfile(uc_fn, tmp_uc)
 
         self.samdb = SamDB(session_info=self.session,
                            credentials=self.creds,
@@ -97,13 +104,14 @@ class SambaDnsUpdateTests(samba.tests.BlackboxTestCase):
             self.samdb.get_config_basedn()),
             ldb.FLAG_MOD_ADD, "siteList")
 
-        out = self.check_output("samba_dnsupdate --verbose")
-        self.assertTrue("No DNS updates needed" in out, out)
+        dns_c = "samba_dnsupdate --verbose --use-file={}".format(tmp_uc)
+        out = self.check_output(dns_c)
+        self.assertFalse(site_name.lower() in out, out)
 
         self.samdb.modify(m)
 
-        out = self.check_output("samba_dnsupdate --verbose --use-samba-tool"
-                                " --rpc-server-ip={}".format(self.server_ip))
+        shutil.copyfile(uc_fn, tmp_uc)
+        out = self.check_output(dns_c)
 
         self.assertFalse("No DNS updates needed" in out, out)
         self.assertTrue(site_name.lower() in out, out)
index 5a3e456b9c88fb82d3a92d53e2a3f6d164ea2a63..7ae19f65e333746e94c1ffd7bdb2a70401d72b4c 100644 (file)
@@ -65,3 +65,5 @@ samba.tests.dns.__main__.TestSimpleQueries.test_qtype_all_query\(rodc:local\)
 
 # The SOA override should not pass against the RODC, it must not overstamp
 samba.tests.dns.__main__.TestSimpleQueries.test_one_SOA_query\(rodc:local\)
+.*samba.tests.blackbox.samba_dnsupdate.SambaDnsUpdateTests.test_samba_dnsupate_set_ip
+.*samba.tests.blackbox.samba_dnsupdate.SambaDnsUpdateTests.test_samba_dnsupate_no_change
index 2d3fedefbc58d0bfe181953650767f6223661861..071cebee7eea0358463e0674f28b765ef36b0dc7 100755 (executable)
@@ -847,15 +847,7 @@ for d in dns_list:
         rebuild_cache = True
         if opts.verbose:
             print "need cache add: %s" % d
-    if opts.all_names:
-        update_list.append(d)
-        if opts.verbose:
-            print "force update: %s" % d
-    elif not check_dns_name(d):
-        update_list.append(d)
-        if opts.verbose:
-            print "need update: %s" % d
-
+    update_list.append(d)
 
 for c in cache_list:
     found = False