smbcacls.c internals

Andrew Bartlett abartlet at samba.org
Fri Apr 25 16:05:09 GMT 2003


On Sat, 2003-04-26 at 01:54, Brett A. Funderburg wrote:
> I am looking at the internals of smbcacls with an eye towards
> implementing python bindings for its functionality. However, I would
> like to be able to handle multiple connections at a time.
> 
> What is the purpose of the TALLOC_CTX struct declared at module scope?
> Should/can there be one per connection?
> Why isn't cli_shutdown or cli_close_connection called in this code?
> Shouldn't the client close the connection prior to the exe exiting?

smbcacls is showing it's age - it's certainly not written in anything
like the way the 'net' is written - considered probably the cleanest of
our client tools.

All the issues you raised sound like 'well, it works' kind of bugs - for
a short-lived client tool, one could argue that not shutting down (the
server will do that after we exit) and other such things can be
tolerated - but feel free to clean them up.

Even better would be to have a 'net acls' that took in this code, and
hung it off the 'net' infrustrcture.  (Which handles getting connections
etc all in once place).


> Does the following pseudo-code look like I'm on the right track?
> 
> /* C struct/PyObject representing an SMB connection */
> struct ConnectionObject {
>   pstring username;

Avoid pstrings

>   fstring password;

Avoid fstrings too.

>   ... /* server, workgroup, etc. */
>   TALLOC_CTX* ctx; /* one per connection */
>   cli_state* cli; /* one per connection */
> }
> 
> /* python module method */
> connect() {
>   /* allocate a ConnectionObject co */
>   ...
>   /* copy username, password, etc. into co struct members */
>   ...
>   /* initialize context */
>   co->ctx = talloc_init();
>   /* do connection */
>   co->cli = connect_one(share);
> 
>   return co;
> }
> 
> ... use co->cli in functions requiring a cli_state pointer ...
> 
> quit()
> {
>   cli_shutdown(co->cli);
>   talloc_destroy(co->ctx);
>   ...
>   /* free co */
>   ...
> }

Looks like a start - I assume this is in 3.0, based with the rest of the
python code?

Andrew Bartlett

-- 
Andrew Bartlett                                 abartlet at pcug.org.au
Manager, Authentication Subsystems, Samba Team  abartlet at samba.org
Student Network Administrator, Hawker College   abartlet at hawkerc.net
http://samba.org     http://build.samba.org     http://hawkerc.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.samba.org/archive/samba-technical/attachments/20030426/2bc956ee/attachment.bin


More information about the samba-technical mailing list