]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ldb-samba:ldif_handlers: dn_link_comparison semi-sorts deleted objects
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 11 Apr 2024 04:25:02 +0000 (16:25 +1200)
committerJule Anger <janger@samba.org>
Mon, 10 Jun 2024 13:25:17 +0000 (13:25 +0000)
We were always returning -1 for a deleted object, which works for an
equality test, but not a relative comparison.

This sorts deleted DNs toward the end of the list -- except when both
DNs are deleted. What should happen there is yet to be determined.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15625

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit db963b1674ede357d4edba578e0e0372dcb2f287)

lib/ldb-samba/ldif_handlers.c

index 522449719316569a2e1bd2a92a3c900739c34cfc..896315de44dab8cbe33f8f30ff02bcf22437f1c9 100644 (file)
@@ -1159,13 +1159,15 @@ static int samba_ldb_dn_link_comparison(struct ldb_context *ldb, void *mem_ctx,
        struct ldb_dn *dn1 = NULL, *dn2 = NULL;
        int ret;
 
+       /*
+        * In a sort context, Deleted DNs get shifted to the end.
+        * They never match in an equality
+        */
        if (dsdb_dn_is_deleted_val(v1)) {
-               /* If the DN is deleted, then we can't search for it */
-               return -1;
+               return 1;
        }
 
        if (dsdb_dn_is_deleted_val(v2)) {
-               /* If the DN is deleted, then we can't search for it */
                return -1;
        }