summaryrefslogtreecommitdiff
path: root/source4/scripting/python
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2010-10-28 13:09:51 +0400
committerMatthieu Patou <mat@samba.org>2010-10-30 14:26:22 +0000
commitdc0000e1a8f5233608d5bf59730200af3e041ce5 (patch)
treed6ba903c00d6fe3be10b4c0792e84b01ba439769 /source4/scripting/python
parentedebb76a616c40565383363bc240c0df50a850f3 (diff)
downloadsamba-dc0000e1a8f5233608d5bf59730200af3e041ce5.tar.gz
samba-dc0000e1a8f5233608d5bf59730200af3e041ce5.tar.bz2
samba-dc0000e1a8f5233608d5bf59730200af3e041ce5.zip
provision: when deriving netbiosname from hostname force the netbiosname to be compliant
It means no space/_/-/@.... and less than 16 chars. Autobuild-User: Matthieu Patou <mat@samba.org> Autobuild-Date: Sat Oct 30 14:26:22 UTC 2010 on sn-devel-104
Diffstat (limited to 'source4/scripting/python')
-rw-r--r--source4/scripting/python/samba/provision.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 5205ba5fa5..49ad5d755d 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -443,6 +443,11 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
netbiosname = lp.get("netbios name")
if netbiosname is None:
netbiosname = hostname
+ # remove forbidden chars
+ for char in " !#$%&'()-.@^_{}~":
+ netbiosname = "".join(netbiosname.split(char))
+ #force the length to be <16
+ netbiosname = netbiosname[0:15]
assert netbiosname is not None
netbiosname = netbiosname.upper()
if not valid_netbios_name(netbiosname):
@@ -534,7 +539,14 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
assert smbconf is not None
if hostname is None:
hostname = socket.gethostname().split(".")[0]
- netbiosname = hostname.upper()
+ netbiosname = hostname.upper()
+ # remove forbidden chars
+ for char in " !#$%&'()-.@^_{}~":
+ netbiosname = "".join(netbiosname.split(char))
+ #force the length to be <16
+ netbiosname = netbiosname[0:15]
+ else:
+ netbiosname = hostname.upper()
if serverrole is None:
serverrole = "standalone"
@@ -1436,12 +1448,10 @@ def provision(setup_dir, logger, session_info,
lp = samba.param.LoadParm()
lp.load(smbconf)
-
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)
paths.bind_gid = bind_gid