summaryrefslogtreecommitdiff
path: root/source4/scripting/python
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting/python')
-rw-r--r--source4/scripting/python/pyglue.c26
-rw-r--r--source4/scripting/python/samba/__init__.py2
2 files changed, 18 insertions, 10 deletions
diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c
index 1480e54403..5816d9637d 100644
--- a/source4/scripting/python/pyglue.c
+++ b/source4/scripting/python/pyglue.c
@@ -31,6 +31,7 @@
#include "libcli/security/security.h"
#include "auth/pyauth.h"
#include "param/pyparam.h"
+#include "auth/credentials/pycredentials.h"
#ifndef Py_RETURN_NONE
#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
@@ -38,16 +39,23 @@
/* FIXME: These should be in a header file somewhere, once we finish moving
* away from SWIG .. */
-extern struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj);
-
#define PyErr_LDB_OR_RAISE(py_ldb, ldb) \
- if (!PyLdb_Check(py_ldb)) { \
- /*PyErr_SetString(PyExc_TypeError, "Ldb connection object required"); \
- return NULL; \ */ \
- } \
+/* if (!PyLdb_Check(py_ldb)) { \
+ PyErr_SetString(py_ldb_get_exception(), "Ldb connection object required"); \
+ return NULL; \
+ } */\
ldb = PyLdb_AsLdbContext(py_ldb);
+static PyObject *py_ldb_get_exception(void)
+{
+ PyObject *mod = PyImport_ImportModule("ldb");
+ if (mod == NULL)
+ return NULL;
+
+ return PyObject_GetAttrString(mod, "LdbError");
+}
+
static PyObject *py_generate_random_str(PyObject *self, PyObject *args)
{
int len;
@@ -90,7 +98,7 @@ static PyObject *py_ldb_set_credentials(PyObject *self, PyObject *args)
return NULL;
}
- ldb_set_opaque(ldb, "credentials", creds);
+ ldb_set_opaque(ldb, "credentials", creds);
Py_RETURN_NONE;
}
@@ -172,7 +180,7 @@ static PyObject *py_ldb_register_samba_handlers(PyObject *self, PyObject *args)
PyErr_LDB_OR_RAISE(py_ldb, ldb);
ret = ldb_register_samba_handlers(ldb);
- PyErr_LDB_ERROR_IS_ERR_RAISE(ret, ldb);
+ PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret, ldb);
Py_RETURN_NONE;
}
@@ -207,7 +215,7 @@ static PyObject *py_dsdb_set_global_schema(PyObject *self, PyObject *args)
PyErr_LDB_OR_RAISE(py_ldb, ldb);
ret = dsdb_set_global_schema(ldb);
- PyErr_LDB_ERROR_IS_ERR_RAISE(ret, ldb);
+ PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret, ldb);
Py_RETURN_NONE;
}
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index 3ecb758595..f93b0eda60 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -28,7 +28,7 @@ import os
def _in_source_tree():
"""Check whether the script is being run from the source dir. """
- return os.path.exists("%s/../../../samba4-skip" % os.path.dirname(__file__))
+ return os.path.exists("%s/../../../selftest/skip" % os.path.dirname(__file__))
# When running, in-tree, make sure bin/python is in the PYTHONPATH