summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/param/provision.c6
-rw-r--r--source4/samba_tool/samba_tool.c2
-rw-r--r--source4/scripting/python/modules.c20
-rw-r--r--source4/scripting/python/modules.h2
-rw-r--r--source4/web_server/wsgi.c3
5 files changed, 8 insertions, 25 deletions
diff --git a/source4/param/provision.c b/source4/param/provision.c
index e4236a59c5..7b6e6e74b3 100644
--- a/source4/param/provision.c
+++ b/source4/param/provision.c
@@ -84,7 +84,7 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
DEBUG(0,("Provision for Become-DC test using python\n"));
Py_Initialize();
- py_update_path("bin"); /* FIXME: Can't assume this is always the case */
+ py_update_path(); /* Put the samba path at the start of sys.path */
provision_mod = provision_module();
@@ -240,7 +240,7 @@ NTSTATUS provision_store_self_join(TALLOC_CTX *mem_ctx, struct loadparm_context
}
Py_Initialize();
- py_update_path("bin"); /* FIXME: Can't assume this is always the case */
+ py_update_path(); /* Put the samba path at the start of sys.path */
provision_mod = provision_module();
if (provision_mod == NULL) {
@@ -336,7 +336,7 @@ struct ldb_context *provision_get_schema(TALLOC_CTX *mem_ctx, struct loadparm_co
PyObject *schema_mod, *schema_dict, *schema_fn, *py_result, *parameters;
Py_Initialize();
- py_update_path("bin"); /* FIXME: Can't assume this is always the case */
+ py_update_path(); /* Put the samba path at the start of sys.path */
schema_mod = schema_module();
diff --git a/source4/samba_tool/samba_tool.c b/source4/samba_tool/samba_tool.c
index da08a716ce..411eb6d98d 100644
--- a/source4/samba_tool/samba_tool.c
+++ b/source4/samba_tool/samba_tool.c
@@ -308,7 +308,7 @@ static int binary_net(int argc, const char **argv)
}
Py_Initialize();
PySys_SetArgv(argc, discard_const_p(char *, argv));
- py_update_path("bin"); /* FIXME: Can't assume this is always the case */
+ py_update_path(); /* Put the Samba path at the start of sys.path */
py_cmds = py_commands();
if (py_cmds == NULL) {
diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c
index 960239e863..f2a45a9893 100644
--- a/source4/scripting/python/modules.c
+++ b/source4/scripting/python/modules.c
@@ -31,7 +31,7 @@ static bool PySys_PathPrepend(PyObject *list, const char *path)
return (PyList_Insert(list, 0, py_path) == 0);
}
-bool py_update_path(const char *bindir)
+bool py_update_path()
{
char *newpath;
PyObject *mod_sys, *py_path;
@@ -58,23 +58,5 @@ bool py_update_path(const char *bindir)
return false;
}
- if (asprintf(&newpath, "%s/../scripting/python", bindir) < 0) {
- return false;
- }
- if (!PySys_PathPrepend(py_path, newpath)) {
- free(newpath);
- return false;
- }
- free(newpath);
-
- if (asprintf(&newpath, "%s/python", bindir) < 0) {
- return false;
- }
- if (!PySys_PathPrepend(py_path, newpath)) {
- free(newpath);
- return false;
- }
- free(newpath);
-
return true;
}
diff --git a/source4/scripting/python/modules.h b/source4/scripting/python/modules.h
index 7c15fecabe..4e43e6de1d 100644
--- a/source4/scripting/python/modules.h
+++ b/source4/scripting/python/modules.h
@@ -20,6 +20,6 @@
#ifndef __SAMBA_PYTHON_MODULES_H__
#define __SAMBA_PYTHON_MODULES_H__
-bool py_update_path(const char *bindir);
+bool py_update_path();
#endif /* __SAMBA_PYTHON_MODULES_H__ */
diff --git a/source4/web_server/wsgi.c b/source4/web_server/wsgi.c
index 2f47af2d25..37ded29480 100644
--- a/source4/web_server/wsgi.c
+++ b/source4/web_server/wsgi.c
@@ -385,7 +385,8 @@ bool wsgi_initialize(struct web_server_data *wdata)
Py_Initialize();
- py_update_path("bin"); /* FIXME: Can't assume this is always the case */
+ py_update_path(); /* Ensure that we have the Samba paths at
+ * the start of the sys.path() */
if (PyType_Ready(&web_request_Type) < 0)
return false;