From 2cff5990daa324226a2c32245eef78019ef1b5bf Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 11 Nov 2020 11:20:29 +0100 Subject: [PATCH] pylibsmb: Add a compatible python-level wrapper Right now this is empty, but it is the basis for moving complexity out or pylibsmb.c into python code. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- python/samba/samba3/libsmb_samba_internal.py | 19 +++++++++++++++++++ source3/libsmb/pylibsmb.c | 12 ++++++------ source3/wscript_build | 2 +- 3 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 python/samba/samba3/libsmb_samba_internal.py diff --git a/python/samba/samba3/libsmb_samba_internal.py b/python/samba/samba3/libsmb_samba_internal.py new file mode 100644 index 00000000000..d8621a270a6 --- /dev/null +++ b/python/samba/samba3/libsmb_samba_internal.py @@ -0,0 +1,19 @@ +# Copyright (C) Volker Lendecke 2020 +# +# 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 +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from samba.samba3.libsmb_samba_cwrapper import * + +class Conn(LibsmbCConn): + pass diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c index 7985b842a15..78bc066ba4f 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -1610,10 +1610,10 @@ static PyMethodDef py_cli_state_methods[] = { static PyTypeObject py_cli_state_type = { PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "libsmb_samba_internal.Conn", + .tp_name = "libsmb_samba_cwrapper.LibsmbCConn", .tp_basicsize = sizeof(struct py_cli_state), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - .tp_doc = "libsmb connection", + .tp_doc = "libsmb cwrapper connection", .tp_new = py_cli_state_new, .tp_init = (initproc)py_cli_state_init, .tp_dealloc = (destructor)py_cli_state_dealloc, @@ -1624,17 +1624,17 @@ static PyMethodDef py_libsmb_methods[] = { {0}, }; -void initlibsmb_samba_internal(void); +void initlibsmb_samba_cwrapper(void); static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, - .m_name = "libsmb_samba_internal", + .m_name = "libsmb_samba_cwrapper", .m_doc = "libsmb wrapper", .m_size = -1, .m_methods = py_libsmb_methods, }; -MODULE_INIT_FUNC(libsmb_samba_internal) +MODULE_INIT_FUNC(libsmb_samba_cwrapper) { PyObject *m = NULL; @@ -1648,7 +1648,7 @@ MODULE_INIT_FUNC(libsmb_samba_internal) return NULL; } Py_INCREF(&py_cli_state_type); - PyModule_AddObject(m, "Conn", (PyObject *)&py_cli_state_type); + PyModule_AddObject(m, "LibsmbCConn", (PyObject *)&py_cli_state_type); #define ADD_FLAGS(val) PyModule_AddObject(m, #val, PyLong_FromLong(val)) diff --git a/source3/wscript_build b/source3/wscript_build index 62d6820b5d2..22e2bc7deea 100644 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -1341,7 +1341,7 @@ pycredentials = 'pycredentials' bld.SAMBA3_PYTHON('pylibsmb', source='libsmb/pylibsmb.c', deps='smbclient samba-credentials %s' % pycredentials, - realname='samba/samba3/libsmb_samba_internal.so' + realname='samba/samba3/libsmb_samba_cwrapper.so' ) bld.SAMBA3_PYTHON('pymdscli', -- 2.47.3