repl_meta_data: Always sort the links when upgrading them
authorAndrew Bartlett <abartlet@samba.org>
Mon, 13 Feb 2017 23:08:35 +0000 (12:08 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 14 Feb 2017 01:20:08 +0000 (02:20 +0100)
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 <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/dsdb/samdb/ldb_modules/repl_meta_data.c

index 8f80ce6b58a289e47ea460382c53692df9fb63b0..c37ed68fc77afb1390d44fda997cc4fa0aecfbc7 100644 (file)
@@ -2278,6 +2278,19 @@ static int replmd_check_upgrade_links(struct ldb_context *ldb,
                        return ret;
                }
        }
                        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;
 }
 
        return LDB_SUCCESS;
 }