Samba 2.0.7: bug regarding environment variables and WORKGROUP

Dirk De Wachter Dirk.DeWachter at
Fri Apr 28 13:23:25 GMT 2000

Dear Jeremy,
Dear Samba Developers,

A. Environment variables in service parameters
Since some time I use environment variables to fill in my "hosts 
allow" parameter:
hosts allow = %$(these_hosts) %$(those_hosts)

As 2.0.7 allows the use of the source environment parameter, I 
decided to switch for flexibility (no restart to change environment). 
However my machine was not allowed to connect, neither with the old 
method or the new parameter.
Debugging revealed the culprit:
at line 1142 of param/loadparm.c the following line is detected:

> ret = (char *)talloc(lp_talloc, len + 100); 
> /* leave room for substitution */

This line creates *ONLY* 100 extra character positions for the value 
of the environment parameter. As my "these_hosts" list is rather long 
(the enumeration of our workgroup at our subnet), it will not fit 
into 100 characters plus the length of "%$(these_hosts)" and 
therefore the value for the szHostsallow parameter is incorrectly 
parsed and becomes too short. The hosts skipped are disallowed 

I tried to increase 100 to 1024 (the length of a true pstring), 
however this crashed the server. Is it possible to either
1. include a check for the length of the environment parameter OR
2. allow more room for substitution (preferred)?
Of course, as it is now, the maximum length of the szHostallow (and 
other) parameters remains 1024 characters (which I still comply to).

Remark: currently I use 2.0.5a with my old method of predefined 
environment and this poses no problems whatsoever.

It also revealed another "parsing" problem. Environment variables 
read via the "source environment" parameter need to be on 1 line: 
i.e. the line continuation character '\' is not parsed but translated 
to '_'.

The second problem is related to smbclient.
The default smb.conf configuration file contains only one important 
config file = /etc/opt/samba/smb.conf
The default config file is in the normal (compiled!) configuration 
directory (/opt/samba/config). As this directory may be NFS mounted, 
the actual (local, machine dependent) config file should reside 
elsewhere. The default workgroup name is WORKGROUP (compiled!). The 
actual workgroup should be specified in the configuration file. As 
different machines that NFSmount the samba suite may have different 
workgroups, the actual workgroup name is normally found in the 
/etc/opt/samba/smb.conf file.
In samba suite 2.0.5a, running smbclient in this fashion produces no 
problems. However in 2.0.7 smbclient uses the compiled workgroup 
WORKGROUP to validate users credentials EVEN if the option -W is 
used. Only by specifying the workgroup parameter in the default 
/opt/samba/config/smb.conf configuration file, produces the correct 

Currently, I have no idea where to look for the cause of this bug.

Final remark: I'm no longer on this list, please post & e-mail any 
response. I also apologize not having tried any 2.0.7pre versions to 
detect these defects earlier, as my main job now lies elsewhere.

Best regards,

Dirk De Wachter

Dirk De Wachter, MScEE, MScBME, PhD      mailto:Dirk.DeWachter at
postdoctoral fellow, systems administrator
Hydraulics Laboratory, Ibitech, University of Gent  voice:+32 9 264 3281
Sint-Pietersnieuwstraat 41, B-9000 Gent Belgium     faxto:+32 9 264 3595

More information about the samba-technical mailing list