summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2009-10-21 19:38:52 +0200
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2009-10-21 23:43:04 +0200
commit33f3d54de4ffab239e107cb8c92a8454080adbf3 (patch)
tree50b92224090ade2d08324da0cfafb3f33adc6976 /source4/scripting
parent78a5e26783aa7a1beff5cd6674e9ff305a0a6390 (diff)
downloadsamba-33f3d54de4ffab239e107cb8c92a8454080adbf3.tar.gz
samba-33f3d54de4ffab239e107cb8c92a8454080adbf3.tar.bz2
samba-33f3d54de4ffab239e107cb8c92a8454080adbf3.zip
s4:provision - rework the "guess_names" and "make_smbconf" method
- Cleans it up from unnecessary "lower()/upper()" and parameters which can be derived through "lp" calls. - Substitute the "HOSTNAME" caption in the "smb.conf" templates with "NETBIOS_NAME" which fits better. - Now the "realm" and "domain" parameter of the provision are totally case insensitive and the script itself up/downcases them appropriately depending on the use (e.g. "realm" upcase for KERBEROS, lowcase for DNS domainname).
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/python/samba/provision.py55
1 files changed, 18 insertions, 37 deletions
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 10f4845fdf..d8c67908c2 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -428,59 +428,38 @@ def provision_paths_from_lp(lp, dnsdomain):
return paths
-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):
+def guess_names(lp=None, hostname=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].lower()
+ hostname = socket.gethostname().split(".")[0]
netbiosname = hostname.upper()
if not valid_netbios_name(netbiosname):
raise InvalidNetbiosName(netbiosname)
- hostname = hostname.lower()
+ dnsdomain = lp.get("realm").lower()
+ realm = lp.get("realm").upper()
+ serverrole = lp.get("server role").lower()
- if dnsdomain is None:
- dnsdomain = lp.get("realm").lower()
-
- if serverrole is None:
- serverrole = lp.get("server role")
-
- assert dnsdomain is not None
- realm = dnsdomain.upper()
-
- if lp.get("realm").upper() != realm:
- raise Exception("realm '%s' in %s must match chosen realm '%s'" %
- (lp.get("realm"), lp.configfile, realm))
-
if serverrole == "domain controller":
- if domain is None:
- domain = lp.get("workgroup")
+ domain = lp.get("workgroup").upper()
if domaindn is None:
domaindn = "DC=" + dnsdomain.replace(".", ",DC=")
- if lp.get("workgroup").upper() != domain.upper():
- raise Exception("workgroup '%s' in smb.conf must match chosen domain '%s'",
- lp.get("workgroup"), domain)
else:
domain = netbiosname
if domaindn is None:
domaindn = "DC=" + netbiosname
- assert domain is not None
- domain = domain.upper()
-
if not valid_netbios_name(domain):
raise InvalidNetbiosName(domain)
- if netbiosname.upper() == realm:
+ if netbiosname == realm:
raise Exception("realm %s must not be equal to netbios domain name %s", realm, netbiosname)
- if hostname.upper() == realm:
- raise Exception("realm %s must not be equal to hostname %s", realm, hostname)
-
- if domain.upper() == realm:
+ if domain == realm:
raise Exception("realm %s must not be equal to domain name %s", realm, domain)
if rootdn is None:
@@ -520,7 +499,8 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
"""
assert smbconf is not None
if hostname is None:
- hostname = socket.gethostname().split(".")[0].lower()
+ hostname = socket.gethostname().split(".")[0]
+ netbiosname = hostname.upper()
if serverrole is None:
serverrole = "standalone"
@@ -534,7 +514,10 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
smbconfsuffix = "standalone"
assert domain is not None
+ domain = domain.upper()
+
assert realm is not None
+ realm = realm.upper()
default_lp = param.LoadParm()
#Load non-existant file
@@ -555,7 +538,7 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
setup_file(setup_path("provision.smb.conf.%s" % smbconfsuffix),
smbconf, {
- "HOSTNAME": hostname,
+ "NETBIOS_NAME": netbiosname,
"DOMAIN": domain,
"REALM": realm,
"SERVERROLE": serverrole,
@@ -1265,10 +1248,8 @@ def provision(setup_dir, message, session_info,
lp = param.LoadParm()
lp.load(smbconf)
- names = guess_names(lp=lp, hostname=hostname, domain=domain,
- dnsdomain=realm.lower(), serverrole=serverrole, sitename=sitename,
- rootdn=rootdn, domaindn=domaindn, configdn=configdn, schemadn=schemadn,
- serverdn=serverdn)
+ names = guess_names(lp=lp, hostname=hostname, domaindn=domaindn,
+ configdn=configdn, schemadn=schemadn, serverdn=serverdn, sitename=sitename)
paths = provision_paths_from_lp(lp, names.dnsdomain)