* ordering
*/
+ if (data == NULL) {
+ TALLOC_CTX *mem_ctx = talloc_new(module);
+
+ data = talloc_zero(mem_ctx, struct partition_private_data);
+ if (data == NULL) {
+ talloc_free(mem_ctx);
+ return ldb_operr(ldb);
+ }
+
+ /*
+ * When used from Samba4, this message is set by the
+ * samba4 module, as a fixed value not read from the
+ * DB. This avoids listing modules in the DB
+ */
+ data->forced_module_msg = talloc_get_type(
+ ldb_get_opaque(ldb,
+ DSDB_OPAQUE_PARTITION_MODULE_MSG_OPAQUE_NAME),
+ struct ldb_message);
+
+ ldb_module_set_private(module, talloc_steal(module,
+ data));
+ talloc_free(mem_ctx);
+ }
+
/*
* This will lock the metadata partition (sam.ldb) and
* will also call event loops, so we do it before we
return ldb_operr(ldb);
}
- data = talloc_zero(mem_ctx, struct partition_private_data);
- if (data == NULL) {
- return ldb_operr(ldb);
- }
-
- /* When used from Samba4, this message is set by the samba4
- * module, as a fixed value not read from the DB. This avoids
- * listing modules in the DB */
- data->forced_module_msg = talloc_get_type(
- ldb_get_opaque(ldb,
- DSDB_OPAQUE_PARTITION_MODULE_MSG_OPAQUE_NAME),
- struct ldb_message);
+ /* We actually got this during the read_lock call */
+ data = talloc_get_type_abort(ldb_module_get_private(module),
+ struct partition_private_data);
/* This loads the partitions */
ret = partition_reload_if_required(module, data, NULL);
static int samba_dsdb_init(struct ldb_module *module)
{
struct ldb_context *ldb = ldb_module_get_ctx(module);
- int ret, len, i, j;
+ int ret, lock_ret, len, i, j;
TALLOC_CTX *tmp_ctx = talloc_new(module);
struct ldb_result *res;
struct ldb_message *rootdse_msg = NULL, *partition_msg;
/* Set this as the 'next' module, so that we effectivly append it to module chain */
ldb_module_set_next(module, module_chain);
- return ldb_next_init(module);
+ ret = ldb_next_read_lock(module);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+
+ ret = ldb_next_init(module);
+
+ lock_ret = ldb_next_read_unlock(module);
+
+ if (lock_ret != LDB_SUCCESS) {
+ return lock_ret;
+ }
+
+ return ret;
}
static const struct ldb_module_ops ldb_samba_dsdb_module_ops = {
static int schema_load_init(struct ldb_module *module)
{
struct ldb_context *ldb = ldb_module_get_ctx(module);
- struct schema_load_private_data *private_data;
+ struct schema_load_private_data *private_data =
+ talloc_get_type_abort(ldb_module_get_private(module),
+ struct schema_load_private_data);
int ret;
- private_data = talloc_zero(module, struct schema_load_private_data);
- if (private_data == NULL) {
- return ldb_oom(ldb);
- }
- private_data->module = module;
-
- ldb_module_set_private(module, private_data);
-
ret = ldb_next_init(module);
if (ret != LDB_SUCCESS) {
return ret;
int ret;
if (private_data == NULL) {
- return ldb_next_read_lock(module);
+ private_data = talloc_zero(module, struct schema_load_private_data);
+ if (private_data == NULL) {
+ return ldb_module_oom(module);
+ }
+
+ private_data->module = module;
+
+ ldb_module_set_private(module, private_data);
}
ret = ldb_next_read_lock(module);
static int schema_read_unlock(struct ldb_module *module)
{
struct schema_load_private_data *private_data =
- talloc_get_type(ldb_module_get_private(module), struct schema_load_private_data);
-
- if (private_data == NULL) {
- return ldb_next_read_unlock(module);
- }
+ talloc_get_type_abort(ldb_module_get_private(module),
+ struct schema_load_private_data);
private_data->in_read_transaction--;