From 6fe9013ae23927a67fa6b6033e2711cef99b3533 Mon Sep 17 00:00:00 2001 From: bubulle Date: Tue, 7 Jun 2011 20:08:36 +0000 Subject: Load samba-3.6.0rc2 into branches/samba/upstream. git-svn-id: svn://svn.debian.org/svn/pkg-samba/branches/samba/upstream@3807 fc4039ab-9d04-0410-8cac-899223bdd6b0 --- source4/scripting/python/modules.c | 77 +++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 42 deletions(-) (limited to 'source4/scripting/python/modules.c') diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c index e53f4cfaf2..78cdbc0d87 100644 --- a/source4/scripting/python/modules.c +++ b/source4/scripting/python/modules.c @@ -17,54 +17,47 @@ along with this program. If not, see . */ +#include #include "includes.h" #include "scripting/python/modules.h" -#include +#include "dynconfig/dynconfig.h" -extern void init_ldb(void); -extern void init_security(void); -extern void init_registry(void); -extern void init_param(void); -extern void init_misc(void); -extern void init_ldb(void); -extern void init_auth(void); -extern void init_credentials(void); -extern void init_tdb(void); -extern void init_dcerpc(void); -extern void init_events(void); -extern void inituuid(void); -extern void init_net(void); -extern void initecho(void); -extern void initdfs(void); -extern void initdrsuapi(void); -extern void initwinreg(void); -extern void initepmapper(void); -extern void initinitshutdown(void); -extern void initmgmt(void); -extern void initnet(void); -extern void initatsvc(void); -extern void initsamr(void); -extern void initlsa(void); -extern void initsvcctl(void); -extern void initwkssvc(void); -extern void initunixinfo(void); -extern void init_libcli_nbt(void); -extern void init_libcli_smb(void); +static bool PySys_PathPrepend(PyObject *list, const char *path) +{ + PyObject *py_path = PyString_FromString(path); + if (py_path == NULL) + return false; -static struct _inittab py_modules[] = { STATIC_LIBPYTHON_MODULES }; + return (PyList_Insert(list, 0, py_path) == 0); +} -void py_load_samba_modules(void) +bool py_update_path(void) { - int i; - for (i = 0; i < ARRAY_SIZE(py_modules); i++) { - PyImport_ExtendInittab(&py_modules[i]); + PyObject *mod_sys, *py_path; + + mod_sys = PyImport_ImportModule("sys"); + if (mod_sys == NULL) { + return false; } -} -void py_update_path(const char *bindir) -{ - char *newpath; - asprintf(&newpath, "%s/python:%s/../scripting/python:%s", bindir, bindir, Py_GetPath()); - PySys_SetPath(newpath); - free(newpath); + py_path = PyObject_GetAttrString(mod_sys, "path"); + if (py_path == NULL) { + return false; + } + + if (!PyList_Check(py_path)) { + return false; + } + + if (!PySys_PathPrepend(py_path, dyn_PYTHONDIR)) { + return false; + } + + if (strcmp(dyn_PYTHONARCHDIR, dyn_PYTHONDIR) != 0) { + if (!PySys_PathPrepend(py_path, dyn_PYTHONARCHDIR)) { + return false; + } + } + + return true; } -- cgit v1.2.3