summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2009-10-22 09:17:27 +0200
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2009-10-22 09:17:27 +0200
commit2b82b8e2d36ca65a6bbb1c92e5d1a9bdf2106927 (patch)
tree523ffa359a3215ac6e136ed9a526b8609a60a954 /source4/scripting
parentfc97c60c56c0492c923743b7e3190fa06cad6e90 (diff)
downloadsamba-2b82b8e2d36ca65a6bbb1c92e5d1a9bdf2106927.tar.gz
samba-2b82b8e2d36ca65a6bbb1c92e5d1a9bdf2106927.tar.bz2
samba-2b82b8e2d36ca65a6bbb1c92e5d1a9bdf2106927.zip
s4:provision - Reintroduce accidentally removed parameters and checks from "guess_names"
abartlet pointed out that those are essential for a safe and consistent provision.
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/python/samba/provision.py51
1 files changed, 38 insertions, 13 deletions
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index d8c67908c2..f3011521d4 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -428,24 +428,46 @@ def provision_paths_from_lp(lp, dnsdomain):
return paths
-def guess_names(lp=None, hostname=None, rootdn=None,
- domaindn=None, configdn=None, schemadn=None, serverdn=None,
- sitename=None, sambadn=None):
+def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
+ serverrole=None, rootdn=None, domaindn=None, configdn=None,
+ schemadn=None, serverdn=None, sitename=None, sambadn=None):
"""Guess configuration settings to use."""
if hostname is None:
hostname = socket.gethostname().split(".")[0]
- netbiosname = hostname.upper()
+ netbiosname = lp.get("netbios name")
+ if netbiosname is None:
+ netbiosname = hostname
+ assert netbiosname is not None
+ netbiosname = netbiosname.upper()
if not valid_netbios_name(netbiosname):
raise InvalidNetbiosName(netbiosname)
- dnsdomain = lp.get("realm").lower()
- realm = lp.get("realm").upper()
- serverrole = lp.get("server role").lower()
+ if dnsdomain is None:
+ dnsdomain = lp.get("realm")
+ assert dnsdomain is not None
+ dnsdomain = dnsdomain.lower()
+
+ if serverrole is None:
+ serverrole = lp.get("server role")
+ assert serverrole is not None
+ serverrole = serverrole.lower()
+
+ realm = dnsdomain.upper()
+
+ if lp.get("realm").upper() != realm:
+ raise ProvisioningError("guess_names: Realm '%s' in smb.conf must match chosen realm '%s'!", lp.get("realm").upper(), realm)
if serverrole == "domain controller":
- domain = lp.get("workgroup").upper()
+ if domain is None:
+ domain = lp.get("workgroup")
+ assert domain is not None
+ domain = domain.upper()
+
+ if lp.get("workgroup").upper() != domain:
+ raise ProvisioningError("guess_names: Workgroup '%s' in smb.conf must match chosen domain '%s'!", lp.get("workgroup").upper(), domain)
+
if domaindn is None:
domaindn = "DC=" + dnsdomain.replace(".", ",DC=")
else:
@@ -456,11 +478,12 @@ def guess_names(lp=None, hostname=None, rootdn=None,
if not valid_netbios_name(domain):
raise InvalidNetbiosName(domain)
+ if hostname.upper() == realm:
+ raise ProvisioningError("guess_names: Realm '%s' must not be equal to hostname '%s'!", realm, hostname)
if netbiosname == realm:
- raise Exception("realm %s must not be equal to netbios domain name %s", realm, netbiosname)
-
+ raise ProvisioningError("guess_names: Realm '%s' must not be equal to netbios hostname '%s'!", realm, netbiosname)
if domain == realm:
- raise Exception("realm %s must not be equal to domain name %s", realm, domain)
+ raise ProvisioningError("guess_names: Realm '%s' must not be equal to short domain name '%s'!", realm, domain)
if rootdn is None:
rootdn = domaindn
@@ -1248,8 +1271,10 @@ def provision(setup_dir, message, session_info,
lp = param.LoadParm()
lp.load(smbconf)
- names = guess_names(lp=lp, hostname=hostname, domaindn=domaindn,
- configdn=configdn, schemadn=schemadn, serverdn=serverdn, sitename=sitename)
+ names = guess_names(lp=lp, hostname=hostname, domain=domain,
+ dnsdomain=realm, serverrole=serverrole,
+ domaindn=domaindn, configdn=configdn, schemadn=schemadn,
+ serverdn=serverdn, sitename=sitename)
paths = provision_paths_from_lp(lp, names.dnsdomain)