From dbef4d76de92c3388f4e1819a76d6febf90be290 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 6 Jan 2006 16:12:45 +0000 Subject: r12743: Remove the ugly way we had to make a second stage init and introduce a second_stage_init private function for modules that need a second stage init. Simo. (This used to be commit 5e8b365fa2d93801a5de1d9ea76ce9d5546bd248) --- source4/dsdb/samdb/ldb_modules/extended_dn.c | 41 +++++++++++++------------- source4/dsdb/samdb/ldb_modules/objectguid.c | 4 +-- source4/dsdb/samdb/ldb_modules/password_hash.c | 4 +-- source4/dsdb/samdb/ldb_modules/proxy.c | 4 +-- source4/dsdb/samdb/ldb_modules/rootdse.c | 4 +-- source4/dsdb/samdb/ldb_modules/samba3sam.c | 4 +-- source4/dsdb/samdb/ldb_modules/samldb.c | 4 +-- 7 files changed, 26 insertions(+), 39 deletions(-) (limited to 'source4/dsdb') diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn.c b/source4/dsdb/samdb/ldb_modules/extended_dn.c index 49af8604d5..839c190a8e 100644 --- a/source4/dsdb/samdb/ldb_modules/extended_dn.c +++ b/source4/dsdb/samdb/ldb_modules/extended_dn.c @@ -266,35 +266,34 @@ static int extended_request(struct ldb_module *module, struct ldb_request *req) } } +static int extended_init_2(struct ldb_module *module) +{ + struct ldb_request request; + int ret; + + request.operation = LDB_REQ_REGISTER; + request.op.reg.oid = LDB_CONTROL_EXTENDED_DN_OID; + request.controls = NULL; + + ret = ldb_request(module->ldb, &request); + if (ret != LDB_SUCCESS) { + ldb_debug(module->ldb, LDB_DEBUG_ERROR, "extended_dn: Unable to register control with rootdse!\n"); + return LDB_ERR_OTHER; + } + + return ldb_next_second_stage_init(module); +} + static const struct ldb_module_ops extended_dn_ops = { .name = "extended_dn", .request = extended_request, + .second_stage_init = extended_init_2 }; -#ifdef HAVE_DLOPEN_DISABLED -struct ldb_module *init_module(struct ldb_context *ldb, int stage, const char *options[]) -#else -struct ldb_module *extended_dn_module_init(struct ldb_context *ldb, int stage, const char *options[]) -#endif +struct ldb_module *extended_dn_module_init(struct ldb_context *ldb, const char *options[]) { struct ldb_module *ctx; - if (stage == LDB_MODULES_INIT_STAGE_2) { - struct ldb_request request; - int ret; - - request.operation = LDB_REQ_REGISTER; - request.op.reg.oid = LDB_CONTROL_EXTENDED_DN_OID; - request.controls = NULL; - - ret = ldb_request(ldb, &request); - if (ret != LDB_SUCCESS) { - ldb_debug(ldb, LDB_DEBUG_ERROR, "extended_dn: Unable to register control with rootdse!\n"); - } - - return NULL; - } - ctx = talloc(ldb, struct ldb_module); if (!ctx) return NULL; diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c index 935f92c55b..c9063af6ef 100644 --- a/source4/dsdb/samdb/ldb_modules/objectguid.c +++ b/source4/dsdb/samdb/ldb_modules/objectguid.c @@ -128,12 +128,10 @@ static const struct ldb_module_ops objectguid_ops = { /* the init function */ -struct ldb_module *objectguid_module_init(struct ldb_context *ldb, int stage, const char *options[]) +struct ldb_module *objectguid_module_init(struct ldb_context *ldb, const char *options[]) { struct ldb_module *ctx; - if (stage != LDB_MODULES_INIT_STAGE_1) return NULL; - ctx = talloc(ldb, struct ldb_module); if (!ctx) return NULL; diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c index 82e4639a23..2b979857d9 100644 --- a/source4/dsdb/samdb/ldb_modules/password_hash.c +++ b/source4/dsdb/samdb/ldb_modules/password_hash.c @@ -717,12 +717,10 @@ static const struct ldb_module_ops password_hash_ops = { /* the init function */ -struct ldb_module *password_hash_module_init(struct ldb_context *ldb, int stage, const char *options[]) +struct ldb_module *password_hash_module_init(struct ldb_context *ldb, const char *options[]) { struct ldb_module *ctx; - if (stage != LDB_MODULES_INIT_STAGE_1) return NULL; - ctx = talloc(ldb, struct ldb_module); if (!ctx) return NULL; diff --git a/source4/dsdb/samdb/ldb_modules/proxy.c b/source4/dsdb/samdb/ldb_modules/proxy.c index 540f4241b9..2c66d2c1ec 100644 --- a/source4/dsdb/samdb/ldb_modules/proxy.c +++ b/source4/dsdb/samdb/ldb_modules/proxy.c @@ -333,12 +333,10 @@ static const struct ldb_module_ops proxy_ops = { .request = proxy_request }; -struct ldb_module *proxy_module_init(struct ldb_context *ldb, int stage, const char *options[]) +struct ldb_module *proxy_module_init(struct ldb_context *ldb, const char *options[]) { struct ldb_module *ctx; - if (stage != LDB_MODULES_INIT_STAGE_1) return NULL; - ctx = talloc(ldb, struct ldb_module); if (!ctx) return NULL; diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c index 8e0c231301..68de8c884c 100644 --- a/source4/dsdb/samdb/ldb_modules/rootdse.c +++ b/source4/dsdb/samdb/ldb_modules/rootdse.c @@ -187,13 +187,11 @@ static const struct ldb_module_ops rootdse_ops = { .request = rootdse_request }; -struct ldb_module *rootdse_module_init(struct ldb_context *ldb, int stage, const char *options[]) +struct ldb_module *rootdse_module_init(struct ldb_context *ldb, const char *options[]) { struct ldb_module *ctx; struct private_data *data; - if (stage != LDB_MODULES_INIT_STAGE_1) return NULL; - ctx = talloc(ldb, struct ldb_module); if (!ctx) return NULL; diff --git a/source4/dsdb/samdb/ldb_modules/samba3sam.c b/source4/dsdb/samdb/ldb_modules/samba3sam.c index 035321a90b..429710c2c5 100644 --- a/source4/dsdb/samdb/ldb_modules/samba3sam.c +++ b/source4/dsdb/samdb/ldb_modules/samba3sam.c @@ -878,9 +878,7 @@ const struct ldb_map_attribute samba3_attributes[] = }; /* the init function */ -struct ldb_module *ldb_samba3sam_module_init(struct ldb_context *ldb, int stage, const char *options[]) +struct ldb_module *ldb_samba3sam_module_init(struct ldb_context *ldb, const char *options[]) { - if (stage != LDB_MODULES_INIT_STAGE_1) return NULL; - return ldb_map_init(ldb, samba3_attributes, samba3_objectclasses, "samba3sam"); } diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index 82c2d4d0cc..7bf25994e2 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -583,12 +583,10 @@ static const struct ldb_module_ops samldb_ops = { /* the init function */ -struct ldb_module *samldb_module_init(struct ldb_context *ldb, int stage, const char *options[]) +struct ldb_module *samldb_module_init(struct ldb_context *ldb, const char *options[]) { struct ldb_module *ctx; - if (stage != LDB_MODULES_INIT_STAGE_1) return NULL; - ctx = talloc(ldb, struct ldb_module); if (!ctx) return NULL; -- cgit