mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
libgpo: port samba.gpo to python3
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
parent
bb88292cee
commit
a032ea5bf8
@ -27,6 +27,7 @@
|
||||
#include "librpc/rpc/pyrpc_util.h"
|
||||
#include "auth/credentials/pycredentials.h"
|
||||
#include "libcli/util/pyerrors.h"
|
||||
#include "python/py3compat.h"
|
||||
|
||||
/* A Python C API module to use LIBGPO */
|
||||
|
||||
@ -37,7 +38,7 @@ static PyObject* GPO_get_##ATTR(PyObject *self, void *closure) \
|
||||
= pytalloc_get_ptr(self); \
|
||||
\
|
||||
if (gpo_ptr->ATTR) \
|
||||
return PyString_FromString(gpo_ptr->ATTR); \
|
||||
return PyStr_FromString(gpo_ptr->ATTR); \
|
||||
else \
|
||||
return Py_None; \
|
||||
}
|
||||
@ -110,7 +111,7 @@ static PyObject *py_gpo_get_unix_path(PyObject *self, PyObject *args,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = PyString_FromString(unix_path);
|
||||
ret = PyStr_FromString(unix_path);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
@ -475,7 +476,7 @@ static PyMethodDef ADS_methods[] = {
|
||||
{ "connect", (PyCFunction)py_ads_connect, METH_NOARGS,
|
||||
"Connect to the LDAP server" },
|
||||
#ifdef HAVE_ADS
|
||||
{ "get_gpo_list", (PyCFunction)py_ads_get_gpo_list, METH_KEYWORDS,
|
||||
{ "get_gpo_list", (PyCFunction)py_ads_get_gpo_list, METH_VARARGS | METH_KEYWORDS,
|
||||
NULL },
|
||||
#endif
|
||||
{ NULL }
|
||||
@ -499,34 +500,45 @@ static PyMethodDef py_gpo_methods[] = {
|
||||
{NULL}
|
||||
};
|
||||
|
||||
static struct PyModuleDef moduledef = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
.m_name = "gpo",
|
||||
.m_doc = "libgpo python bindings",
|
||||
.m_size = -1,
|
||||
.m_methods = py_gpo_methods,
|
||||
};
|
||||
|
||||
/* Will be called by python when loading this module */
|
||||
void initgpo(void)
|
||||
void initgpo(void);
|
||||
|
||||
MODULE_INIT_FUNC(gpo)
|
||||
{
|
||||
PyObject *m;
|
||||
|
||||
debug_setup_talloc_log();
|
||||
|
||||
/* Instantiate the types */
|
||||
m = Py_InitModule3("gpo", py_gpo_methods, "libgpo python bindings");
|
||||
m = PyModule_Create(&moduledef);
|
||||
if (m == NULL) {
|
||||
return;
|
||||
return m;
|
||||
}
|
||||
|
||||
PyModule_AddObject(m, "version",
|
||||
PyString_FromString(SAMBA_VERSION_STRING));
|
||||
PyStr_FromString(SAMBA_VERSION_STRING));
|
||||
|
||||
if (PyType_Ready(&ads_ADSType) < 0) {
|
||||
return;
|
||||
return m;
|
||||
}
|
||||
|
||||
PyModule_AddObject(m, "ADS_STRUCT", (PyObject *)&ads_ADSType);
|
||||
|
||||
if (pytalloc_BaseObject_PyType_Ready(&GPOType) < 0) {
|
||||
return;
|
||||
return m;
|
||||
}
|
||||
|
||||
Py_INCREF((PyObject *)(void *)&GPOType);
|
||||
PyModule_AddObject(m, "GROUP_POLICY_OBJECT",
|
||||
(PyObject *)&GPOType);
|
||||
return m;
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ bld.SAMBA3_LIBRARY('gpext',
|
||||
deps='talloc ads TOKEN_UTIL auth',
|
||||
private_library=True)
|
||||
|
||||
bld.SAMBA3_PYTHON('python_samba_libgpo', 'pygpo.c',
|
||||
deps='''pyparam_util gpext talloc ads TOKEN_UTIL
|
||||
auth pyrpc_util''',
|
||||
realname='samba/gpo.so')
|
||||
for env in bld.gen_python_environments():
|
||||
bld.SAMBA3_PYTHON('python_samba_libgpo', 'pygpo.c',
|
||||
deps='''pyparam_util gpext talloc ads TOKEN_UTIL
|
||||
auth pyrpc_util''',
|
||||
realname='samba/gpo.so')
|
||||
|
Loading…
Reference in New Issue
Block a user