1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

samba-tool drs clone-dc-database: Require --targetdir

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2015-10-12 17:50:27 +13:00
parent 04512d1a9d
commit ffe8090c89
2 changed files with 18 additions and 1 deletions

View File

@ -528,7 +528,7 @@ class cmd_drs_clone_dc_database(Command):
takes_options = [
Option("--server", help="DC to join", type=str),
Option("--targetdir", help="where to store provision", type=str),
Option("--targetdir", help="where to store provision (required)", type=str),
Option("--quiet", help="Be quiet", action="store_true"),
Option("--include-secrets", help="Also replicate secret values", action="store_true"),
Option("--verbose", help="Be verbose", action="store_true")
@ -550,6 +550,10 @@ class cmd_drs_clone_dc_database(Command):
else:
logger.setLevel(logging.INFO)
if targetdir is None:
raise CommandError("--targetdir option must be specified")
join_clone(logger=logger, server=server, creds=creds, lp=lp, domain=domain,
targetdir=targetdir, include_secrets=include_secrets)

View File

@ -167,3 +167,16 @@ class SambaToolDrsTests(samba.tests.BlackboxTestCase):
shutil.rmtree(os.path.join(self.tempdir, "msg.lock"))
os.remove(os.path.join(self.tempdir, "names.tdb"))
shutil.rmtree(os.path.join(self.tempdir, "state"))
def test_samba_tool_drs_clone_dc_secrets_without_targetdir(self):
"""Tests 'samba-tool drs clone-dc-database' command without --targetdir."""
server_rootdse = self._get_rootDSE(self.dc1)
server_ldap_service_name = str(server_rootdse["ldapServiceName"][0])
server_realm = server_ldap_service_name.split(":")[0]
creds = self.get_credentials()
def attempt_clone():
out = self.check_output("samba-tool drs clone-dc-database %s --server=%s %s"
% (server_realm,
self.dc1,
self.cmdline_creds))
self.assertRaises(samba.tests.BlackboxProcessError, attempt_clone)