]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ldb-samba: use ldb_comparison_fold_utf8()
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 16 May 2024 02:09:46 +0000 (14:09 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 22 May 2024 23:12:32 +0000 (23:12 +0000)
This means ldb-samba/dsdb comparisons will be case-insensitive for
non-ASCII UTF-8 characters (within the bounds of the 16-bit casefold
table). And they will remain transitive.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb-samba/ldb_wrap.c
lib/ldb-samba/pyldb.c
lib/ldb-samba/samba_extensions.c
lib/ldb/tests/test_ldb_comparison_fold.c
selftest/knownfail.d/ldb_comparison_fold [deleted file]
source4/dsdb/common/tests/dsdb_dn.c
source4/torture/ldb/ldb.c

index 31775c59c2bb1cf237d78834c88d650a8b81a356..e5876c80a9cf43a4e2a70db516334dfd2d6aba53 100644 (file)
@@ -152,7 +152,7 @@ int ldb_comparison_fold_utf8(void *ignored,
 
        ldb_set_debug(ldb, ldb_wrap_debug, NULL);
 
-       ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+       ldb_set_utf8_functions(ldb, NULL, wrap_casefold, ldb_comparison_fold_utf8);
 
        if (session_info) {
                if (ldb_set_opaque(ldb, DSDB_SESSION_INFO, session_info)) {
index 958b3ad4b166fa7e216db2c3814b4f48ca351c8b..b2a485aaefad6cdfddc6aa232b54f87123e925eb 100644 (file)
@@ -88,7 +88,7 @@ static PyObject *py_ldb_set_utf8_casefold(PyObject *self,
 
        ldb = pyldb_Ldb_AS_LDBCONTEXT(self);
 
-       ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+       ldb_set_utf8_functions(ldb, NULL, wrap_casefold, ldb_comparison_fold_utf8);
 
        Py_RETURN_NONE;
 }
index be92d982dde0533bfe6f58cf7ca89137793fda97..aecc2d70deacc57741f2fd81be9c4428aeb9321f 100644 (file)
@@ -144,7 +144,7 @@ static int extensions_hook(struct ldb_context *ldb, enum ldb_module_hook_type t)
                        return ldb_operr(ldb);
                }
 
-               ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+               ldb_set_utf8_functions(ldb, NULL, wrap_casefold, ldb_comparison_fold_utf8);
                break;
        }
 
index df1fb31495b4948f60786c8ab068f5c95021208c..601cfe6c482a52bb0079a32c5c11df9242de63ee 100644 (file)
@@ -177,7 +177,7 @@ static void test_ldb_comparison_fold_default_common(void **state)
 static void test_ldb_comparison_fold_utf8_common(void **state)
 {
        struct ldb_context *ldb = ldb_init(NULL, NULL);
-       ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+       ldb_set_utf8_functions(ldb, NULL, wrap_casefold, ldb_comparison_fold_utf8);
        _test_ldb_comparison_fold_set(ldb,
                                      values_common,
                                      ARRAY_SIZE(values_common));
@@ -190,7 +190,7 @@ static void test_ldb_comparison_fold_utf8_common(void **state)
 static void test_ldb_comparison_fold_utf8(void **state)
 {
        struct ldb_context *ldb = ldb_init(NULL, NULL);
-       ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+       ldb_set_utf8_functions(ldb, NULL, wrap_casefold, ldb_comparison_fold_utf8);
        _test_ldb_comparison_fold_set(ldb,
                                      values_utf8,
                                      ARRAY_SIZE(values_utf8));
diff --git a/selftest/knownfail.d/ldb_comparison_fold b/selftest/knownfail.d/ldb_comparison_fold
deleted file mode 100644 (file)
index f5673ab..0000000
+++ /dev/null
@@ -1 +0,0 @@
-^ldb.unittests.test_ldb_comparison_fold.test_ldb_comparison_fold_utf8\b
index 66c7e125a476e705eacd27011863d9666201d2db..3308cb6e6f87b8e5650b921904e3eff456e44d97 100644 (file)
@@ -47,7 +47,7 @@ static bool torture_dsdb_dn_attrs(struct torture_context *torture)
                                 ldb_register_samba_handlers(ldb), LDB_SUCCESS,
                                 "Failed to register Samba handlers");
 
-       ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+       ldb_set_utf8_functions(ldb, NULL, wrap_casefold, ldb_comparison_fold_utf8);
 
        /* Test DN+Binary behaviour */
        torture_assert(torture, syntax = ldb_samba_syntax_by_name(ldb, DSDB_SYNTAX_BINARY_DN), 
@@ -144,7 +144,7 @@ static bool torture_dsdb_dn_valid(struct torture_context *torture)
                                 ldb_register_samba_handlers(ldb), LDB_SUCCESS,
                                 "Failed to register Samba handlers");
 
-       ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+       ldb_set_utf8_functions(ldb, NULL, wrap_casefold, ldb_comparison_fold_utf8);
 
        /* Check behaviour of a normal DN */
        torture_assert(torture, 
@@ -266,7 +266,7 @@ static bool torture_dsdb_dn_invalid(struct torture_context *torture)
                                 ldb_register_samba_handlers(ldb), LDB_SUCCESS,
                                 "Failed to register Samba handlers");
 
-       ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+       ldb_set_utf8_functions(ldb, NULL, wrap_casefold, ldb_comparison_fold_utf8);
 
        /* Check behaviour of a normal DN */
        val = data_blob_string_const("samba,dc=org");
index 69bd57e6b30772c24fb27aeecddb7f9a11101f12..68a3ecfb4708213b0e2470dc03ebc67f3a54c1cf 100644 (file)
@@ -444,7 +444,7 @@ static bool torture_ldb_attrs(struct torture_context *torture)
                                 ldb_register_samba_handlers(ldb), LDB_SUCCESS,
                                 "Failed to register Samba handlers");
 
-       ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+       ldb_set_utf8_functions(ldb, NULL, wrap_casefold, ldb_comparison_fold_utf8);
 
        /* Test SID behaviour */
        torture_assert(torture, attr = ldb_schema_attribute_by_name(ldb, "objectSid"), 
@@ -603,7 +603,7 @@ static bool torture_ldb_dn_attrs(struct torture_context *torture)
                                 ldb_register_samba_handlers(ldb), LDB_SUCCESS,
                                 "Failed to register Samba handlers");
 
-       ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+       ldb_set_utf8_functions(ldb, NULL, wrap_casefold, ldb_comparison_fold_utf8);
 
        /* Test SID behaviour */
        torture_assert(torture, attr = ldb_dn_extended_syntax_by_name(ldb, "SID"), 
@@ -721,7 +721,7 @@ static bool torture_ldb_dn_extended(struct torture_context *torture)
                                 ldb_register_samba_handlers(ldb), LDB_SUCCESS,
                                 "Failed to register Samba handlers");
 
-       ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+       ldb_set_utf8_functions(ldb, NULL, wrap_casefold, ldb_comparison_fold_utf8);
 
        /* Check behaviour of a normal DN */
        torture_assert(torture, 
@@ -982,7 +982,7 @@ static bool torture_ldb_dn(struct torture_context *torture)
                                 ldb_register_samba_handlers(ldb), LDB_SUCCESS,
                                 "Failed to register Samba handlers");
 
-       ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+       ldb_set_utf8_functions(ldb, NULL, wrap_casefold, ldb_comparison_fold_utf8);
 
        /* Check behaviour of a normal DN */
        torture_assert(torture, 
@@ -1100,7 +1100,7 @@ static bool torture_ldb_dn_invalid_extended(struct torture_context *torture)
                                 ldb_register_samba_handlers(ldb), LDB_SUCCESS,
                                 "Failed to register Samba handlers");
 
-       ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+       ldb_set_utf8_functions(ldb, NULL, wrap_casefold, ldb_comparison_fold_utf8);
 
        /* Check behaviour of a normal DN */
        torture_assert(torture,