From c874b9f42eebacd9ad6baa90309635db8b8ec3fb Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 16 Mar 2010 14:40:15 +1100 Subject: s4:dsdb Don't error out if we can't get the Aggregate schema DN yet It's easier to just set it up when we can, then to deal with the ordering issues in ldb startup. As long as we have it ready if a real client ever asks for it, then we should be happy. Andrew Bartlett --- source4/dsdb/samdb/ldb_modules/operational.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'source4') diff --git a/source4/dsdb/samdb/ldb_modules/operational.c b/source4/dsdb/samdb/ldb_modules/operational.c index 1d0269854f..9fc0d1aeae 100644 --- a/source4/dsdb/samdb/ldb_modules/operational.c +++ b/source4/dsdb/samdb/ldb_modules/operational.c @@ -265,7 +265,21 @@ static int construct_subschema_subentry(struct ldb_module *module, { struct operational_data *data = talloc_get_type(ldb_module_get_private(module), struct operational_data); char *subSchemaSubEntry; - if (data && data->aggregate_dn) { + + /* We may be being called before the init function has finished */ + if (!data) { + return LDB_SUCCESS; + } + + /* Try and set this value up, if possible. Don't worry if it + * fails, we may not have the DB set up yet, and it's not + * really vital anyway */ + if (!data->aggregate_dn) { + struct ldb_context *ldb = ldb_module_get_ctx(module); + data->aggregate_dn = samdb_aggregate_schema_dn(ldb, data); + } + + if (data->aggregate_dn) { subSchemaSubEntry = ldb_dn_alloc_linearized(msg, data->aggregate_dn); return ldb_msg_add_steal_string(msg, "subSchemaSubEntry", subSchemaSubEntry); } @@ -563,25 +577,18 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req static int operational_init(struct ldb_module *ctx) { struct operational_data *data; - struct ldb_context *ldb = ldb_module_get_ctx(ctx); int ret = ldb_next_init(ctx); if (ret != LDB_SUCCESS) { return ret; } - data = talloc(ctx, struct operational_data); + data = talloc_zero(ctx, struct operational_data); if (!data) { ldb_module_oom(ctx); return LDB_ERR_OPERATIONS_ERROR; } - data->aggregate_dn = samdb_aggregate_schema_dn(ldb, data); - if (!data->aggregate_dn) { - ldb_set_errstring(ldb, "Could not build aggregate schema DN"); - return LDB_ERR_OPERATIONS_ERROR; - } - ldb_module_set_private(ctx, data); return LDB_SUCCESS; -- cgit