1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-25 17:57:42 +03:00

python: Port ntvfs posix bindings to Python 3 compatible form

Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Andrew Bartlet <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Lumir Balhar 2017-10-24 09:00:11 +02:00 committed by Andreas Schneider
parent aed7faeab4
commit e00ba05d33
5 changed files with 61 additions and 34 deletions

View File

@ -126,7 +126,7 @@ plantestsuite(
os.path.join(bbdir, "dbcheck-links.sh"),
'$PREFIX_ABS/provision', 'release-4-5-0-pre1', configuration])
planpythontestsuite("none", "samba.tests.upgradeprovision")
planpythontestsuite("none", "samba.tests.xattr")
planpythontestsuite("none", "samba.tests.xattr", py3_compatible=True)
planpythontestsuite("none", "samba.tests.ntacls")
planpythontestsuite("none", "samba.tests.policy")
planpythontestsuite("none", "samba.tests.kcc.graph")

View File

@ -19,6 +19,7 @@
*/
#include <Python.h>
#include "python/py3compat.h"
#include "includes.h"
#include "system/filesys.h"
#include <tdb.h>
@ -28,8 +29,6 @@
#include "libcli/util/pyerrors.h"
#include "param/pyparam.h"
void initposix_eadb(void);
static PyObject *py_is_xattr_supported(PyObject *self)
{
return Py_True;
@ -102,7 +101,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args)
talloc_free(mem_ctx);
return NULL;
}
ret = PyString_FromStringAndSize((char *)blob.data, blob.length);
ret = PyStr_FromStringAndSize((char *)blob.data, blob.length);
talloc_free(mem_ctx);
return ret;
}
@ -119,12 +118,22 @@ static PyMethodDef py_posix_eadb_methods[] = {
{ NULL }
};
void initposix_eadb(void)
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
.m_name = "posix_eadb",
.m_doc = "Python bindings for xattr manipulation.",
.m_size = -1,
.m_methods = py_posix_eadb_methods,
};
MODULE_INIT_FUNC(posix_eadb)
{
PyObject *m;
m = Py_InitModule3("posix_eadb", py_posix_eadb_methods,
"Python bindings for xattr manipulation.");
m = PyModule_Create(&moduledef);
if (m == NULL)
return;
return NULL;
return m;
}

View File

@ -19,13 +19,12 @@
*/
#include <Python.h>
#include "python/py3compat.h"
#include "includes.h"
#include "librpc/ndr/libndr.h"
#include "system/filesys.h"
#include "lib/util/base64.h"
void initxattr_native(void);
static PyObject *py_is_xattr_supported(PyObject *self)
{
#if !defined(HAVE_XATTR_SUPPORT)
@ -91,7 +90,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args)
talloc_free(mem_ctx);
return NULL;
}
ret = PyString_FromStringAndSize(buf, len);
ret = PyStr_FromStringAndSize(buf, len);
talloc_free(mem_ctx);
return ret;
}
@ -108,14 +107,22 @@ static PyMethodDef py_xattr_methods[] = {
{ NULL }
};
void initxattr_native(void)
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
.m_name = "xattr_native",
.m_doc = "Python bindings for xattr manipulation.",
.m_size = -1,
.m_methods = py_xattr_methods,
};
MODULE_INIT_FUNC(xattr_native)
{
PyObject *m;
m = Py_InitModule3("xattr_native", py_xattr_methods,
"Python bindings for xattr manipulation.");
m = PyModule_Create(&moduledef);
if (m == NULL)
return;
}
return NULL;
return m;
}

View File

@ -19,6 +19,7 @@
*/
#include <Python.h>
#include "python/py3compat.h"
#include "includes.h"
#include "system/filesys.h"
#include <tdb.h>
@ -32,8 +33,6 @@
#include "lib/dbwrap/dbwrap_tdb.h"
#include "source3/lib/xattr_tdb.h"
void initxattr_tdb(void);
static PyObject *py_is_xattr_supported(PyObject *self)
{
return Py_True;
@ -138,7 +137,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args)
talloc_free(mem_ctx);
return NULL;
}
ret_obj = PyString_FromStringAndSize((char *)blob.data, xattr_size);
ret_obj = PyStr_FromStringAndSize((char *)blob.data, xattr_size);
talloc_free(mem_ctx);
return ret_obj;
}
@ -155,13 +154,23 @@ static PyMethodDef py_xattr_methods[] = {
{ NULL }
};
void initxattr_tdb(void)
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
.m_name = "xattr_tdb",
.m_doc = "Python bindings for xattr manipulation.",
.m_size = -1,
.m_methods = py_xattr_methods,
};
MODULE_INIT_FUNC(xattr_tdb)
{
PyObject *m;
m = Py_InitModule3("xattr_tdb", py_xattr_methods,
"Python bindings for xattr manipulation.");
m = PyModule_Create(&moduledef);
if (m == NULL)
return;
return NULL;
return m;
}

View File

@ -41,27 +41,29 @@ if bld.CONFIG_SET('WITH_NTVFS_FILESERVER'):
)
bld.SAMBA_PYTHON('python_xattr_native',
source='python/pyxattr_native.c',
deps='ndr ldb samdb samba-credentials pyparam_util attr',
realname='samba/xattr_native.so'
)
bld.SAMBA_LIBRARY('posix_eadb',
source='posix_eadb.c',
deps='tdb tdb-wrap samba-util',
autoproto='posix_eadb_proto.h',
private_library=True)
bld.SAMBA_PYTHON('python_posix_eadb',
for env in bld.gen_python_environments():
pyparam_util = bld.pyembed_libname('pyparam_util')
bld.SAMBA_PYTHON('python_xattr_native',
source='python/pyxattr_native.c',
deps='ndr ldb samdb samba-credentials %s attr' % pyparam_util,
realname='samba/xattr_native.so'
)
bld.SAMBA_PYTHON('python_posix_eadb',
source='python/pyposix_eadb.c',
deps='pyparam_util posix_eadb tdb',
deps='%s posix_eadb tdb' % pyparam_util,
realname='samba/posix_eadb.so'
)
bld.SAMBA_PYTHON('python_xattr_tdb',
bld.SAMBA_PYTHON('python_xattr_tdb',
source='python/pyxattr_tdb.c',
deps='pyparam_util xattr_tdb',
deps='%s xattr_tdb' % pyparam_util,
realname='samba/xattr_tdb.so'
)