summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-12-12 16:56:53 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:29:09 -0500
commitddfb73568aac22f7d98264fe5faec532f2500905 (patch)
treee1837be7fdad14f85709f30f5c6eded82698a42a /source4
parentf1aaa16cbc1747d411aa4b3ec82992f44c64fe7b (diff)
downloadsamba-ddfb73568aac22f7d98264fe5faec532f2500905.tar.gz
samba-ddfb73568aac22f7d98264fe5faec532f2500905.tar.bz2
samba-ddfb73568aac22f7d98264fe5faec532f2500905.zip
r20120: fix the talloc hierachy and make ildb a child of module
metze (This used to be commit b85d5cb7a4931d1d43a0ec73f1de1519c720f1af)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index 567fe4bd5f..9a0157e517 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -54,6 +54,7 @@
struct ildb_private {
struct ldap_connection *ldap;
struct ldb_context *ldb;
+ struct ldb_module *module;
};
struct ildb_context {
@@ -738,20 +739,32 @@ static const struct ldb_module_ops ildb_ops = {
*/
static int ildb_connect(struct ldb_context *ldb, const char *url,
unsigned int flags, const char *options[],
- struct ldb_module **module)
+ struct ldb_module **_module)
{
- struct ildb_private *ildb = NULL;
+ struct ldb_module *module;
+ struct ildb_private *ildb;
NTSTATUS status;
struct cli_credentials *creds;
- ildb = talloc(ldb, struct ildb_private);
+ module = talloc(ldb, struct ldb_module);
+ if (!module) {
+ ldb_oom(ldb);
+ return -1;
+ }
+ talloc_set_name_const(module, "ldb_ildap backend");
+ module->ldb = ldb;
+ module->prev = module->next = NULL;
+ module->private_data = NULL;
+ module->ops = &ildb_ops;
+
+ ildb = talloc(module, struct ildb_private);
if (!ildb) {
ldb_oom(ldb);
goto failed;
}
-
- ildb->ldb = ldb;
-
+ module->private_data = ildb;
+ ildb->ldb = ldb;
+ ildb->module = module;
ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "EventContext"));
if (!ildb->ldap) {
ldb_oom(ldb);
@@ -769,19 +782,6 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
goto failed;
}
-
- *module = talloc(ldb, struct ldb_module);
- if (!module) {
- ldb_oom(ldb);
- talloc_free(ildb);
- return -1;
- }
- talloc_set_name_const(*module, "ldb_ildap backend");
- (*module)->ldb = ldb;
- (*module)->prev = (*module)->next = NULL;
- (*module)->private_data = ildb;
- (*module)->ops = &ildb_ops;
-
/* caller can optionally setup credentials using the opaque token 'credentials' */
creds = talloc_get_type(ldb_get_opaque(ldb, "credentials"), struct cli_credentials);
if (creds == NULL) {
@@ -811,10 +811,11 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
}
}
+ *_module = module;
return 0;
failed:
- talloc_free(ildb);
+ talloc_free(module);
return -1;
}