1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

provision/pyldb: Avoid linking in static python ldb module.

This commit is contained in:
Jelmer Vernooij 2009-12-20 18:31:27 +01:00 committed by Jelmer Vernooij
parent 1d9a243d68
commit 5b9e98a382
4 changed files with 32 additions and 6 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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)

View File

@ -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) {