1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

smbtorture: add test for fruit:validate_afpinfo option

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Oct 24 22:30:06 UTC 2023 on atb-devel-224
This commit is contained in:
Ralph Boehme 2023-10-20 15:45:31 +02:00 committed by Jeremy Allison
parent 825a992a62
commit 7c8dea14da
4 changed files with 78 additions and 0 deletions

View File

@ -3246,6 +3246,7 @@ sub provision($$)
fruit:resource = file
fruit:metadata = stream
fruit:zero_file_id=yes
fruit:validate_afpinfo = no
[fruit_resource_stream]
path = $fruit_resource_stream_shrdir

View File

@ -1836,6 +1836,13 @@ plantestsuite("samba3.blackbox.force-user-unlink",
[os.path.join(samba3srcdir,
"script/tests/test_force_user_unlink.sh")])
plansmbtorture4testsuite(
"vfs.fruit_validate_afpinfo", "fileserver",
'//$SERVER_IP/vfs_fruit -U$USERNAME%$PASSWORD --option=torture:validate_afpinfo=yes')
plansmbtorture4testsuite(
"vfs.fruit_validate_afpinfo", "fileserver",
'//$SERVER_IP/vfs_fruit_zero_fileid -U$USERNAME%$PASSWORD --option=torture:validate_afpinfo=no')
def planclusteredmembertestsuite(tname, prefix):
'''Define a clustered test for the clusteredmember environment'''

View File

@ -8768,3 +8768,72 @@ struct torture_suite *torture_vfs_fruit_unfruit(TALLOC_CTX *ctx)
return suite;
}
/*
* Write an invalid AFP_AfpInfo stream header
*/
bool test_fruit_validate_afpinfo(struct torture_context *tctx,
struct smb2_tree *tree)
{
bool expect_invalid_param = torture_setting_bool(tctx, "validate_afpinfo", true);
const char *fname = "test_fruit_validate_afpinfo";
const char *sname = "test_fruit_validate_afpinfo" AFPINFO_STREAM_NAME;
struct smb2_handle handle;
AfpInfo *afpinfo = NULL;
char *afpinfo_buf = NULL;
uint8_t valbuf[8];
NTSTATUS status;
bool ret = true;
torture_comment(tctx, "Checking create of AfpInfo stream\n");
smb2_util_unlink(tree, fname);
ret = torture_setup_file(tctx, tree, fname, false);
torture_assert_goto(tctx, ret == true, ret, done, "torture_setup_file failed");
afpinfo = torture_afpinfo_new(tctx);
torture_assert_not_null_goto(tctx, afpinfo, ret, done,
"torture_afpinfo_new failed\n");
memcpy(afpinfo->afpi_FinderInfo, "FOO BAR ", 8);
ret = torture_write_afpinfo(tree, tctx, tctx, fname, afpinfo);
torture_assert_goto(tctx, ret == true, ret, done,
"torture_write_afpinfo failed\n");
afpinfo_buf = talloc_zero_size(tctx, 60);
torture_assert_goto(tctx, afpinfo_buf != NULL, ret, done,
"torture_afpinfo_new failed");
memcpy(afpinfo_buf + 16, "FOO ", 4);
status = torture_smb2_testfile_access(
tree, sname, &handle, SEC_FILE_ALL);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"smb2_create failed\n");
status = smb2_util_write(tree, handle, afpinfo_buf, 0, AFP_INFO_SIZE);
if (expect_invalid_param) {
torture_assert_ntstatus_equal_goto(
tctx, status, NT_STATUS_INVALID_PARAMETER, ret, done,
"write didn't fail as expected\n");
} else {
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"smb2_util_write failed");
}
smb2_util_close(tree, handle);
/*
* Verify the server fixed the header
*/
PUSH_BE_U32(valbuf, 0, AFP_Signature);
PUSH_BE_U32(valbuf + 4, 0, AFP_Version);
ret = check_stream(tree, __location__, tctx, tctx, fname,
AFPINFO_STREAM, 0, 60, 0, 8, (char *)valbuf);
torture_assert_goto(tctx, ret == true, ret, done, "check_stream failed");
done:
smb2_util_unlink(tree, fname);
return ret;
}

View File

@ -115,6 +115,7 @@ NTSTATUS torture_vfs_init(TALLOC_CTX *ctx)
torture_suite_add_suite(suite, torture_vfs_fruit_timemachine(suite));
torture_suite_add_suite(suite, torture_vfs_fruit_conversion(suite));
torture_suite_add_suite(suite, torture_vfs_fruit_unfruit(suite));
torture_suite_add_1smb2_test(suite, "fruit_validate_afpinfo", test_fruit_validate_afpinfo);
torture_register_suite(ctx, suite);