smbcacls.c internals

Brett A. Funderburg brettf at deepfile.com
Fri Apr 25 15:54:21 GMT 2003


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?

Does the following pseudo-code look like I'm on the right track?

/* C struct/PyObject representing an SMB connection */
struct ConnectionObject {
  pstring username;
  fstring password;
  ... /* 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 */
  ...
}

thanks,

brett



More information about the samba-technical mailing list