The branch, master has been updated via f9df57043e4 lib/smbconf: add python wrapper functions for transaction management via cc26fe829cb lib/smbconf: add delete_global_parameter method to SMBConf via 64a36f5bf02 lib/smbconf: add delete_parameter method to SMBConf via 2b6bd70cdcc lib/smbconf: add create_set_share method to SMBConf via 7e4bc41983a lib/smbconf: add delete_share method to SMBConf via 35df07d5ca6 lib/smbconf: add set_global_parameter method to SMBConf via 565d8ae8cdf lib/smbconf: add set_parameter method to SMBConf via ff603de514b lib/smbconf: add drop method to SMBConf via eb84f67e80c lib/smbconf: add create_share method to SMBConf via 67807a642a8 python/samba/tests: add test cases for s3/registry init funcs via 733ac02b297 source3/lib/smbconf: add python bindings for init functions via fcd50ea4ab4 lib/smbconf: add a python function for raising smbconf exceptions via f74d163ef08 lib/smbconf: move python smbconf type definition to header via f0e157747fa s3/lib/smbconf: add talloc_stackframe to smbconf_init_reg via 3453ab99943 s3/lib/smbconf: replace uses of talloc_tos with talloc_stackframe from e008c8f8303 python/gp_cert_auto_enroll: removed unused imports
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit f9df57043e487d951e371367ebe41e1ed0124959 Author: John Mulligan <jmulli...@redhat.com> Date: Mon Apr 25 12:04:20 2022 -0400 lib/smbconf: add python wrapper functions for transaction management The smbconf API supports transactions. This changes adds wrapper functions transaction_start, transaction_commit, and transaction_cancel. It also adds tests for the functions, one of which demonstrates a semi-pythonic way to use said functions. Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Fri May 6 18:14:30 UTC 2022 on sn-devel-184 commit cc26fe829cb576f7ed5371d157da3fe5e165597b Author: John Mulligan <jmulli...@redhat.com> Date: Mon Apr 25 10:16:56 2022 -0400 lib/smbconf: add delete_global_parameter method to SMBConf Add a delete_global_parameter method wrapping smbconf_delete_global_parameter. Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit 64a36f5bf025616aeaae7412980883a0381c8a19 Author: John Mulligan <jmulli...@redhat.com> Date: Mon Apr 25 09:59:36 2022 -0400 lib/smbconf: add delete_parameter method to SMBConf Add a delete_parameter method wrapping smbconf_delete_parameter. Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit 2b6bd70cdccf5077377f7da74bd53ed1295280fd Author: John Mulligan <jmulli...@redhat.com> Date: Sun Apr 24 11:48:41 2022 -0400 lib/smbconf: add create_set_share method to SMBConf Add the create_set_share method wrapping smbconf_create_set_share. This method is one of the most complex as it must "unpack" the list of key-value pairs from python and convert that to a `struct smbconf_service` for the smbconfig C API. Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit 7e4bc41983a8660f1d16c14ba60d9f3c26e9fc60 Author: John Mulligan <jmulli...@redhat.com> Date: Sun Apr 24 10:25:50 2022 -0400 lib/smbconf: add delete_share method to SMBConf Add a delete_share method wrapping smbconf_delete_share. Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit 35df07d5ca639d6ee39903976ed0c329d3bfd4ec Author: John Mulligan <jmulli...@redhat.com> Date: Sun Apr 24 10:19:37 2022 -0400 lib/smbconf: add set_global_parameter method to SMBConf Add a set_global_parameter method wrapping smbconf_set_global_parameter. Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit 565d8ae8cdfae9e15e18a0c9350e2ebb4f502f92 Author: John Mulligan <jmulli...@redhat.com> Date: Sun Apr 24 10:18:42 2022 -0400 lib/smbconf: add set_parameter method to SMBConf Add a set_parameter method wrapping smbconf_set_parameter. Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit ff603de514b0b6dc654d6b3465df6ef9552c7e3c Author: John Mulligan <jmulli...@redhat.com> Date: Sun Apr 24 08:17:53 2022 -0400 lib/smbconf: add drop method to SMBConf Add a drop method wrapping smbconf_drop. Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit eb84f67e80cbbba47f572c5f1cbe35f39d224b10 Author: John Mulligan <jmulli...@redhat.com> Date: Sun Apr 24 08:10:36 2022 -0400 lib/smbconf: add create_share method to SMBConf Add a create_share method wrapping smbconf_create_share. Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit 67807a642a8b20943c5ed80e71ae05fe8d21fce0 Author: John Mulligan <jmulli...@redhat.com> Date: Sat Apr 23 14:42:44 2022 -0400 python/samba/tests: add test cases for s3/registry init funcs A previous change added smbconf initialization functions that allow access to the registry back-end. Add some simple tests cases that exercise these new functions. Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit 733ac02b2978777026719bd3651a39c5aaf04f41 Author: John Mulligan <jmulli...@redhat.com> Date: Sat Apr 23 14:38:42 2022 -0400 source3/lib/smbconf: add python bindings for init functions Add functions that allow python to access the registry back-end initialization function as well as the "general" init function that parses the back-end out of given string "path". With the registry back-end it will be possible to implement and test read-write functions of smbconf API in the future. Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit fcd50ea4ab4cc2f4f7cf7f21da3092cd107530ad Author: John Mulligan <jmulli...@redhat.com> Date: Sat Apr 23 14:19:59 2022 -0400 lib/smbconf: add a python function for raising smbconf exceptions The previous implementation in C was private to the module. Add a small python wrapper function so that a different python module may reuse the implementation. The python level function is prefixed with "_" to mark it as "private". Only future cooperating modules in the samba sources should make use of it. The function is shared at the python level as per the recommendation: https://stackoverflow.com/a/2136670 Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit f74d163ef088eb279110dfc872a18a2fc0d8fb71 Author: John Mulligan <jmulli...@redhat.com> Date: Sat Apr 23 14:17:48 2022 -0400 lib/smbconf: move python smbconf type definition to header Moving the definition of the type to a header file will allow future reuse of the C-type fields in a different C-API python module. Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit f0e157747fab81eda6e749320dd673f4cd1a1c73 Author: John Mulligan <jmulli...@redhat.com> Date: Thu May 5 10:05:49 2022 -0400 s3/lib/smbconf: add talloc_stackframe to smbconf_init_reg Previously, if this function was called without an existing stackframe then uses of talloc_tos in source3/registry trigger a panic. Since we intend to add patches that allow access to this call with Python bindings, that will not typically have a talloc_stackframe already, we add a talloc_stackframe call around the call to smbconf_init_reg_internal. This hides the use of talloc_tos in the registry code from higher level code that needs to call smbconf. Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit 3453ab999436cd2a46ea4b614332f1e04974d4e2 Author: John Mulligan <jmulli...@redhat.com> Date: Wed May 4 10:57:49 2022 -0400 s3/lib/smbconf: replace uses of talloc_tos with talloc_stackframe There are two calls to talloc_tos in the smbconf registry code. In order not to make callers of this library have to "know" what calls need an existing talloc stackframe, convert these uses to match other functions in the same file that already use talloc_stackframe. Signed-off-by: John Mulligan <jmulli...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> ----------------------------------------------------------------------- Summary of changes: lib/smbconf/pysmbconf.c | 366 ++++++++++++++++++++- .../rpc_sock_helper.h => lib/smbconf/pysmbconf.h | 26 +- python/samba/tests/smbconf.py | 229 +++++++++++++ source3/lib/smbconf/pys3smbconf.c | 212 ++++++++++++ source3/lib/smbconf/smbconf_reg.c | 19 +- source3/wscript_build | 5 + 6 files changed, 832 insertions(+), 25 deletions(-) copy source3/rpc_server/rpc_sock_helper.h => lib/smbconf/pysmbconf.h (63%) create mode 100644 source3/lib/smbconf/pys3smbconf.c Changeset truncated at 500 lines: diff --git a/lib/smbconf/pysmbconf.c b/lib/smbconf/pysmbconf.c index abf77ddc1eb..b0aca4508af 100644 --- a/lib/smbconf/pysmbconf.c +++ b/lib/smbconf/pysmbconf.c @@ -24,17 +24,10 @@ #include "lib/smbconf/smbconf.h" #include "lib/smbconf/smbconf_txt.h" +#include "lib/smbconf/pysmbconf.h" static PyObject *PyExc_SMBConfError; -typedef struct { - PyObject_HEAD - - /* C values embedded in our python type */ - TALLOC_CTX * mem_ctx; - struct smbconf_ctx *conf_ctx; -} py_SMBConf_Object; - static void py_raise_SMBConfError(sbcErr err) { PyObject *v = NULL; @@ -286,6 +279,278 @@ static PyObject *obj_get_config(py_SMBConf_Object * self, return svclist; } +static PyObject *obj_create_share(py_SMBConf_Object * self, PyObject * args) +{ + sbcErr err; + char *servicename = NULL; + + if (!PyArg_ParseTuple(args, "s", &servicename)) { + return NULL; + } + + err = smbconf_create_share(self->conf_ctx, servicename); + if (err != SBC_ERR_OK) { + py_raise_SMBConfError(err); + return NULL; + } + Py_RETURN_NONE; +} + +static PyObject *obj_drop(py_SMBConf_Object * self, + PyObject * Py_UNUSED(ignored)) +{ + sbcErr err; + + err = smbconf_drop(self->conf_ctx); + if (err != SBC_ERR_OK) { + py_raise_SMBConfError(err); + return NULL; + } + Py_RETURN_NONE; +} + +static PyObject *obj_set_parameter(py_SMBConf_Object * self, PyObject * args) +{ + sbcErr err; + char *servicename = NULL; + char *param = NULL; + char *val = NULL; + + if (!PyArg_ParseTuple(args, "sss", &servicename, ¶m, &val)) { + return NULL; + } + + err = smbconf_set_parameter(self->conf_ctx, servicename, param, val); + if (err != SBC_ERR_OK) { + py_raise_SMBConfError(err); + return NULL; + } + Py_RETURN_NONE; +} + +static PyObject *obj_set_global_parameter(py_SMBConf_Object * self, + PyObject * args) +{ + sbcErr err; + char *param = NULL; + char *val = NULL; + + if (!PyArg_ParseTuple(args, "ss", ¶m, &val)) { + return NULL; + } + + err = smbconf_set_global_parameter(self->conf_ctx, param, val); + if (err != SBC_ERR_OK) { + py_raise_SMBConfError(err); + return NULL; + } + Py_RETURN_NONE; +} + +static PyObject *obj_delete_share(py_SMBConf_Object * self, PyObject * args) +{ + sbcErr err; + char *servicename = NULL; + + if (!PyArg_ParseTuple(args, "s", &servicename)) { + return NULL; + } + + err = smbconf_delete_share(self->conf_ctx, servicename); + if (err != SBC_ERR_OK) { + py_raise_SMBConfError(err); + return NULL; + } + Py_RETURN_NONE; +} + +static char *py_get_kv_str(TALLOC_CTX * mem_ctx, PyObject * obj, Py_ssize_t idx) +{ + char *ss = NULL; + PyObject *pystr = PySequence_GetItem(obj, idx); + if (pystr == NULL) { + return NULL; + } + if (!PyUnicode_Check(pystr)) { + PyErr_SetString(PyExc_TypeError, "keys/values expect a str"); + Py_CLEAR(pystr); + return NULL; + } + ss = talloc_strdup(mem_ctx, PyUnicode_AsUTF8(pystr)); + Py_CLEAR(pystr); + return ss; +} + +static PyObject *obj_create_set_share(py_SMBConf_Object * self, PyObject * args) +{ + sbcErr err; + char *servicename = NULL; + PyObject *kvs = NULL; + Py_ssize_t size, idx; + struct smbconf_service *tmp_service = NULL; + TALLOC_CTX *tmp_ctx = talloc_new(self->mem_ctx); + + if (!PyArg_ParseTuple(args, "sO", &servicename, &kvs)) { + talloc_free(tmp_ctx); + return NULL; + } + + if (PySequence_Check(kvs) == 0) { + PyErr_SetString(PyExc_TypeError, + "a sequence object is required"); + talloc_free(tmp_ctx); + return NULL; + } + + size = PySequence_Size(kvs); + if (size == -1) { + PyErr_SetString(PyExc_ValueError, "failed to get size"); + talloc_free(tmp_ctx); + return NULL; + } + + tmp_service = talloc_zero(tmp_ctx, struct smbconf_service); + if (tmp_service == NULL) { + PyErr_NoMemory(); + talloc_free(tmp_ctx); + return NULL; + } + + tmp_service->name = talloc_strdup(tmp_service, servicename); + if (tmp_service->name == NULL) { + PyErr_NoMemory(); + talloc_free(tmp_ctx); + return NULL; + } + tmp_service->num_params = (uint32_t) size; + tmp_service->param_names = talloc_array(tmp_ctx, char *, size); + if (tmp_service->param_names == NULL) { + PyErr_NoMemory(); + talloc_free(tmp_ctx); + return NULL; + } + tmp_service->param_values = talloc_array(tmp_ctx, char *, size); + if (tmp_service->param_values == NULL) { + PyErr_NoMemory(); + talloc_free(tmp_ctx); + return NULL; + } + + for (idx = 0; idx < size; idx++) { + char *tmp_str = NULL; + PyObject *tmp_pair = PySequence_GetItem(kvs, idx); + if (tmp_pair == NULL) { + talloc_free(tmp_ctx); + return NULL; + } + if (PySequence_Size(tmp_pair) != 2) { + PyErr_SetString(PyExc_ValueError, + "expecting two-item tuples"); + Py_CLEAR(tmp_pair); + talloc_free(tmp_ctx); + return NULL; + } + + /* fetch key */ + tmp_str = py_get_kv_str(tmp_ctx, tmp_pair, 0); + if (tmp_str == NULL) { + Py_CLEAR(tmp_pair); + talloc_free(tmp_ctx); + return NULL; + } + tmp_service->param_names[idx] = tmp_str; + + /* fetch value */ + tmp_str = py_get_kv_str(tmp_ctx, tmp_pair, 1); + if (tmp_str == NULL) { + Py_CLEAR(tmp_pair); + talloc_free(tmp_ctx); + return NULL; + } + tmp_service->param_values[idx] = tmp_str; + + Py_CLEAR(tmp_pair); + } + + err = smbconf_create_set_share(self->conf_ctx, tmp_service); + if (err != SBC_ERR_OK) { + py_raise_SMBConfError(err); + talloc_free(tmp_ctx); + return NULL; + } + talloc_free(tmp_ctx); + Py_RETURN_NONE; +} + +static PyObject *obj_delete_parameter(py_SMBConf_Object * self, PyObject * args) +{ + sbcErr err; + char *servicename = NULL; + char *param_name = NULL; + + if (!PyArg_ParseTuple(args, "ss", &servicename, ¶m_name)) { + return NULL; + } + + err = smbconf_delete_parameter(self->conf_ctx, servicename, param_name); + if (err != SBC_ERR_OK) { + py_raise_SMBConfError(err); + return NULL; + } + Py_RETURN_NONE; +} + +static PyObject *obj_delete_global_parameter(py_SMBConf_Object * self, + PyObject * args) +{ + sbcErr err; + char *param_name = NULL; + + if (!PyArg_ParseTuple(args, "s", ¶m_name)) { + return NULL; + } + + err = smbconf_delete_global_parameter(self->conf_ctx, param_name); + if (err != SBC_ERR_OK) { + py_raise_SMBConfError(err); + return NULL; + } + Py_RETURN_NONE; +} + +static PyObject *obj_transaction_start(py_SMBConf_Object * self, + PyObject * Py_UNUSED(ignored)) +{ + sbcErr err = smbconf_transaction_start(self->conf_ctx); + if (err != SBC_ERR_OK) { + py_raise_SMBConfError(err); + return NULL; + } + Py_RETURN_NONE; +} + +static PyObject *obj_transaction_commit(py_SMBConf_Object * self, + PyObject * Py_UNUSED(ignored)) +{ + sbcErr err = smbconf_transaction_commit(self->conf_ctx); + if (err != SBC_ERR_OK) { + py_raise_SMBConfError(err); + return NULL; + } + Py_RETURN_NONE; +} + +static PyObject *obj_transaction_cancel(py_SMBConf_Object * self, + PyObject * Py_UNUSED(ignored)) +{ + sbcErr err = smbconf_transaction_cancel(self->conf_ctx); + if (err != SBC_ERR_OK) { + py_raise_SMBConfError(err); + return NULL; + } + Py_RETURN_NONE; +} + PyDoc_STRVAR(obj_requires_messaging_doc, "requires_messaging() -> bool\n" "\n" @@ -316,6 +581,54 @@ PyDoc_STRVAR(obj_get_config_doc, "configuration. Each tuple in the list is the same as described\n" "for get_share().\n"); +PyDoc_STRVAR(obj_create_share_doc, +"create_share(name: str) -> None\n" +"Create a new empty share in the configuration. The share\n" +"name must not exist or an error will be raised.\n"); + +PyDoc_STRVAR(obj_drop_doc, +"drop() -> None\n" +"Drop the entire configuration, resetting it to an empty state.\n"); + +PyDoc_STRVAR(obj_set_parameter_doc, +"set_parameter(str, str, str) -> None\n" +"Set a configuration parmeter. Specify service name, parameter name,\n" +"and parameter value.\n"); + +PyDoc_STRVAR(obj_set_global_parameter_doc, +"set_global_parameter(str, str) -> None\n" +"Set a global configuration parmeter. Specify the parameter name\n" +"and parameter value.\n"); + +PyDoc_STRVAR(obj_delete_share_doc, +"delete_share(str) -> None\n" +"Delete a service from the configuration.\n"); + +PyDoc_STRVAR(obj_create_set_share_doc, +"create_set_share(str, [(str, str)...]) -> None\n" +"Create and set the definition of a service.\n"); + +PyDoc_STRVAR(obj_delete_parameter_doc, +"delete_parameter(str, str) -> None\n" +"Delete a single configuration parameter.\n"); + +PyDoc_STRVAR(obj_delete_global_parameter_doc, +"delete_parameter(str, str) -> None\n" +"Delete a single global configuration parameter.\n"); + +PyDoc_STRVAR(obj_transaction_start_doc, +"transaction_start() -> None\n" +"Start a transaction.\n" +"Transactions allow making compound sets of changes atomically.\n"); + +PyDoc_STRVAR(obj_transaction_commit_doc, +"transaction_commit() -> None\n" +"Commit the transaction.\n"); + +PyDoc_STRVAR(obj_transaction_cancel_doc, +"transaction_cancel() -> None\n" +"Cancel the transaction.\n"); + static PyMethodDef py_smbconf_obj_methods[] = { { "requires_messaging", (PyCFunction) obj_requires_messaging, METH_NOARGS, obj_requires_messaging_doc }, @@ -327,6 +640,28 @@ static PyMethodDef py_smbconf_obj_methods[] = { obj_get_share_doc }, { "get_config", (PyCFunction) obj_get_config, METH_NOARGS, obj_get_config_doc }, + { "create_share", (PyCFunction) obj_create_share, METH_VARARGS, + obj_create_share_doc }, + { "create_set_share", (PyCFunction) obj_create_set_share, METH_VARARGS, + obj_create_set_share_doc }, + { "drop", (PyCFunction) obj_drop, METH_NOARGS, + obj_drop_doc }, + { "set_parameter", (PyCFunction) obj_set_parameter, METH_VARARGS, + obj_set_parameter_doc }, + { "set_global_parameter", (PyCFunction) obj_set_global_parameter, + METH_VARARGS, obj_set_global_parameter_doc }, + { "delete_share", (PyCFunction) obj_delete_share, METH_VARARGS, + obj_delete_share_doc }, + { "delete_parameter", (PyCFunction) obj_delete_parameter, METH_VARARGS, + obj_delete_parameter_doc }, + { "delete_global_parameter", (PyCFunction) obj_delete_global_parameter, + METH_VARARGS, obj_delete_global_parameter_doc }, + { "transaction_start", (PyCFunction) obj_transaction_start, METH_NOARGS, + obj_transaction_start_doc }, + { "transaction_commit", (PyCFunction) obj_transaction_commit, + METH_NOARGS, obj_transaction_commit_doc }, + { "transaction_cancel", (PyCFunction) obj_transaction_cancel, + METH_NOARGS, obj_transaction_cancel_doc }, { 0 }, }; @@ -372,9 +707,24 @@ static PyObject *py_init_txt(PyObject * module, PyObject * args) return (PyObject *) obj; } +static PyObject *py_smbconf_error(PyObject * module, PyObject * args) +{ + sbcErr errcode; + + if (!PyArg_ParseTuple(args, "i", &errcode)) { + return NULL; + } + + /* this always raises an exception. it doesn't return the exception. */ + py_raise_SMBConfError(errcode); + return NULL; +} + static PyMethodDef pysmbconf_methods[] = { { "init_txt", (PyCFunction) py_init_txt, METH_VARARGS, "Return an SMBConf object for the given text config file." }, + { "_smbconf_error", (PyCFunction) py_smbconf_error, METH_VARARGS, + "Raise an SMBConfError based on the given error code." }, { 0 }, }; diff --git a/source3/rpc_server/rpc_sock_helper.h b/lib/smbconf/pysmbconf.h similarity index 63% copy from source3/rpc_server/rpc_sock_helper.h copy to lib/smbconf/pysmbconf.h index 9c8128afe8c..e8c6c9998e3 100644 --- a/source3/rpc_server/rpc_sock_helper.h +++ b/lib/smbconf/pysmbconf.h @@ -1,9 +1,8 @@ /* * Unix SMB/CIFS implementation. + * libsmbconf - Samba configuration library - Python bindings * - * RPC Socket Helper - * - * Copyright (c) 2011 Andreas Schneider <a...@samba.org> + * Copyright (C) John Mulligan <phlogistonj...@asynchrono.us> 2022 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,18 +18,19 @@ * along with this program; if not, see <http://www.gnu.org/licenses/>. */ +#ifndef _PYSMBCONF_H_ +#define _PYSMBCONF_H_ -#ifndef _RPC_SOCK_HELPER_H_ -#define _RPC_SOCK_HELPER_H_ +#include <Python.h> +#include "lib/smbconf/smbconf.h" -#include "rpc_server.h" +typedef struct { + PyObject_HEAD -NTSTATUS dcesrv_create_binding_sockets( - struct dcerpc_binding *b, - TALLOC_CTX *mem_ctx, - size_t *pnum_fds, - int **fds); + /* C values embedded in our python type */ + TALLOC_CTX * mem_ctx; + struct smbconf_ctx *conf_ctx; +} py_SMBConf_Object; -#endif /* _RPC_SOCK_HELPER_H_ */ -/* vim: set ts=8 sw=8 noet cindent syntax=c.doxygen: */ +#endif /* _PYSMBCONF_H_ */ diff --git a/python/samba/tests/smbconf.py b/python/samba/tests/smbconf.py index 41d9889cf02..e023e2ad59b 100644 --- a/python/samba/tests/smbconf.py +++ b/python/samba/tests/smbconf.py @@ -20,11 +20,13 @@ Tests for samba.smbconf module """ +from samba.samba3 import param as s3param import samba.tests class SMBConfTests(samba.tests.TestCase): _smbconf = None + _s3smbconf = None @property def smbconf(self): @@ -39,10 +41,30 @@ class SMBConfTests(samba.tests.TestCase): self._smbconf = samba.smbconf return self._smbconf + @property + def s3smbconf(self): + if self._s3smbconf is not None: + return self._s3smbconf + + import samba.samba3.smbconf + + self._s3smbconf = samba.samba3.smbconf + return self._s3smbconf + @property def example_conf_default(self): return "./testdata/samba3/smb.conf" + def setUp(self): + super().setUp() + # fetch the configuration in the same style as other test suites + self.lp_ctx = samba.tests.env_loadparm() -- Samba Shared Repository