]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ldb-samba:ldif_handlers: dn_link_comparison correctly sorts deleted objects
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 11 Apr 2024 04:53:03 +0000 (16:53 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 23 Apr 2024 01:33:29 +0000 (01:33 +0000)
This changes the behaviour of the DN syntax .comparison_fn when being
used in a search, if the search key is a deleted DN.

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>
lib/ldb-samba/ldif_handlers.c

index 1229d7466b6067f26392b5b06153b45111edc700..2e8b6afb7a8c5b1032853fbeeae70009a2b7ab9e 100644 (file)
@@ -1166,10 +1166,17 @@ static int samba_ldb_dn_link_comparison(struct ldb_context *ldb, void *mem_ctx,
         * They never match in an equality
         */
        if (dsdb_dn_is_deleted_val(v1)) {
-               return 1;
-       }
-
-       if (dsdb_dn_is_deleted_val(v2)) {
+               if (! dsdb_dn_is_deleted_val(v2)) {
+                       return 1;
+               }
+               /*
+                * They are both deleted!
+                *
+                * The soundest thing to do at this point is carry on
+                * and compare the DNs normally. This matches the
+                * behaviour of samba_dn_extended_match() below.
+                */
+       } else if (dsdb_dn_is_deleted_val(v2)) {
                return -1;
        }