diff options
-rw-r--r-- | source4/lib/ldb/pyldb.c | 4 | ||||
-rw-r--r-- | source4/lib/ldb/pyldb.h | 1 | ||||
-rw-r--r-- | source4/param/config.mk | 2 | ||||
-rw-r--r-- | source4/param/provision.c | 31 |
4 files changed, 32 insertions, 6 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index 0ba69e1c48..a19768d41b 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -61,6 +61,8 @@ PyAPI_DATA(PyTypeObject) PyLdb; PyAPI_DATA(PyTypeObject) PyLdbMessageElement; PyAPI_DATA(PyTypeObject) PyLdbTree; +static PyObject *PyLdb_FromLdbContext(struct ldb_context *ldb_ctx); + static PyObject *PyObject_FromLdbValue(struct ldb_context *ldb_ctx, struct ldb_message_element *el, struct ldb_val *val) @@ -1357,7 +1359,7 @@ static PySequenceMethods py_ldb_seq = { .sq_contains = (objobjproc)py_ldb_contains, }; -PyObject *PyLdb_FromLdbContext(struct ldb_context *ldb_ctx) +static PyObject *PyLdb_FromLdbContext(struct ldb_context *ldb_ctx) { PyLdbObject *ret; diff --git a/source4/lib/ldb/pyldb.h b/source4/lib/ldb/pyldb.h index a0954158bd..289159c5b3 100644 --- a/source4/lib/ldb/pyldb.h +++ b/source4/lib/ldb/pyldb.h @@ -35,7 +35,6 @@ typedef struct { TALLOC_CTX *mem_ctx; } PyLdbObject; -PyObject *PyLdb_FromLdbContext(struct ldb_context *ldb_ctx); #define PyLdb_AsLdbContext(pyobj) ((PyLdbObject *)pyobj)->ldb_ctx #define PyLdb_Check(ob) PyObject_TypeCheck(ob, &PyLdb) 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) { |