summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/python/samba/provision/__init__.py18
-rw-r--r--source4/scripting/python/samba/upgrade.py13
2 files changed, 19 insertions, 12 deletions
diff --git a/source4/scripting/python/samba/provision/__init__.py b/source4/scripting/python/samba/provision/__init__.py
index c00c2e8481..d0e6461930 100644
--- a/source4/scripting/python/samba/provision/__init__.py
+++ b/source4/scripting/python/samba/provision/__init__.py
@@ -1651,6 +1651,22 @@ def provision(logger, session_info, credentials, smbconf=None,
:note: caution, this wipes all existing data!
"""
+ roles = {}
+ roles["ROLE_STANDALONE"] = "standalone"
+ roles["ROLE_DOMAIN_MEMBER"] = "member server"
+ roles["ROLE_DOMAIN_BDC"] = "domain controller"
+ roles["ROLE_DOMAIN_PDC"] = "domain controller"
+ roles["dc"] = "domain controller"
+ roles["member"] = "member server"
+ roles["domain controller"] = "domain controller"
+ roles["member server"] = "member server"
+ roles["standalone"] = "standalone"
+
+ try:
+ serverrole = roles[serverrole]
+ except KeyError:
+ raise ProvisioningError('server role (%s) should be one of "domain controller", "member server", "standalone"' % serverrole)
+
if ldapadminpass is None:
# Make a new, random password between Samba and it's LDAP server
ldapadminpass=samba.generate_random_password(128, 255)
@@ -1742,8 +1758,6 @@ def provision(logger, session_info, credentials, smbconf=None,
if serverrole is None:
serverrole = lp.get("server role")
- assert serverrole in ("domain controller", "member server", "standalone")
-
if not os.path.exists(paths.private_dir):
os.mkdir(paths.private_dir)
if not os.path.exists(os.path.join(paths.private_dir, "tls")):
diff --git a/source4/scripting/python/samba/upgrade.py b/source4/scripting/python/samba/upgrade.py
index 5be2eab02b..0636d2bac5 100644
--- a/source4/scripting/python/samba/upgrade.py
+++ b/source4/scripting/python/samba/upgrade.py
@@ -463,14 +463,7 @@ def upgrade_from_samba3(samba3, logger, targetdir, session_info=None, useeadb=Fa
:param targetdir: samba4 database directory
:param session_info: Session information
"""
-
- if samba3.lp.get("domain logons"):
- serverrole = "domain controller"
- else:
- if samba3.lp.get("security") == "user":
- serverrole = "standalone"
- else:
- serverrole = "member server"
+ serverrole = samba3.lp.server_role()
domainname = samba3.lp.get("workgroup")
realm = samba3.lp.get("realm")
@@ -488,7 +481,7 @@ def upgrade_from_samba3(samba3, logger, targetdir, session_info=None, useeadb=Fa
domainname)
if not realm:
- if serverrole == "domain controller":
+ if serverrole == "ROLE_DOMAIN_BDC" or serverrole == "ROLE_DOMAIN_PDC":
raise ProvisioningError("No realm specified in smb.conf file and being a DC. That upgrade path doesn't work! Please add a 'realm' directive to your old smb.conf to let us know which one you want to use (it is the DNS name of the AD domain you wish to create.")
else:
realm = domainname.upper()
@@ -632,7 +625,7 @@ Please fix this account before attempting to upgrade again
logger.error(" %s" % str(sid))
raise ProvisioningError("Please remove duplicate sid entries before upgrade.")
- if serverrole == "domain controller":
+ if serverrole == "ROLE_DOMAIN_BDC" or serverrole == "ROLE_DOMAIN_PDC":
dns_backend = "BIND9_FLATFILE"
else:
dns_backend = "NONE"