Samba config grammar

Christopher R. Hertel crh at ubiqx.mn.org
Wed Dec 21 11:47:24 MST 2011


Back in the Samba 2.0 days I wrote a full syntax for the smb.conf file
format.  The text copied below (thanks, Jelmer) is based upon that full
syntax.  I've gone digging and found a copy of the original text file.  It's
14 years old, but I don't think the syntax of the smb.conf file has changed
all that much since then.

Chris -)-----

Jelmer Vernooij wrote:
> On 12/21/2011 07:35 PM, Adam Przybyla wrote:
>> On Wed, Dec 21, 2011 at 10:13:07AM -0600, Christopher R. Hertel wrote:
>>> Do you mean the grammar of the smb.conf file or the grammar of the
> protocol?
>> ... grammar of the config file.
> The closest thing we have is probably the header of lib/util/params.c in
> the source tree.
> 
>  *  This module performs lexical analysis and initial parsing of a
>  *  Windows-like parameter file.  It recognizes and handles four token
>  *  types:  section-name, parameter-name, parameter-value, and
>  *  end-of-file.  Comments and line continuation are handled
>  *  internally.
>  *
>  *  The entry point to the module is function pm_process().  This
>  *  function opens the source file, calls the Parse() function to parse
>  *  the input, and then closes the file when either the EOF is reached
>  *  or a fatal error is encountered.
>  *
>  *  A sample parameter file might look like this:
>  *
>  *  [section one]
>  *  parameter one = value string
>  *  parameter two = another value
>  *  [section two]
>  *  new parameter = some value or t'other
>  *
>  *  The parameter file is divided into sections by section headers:
>  *  section names enclosed in square brackets (eg. [section one]).
>  *  Each section contains parameter lines, each of which consist of a
>  *  parameter name and value delimited by an equal sign.  Roughly, the
>  *  syntax is:
>  *
>  *    <file>            :==  { <section> } EOF
>  *
>  *    <section>         :==  <section header> { <parameter line> }
>  *
>  *    <section header>  :==  '[' NAME ']'
>  *
>  *    <parameter line>  :==  NAME '=' VALUE '\n'
>  *
>  *  Blank lines and comment lines are ignored.  Comment lines are lines
>  *  beginning with either a semicolon (';') or a pound sign ('#').
>  *
>  *  All whitespace in section names and parameter names is compressed
>  *  to single spaces.  Leading and trailing whitespace is stipped from
>  *  both names and values.
>  *
>  *  Only the first equals sign in a parameter line is significant.
>  *  Parameter values may contain equals signs, square brackets and
>  *  semicolons.  Internal whitespace is retained in parameter values,
>  *  with the exception of the '\r' character, which is stripped for
>  *  historic reasons.  Parameter names may not start with a left square
>  *  bracket, an equal sign, a pound sign, or a semicolon, because these
>  *  are used to identify other tokens.
> 
> Cheers,
> 
> Jelmer

-- 
"Implementing CIFS - the Common Internet FileSystem" ISBN: 013047116X
Samba Team -- http://www.samba.org/     -)-----   Christopher R. Hertel
jCIFS Team -- http://jcifs.samba.org/   -)-----   ubiqx development, uninq.
ubiqx Team -- http://www.ubiqx.org/     -)-----   crh at ubiqx.mn.org
OnLineBook -- http://ubiqx.org/cifs/    -)-----   crh at ubiqx.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parsing.doc
Type: application/msword
Size: 12916 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20111221/df4d2f6d/attachment.doc>


More information about the samba-technical mailing list