diff options
Diffstat (limited to 'source4/dsdb/samdb')
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/anr.c | 2 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/descriptor.c | 4 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/extended_dn_out.c | 4 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/extended_dn_store.c | 2 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/kludge_acl.c | 7 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/linked_attributes.c | 9 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/objectclass.c | 13 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 36 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/resolve_oids.c | 20 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/rootdse.c | 2 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/schema_data.c | 12 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/schema_load.c | 2 |
12 files changed, 85 insertions, 28 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/anr.c b/source4/dsdb/samdb/ldb_modules/anr.c index dbd0838c60..8411d98bdb 100644 --- a/source4/dsdb/samdb/ldb_modules/anr.c +++ b/source4/dsdb/samdb/ldb_modules/anr.c @@ -139,7 +139,7 @@ static int anr_replace_value(struct anr_context *ac, ldb = ldb_module_get_ctx(module); - schema = dsdb_get_schema(ldb); + schema = dsdb_get_schema(ldb, ac); if (!schema) { ldb_asprintf_errstring(ldb, "no schema with which to construct anr filter"); return LDB_ERR_OPERATIONS_ERROR; diff --git a/source4/dsdb/samdb/ldb_modules/descriptor.c b/source4/dsdb/samdb/ldb_modules/descriptor.c index f07743c4a2..efd331b054 100644 --- a/source4/dsdb/samdb/ldb_modules/descriptor.c +++ b/source4/dsdb/samdb/ldb_modules/descriptor.c @@ -591,7 +591,7 @@ static int descriptor_do_mod(struct descriptor_context *ac) uint32_t sd_flags = 0; ldb = ldb_module_get_ctx(ac->module); - schema = dsdb_get_schema(ldb); + schema = dsdb_get_schema(ldb, ac); msg = ldb_msg_copy_shallow(ac, ac->req->op.mod.message); objectclass_element = ldb_msg_find_element(ac->search_oc_res->message, "objectClass"); objectclass = get_last_structural_class(schema, objectclass_element); @@ -667,7 +667,7 @@ static int descriptor_do_add(struct descriptor_context *ac) struct ldb_request *search_req; ldb = ldb_module_get_ctx(ac->module); - schema = dsdb_get_schema(ldb); + schema = dsdb_get_schema(ldb, ac); mem_ctx = talloc_new(ac); if (mem_ctx == NULL) { return LDB_ERR_OPERATIONS_ERROR; diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn_out.c b/source4/dsdb/samdb/ldb_modules/extended_dn_out.c index c986f8fe93..b5f4567e5f 100644 --- a/source4/dsdb/samdb/ldb_modules/extended_dn_out.c +++ b/source4/dsdb/samdb/ldb_modules/extended_dn_out.c @@ -592,7 +592,7 @@ static int extended_dn_out_search(struct ldb_module *module, struct ldb_request } ac->module = module; - ac->schema = dsdb_get_schema(ldb); + ac->schema = dsdb_get_schema(ldb, ac); ac->req = req; ac->inject = false; ac->remove_guid = false; @@ -786,7 +786,7 @@ static int extended_dn_out_dereference_init(struct ldb_module *module, const cha return ret; } - schema = dsdb_get_schema(ldb); + schema = dsdb_get_schema(ldb, p); if (!schema) { /* No schema on this DB (yet) */ return LDB_SUCCESS; diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn_store.c b/source4/dsdb/samdb/ldb_modules/extended_dn_store.c index 3c4c171c19..731e4c368b 100644 --- a/source4/dsdb/samdb/ldb_modules/extended_dn_store.c +++ b/source4/dsdb/samdb/ldb_modules/extended_dn_store.c @@ -78,7 +78,7 @@ static struct extended_dn_context *extended_dn_context_init(struct ldb_module *m return NULL; } - ac->schema = dsdb_get_schema(ldb_module_get_ctx(module)); + ac->schema = dsdb_get_schema(ldb_module_get_ctx(module), ac); ac->module = module; ac->ldb = ldb; ac->req = req; diff --git a/source4/dsdb/samdb/ldb_modules/kludge_acl.c b/source4/dsdb/samdb/ldb_modules/kludge_acl.c index 3bdcaff2d0..72863adebd 100644 --- a/source4/dsdb/samdb/ldb_modules/kludge_acl.c +++ b/source4/dsdb/samdb/ldb_modules/kludge_acl.c @@ -94,7 +94,8 @@ static int kludge_acl_allowedAttributes(struct ldb_context *ldb, struct ldb_mess { struct ldb_message_element *oc_el; struct ldb_message_element *allowedAttributes; - const struct dsdb_schema *schema = dsdb_get_schema(ldb); + /* We need to ensure that the strings returned are valid for as long as the msg is valid */ + const struct dsdb_schema *schema = dsdb_get_schema(ldb, msg); TALLOC_CTX *mem_ctx; const char **attr_list; unsigned int i; @@ -143,7 +144,9 @@ static int kludge_acl_childClasses(struct ldb_context *ldb, struct ldb_message * { struct ldb_message_element *oc_el; struct ldb_message_element *allowedClasses; - const struct dsdb_schema *schema = dsdb_get_schema(ldb); + + /* We need to ensure that the strings returned are valid for as long as the msg is valid */ + const struct dsdb_schema *schema = dsdb_get_schema(ldb, msg); const struct dsdb_class *sclass; unsigned int i, j; int ret; diff --git a/source4/dsdb/samdb/ldb_modules/linked_attributes.c b/source4/dsdb/samdb/ldb_modules/linked_attributes.c index 9bea7db31c..1e0a2b05f3 100644 --- a/source4/dsdb/samdb/ldb_modules/linked_attributes.c +++ b/source4/dsdb/samdb/ldb_modules/linked_attributes.c @@ -148,7 +148,7 @@ static int linked_attributes_rename(struct ldb_module *module, struct ldb_reques unsigned int i; int ret; struct ldb_context *ldb = ldb_module_get_ctx(module); - struct dsdb_schema *schema = dsdb_get_schema(ldb); + struct dsdb_schema *schema; /* - load the current msg - find any linked attributes @@ -160,6 +160,13 @@ static int linked_attributes_rename(struct ldb_module *module, struct ldb_reques if (ret != LDB_SUCCESS) { return ret; } + + schema = dsdb_get_schema(ldb, res); + if (!schema) { + ldb_oom(schema); + return LDB_ERR_OPERATIONS_ERROR; + } + msg = res->msgs[0]; for (i=0; i<msg->num_elements; i++) { diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c index d5e28d3152..910dc92e71 100644 --- a/source4/dsdb/samdb/ldb_modules/objectclass.c +++ b/source4/dsdb/samdb/ldb_modules/objectclass.c @@ -453,10 +453,11 @@ static int objectclass_do_add(struct oc_context *ac) const char *rdn_name = NULL; ldb = ldb_module_get_ctx(ac->module); - schema = dsdb_get_schema(ldb); + schema = dsdb_get_schema(ldb, ac); mem_ctx = talloc_new(ac); if (mem_ctx == NULL) { + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -695,7 +696,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req struct ldb_context *ldb = ldb_module_get_ctx(module); struct ldb_message_element *objectclass_element; struct ldb_message *msg; - const struct dsdb_schema *schema = dsdb_get_schema(ldb); + const struct dsdb_schema *schema = dsdb_get_schema(ldb, NULL); struct class_list *sorted, *current; struct ldb_request *down_req; struct oc_context *ac; @@ -724,6 +725,12 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req ac = oc_init_context(module, req); if (ac == NULL) { + ldb_oom(ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + + if (!talloc_reference(ac, schema)) { + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -934,7 +941,7 @@ static int objectclass_do_mod(struct oc_context *ac) if (ac->search_res == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - schema = dsdb_get_schema(ldb); + schema = dsdb_get_schema(ldb, ac); mem_ctx = talloc_new(ac); if (mem_ctx == NULL) { diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index e96a2059a6..a7e2a48ff2 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -322,6 +322,13 @@ static int replmd_add_backlink(struct ldb_module *module, const struct dsdb_sche return LDB_ERR_OPERATIONS_ERROR; } + /* Ensure the schema does not go away before the bl->attr_name is used */ + if (!talloc_reference(bl, schema)) { + talloc_free(bl); + ldb_module_oom(module); + return LDB_ERR_OPERATIONS_ERROR; + } + bl->attr_name = target_attr->lDAPDisplayName; bl->forward_guid = *forward_guid; bl->target_guid = *target_guid; @@ -489,7 +496,7 @@ static struct replmd_replicated_request *replmd_ctx_init(struct ldb_module *modu ac->module = module; ac->req = req; - ac->schema = dsdb_get_schema(ldb); + ac->schema = dsdb_get_schema(ldb, ac); if (!ac->schema) { ldb_debug_set(ldb, LDB_DEBUG_FATAL, "replmd_modify: no dsdb_schema loaded"); @@ -659,7 +666,9 @@ static int replmd_add_fix_la(struct ldb_module *module, struct ldb_message_eleme unsigned int i; TALLOC_CTX *tmp_ctx = talloc_new(el->values); struct ldb_context *ldb = ldb_module_get_ctx(module); - struct dsdb_schema *schema = dsdb_get_schema(ldb); + + /* We will take a reference to the schema in replmd_add_backlink */ + struct dsdb_schema *schema = dsdb_get_schema(ldb, NULL); NTTIME now; unix_to_nt_time(&now, t); @@ -1927,7 +1936,8 @@ static int replmd_modify_handle_linked_attribs(struct ldb_module *module, int ret; struct ldb_context *ldb = ldb_module_get_ctx(module); struct ldb_message *old_msg; - struct dsdb_schema *schema = dsdb_get_schema(ldb); + + struct dsdb_schema *schema; struct GUID old_guid; if (seq_num == 0) { @@ -1953,6 +1963,11 @@ static int replmd_modify_handle_linked_attribs(struct ldb_module *module, if (ret != LDB_SUCCESS) { return ret; } + schema = dsdb_get_schema(ldb, res); + if (!schema) { + return LDB_ERR_OPERATIONS_ERROR; + } + old_msg = res->msgs[0]; old_guid = samdb_result_guid(old_msg, "objectGUID"); @@ -2307,7 +2322,7 @@ static int replmd_delete(struct ldb_module *module, struct ldb_request *req) const struct ldb_val *rdn_value, *new_rdn_value; struct GUID guid; struct ldb_context *ldb = ldb_module_get_ctx(module); - struct dsdb_schema *schema = dsdb_get_schema(ldb); + struct dsdb_schema *schema; struct ldb_message *msg, *old_msg; struct ldb_message_element *el; TALLOC_CTX *tmp_ctx; @@ -2330,6 +2345,15 @@ static int replmd_delete(struct ldb_module *module, struct ldb_request *req) } tmp_ctx = talloc_new(ldb); + if (!tmp_ctx) { + ldb_oom(ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + + schema = dsdb_get_schema(ldb, tmp_ctx); + if (!schema) { + return LDB_ERR_OPERATIONS_ERROR; + } old_dn = ldb_dn_copy(tmp_ctx, req->op.del.dn); @@ -3418,7 +3442,7 @@ static int replmd_extended_replicated_objects(struct ldb_module *module, struct /* Set the flags to have the replmd_op_callback run over the full set of objects */ ar->apply_mode = true; ar->objs = objs; - ar->schema = dsdb_get_schema(ldb); + ar->schema = dsdb_get_schema(ldb, ar); if (!ar->schema) { ldb_debug_set(ldb, LDB_DEBUG_FATAL, "replmd_ctx_init: no loaded schema found\n"); talloc_free(ar); @@ -3484,9 +3508,9 @@ static int replmd_process_linked_attribute(struct ldb_module *module, { struct drsuapi_DsReplicaLinkedAttribute *la = la_entry->la; struct ldb_context *ldb = ldb_module_get_ctx(module); - struct dsdb_schema *schema = dsdb_get_schema(ldb); struct ldb_message *msg; TALLOC_CTX *tmp_ctx = talloc_new(la_entry); + struct dsdb_schema *schema = dsdb_get_schema(ldb, tmp_ctx); int ret; const struct dsdb_attribute *attr; struct dsdb_dn *dsdb_dn; 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; diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c index bd46ec5cbc..808552f327 100644 --- a/source4/dsdb/samdb/ldb_modules/rootdse.c +++ b/source4/dsdb/samdb/ldb_modules/rootdse.c @@ -178,7 +178,7 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms }; ldb = ldb_module_get_ctx(module); - schema = dsdb_get_schema(ldb); + schema = dsdb_get_schema(ldb, NULL); msg->dn = ldb_dn_new(msg, ldb, NULL); diff --git a/source4/dsdb/samdb/ldb_modules/schema_data.c b/source4/dsdb/samdb/ldb_modules/schema_data.c index 20c85e28bd..c71a01d630 100644 --- a/source4/dsdb/samdb/ldb_modules/schema_data.c +++ b/source4/dsdb/samdb/ldb_modules/schema_data.c @@ -105,7 +105,7 @@ static int schema_data_init(struct ldb_module *module) } ldb = ldb_module_get_ctx(module); - schema_dn = samdb_schema_dn(ldb); + schema_dn = ldb_get_schema_basedn(ldb); if (!schema_dn) { ldb_reset_err_string(ldb); ldb_debug(ldb, LDB_DEBUG_WARNING, @@ -154,7 +154,7 @@ static int schema_data_add(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - schema = dsdb_get_schema(ldb); + schema = dsdb_get_schema(ldb, req); if (!schema) { return ldb_next_request(module, req); } @@ -417,7 +417,7 @@ static int schema_data_search(struct ldb_module *module, struct ldb_request *req int ret; struct schema_data_search_data *search_context; struct ldb_request *down_req; - struct dsdb_schema *schema = dsdb_get_schema(ldb); + struct dsdb_schema *schema = dsdb_get_schema(ldb, NULL); if (!schema || !ldb_module_get_private(module)) { /* If there is no schema, there is little we can do */ @@ -442,7 +442,11 @@ static int schema_data_search(struct ldb_module *module, struct ldb_request *req search_context->module = module; search_context->req = req; - search_context->schema = schema; + search_context->schema = talloc_reference(search_context, schema); + if (!search_context->schema) { + ldb_oom(ldb); + return LDB_ERR_OPERATIONS_ERROR; + } ret = ldb_build_search_req_ex(&down_req, ldb, search_context, req->op.search.base, diff --git a/source4/dsdb/samdb/ldb_modules/schema_load.c b/source4/dsdb/samdb/ldb_modules/schema_load.c index 3442e821ce..5ea70fbe3e 100644 --- a/source4/dsdb/samdb/ldb_modules/schema_load.c +++ b/source4/dsdb/samdb/ldb_modules/schema_load.c @@ -150,7 +150,7 @@ static int schema_load_init(struct ldb_module *module) return LDB_SUCCESS; } - if (dsdb_get_schema(ldb)) { + if (dsdb_get_schema(ldb, NULL)) { return LDB_SUCCESS; } |