From dc0000e1a8f5233608d5bf59730200af3e041ce5 Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Thu, 28 Oct 2010 13:09:51 +0400 Subject: 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 Autobuild-Date: Sat Oct 30 14:26:22 UTC 2010 on sn-devel-104 --- source4/scripting/python/samba/provision.py | 16 +++++++++++++--- 1 file 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 -- cgit