mirror of
https://github.com/samba-team/samba.git
synced 2025-08-04 08:22:08 +03:00
provision: Put adminpass details in ProvisionResult.
This commit is contained in:
@ -377,9 +377,13 @@ class ProvisionResult(object):
|
|||||||
self.idmap = None
|
self.idmap = None
|
||||||
self.names = None
|
self.names = None
|
||||||
self.domainsid = None
|
self.domainsid = None
|
||||||
|
self.adminpass_generated = None
|
||||||
|
self.adminpass = None
|
||||||
|
|
||||||
def report_logger(self, logger):
|
def report_logger(self, logger):
|
||||||
"""Report this provision result to a 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("Server Role: %s", self.server_role)
|
||||||
logger.info("Hostname: %s", self.names.hostname)
|
logger.info("Hostname: %s", self.names.hostname)
|
||||||
logger.info("NetBIOS Domain: %s", self.names.domain)
|
logger.info("NetBIOS Domain: %s", self.names.domain)
|
||||||
@ -388,7 +392,8 @@ class ProvisionResult(object):
|
|||||||
|
|
||||||
if self.paths.phpldapadminconfig is not None:
|
if self.paths.phpldapadminconfig is not None:
|
||||||
logger.info(
|
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)
|
self.paths.phpldapadminconfig)
|
||||||
|
|
||||||
|
|
||||||
@ -1790,16 +1795,17 @@ def provision(logger, session_info, credentials, smbconf=None,
|
|||||||
adminpass_generated = False
|
adminpass_generated = False
|
||||||
|
|
||||||
if samdb_fill == FILL_FULL:
|
if samdb_fill == FILL_FULL:
|
||||||
provision_fill(samdb, secrets_ldb, logger,
|
provision_fill(samdb, secrets_ldb, logger, names, paths,
|
||||||
names, paths, schema=schema, targetdir=targetdir,
|
schema=schema, targetdir=targetdir, samdb_fill=samdb_fill,
|
||||||
samdb_fill=samdb_fill, hostip=hostip, hostip6=hostip6, domainsid=domainsid,
|
hostip=hostip, hostip6=hostip6, domainsid=domainsid,
|
||||||
next_rid=next_rid, dc_rid=dc_rid, adminpass=adminpass,
|
next_rid=next_rid, dc_rid=dc_rid, adminpass=adminpass,
|
||||||
krbtgtpass=krbtgtpass, domainguid=domainguid,
|
krbtgtpass=krbtgtpass, domainguid=domainguid,
|
||||||
policyguid=policyguid, policyguid_dc=policyguid_dc,
|
policyguid=policyguid, policyguid_dc=policyguid_dc,
|
||||||
invocationid=invocationid, machinepass=machinepass,
|
invocationid=invocationid, machinepass=machinepass,
|
||||||
ntdsguid=ntdsguid, dns_backend=dns_backend, dnspass=dnspass,
|
ntdsguid=ntdsguid, dns_backend=dns_backend,
|
||||||
serverrole=serverrole, dom_for_fun_level=dom_for_fun_level,
|
dnspass=dnspass, serverrole=serverrole,
|
||||||
am_rodc=am_rodc, lp=lp)
|
dom_for_fun_level=dom_for_fun_level, am_rodc=am_rodc,
|
||||||
|
lp=lp)
|
||||||
|
|
||||||
create_krb5_conf(paths.krb5conf,
|
create_krb5_conf(paths.krb5conf,
|
||||||
dnsdomain=names.dnsdomain, hostname=names.hostname,
|
dnsdomain=names.dnsdomain, hostname=names.hostname,
|
||||||
@ -1845,8 +1851,11 @@ def provision(logger, session_info, credentials, smbconf=None,
|
|||||||
result.domainsid = str(domainsid)
|
result.domainsid = str(domainsid)
|
||||||
|
|
||||||
if samdb_fill == FILL_FULL:
|
if samdb_fill == FILL_FULL:
|
||||||
if adminpass_generated:
|
result.adminpass_generated = adminpass_generated
|
||||||
logger.info("Admin password: %s" % adminpass)
|
result.adminpass = adminpass
|
||||||
|
else:
|
||||||
|
result.adminpass_generated = False
|
||||||
|
result.adminpass = None
|
||||||
if provision_backend.type is not "ldb":
|
if provision_backend.type is not "ldb":
|
||||||
if provision_backend.credentials.get_bind_dn() is not None:
|
if provision_backend.credentials.get_bind_dn() is not None:
|
||||||
logger.info("LDAP Backend Admin DN: %s" %
|
logger.info("LDAP Backend Admin DN: %s" %
|
||||||
|
@ -152,7 +152,7 @@ class ProvisionResultTests(TestCase):
|
|||||||
result.report_logger(logger)
|
result.report_logger(logger)
|
||||||
return logger.entries
|
return logger.entries
|
||||||
|
|
||||||
def test_basic_report_logger(self):
|
def base_result(self):
|
||||||
result = ProvisionResult()
|
result = ProvisionResult()
|
||||||
result.server_role = "domain controller"
|
result.server_role = "domain controller"
|
||||||
result.names = ProvisionNames()
|
result.names = ProvisionNames()
|
||||||
@ -161,6 +161,10 @@ class ProvisionResultTests(TestCase):
|
|||||||
result.names.dnsdomain = "dnsdomein"
|
result.names.dnsdomain = "dnsdomein"
|
||||||
result.domainsid = "S1-1-1"
|
result.domainsid = "S1-1-1"
|
||||||
result.paths = ProvisionPaths()
|
result.paths = ProvisionPaths()
|
||||||
|
return result
|
||||||
|
|
||||||
|
def test_basic_report_logger(self):
|
||||||
|
result = self.base_result()
|
||||||
entries = self.report_logger(result)
|
entries = self.report_logger(result)
|
||||||
self.assertEquals(entries, [
|
self.assertEquals(entries, [
|
||||||
('INFO', 'Server Role: domain controller'),
|
('INFO', 'Server Role: domain controller'),
|
||||||
@ -170,15 +174,17 @@ class ProvisionResultTests(TestCase):
|
|||||||
('INFO', 'DOMAIN SID: S1-1-1')])
|
('INFO', 'DOMAIN SID: S1-1-1')])
|
||||||
|
|
||||||
def test_report_logger_phpldapadmin(self):
|
def test_report_logger_phpldapadmin(self):
|
||||||
result = ProvisionResult()
|
result = self.base_result()
|
||||||
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.paths.phpldapadminconfig = "/some/ldapconfig"
|
result.paths.phpldapadminconfig = "/some/ldapconfig"
|
||||||
entries = self.report_logger(result)
|
entries = self.report_logger(result)
|
||||||
self.assertEquals(entries[-1],
|
self.assertEquals(entries[-1],
|
||||||
("INFO", "A phpLDAPadmin configuration file suitable for administering the Samba 4 LDAP server has been created in /some/ldapconfig."))
|
("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'))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user