Using env variables to config Samba (was Re: ideas for multiple group macro expansion)

Nicolas Williams Nicolas.Williams at wdr.com
Thu Mar 25 15:29:15 GMT 1999


On Thu, Mar 25, 1999 at 09:16:32AM -0600, Andy Bakun wrote:
> Sorry that this is an older message, but I had a few questions.

NP.

> Nicolas Williams wrote:
> 
> > On Thu, Mar 18, 1999 at 07:36:52AM +1100, Andy Bakun wrote:
> > > Every day samba gets closer to having more complete NT acl and group
> > > support, and it would be nice to be able to do things on the samba side
> > > that take greater advantage of multiple groups.  One area I think is
> > > lacking is the expansion of the group macros %g and %G, which only expand
> > > to the primary group.  It would be nice to have expansions for all the
> > > groups.  Here are a few ideas.
> > Yes.
> 
> > We make much use of %$(env var name) syntax in smb.conf.
> >
> > Here's an idea:
> >
> > A new parameter called "source environment" that would take a file name
> > or a pipeline (ending with a '|') whose contents/output would be a set
> > of variable="value" pairs that would then be set in the environment.
> >
> > Those environment variables would then be available for use via %$()
> > syntax after the 'source environment' parameter.
> >
> > Of course, the various standard % macros could be used in 'source
> > environment' parameters as well.
> >
>
> Where can I docs and source on the %$() syntax?  And by "the environment" do you
> mean the samba parameters or the process's environment variables?  And if you
> mean the process's environment variables, can you explain how setting those is
> useful.  I think I'm missing something.

Environment variable token expansion is not documented. But it is
present in Samba 1.9.x and Samba 2.x and I've been told, on this list,
by Samba Team members, that it's not going to go away; it just needs to
be documented.

Yes, %$(<varname>) syntax expands to the value of the environment
variable named <varname>; that's "environment" as in putenv()/getenv(),
i.e., Samba uses getenv() to get at the variables' values; you can set
these variables in a start/stop shell script prior to starting Samba.

This feature is useful to use because we can make sure that ALL Samba
servers use the same basic, standard config file which sets all
server-specific parameters using environment variables; local share
definitions go in a separate file which the standard config file
includes at the end (the path name of that include file, of course, is
given, partially, by an environment variable).

Having a standard configuration across the board helps us provide
in-house support for Samba. At the same time, our configuration system
is very flexible, but only within certain bounds. Also, we keep the
environment variable settings in a separate file, /etc/smb.conf.env,
and this makes it very easy to examine any given Samba server's
configuration.

> Andy.
> 

Nico

PS: I am posting this reply to the Samba list; it may prove useful to
    others.


More information about the samba mailing list