From 75d523f5792275b8aa357d0f266b0bc9b7a1c935 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 14 Feb 2017 12:08:35 +1300 Subject: [PATCH] repl_meta_data: Always sort the links when upgrading them This allows us to know that the output of get_parsed_dns_trusted() is sorted, as an upgraded attribute of FL2000 links would not otherwise be sorted in the DB This allows us to delete linked objects that have a forward link from a FL2000 style linked attribute once the DN+Binary patches land. Signed-off-by: Andrew Bartlett Reviewed-by: Garming Sam --- source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index 8f80ce6b58a..c37ed68fc77 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -2278,6 +2278,19 @@ static int replmd_check_upgrade_links(struct ldb_context *ldb, return ret; } } + + /* + * This sort() is critical for the operation of + * get_parsed_dns_trusted() because callers of this function + * expect a sorted list, and FL2000 style links are not + * sorted. In particular, as well as the upgrade case, + * get_parsed_dns_trusted() is called from + * replmd_delete_remove_link() even in FL2000 mode + * + * We do not normally pay the cost of the qsort() due to the + * early return in the RMD_VERSION found case. + */ + TYPESAFE_QSORT(dns, count, parsed_dn_compare); return LDB_SUCCESS; } -- 2.11.4.GIT