diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2012-02-26 16:07:21 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2012-02-26 16:27:06 +0100 |
commit | eeb5f66d902467524641b54e2d4180a31edbe4e7 (patch) | |
tree | 3e541138fbe1831093c1100797b47aa7ab7be866 /source4/scripting | |
parent | 3e6fa054f9567c8ba741969c6961d7f0eda5c1ca (diff) | |
download | samba-eeb5f66d902467524641b54e2d4180a31edbe4e7.tar.gz samba-eeb5f66d902467524641b54e2d4180a31edbe4e7.tar.bz2 samba-eeb5f66d902467524641b54e2d4180a31edbe4e7.zip |
provision: Put adminpass details in ProvisionResult.
Diffstat (limited to 'source4/scripting')
-rw-r--r-- | source4/scripting/python/samba/provision/__init__.py | 35 | ||||
-rw-r--r-- | source4/scripting/python/samba/tests/provision.py | 24 |
2 files changed, 37 insertions, 22 deletions
diff --git a/source4/scripting/python/samba/provision/__init__.py b/source4/scripting/python/samba/provision/__init__.py index f92ee67be5..2f6a84c709 100644 --- a/source4/scripting/python/samba/provision/__init__.py +++ b/source4/scripting/python/samba/provision/__init__.py @@ -377,9 +377,13 @@ class ProvisionResult(object): self.idmap = None self.names = None self.domainsid = None + self.adminpass_generated = None + self.adminpass = None def report_logger(self, logger): """Report this provision result to a logger.""" + if self.adminpass_generated: + logger.info("Admin password: %s", self.adminpass) logger.info("Server Role: %s", self.server_role) logger.info("Hostname: %s", self.names.hostname) logger.info("NetBIOS Domain: %s", self.names.domain) @@ -388,7 +392,8 @@ class ProvisionResult(object): if self.paths.phpldapadminconfig is not None: logger.info( - "A phpLDAPadmin configuration file suitable for administering the Samba 4 LDAP server has been created in %s.", + "A phpLDAPadmin configuration file suitable for administering " + "the Samba 4 LDAP server has been created in %s.", self.paths.phpldapadminconfig) @@ -1790,16 +1795,17 @@ def provision(logger, session_info, credentials, smbconf=None, adminpass_generated = False if samdb_fill == FILL_FULL: - provision_fill(samdb, secrets_ldb, logger, - names, paths, schema=schema, targetdir=targetdir, - samdb_fill=samdb_fill, hostip=hostip, hostip6=hostip6, domainsid=domainsid, - next_rid=next_rid, dc_rid=dc_rid, adminpass=adminpass, - krbtgtpass=krbtgtpass, domainguid=domainguid, - policyguid=policyguid, policyguid_dc=policyguid_dc, - invocationid=invocationid, machinepass=machinepass, - ntdsguid=ntdsguid, dns_backend=dns_backend, dnspass=dnspass, - serverrole=serverrole, dom_for_fun_level=dom_for_fun_level, - am_rodc=am_rodc, lp=lp) + provision_fill(samdb, secrets_ldb, logger, names, paths, + schema=schema, targetdir=targetdir, samdb_fill=samdb_fill, + hostip=hostip, hostip6=hostip6, domainsid=domainsid, + next_rid=next_rid, dc_rid=dc_rid, adminpass=adminpass, + krbtgtpass=krbtgtpass, domainguid=domainguid, + policyguid=policyguid, policyguid_dc=policyguid_dc, + invocationid=invocationid, machinepass=machinepass, + ntdsguid=ntdsguid, dns_backend=dns_backend, + dnspass=dnspass, serverrole=serverrole, + dom_for_fun_level=dom_for_fun_level, am_rodc=am_rodc, + lp=lp) create_krb5_conf(paths.krb5conf, dnsdomain=names.dnsdomain, hostname=names.hostname, @@ -1845,8 +1851,11 @@ def provision(logger, session_info, credentials, smbconf=None, result.domainsid = str(domainsid) if samdb_fill == FILL_FULL: - if adminpass_generated: - logger.info("Admin password: %s" % adminpass) + result.adminpass_generated = adminpass_generated + result.adminpass = adminpass + else: + result.adminpass_generated = False + result.adminpass = None if provision_backend.type is not "ldb": if provision_backend.credentials.get_bind_dn() is not None: logger.info("LDAP Backend Admin DN: %s" % diff --git a/source4/scripting/python/samba/tests/provision.py b/source4/scripting/python/samba/tests/provision.py index 40665c01f4..8420f9c152 100644 --- a/source4/scripting/python/samba/tests/provision.py +++ b/source4/scripting/python/samba/tests/provision.py @@ -152,7 +152,7 @@ class ProvisionResultTests(TestCase): result.report_logger(logger) return logger.entries - def test_basic_report_logger(self): + def base_result(self): result = ProvisionResult() result.server_role = "domain controller" result.names = ProvisionNames() @@ -161,6 +161,10 @@ class ProvisionResultTests(TestCase): result.names.dnsdomain = "dnsdomein" result.domainsid = "S1-1-1" result.paths = ProvisionPaths() + return result + + def test_basic_report_logger(self): + result = self.base_result() entries = self.report_logger(result) self.assertEquals(entries, [ ('INFO', 'Server Role: domain controller'), @@ -170,15 +174,17 @@ class ProvisionResultTests(TestCase): ('INFO', 'DOMAIN SID: S1-1-1')]) def test_report_logger_phpldapadmin(self): - result = ProvisionResult() - result.server_role = "domain controller" - result.names = ProvisionNames() - result.names.hostname = "hostnaam" - result.names.domain = "DOMEIN" - result.names.dnsdomain = "dnsdomein" - result.domainsid = "S1-1-1" - result.paths = ProvisionPaths() + result = self.base_result() result.paths.phpldapadminconfig = "/some/ldapconfig" entries = self.report_logger(result) self.assertEquals(entries[-1], ("INFO", "A phpLDAPadmin configuration file suitable for administering the Samba 4 LDAP server has been created in /some/ldapconfig.")) + + def test_report_logger_adminpass(self): + result = self.base_result() + result.adminpass_generated = True + result.adminpass = "geheim" + entries = self.report_logger(result) + self.assertEquals(entries[0], + ("INFO", 'Admin password: geheim')) + |