1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-31 20:22:15 +03:00

provision: Put adminpass details in ProvisionResult.

This commit is contained in:
Jelmer Vernooij
2012-02-26 16:07:21 +01:00
parent 3e6fa054f9
commit eeb5f66d90
2 changed files with 37 additions and 22 deletions

View File

@ -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" %

View File

@ -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'))