From: Andrew Bartlett Date: Mon, 13 Feb 2017 23:08:35 +0000 (+1300) Subject: repl_meta_data: Always sort the links when upgrading them X-Git-Tag: talloc-2.1.9~191 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75d523f5792275b8aa357d0f266b0bc9b7a1c935;p=thirdparty%2Fsamba.git 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 --- 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; }