Py_XDECREF(mod_sys);
return false;
}
+
+const char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list,
+ const char *paramname)
+{
+ const char **ret;
+ Py_ssize_t i;
+ if (!PyList_Check(list)) {
+ PyErr_Format(PyExc_TypeError, "%s is not a list", paramname);
+ return NULL;
+ }
+ ret = talloc_array(NULL, const char *, PyList_Size(list)+1);
+ if (ret == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ for (i = 0; i < PyList_Size(list); i++) {
+ const char *value;
+ Py_ssize_t size;
+ PyObject *item = PyList_GetItem(list, i);
+ if (!PyUnicode_Check(item)) {
+ PyErr_Format(PyExc_TypeError, "%s should be strings", paramname);
+ return NULL;
+ }
+ value = PyUnicode_AsUTF8AndSize(item, &size);
+ if (value == NULL) {
+ talloc_free(ret);
+ return NULL;
+ }
+ ret[i] = talloc_strndup(ret, value, size);
+ }
+ ret[i] = NULL;
+ return ret;
+}
+
#ifndef __SAMBA_PYTHON_MODULES_H__
#define __SAMBA_PYTHON_MODULES_H__
+#include <talloc.h>
+
bool py_update_path(void);
/* discard signature of 'func' in favour of 'target_sig' */
#define PY_DISCARD_FUNC_SIG(target_sig, func) (target_sig)(void(*)(void))func
+
+const char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list,
+ const char *paramname);
+
#endif /* __SAMBA_PYTHON_MODULES_H__ */
+
#include <Python.h>
#include "python/py3compat.h"
#include "includes.h"
+#include "python/modules.h"
#include "version.h"
#include "param/pyparam.h"
#include "lib/socket/netif.h"
}
-static const char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list,
- const char *paramname)
-{
- const char **ret;
- Py_ssize_t i;
- if (!PyList_Check(list)) {
- PyErr_Format(PyExc_TypeError, "%s is not a list", paramname);
- return NULL;
- }
- ret = talloc_array(NULL, const char *, PyList_Size(list)+1);
- if (ret == NULL) {
- PyErr_NoMemory();
- return NULL;
- }
-
- for (i = 0; i < PyList_Size(list); i++) {
- const char *value;
- Py_ssize_t size;
- PyObject *item = PyList_GetItem(list, i);
- if (!PyUnicode_Check(item)) {
- PyErr_Format(PyExc_TypeError, "%s should be strings", paramname);
- return NULL;
- }
- value = PyUnicode_AsUTF8AndSize(item, &size);
- if (value == NULL) {
- talloc_free(ret);
- return NULL;
- }
- ret[i] = talloc_strndup(ret, value, size);
- }
- ret[i] = NULL;
- return ret;
-}
-
static PyObject *PyAuthContext_FromContext(struct auth4_context *auth_context)
{
return pytalloc_reference(&PyAuthContext, auth_context);
pyparam_util = bld.pyembed_libname('pyparam_util')
pyldb_util = bld.pyembed_libname('pyldb-util')
pycredentials = 'pycredentials'
+libpython = bld.pyembed_libname('LIBPYTHON')
+
bld.SAMBA_PYTHON('pyauth',
source='pyauth.c',
public_deps='auth_system_session',
- deps='samdb %s %s %s %s auth4' % (pytalloc_util, pyparam_util, pyldb_util, pycredentials),
+ deps=f'samdb {pytalloc_util} {pyparam_util} {pyldb_util} {pycredentials} {libpython} auth4',
realname='samba/auth.so'
)