From: Ralph Boehme Date: Fri, 19 Sep 2025 04:43:57 +0000 (+0200) Subject: smbtorture: add test vfs.fruit.case_insensitive_find X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68ed6279335cfac13a624ae8a7738dac3d9b0d1a;p=thirdparty%2Fsamba.git smbtorture: add test vfs.fruit.case_insensitive_find Verifies case insensitive directory scanning works. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15926 Signed-off-by: Ralph Boehme Reviewed-by: Volker Lendecke --- diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c index 02f7acd0fea..a6f86cd5edf 100644 --- a/source4/torture/vfs/fruit.c +++ b/source4/torture/vfs/fruit.c @@ -7930,6 +7930,89 @@ done: return ret; } +/* + * Test case-insensitive file finding with AAPL extensions + * Add this function to source4/torture/vfs/fruit.c + */ + +static bool test_case_insensitive_find(struct torture_context *tctx, + struct smb2_tree *tree) +{ + NTSTATUS status; + bool ret = true; + const char *fname = "TestFile.txt"; + const char *fname_upper = "TESTFILE.TXT"; + struct smb2_handle testdirh; + struct smb2_handle h1; + struct smb2_create create; + struct smb2_find f; + union smb_search_data *d; + uint_t count; + + smb2_deltree(tree, BASEDIR); + + status = torture_smb2_testdir(tree, BASEDIR, &testdirh); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + "torture_smb2_testdir failed"); + + /* Enable AAPL extensions */ + ret = enable_aapl(tctx, tree); + torture_assert_goto(tctx, ret, ret, done, + "enable_aapl failed"); + + /* Create test file */ + ZERO_STRUCT(create); + create.in.desired_access = SEC_RIGHTS_FILE_ALL; + create.in.file_attributes = FILE_ATTRIBUTE_NORMAL; + create.in.share_access = NTCREATEX_SHARE_ACCESS_READ | + NTCREATEX_SHARE_ACCESS_WRITE | + NTCREATEX_SHARE_ACCESS_DELETE; + create.in.create_disposition = NTCREATEX_DISP_CREATE; + create.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS; + create.in.fname = talloc_asprintf(tctx, "%s\\%s", BASEDIR, fname); + + status = smb2_create(tree, tctx, &create); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + talloc_asprintf(tctx, "failed to create %s", fname)); + h1 = create.out.file.handle; + + /* Close the file */ + status = smb2_util_close(tree, h1); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + "failed to close test file"); + + /* Search for file using different case */ + f = (struct smb2_find) { + .in.file.handle = testdirh, + .in.pattern = fname_upper, + .in.max_response_size = 0x1000, + .in.level = SMB2_FIND_ID_BOTH_DIRECTORY_INFO, + }; + + status = smb2_find_level(tree, tctx, &f, &count, &d); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + talloc_asprintf(tctx, "smb2_find_level failed searching for %s", fname_upper)); + + /* Verify we found exactly one file */ + torture_assert_int_equal_goto(tctx, count, 1, ret, done, + talloc_asprintf(tctx, "Expected 1 file, got %u", count)); + + /* Verify the filename matches our original file (case may differ) */ + torture_assert_str_equal_goto(tctx, + d[0].id_both_directory_info.name.s, fname, ret, done, + talloc_asprintf(tctx, "Found file name '%s' doesn't match expected '%s'", + d[0].directory_info.name.s, fname)); + + torture_comment(tctx, "Case-insensitive find test passed: " + "searched for '%s', found '%s'\n", + fname_upper, d[0].id_both_directory_info.name.s); + +done: + smb2_util_close(tree, testdirh); + smb2_deltree(tree, BASEDIR); + return ret; +} + /* * Note: This test depends on "vfs objects = catia fruit streams_xattr". For * some tests torture must be run on the host it tests and takes an additional @@ -7977,7 +8060,7 @@ struct torture_suite *torture_vfs_fruit(TALLOC_CTX *ctx) torture_suite_add_1smb2_test(suite, "writing_afpinfo", test_writing_afpinfo); torture_suite_add_1smb2_test(suite, "delete_trigger_convert_sharing_violation", test_delete_trigger_convert_sharing_violation); torture_suite_add_1smb2_test(suite, "readonly-exclusive-lock", test_readonly_exclusive_lock); - + torture_suite_add_1smb2_test(suite, "case_insensitive_find", test_case_insensitive_find); return suite; }