Are there Python3 libraries for the net commands and etc?

John Mulligan phlogistonjohn at
Thu Mar 31 22:40:05 UTC 2022

On Thursday, March 31, 2022 4:02:32 PM EDT Richard Sharpe wrote:
> On Thu, Mar 31, 2022 at 10:57 AM John Mulligan via samba-technical
> <samba-technical at> wrote:
> > > We don't have bindings for these right now. It probably wouldn't be
> > > difficult to add them though.
> > 
> > I'm interested in contributing patches for this. I've already looked at
> > the
> > code needed to be wrapped (lib/smbconf and source3/lib/smbconf). I've even
> > started prototyping.  I've done C/Python APIs before, but it's been a
> > while
> > and I'm rusty, so I'll probably start by making a draft merge request for
> > a
> > subset of these API to get early feedback.
> How were you planning on dealing with the 'net conf list output'? As a
> list of dictionaries, one per section or a dictionary of dictionaries?

The bindings are a bit low level, so my plan is to map the `struct 
smbconf_service` to a tuple, like so:
(<name>, [(<param-name 0>, <param-value 0>), (<param-name 1>, <param-value 
That's a two-tuple of the share/section name, an then a list of two-tuples 
each as a pair for the param name & param value.  It's very easy to go back 
and forth between a dict and a list of key-value pairs.  Once the low level 
bindings are more in shape we can also discuss if there should be a more 
"pythonic" wrapper on top.  

For example, I want to have a python function that implements the equivalent 
of `net conf import` but I'd rather (re)implement the logic in python not C. 
And if so, we'll need another py file in the samba tree for that. It could 
contain other useful wrapper types and functions. We'll see what others think 
when it comes time... :-)

I just filed a draft MR with my prototype. Please feel free to provide feedback 
on this attempt so far:

More information about the samba-technical mailing list