generalising source of smb.conf

nigel.williams at nomura.co.uk nigel.williams at nomura.co.uk
Tue Mar 30 17:54:05 GMT 1999


Hi

I hope to implement access to Samba configuration parameters from LDAP 
in the next few weeks.  I think generalising the way the configuration 
source is specified could be the most simple method of integration. I 
have written some notes suggesting how it may be done.  Is anybody 
already working on this? Would this be of general use? If it could be 
merged into Samba, are there any suggestions for simple modifications 
that may make it more compatible. 

Nigel Williams

LDAP storage format
-------------------

Hierarchical storage 

Split on type (application server, home server ...) then domain, then 
hostname. (specific to this site)

To generate a config file start from root and follow path as far as 
possible overlaying options. 

Updating the LDAP storage
-------------------------

Initially. Store data in text format using directories to provide 
structure. This will 
provide text backup. 

Write a make script to update storage.

Eventually. Allow modification in place. 

locking ... 

Method
------

Create URL style syntax for configuration files.  Associate functions 
with URL types 

e.g. smb.conf, file://localhost/etc/smb.conf, 
ldap://[host=%m,hostdomain=nt.dev.uk,hosttype=core_server],U=Samba,OU=ap
ps,l=eu,o=nomura.com

Dynamically load (dlopen(), dlsym()) modules to handle types (file, 
ldap ...) specified in the URL (default to local file).

The module parses the name to provide a 

1. path         (opaque argument to read/stat method. May locate host 
in host type space.)
2. stat method  (get modification date)
3. read method  (extract data and write to local file.  Return path to 
local file)
 
Functions to modify
-------------------

param/loadparam.c
-----------------

add_to_file_list()

Check file name format.  Set stat method for the file. Each entry in 
the linked list could have a pointer to the stat method for its 
associated file. The stat method would take the "path" as an argument. 

handle_include()

Get read file method for file name.  Call the read file method 
associated with the file name.  This function 
should take the "path" as an argument and return the name of a local 
file that it has created.  This file will contain the configuration 
data. The filename can then be passed on to lp_load().

As there may be many processes all accessing configuration data care 
must be taken to ensure that configuration files are not created for 
each process.  The filename of the file should contain the modification 
date of the LDAP data.  The read method can check the modified date 
using the stat method, fabricate the filename and then check for its 
existence.  Old files should be deleted whenever a new one has been 
created.

lp_file_list_changed

Use stat method for file to check modification date.

lp_load ?

A change to this function may be required. It is called directly (i.e. 
not from reload services) in several pieces of Samba code and passed 
the configuration file name.  It may be best to get a pointer to and 
run the read-file method within this code so that all files are caught 
including those given on the command line.      

smbd/server.c
nmbd/server.c
-------------

reload_services

This function calls lp_load() passing the return value of 
lp_configfile().

It may be a good point to check for source type and read method.


More information about the samba-technical mailing list