From 68fbfa2237a570a48d2ae3a5421cdcacae6e6d34 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Sat, 5 Mar 2011 14:25:59 +0100 Subject: s4:partition LDB module - the current partition control should only be added if requested That means if the informations before a request are unknown ("repl_meta_data" LDB module) then an empty control (no data) has to be sent. --- source4/dsdb/samdb/ldb_modules/partition.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'source4/dsdb/samdb') diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c index f75085e8a2..ba77ca0ad1 100644 --- a/source4/dsdb/samdb/ldb_modules/partition.c +++ b/source4/dsdb/samdb/ldb_modules/partition.c @@ -239,6 +239,7 @@ static int partition_prep_request(struct partition_context *ac, { int ret; struct ldb_request *req; + struct ldb_control *partition_ctrl = NULL; ac->part_req = talloc_realloc(ac, ac->part_req, struct part_request, @@ -316,20 +317,31 @@ static int partition_prep_request(struct partition_context *ac, ac->part_req[ac->num_requests].req = req; if (ac->req->controls) { - req->controls = talloc_memdup(req, ac->req->controls, - talloc_get_size(ac->req->controls)); - if (req->controls == NULL) { - return ldb_oom(ldb_module_get_ctx(ac->module)); + /* Duplicate everything beside the current partition control */ + partition_ctrl = ldb_request_get_control(ac->req, + DSDB_CONTROL_CURRENT_PARTITION_OID); + if (!ldb_save_controls(partition_ctrl, req, NULL)) { + return ldb_module_oom(ac->module); } } if (partition) { + void *part_data = partition->ctrl; + ac->part_req[ac->num_requests].module = partition->module; - if (!ldb_request_get_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID)) { + if (partition_ctrl != NULL) { + if (partition_ctrl->data != NULL) { + part_data = partition_ctrl->data; + } + + /* + * If the provided current partition control is without + * data then use the calculated one. + */ ret = ldb_request_add_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID, - false, partition->ctrl); + false, part_data); if (ret != LDB_SUCCESS) { return ret; } -- cgit