[Samba] How to handle multi process open smb.conf at the time
ma at sernet.de
Tue Jul 8 21:04:08 GMT 2008
Jeremy Allison wrote:
> On Wed, Jul 09, 2008 at 12:39:13AM +0800, chenyun_zhou wrote:
> > Hi, everyone
> > I am try to write a program to edit smb.conf, and the question is "
> > If I open smb.conf for editing, but other process such as smbd , nmbd and winbind is reading the file, How to handle the this collision, and I want to open this file immediaetly ,and afte closing this file , tell these process to read it."
> Do what all other unix programs do in this circumstance.
> Create a temp smb.conf file and then do an atomic rename
> into place. The next time smbd/nmbd re-read the file (or
> when you tell them to do it via a MSG_SMB_CONF_UPDATED
> message) they'll see the new contents.
Let me draw your attention to the new registry based
configuration that is offered as a new feature in 3.2.0.
Configuration stored in samba's registry.tdb database
can be used if you activate it in a (minimal) smb.conf.
Then you can edit the configuration comfortably with
the new "net conf" command. (e.g. from scripts).
Since the tdb databases support locking, this method has
no problems with concurrent access.
To give you an idea, here is the list of subcommands of net conf:
net conf list Dump the complete configuration in smb.conf like format.
net conf import Import configuration from file in smb.conf format.
net conf listshares List the share names.
net conf drop Delete the complete configuration.
net conf showshare Show the definition of a share.
net conf addshare Create a new share.
net conf delshare Delete a share.
net conf setparm Store a parameter.
net conf getparm Retrieve the value of a parameter.
net conf delparm Delete a parameter.
net conf getincludes Show the includes of a share definition.
net conf setincludes Set includes for a share.
net conf delincludes Delete includes from a share definition.
This is simply the output of "net conf" without further arguements.
For details, see the smb.conf(5) and net(8) manpages.
Yesterday, I have also started to write a document about this at:
But is really only started, needs to be completed...
There also is a "libsmbconf" library that proveds an
interface to the configuration, but it is not yet provided
as a shared library.
In source/lib/netapi/examples/netdomjoin-gui/ you can
find an example gui program that uses libsmbconf to edit
parts of the configuration.
Cheers - Michael
Michael Adam <ma at sernet.de> <obnox at samba.org>
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.SerNet.DE, mailto: Info @ SerNet.DE
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 206 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba/attachments/20080708/ec5d9114/attachment.bin
More information about the samba