[SCM] Samba Shared Repository - branch master updated

Jelmer Vernooij jelmer at vernstok.nl
Sat Oct 30 10:13:08 MDT 2010


Hi Matthieu,

On Sat, 2010-10-30 at 16:27 +0200, Matthieu Patou wrote:
> - Log -----------------------------------------------------------------
> commit dc0000e1a8f5233608d5bf59730200af3e041ce5
> Author: Matthieu Patou <mat at matws.net>
> Date:   Thu Oct 28 13:09:51 2010 +0400
> 
>     provision: when deriving netbiosname from hostname force the netbiosname to be compliant
>     
>     It means no space/_/-/@.... and less than 16 chars.
>     
> diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
> index 5205ba5..49ad5d7 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))
This logic is flawed - those characters are the ones that are allowed
(in addition to alphanumeric characters). Any other characters should be
stripped out. 

It would also be nice if we could share the list of acceptable NetBIOS
name characters between these two functions. 

> +        #force the length to be <16
> +        netbiosname = netbiosname[0:15]
If we have to do this sort of mangling I wonder if we shouldn't better
raise an error and let the user specify a name. 

Cheers,

Jelmer


More information about the samba-cvs mailing list