From 8ef42d4dab4dfaf5ad225b33f7748914f14dcd8c Mon Sep 17 00:00:00 2001 From: Aaron Haslett Date: Tue, 10 Jul 2018 13:14:18 +1200 Subject: [PATCH] dns: update tool changed for scavenging 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 Reviewed-by: Gary Lockyer Reviewed-by: Andrew Bartlett --- python/samba/tests/blackbox/samba_dnsupdate.py | 18 +++++++++++++----- selftest/knownfail.d/dns | 2 ++ source4/scripting/bin/samba_dnsupdate | 10 +--------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/python/samba/tests/blackbox/samba_dnsupdate.py b/python/samba/tests/blackbox/samba_dnsupdate.py index e6cad3bbaba..c4f14b319dc 100644 --- a/python/samba/tests/blackbox/samba_dnsupdate.py +++ b/python/samba/tests/blackbox/samba_dnsupdate.py @@ -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) diff --git a/selftest/knownfail.d/dns b/selftest/knownfail.d/dns index 5a3e456b9c8..7ae19f65e33 100644 --- a/selftest/knownfail.d/dns +++ b/selftest/knownfail.d/dns @@ -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 diff --git a/source4/scripting/bin/samba_dnsupdate b/source4/scripting/bin/samba_dnsupdate index 2d3fedefbc5..071cebee7ee 100755 --- a/source4/scripting/bin/samba_dnsupdate +++ b/source4/scripting/bin/samba_dnsupdate @@ -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