summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/dsdb/samdb/ldb_modules/extended_dn.c41
-rw-r--r--source4/dsdb/samdb/ldb_modules/objectguid.c4
-rw-r--r--source4/dsdb/samdb/ldb_modules/password_hash.c4
-rw-r--r--source4/dsdb/samdb/ldb_modules/proxy.c4
-rw-r--r--source4/dsdb/samdb/ldb_modules/rootdse.c4
-rw-r--r--source4/dsdb/samdb/ldb_modules/samba3sam.c4
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c4
-rw-r--r--source4/lib/ldb/common/ldb.c13
-rw-r--r--source4/lib/ldb/common/ldb_modules.c21
-rw-r--r--source4/lib/ldb/include/ldb_private.h21
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c8
-rw-r--r--source4/lib/ldb/ldb_ldap/ldb_ldap.c8
-rw-r--r--source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c7
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c8
-rw-r--r--source4/lib/ldb/modules/objectclass.c4
-rw-r--r--source4/lib/ldb/modules/operational.c4
-rw-r--r--source4/lib/ldb/modules/paged_results.c37
-rw-r--r--source4/lib/ldb/modules/rdn_name.c4
-rw-r--r--source4/lib/ldb/modules/schema.c4
-rw-r--r--source4/lib/ldb/modules/skel.c16
-rw-r--r--source4/lib/ldb/modules/sort.c37
21 files changed, 142 insertions, 115 deletions
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;
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 604f02a1f7..78e6a74425 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -121,6 +121,19 @@ static void ldb_reset_err_string(struct ldb_context *ldb)
} while (0)
/*
+ second stage init all modules loaded
+*/
+int ldb_second_stage_init(struct ldb_context *ldb)
+{
+ struct ldb_module *module;
+
+ FIRST_OP(ldb, second_stage_init);
+
+ return module->ops->second_stage_init(module);
+}
+
+
+/*
start a transaction
*/
int ldb_transaction_start(struct ldb_context *ldb)
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index 26a397dccc..715112a628 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -201,7 +201,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
int m;
for (m=0;well_known_modules[m].name;m++) {
if (strcmp(modules[i], well_known_modules[m].name) == 0) {
- current = well_known_modules[m].init(ldb, LDB_MODULES_INIT_STAGE_1, options);
+ current = well_known_modules[m].init(ldb, options);
if (current == NULL) {
ldb_debug(ldb, LDB_DEBUG_FATAL, "function 'init_module' in %s fails\n", modules[i]);
return -1;
@@ -217,14 +217,9 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
}
/* second stage init */
- for (i = 0; modules[i] != NULL; i++) {
- int m;
- for (m = 0; well_known_modules[m].name; m++) {
- if (strcmp(modules[i], well_known_modules[m].name) == 0) {
- well_known_modules[m].init(ldb, LDB_MODULES_INIT_STAGE_2, options);
- break;
- }
- }
+ if (ldb_second_stage_init(ldb) != LDB_SUCCESS) {
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ERROR: Second stage init failed!\n");
+ return -1;
}
talloc_free(modules);
@@ -239,7 +234,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
#define FIND_OP(module, op) do { \
module = module->next; \
while (module && module->ops->op == NULL) module = module->next; \
- if (module == NULL) return -1; \
+ if (module == NULL) return LDB_ERR_OTHER; \
} while (0)
@@ -252,6 +247,12 @@ int ldb_next_request(struct ldb_module *module, struct ldb_request *request)
return module->ops->request(module, request);
}
+int ldb_next_second_stage_init(struct ldb_module *module)
+{
+ FIND_OP(module, second_stage_init);
+ return module->ops->second_stage_init(module);
+}
+
int ldb_next_start_trans(struct ldb_module *module)
{
FIND_OP(module, start_transaction);
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index e8a4d1820a..4ef7c5a96d 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -60,6 +60,7 @@ struct ldb_module_ops {
int (*start_transaction)(struct ldb_module *);
int (*end_transaction)(struct ldb_module *);
int (*del_transaction)(struct ldb_module *);
+ int (*second_stage_init)(struct ldb_module *);
};
@@ -104,9 +105,7 @@ struct ldb_context {
};
/* the modules init function */
-#define LDB_MODULES_INIT_STAGE_1 1
-#define LDB_MODULES_INIT_STAGE_2 2
-typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, int stage, const char **);
+typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, const char **);
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
@@ -117,6 +116,9 @@ typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, int stage,
*/
#define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__)
+/* The following definitions come from lib/ldb/common/ldb.c */
+int ldb_second_stage_init(struct ldb_context *ldb);
+
/* The following definitions come from lib/ldb/common/ldb_modules.c */
int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
@@ -124,6 +126,7 @@ int ldb_next_request(struct ldb_module *module, struct ldb_request *request);
int ldb_next_start_trans(struct ldb_module *module);
int ldb_next_end_trans(struct ldb_module *module);
int ldb_next_del_trans(struct ldb_module *module);
+int ldb_next_second_stage_init(struct ldb_module *module);
void ldb_set_errstring(struct ldb_module *module, char *err_string);
@@ -149,12 +152,12 @@ int lsqlite3_connect(struct ldb_context *ldb,
const char *url,
unsigned int flags,
const char *options[]);
-struct ldb_module *objectclass_module_init(struct ldb_context *ldb, int stage, const char *options[]);
-struct ldb_module *operational_module_init(struct ldb_context *ldb, int stage, const char *options[]);
-struct ldb_module *paged_results_module_init(struct ldb_context *ldb, int stage, const char *options[]);
-struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, int stage, const char *options[]);
-struct ldb_module *schema_module_init(struct ldb_context *ldb, int stage, const char *options[]);
-struct ldb_module *server_sort_module_init(struct ldb_context *ldb, int stage, const char *options[]);
+struct ldb_module *objectclass_module_init(struct ldb_context *ldb, const char *options[]);
+struct ldb_module *operational_module_init(struct ldb_context *ldb, const char *options[]);
+struct ldb_module *paged_results_module_init(struct ldb_context *ldb, const char *options[]);
+struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[]);
+struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]);
+struct ldb_module *server_sort_module_init(struct ldb_context *ldb, const char *options[]);
int ldb_match_msg(struct ldb_context *ldb,
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index ff00a61163..2837296b68 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -441,12 +441,18 @@ static int ildb_request(struct ldb_module *module, struct ldb_request *req)
}
}
+static int ildb_init_2(struct ldb_module *module)
+{
+ return LDB_SUCCESS;
+}
+
static const struct ldb_module_ops ildb_ops = {
.name = "ldap",
.request = ildb_request,
.start_transaction = ildb_start_trans,
.end_transaction = ildb_end_trans,
- .del_transaction = ildb_del_trans
+ .del_transaction = ildb_del_trans,
+ .second_stage_init = ildb_init_2
};
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
index 8207b5f592..dffd0e969c 100644
--- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
@@ -514,12 +514,18 @@ static int lldb_request(struct ldb_module *module, struct ldb_request *req)
}
}
+static int lldb_init_2(struct ldb_module *module)
+{
+ return LDB_SUCCESS;
+}
+
static const struct ldb_module_ops lldb_ops = {
.name = "ldap",
.request = lldb_request,
.start_transaction = lldb_start_trans,
.end_transaction = lldb_end_trans,
- .del_transaction = lldb_del_trans
+ .del_transaction = lldb_del_trans,
+ .second_stage_init = lldb_init_2
};
diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
index 464c8ce69f..2e8b88a090 100644
--- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
+++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
@@ -1819,6 +1819,10 @@ static int lsqlite3_request(struct ldb_module *module, struct ldb_request *req)
}
}
+static int lsqlite3_init_2(struct ldb_module *module)
+{
+ return LDB_SUCCESS;
+}
/*
* Table of operations for the sqlite3 backend
@@ -1828,7 +1832,8 @@ static const struct ldb_module_ops lsqlite3_ops = {
.request = lsqlite3_request,
.start_transaction = lsqlite3_start_trans,
.end_transaction = lsqlite3_end_trans,
- .del_transaction = lsqlite3_del_trans
+ .del_transaction = lsqlite3_del_trans,
+ .second_stage_init = lsqlite3_init_2
};
/*
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 432c713336..0a9a99ccea 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -773,12 +773,18 @@ static int ltdb_request(struct ldb_module *module, struct ldb_request *req)
}
}
+static int ltdb_init_2(struct ldb_module *module)
+{
+ return LDB_SUCCESS;
+}
+
static const struct ldb_module_ops ltdb_ops = {
.name = "tdb",
.request = ltdb_request,
.start_transaction = ltdb_start_trans,
.end_transaction = ltdb_end_trans,
- .del_transaction = ltdb_del_trans
+ .del_transaction = ltdb_del_trans,
+ .second_stage_init = ltdb_init_2
};
diff --git a/source4/lib/ldb/modules/objectclass.c b/source4/lib/ldb/modules/objectclass.c
index 7a037cc98a..c38b3167e8 100644
--- a/source4/lib/ldb/modules/objectclass.c
+++ b/source4/lib/ldb/modules/objectclass.c
@@ -305,12 +305,10 @@ static const struct ldb_module_ops objectclass_ops = {
.request = objectclass_request,
};
-struct ldb_module *objectclass_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *objectclass_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/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c
index 09de0936a1..65d9f12e34 100644
--- a/source4/lib/ldb/modules/operational.c
+++ b/source4/lib/ldb/modules/operational.c
@@ -368,12 +368,10 @@ static const struct ldb_module_ops operational_ops = {
/* the init function */
-struct ldb_module *operational_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *operational_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/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c
index 31b73d2ae4..8e9fc28348 100644
--- a/source4/lib/ldb/modules/paged_results.c
+++ b/source4/lib/ldb/modules/paged_results.c
@@ -248,32 +248,35 @@ static int paged_request(struct ldb_module *module, struct ldb_request *req)
}
}
+static int paged_request_init_2(struct ldb_module *module)
+{
+ struct ldb_request request;
+ int ret;
+
+ request.operation = LDB_REQ_REGISTER;
+ request.op.reg.oid = LDB_CONTROL_PAGED_RESULTS_OID;
+ request.controls = NULL;
+
+ ret = ldb_request(module->ldb, &request);
+ if (ret != LDB_SUCCESS) {
+ ldb_debug(module->ldb, LDB_DEBUG_ERROR, "paged_request: Unable to register control with rootdse!\n");
+ return LDB_ERR_OTHER;
+ }
+
+ return ldb_next_second_stage_init(module);
+}
+
static const struct ldb_module_ops paged_ops = {
.name = "paged_results",
.request = paged_request,
+ .second_stage_init = paged_request_init_2
};
-struct ldb_module *paged_results_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *paged_results_module_init(struct ldb_context *ldb, const char *options[])
{
struct ldb_module *ctx;
struct private_data *data;
- if (stage == LDB_MODULES_INIT_STAGE_2) {
- struct ldb_request request;
- int ret;
-
- request.operation = LDB_REQ_REGISTER;
- request.op.reg.oid = LDB_CONTROL_PAGED_RESULTS_OID;
- request.controls = NULL;
-
- ret = ldb_request(ldb, &request);
- if (ret != LDB_SUCCESS) {
- ldb_debug(ldb, LDB_DEBUG_ERROR, "paged_request: Unable to register control with rootdse!\n");
- }
-
- return NULL;
- }
-
ctx = talloc(ldb, struct ldb_module);
if (!ctx)
return NULL;
diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c
index f6dbc38740..f35cff916c 100644
--- a/source4/lib/ldb/modules/rdn_name.c
+++ b/source4/lib/ldb/modules/rdn_name.c
@@ -214,12 +214,10 @@ static const struct ldb_module_ops rdn_name_ops = {
/* the init function */
-struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *rdn_name_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/lib/ldb/modules/schema.c b/source4/lib/ldb/modules/schema.c
index 778f52885c..9fb2efee30 100644
--- a/source4/lib/ldb/modules/schema.c
+++ b/source4/lib/ldb/modules/schema.c
@@ -484,12 +484,10 @@ static const struct ldb_module_ops schema_ops = {
.request = schema_request
};
-struct ldb_module *schema_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *schema_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/lib/ldb/modules/skel.c b/source4/lib/ldb/modules/skel.c
index dacbd6960e..10f730b2f9 100644
--- a/source4/lib/ldb/modules/skel.c
+++ b/source4/lib/ldb/modules/skel.c
@@ -123,25 +123,27 @@ static int skel_request(struct ldb_module *module, struct ldb_request *req)
}
}
+static int skel_init_2(struct ldb_module *module)
+{
+ /* second stage init stuff */
+ /* see control modules as example */
+ return ldb_next_second_stage_init(module);
+}
+
static const struct ldb_module_ops skel_ops = {
.name = "skel",
.request = skel_request,
.start_transaction = skel_start_trans,
.end_transaction = skel_end_trans,
.del_transaction = skel_del_trans,
+ .second_stage_init = skel_init_2
};
-struct ldb_module *skel_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *skel_module_init(struct ldb_context *ldb, const char *options[])
{
struct ldb_module *ctx;
struct private_data *data;
- if (stage == LDB_MODULES_INIT_STAGE_2) {
- /* second stage init stuff */
- /* see control modules as example */
- return NULL;
- }
-
ctx = talloc(ldb, struct ldb_module);
if (!ctx)
return NULL;
diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c
index 2757647710..88b967b276 100644
--- a/source4/lib/ldb/modules/sort.c
+++ b/source4/lib/ldb/modules/sort.c
@@ -227,31 +227,34 @@ static int server_sort(struct ldb_module *module, struct ldb_request *req)
}
}
+static int server_sort_init_2(struct ldb_module *module)
+{
+ struct ldb_request request;
+ int ret;
+
+ request.operation = LDB_REQ_REGISTER;
+ request.op.reg.oid = LDB_CONTROL_SERVER_SORT_OID;
+ request.controls = NULL;
+
+ ret = ldb_request(module->ldb, &request);
+ if (ret != LDB_SUCCESS) {
+ ldb_debug(module->ldb, LDB_DEBUG_ERROR, "server_sort: Unable to register control with rootdse!\n");
+ return LDB_ERR_OTHER;
+ }
+
+ return ldb_next_second_stage_init(module);
+}
+
static const struct ldb_module_ops server_sort_ops = {
.name = "server_sort",
.request = server_sort,
+ .second_stage_init = server_sort_init_2
};
-struct ldb_module *server_sort_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *server_sort_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_SERVER_SORT_OID;
- request.controls = NULL;
-
- ret = ldb_request(ldb, &request);
- if (ret != LDB_SUCCESS) {
- ldb_debug(ldb, LDB_DEBUG_ERROR, "server_sort: Unable to register control with rootdse!\n");
- }
-
- return NULL;
- }
-
ctx = talloc(ldb, struct ldb_module);
if (!ctx)
return NULL;