diff options
author | bubulle <bubulle@alioth.debian.org> | 2012-01-26 19:58:37 +0000 |
---|---|---|
committer | bubulle <bubulle@alioth.debian.org> | 2012-01-26 19:58:37 +0000 |
commit | cb25bc5ca98dff7a896f596f9f1586a4739ad8ec (patch) | |
tree | 31bd310956a0c533e3e46cb88aec6e00b5eedf53 /source4/scripting/python/modules.c | |
parent | 5f021ee1efe415ba8fe4281d0622204a68074ea8 (diff) | |
download | samba-cb25bc5ca98dff7a896f596f9f1586a4739ad8ec.tar.gz |
Load samba-3.6.2 into branches/samba/upstream.upstream/3.6.2
git-svn-id: svn://svn.debian.org/svn/pkg-samba/branches/samba/upstream@3992 fc4039ab-9d04-0410-8cac-899223bdd6b0
Diffstat (limited to 'source4/scripting/python/modules.c')
-rw-r--r-- | source4/scripting/python/modules.c | 77 |
1 files changed, 35 insertions, 42 deletions
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 <http://www.gnu.org/licenses/>. */ +#include <Python.h> #include "includes.h" #include "scripting/python/modules.h" -#include <Python.h> +#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; } |