summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2018-02-05 11:04:53 +0000
committerAndrew Bartlett <abartlet@samba.org>2018-04-05 08:59:08 +0200
commit522243364139e88352fd6f58a0eda5a950a35c8e (patch)
tree097e33f341cd8407ad86339034388bf13ccc0d9a /source4
parent0210f60759c90e22fe86738490b328df7ff23b6f (diff)
downloadsamba-522243364139e88352fd6f58a0eda5a950a35c8e.tar.gz
python3 port for policy module
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/policy/pypolicy.c22
-rw-r--r--source4/lib/policy/wscript_build11
2 files changed, 22 insertions, 11 deletions
diff --git a/source4/lib/policy/pypolicy.c b/source4/lib/policy/pypolicy.c
index 8a9aa47f1fd..dd44c0fcf16 100644
--- a/source4/lib/policy/pypolicy.c
+++ b/source4/lib/policy/pypolicy.c
@@ -19,6 +19,7 @@
#include <Python.h>
#include "includes.h"
+#include "python/py3compat.h"
#include "policy.h"
#include "libcli/util/pyerrors.h"
@@ -51,7 +52,7 @@ static PyObject *py_get_gpo_flags(PyObject *self, PyObject *args)
py_ret = PyList_New(0);
for (i = 0; ret[i]; i++) {
- PyObject *item = PyString_FromString(ret[i]);
+ PyObject *item = PyStr_FromString(ret[i]);
if (item == NULL) {
talloc_free(mem_ctx);
Py_DECREF(py_ret);
@@ -93,7 +94,7 @@ static PyObject *py_get_gplink_options(PyObject *self, PyObject *args)
py_ret = PyList_New(0);
for (i = 0; ret[i]; i++) {
- PyObject *item = PyString_FromString(ret[i]);
+ PyObject *item = PyStr_FromString(ret[i]);
if (item == NULL) {
talloc_free(mem_ctx);
Py_DECREF(py_ret);
@@ -131,13 +132,21 @@ static PyMethodDef py_policy_methods[] = {
{ NULL }
};
-void initpolicy(void)
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "policy",
+ .m_doc = "(Group) Policy manipulation",
+ .m_size = -1,
+ .m_methods = py_policy_methods,
+};
+
+MODULE_INIT_FUNC(policy)
{
- PyObject *m;
+ PyObject *m = NULL;
- m = Py_InitModule3("policy", py_policy_methods, "(Group) Policy manipulation");
+ m = PyModule_Create(&moduledef);
if (!m)
- return;
+ return m;
PyModule_AddObject(m, "GPO_FLAG_USER_DISABLE",
PyInt_FromLong(GPO_FLAG_USER_DISABLE));
@@ -147,4 +156,5 @@ void initpolicy(void)
PyInt_FromLong(GPLINK_OPT_DISABLE ));
PyModule_AddObject(m, "GPLINK_OPT_ENFORCE ",
PyInt_FromLong(GPLINK_OPT_ENFORCE ));
+ return m;
}
diff --git a/source4/lib/policy/wscript_build b/source4/lib/policy/wscript_build
index f7c59090b84..0d23bcb205e 100644
--- a/source4/lib/policy/wscript_build
+++ b/source4/lib/policy/wscript_build
@@ -10,8 +10,9 @@ bld.SAMBA_LIBRARY('samba-policy',
enabled=bld.PYTHON_BUILD_IS_ENABLED()
)
-bld.SAMBA_PYTHON('py_policy',
- source='pypolicy.c',
- public_deps='samba-policy pytalloc-util',
- realname='samba/policy.so'
- )
+for env in bld.gen_python_environments():
+ bld.SAMBA_PYTHON('py_policy',
+ source='pypolicy.c',
+ public_deps='samba-policy pytalloc-util',
+ realname='samba/policy.so'
+ )