1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-13 08:59:08 +03:00

Rework provision scripts for more testing

This fixes up some issues with testdir (was not honoured) and
increases test coverage.

We now check all the major provision modes.  In doing so, to make it
possible to call from the multiple layers of 'sh', I have allowed 'dc'
to alias 'domain controller' and 'member' to alias 'member server'.
Fighting shell quoting in the test system was just too hard...

Also fix upgrade.py

Andrew Bartlett
(This used to be commit 0923de1228)
This commit is contained in:
Andrew Bartlett
2008-03-07 10:57:52 +11:00
parent 45149fbf9d
commit 14c5f968e1
8 changed files with 41 additions and 32 deletions

View File

@ -572,9 +572,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
:note: This will wipe the main SAM database file!
"""
assert serverrole in ("domain controller", "member server")
erase = (fill != FILL_DRS)
erase = (fill != FILL_DRS)
# Also wipes the database
setup_samdb_partitions(path, setup_path, schemadn=schemadn, configdn=configdn,
@ -796,17 +794,22 @@ def provision(setup_dir, message, session_info,
if not os.path.exists(os.path.join(targetdir, "etc")):
os.mkdir(os.path.join(targetdir, "etc"))
if smbconf is None:
smbconf = os.path.join(targetdir, os.path.join("etc", "smb.conf"))
smbconf = os.path.join(targetdir, os.path.join("etc", "smb.conf"))
# only install a new smb.conf if there isn't one there already
if not os.path.exists(smbconf):
message("Setting up smb.conf")
assert serverrole is not None
if serverrole is None:
serverrole = "standalone"
assert serverrole in ("domain controller", "member server", "standalone")
if serverrole == "domain controller":
smbconfsuffix = "dc"
elif serverrole == "member server":
smbconfsuffix = "member"
elif serverrole == "standalone":
smbconfsuffix = "standalone"
assert domain is not None
assert realm is not None
@ -827,8 +830,8 @@ def provision(setup_dir, message, session_info,
setup_file(setup_path("provision.smb.conf.%s" % smbconfsuffix),
smbconf, {
"HOSTNAME": hostname,
"DOMAIN_CONF": domain,
"REALM_CONF": realm,
"DOMAIN": domain,
"REALM": realm,
"SERVERROLE": serverrole,
"NETLOGONPATH": netlogon,
"SYSVOLPATH": sysvol,
@ -841,7 +844,7 @@ def provision(setup_dir, message, session_info,
if serverrole is None:
serverrole = lp.get("server role")
assert serverrole in ("domain controller", "member server")
assert serverrole in ("domain controller", "member server", "standalone")
if invocationid is None and serverrole == "domain controller":
invocationid = uuid.random()
@ -851,6 +854,10 @@ def provision(setup_dir, message, session_info,
assert realm is not None
realm = realm.upper()
if lp.get("realm").upper() != realm.upper():
raise Exception("realm '%s' in %s must match chosen realm '%s'" %
(lp.get("realm"), smbconf, realm))
dnsdomain = realm.lower()
paths = provision_paths_from_lp(lp, dnsdomain)
@ -896,10 +903,6 @@ def provision(setup_dir, message, session_info,
message("Provisioning for %s in realm %s" % (domain, realm))
message("Using administrator password: %s" % adminpass)
if lp.get("realm").upper() != realm.upper():
raise Exception("realm '%s' in smb.conf must match chosen realm '%s'" %
(lp.get("realm"), realm))
# only install a new shares config db if there is none
if not os.path.exists(paths.shareconf):
message("Setting up share.ldb")

View File

@ -218,11 +218,9 @@ def upgrade_provision(samba3, setup_dir, message, credentials, session_info, lp,
else:
serverrole = "member server"
lp.set("server role", serverrole)
domainname = oldconf.get("workgroup")
if domainname:
domainname = str(domainname)
lp.set("workgroup", domainname)
realm = oldconf.get("realm")
netbiosname = oldconf.get("netbios name")
@ -235,7 +233,6 @@ def upgrade_provision(samba3, setup_dir, message, credentials, session_info, lp,
if realm is None:
realm = domainname.lower()
message("No realm specified in smb.conf file, assuming '%s'\n" % realm)
lp.set("realm", realm)
domainguid = secrets_db.get_domain_guid(domainname)
domainsid = secrets_db.get_sid(domainname)
@ -247,7 +244,7 @@ def upgrade_provision(samba3, setup_dir, message, credentials, session_info, lp,
else:
machinepass = None
domaindn = provision(lp=lp, setup_dir=setup_dir, message=message,
domaindn = provision(setup_dir=setup_dir, message=message,
samdb_fill=FILL_DRS, paths=paths, session_info=session_info,
credentials=credentials, realm=realm,
domain=domainname, domainsid=domainsid, domainguid=domainguid,