From 2de07761e071ccf09c0ea9e0fdc6a61303356549 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 16 Mar 2010 14:52:39 +1100 Subject: s4:dsdb Change dsdb_get_schema() callers to use new talloc argument This choses an appropriate talloc context to attach the schema too, long enough lived to ensure it does not go away before the operation compleates. Andrew Bartlett --- source4/dsdb/samdb/ldb_modules/resolve_oids.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'source4/dsdb/samdb/ldb_modules/resolve_oids.c') diff --git a/source4/dsdb/samdb/ldb_modules/resolve_oids.c b/source4/dsdb/samdb/ldb_modules/resolve_oids.c index 5ff246b191..aab997d996 100644 --- a/source4/dsdb/samdb/ldb_modules/resolve_oids.c +++ b/source4/dsdb/samdb/ldb_modules/resolve_oids.c @@ -464,7 +464,7 @@ static int resolve_oids_search(struct ldb_module *module, struct ldb_request *re uint32_t i; ldb = ldb_module_get_ctx(module); - schema = dsdb_get_schema(ldb); + schema = dsdb_get_schema(ldb, NULL); if (!schema) { return ldb_next_request(module, req); @@ -487,7 +487,7 @@ static int resolve_oids_search(struct ldb_module *module, struct ldb_request *re for (i=0; attrs1 && attrs1[i]; i++) { const char *p; - struct dsdb_attribute *a; + const struct dsdb_attribute *a; p = strchr(attrs1[i], '.'); if (p == NULL) { @@ -521,6 +521,8 @@ static int resolve_oids_search(struct ldb_module *module, struct ldb_request *re return LDB_ERR_OPERATIONS_ERROR; } + talloc_reference(tree, schema); + ret = resolve_oids_parse_tree_replace(ldb, schema, tree); if (ret != LDB_SUCCESS) { @@ -576,7 +578,7 @@ static int resolve_oids_add(struct ldb_module *module, struct ldb_request *req) struct resolve_oids_context *ac; ldb = ldb_module_get_ctx(module); - schema = dsdb_get_schema(ldb); + schema = dsdb_get_schema(ldb, NULL); if (!schema) { return ldb_next_request(module, req); @@ -609,6 +611,11 @@ static int resolve_oids_add(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } + if (!talloc_reference(msg, schema)) { + ldb_oom(ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + ret = resolve_oids_message_replace(ldb, schema, msg); if (ret != LDB_SUCCESS) { return ret; @@ -637,7 +644,7 @@ static int resolve_oids_modify(struct ldb_module *module, struct ldb_request *re struct resolve_oids_context *ac; ldb = ldb_module_get_ctx(module); - schema = dsdb_get_schema(ldb); + schema = dsdb_get_schema(ldb, NULL); if (!schema) { return ldb_next_request(module, req); @@ -671,6 +678,11 @@ static int resolve_oids_modify(struct ldb_module *module, struct ldb_request *re return LDB_ERR_OPERATIONS_ERROR; } + if (!talloc_reference(msg, schema)) { + ldb_oom(ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + ret = resolve_oids_message_replace(ldb, schema, msg); if (ret != LDB_SUCCESS) { return ret; -- cgit