From: Douglas Bagnall Date: Thu, 16 May 2024 02:09:46 +0000 (+1200) Subject: ldb-samba: use ldb_comparison_fold_utf8() X-Git-Tag: tdb-1.4.11~560 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=edabb9f4cb9460f382a621a1f494cfdac615232a;p=thirdparty%2Fsamba.git ldb-samba: use ldb_comparison_fold_utf8() 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 Reviewed-by: Andrew Bartlett --- diff --git a/lib/ldb-samba/ldb_wrap.c b/lib/ldb-samba/ldb_wrap.c index 31775c59c2b..e5876c80a9c 100644 --- a/lib/ldb-samba/ldb_wrap.c +++ b/lib/ldb-samba/ldb_wrap.c @@ -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)) { diff --git a/lib/ldb-samba/pyldb.c b/lib/ldb-samba/pyldb.c index 958b3ad4b16..b2a485aaefa 100644 --- a/lib/ldb-samba/pyldb.c +++ b/lib/ldb-samba/pyldb.c @@ -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; } diff --git a/lib/ldb-samba/samba_extensions.c b/lib/ldb-samba/samba_extensions.c index be92d982dde..aecc2d70dea 100644 --- a/lib/ldb-samba/samba_extensions.c +++ b/lib/ldb-samba/samba_extensions.c @@ -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; } diff --git a/lib/ldb/tests/test_ldb_comparison_fold.c b/lib/ldb/tests/test_ldb_comparison_fold.c index df1fb31495b..601cfe6c482 100644 --- a/lib/ldb/tests/test_ldb_comparison_fold.c +++ b/lib/ldb/tests/test_ldb_comparison_fold.c @@ -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 index f5673ab4c01..00000000000 --- a/selftest/knownfail.d/ldb_comparison_fold +++ /dev/null @@ -1 +0,0 @@ -^ldb.unittests.test_ldb_comparison_fold.test_ldb_comparison_fold_utf8\b diff --git a/source4/dsdb/common/tests/dsdb_dn.c b/source4/dsdb/common/tests/dsdb_dn.c index 66c7e125a47..3308cb6e6f8 100644 --- a/source4/dsdb/common/tests/dsdb_dn.c +++ b/source4/dsdb/common/tests/dsdb_dn.c @@ -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"); diff --git a/source4/torture/ldb/ldb.c b/source4/torture/ldb/ldb.c index 69bd57e6b30..68a3ecfb470 100644 --- a/source4/torture/ldb/ldb.c +++ b/source4/torture/ldb/ldb.c @@ -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,