summaryrefslogtreecommitdiff
path: root/source4/param
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-12-20 18:31:27 +0100
committerJelmer Vernooij <jelmer@ganieda.vernstok.nl>2009-12-21 23:40:12 +0100
commit5b9e98a3826f294a9a9451adacdf77839d30244d (patch)
tree32af4daa3766eb17c8da09a74df7ee285180426c /source4/param
parent1d9a243d68539438441a488d09c1200bf22c7462 (diff)
downloadsamba-5b9e98a3826f294a9a9451adacdf77839d30244d.tar.gz
samba-5b9e98a3826f294a9a9451adacdf77839d30244d.tar.bz2
samba-5b9e98a3826f294a9a9451adacdf77839d30244d.zip
provision/pyldb: Avoid linking in static python ldb module.
Diffstat (limited to 'source4/param')
-rw-r--r--source4/param/config.mk2
-rw-r--r--source4/param/provision.c31
2 files changed, 29 insertions, 4 deletions
diff --git a/source4/param/config.mk b/source4/param/config.mk
index 6e5290b64d..02bbdd5677 100644
--- a/source4/param/config.mk
+++ b/source4/param/config.mk
@@ -13,7 +13,7 @@ PUBLIC_HEADERS += param/param.h
PC_FILES += $(paramsrcdir)/samba-hostconfig.pc
[SUBSYSTEM::PROVISION]
-PRIVATE_DEPENDENCIES = LIBPYTHON pyldb pyparam_util
+PRIVATE_DEPENDENCIES = LIBPYTHON pyparam_util
PROVISION_OBJ_FILES = $(paramsrcdir)/provision.o $(param_OBJ_FILES)
diff --git a/source4/param/provision.c b/source4/param/provision.c
index 8c6e1c0f68..7bd10ca522 100644
--- a/source4/param/provision.c
+++ b/source4/param/provision.c
@@ -52,6 +52,34 @@ static PyObject *schema_module(void)
return PyImport_Import(name);
}
+static PyObject *ldb_module(void)
+{
+ PyObject *name = PyString_FromString("ldb");
+ if (name == NULL)
+ return NULL;
+ return PyImport_Import(name);
+}
+
+static PyObject *PyLdb_FromLdbContext(struct ldb_context *ldb_ctx)
+{
+ PyLdbObject *ret;
+ PyObject *ldb_mod = ldb_module();
+ PyTypeObject *ldb_ctx_type;
+ if (ldb_mod == NULL)
+ return NULL;
+
+ ldb_ctx_type = PyObject_GetAttrString(ldb_mod, "Ldb");
+
+ ret = (PyLdbObject *)ldb_ctx_type->tp_alloc(ldb_ctx_type, 0);
+ if (ret == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ ret->mem_ctx = talloc_new(NULL);
+ ret->ldb_ctx = talloc_reference(ret->mem_ctx, ldb_ctx);
+ return (PyObject *)ret;
+}
+
NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
struct provision_settings *settings,
struct provision_result *result)
@@ -167,8 +195,6 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
return NT_STATUS_OK;
}
-extern void initldb(void);
-
static PyObject *py_dom_sid_FromSid(struct dom_sid *sid)
{
PyObject *mod_security, *dom_sid_Type;
@@ -220,7 +246,6 @@ NTSTATUS provision_store_self_join(TALLOC_CTX *mem_ctx, struct loadparm_context
py_load_samba_modules();
Py_Initialize();
py_update_path("bin"); /* FIXME: Can't assume this is always the case */
- initldb();
provision_mod = provision_module();
if (provision_mod == NULL) {