smb2www -

Richard Sharpe sharpe at
Thu Jan 3 20:04:02 GMT 2002

Andrew Bartlett wrote:

>Richard Sharpe wrote:
>>I guess I should look at this :-)
>I just started looking at this, and it looks to me like a fundamental
>design problem :-(

>The problem (IMHO) is that you are using global variables in your lib,
>preventing people from creating multiple contexts - in this case the
>ability to shut that context down.
Yes. The usage model we were thinking off was process based. We were 
trying to provide a Posix-like library, and did not think of a 
persistant script that needs to change context.

>As this is a part of Samba I actually want to use (the new smb2www
>sounds *really* neat) I put some thought into how I would fix it:
>smbc_init() returns a SMBC_CTX.

>All functions are pointers off that context, and take that context as
>their first arg.

>For backward compatibility, existing functions are replaced with new
>functions that use a static SMBC_CTX, initilised at startup in the same
>way the current stuff is.
OK, that should work. It would even allow programs coded to the existing 
interface to do a shutdown if they needed to. If smbc_init() is called 
twice, then does the static SMBC_CTX gets overwritten with the new one? 
 Hmmm, perhaps we need smbc_init(), like now, and then struct smbc_ctx_t 

>We then have the ability to sensibly do a smbc_destroy() without
>significant pain, and programs that accidentily use the lib twice don't
>get nasty shocks (becouse it should be up to the app to determine the
>scope for 'magic' connection reuse, not the lib).
>This would not only solve the problem mentioned, but would make the lib
>much more flexible.
>Other ideas I have:  I want to allow kerberos authentication via
>libsmbclient, because I'll be using mod_auth_krb5 on my webserver, and
>this will allow me to avoid passing passwords about :-).
I also want to extend libsmbclient. I want to provide a way to access 
all the extra bits than a Posix-like interface does not give you access to.

Having a vnode-like interface as well as the current posix-like 
interface would seem to solve that problem.

Richard Sharpe, rsharpe at, LPIC-1,, SAMS Teach Yourself Samba 
in 24 Hours, Special Edition, Using Samba

More information about the samba-technical mailing list