From 6f8c188dfc81a6d22bd54f248327b787e0b48f09 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Sun, 20 Dec 2015 18:42:23 +0100 Subject: [PATCH] s4:torture:vfs_fruit: file without AFP_AfpInfo Opening the AFP_AfpInfo on a file that doesn't have that stream must return ENOENT. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11347 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- source4/torture/vfs/fruit.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c index 07124769c88..764bbcb141d 100644 --- a/source4/torture/vfs/fruit.c +++ b/source4/torture/vfs/fruit.c @@ -2769,6 +2769,43 @@ static bool test_rename_dir_openfile(struct torture_context *torture, return ret; } +static bool test_afpinfo_enoent(struct torture_context *tctx, + struct smb2_tree *tree) +{ + bool ret = true; + NTSTATUS status; + struct smb2_create create; + struct smb2_handle h1; + TALLOC_CTX *mem_ctx = talloc_new(tctx); + const char *fname = BASEDIR "\\file"; + const char *sname = BASEDIR "\\file" AFPINFO_STREAM_NAME; + + torture_comment(tctx, "Opening file without AFP_AfpInfo\n"); + + smb2_deltree(tree, BASEDIR); + status = torture_smb2_testdir(tree, BASEDIR, &h1); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "torture_smb2_testdir"); + smb2_util_close(tree, h1); + ret = torture_setup_file(mem_ctx, tree, fname, false); + torture_assert_goto(tctx, ret == true, ret, done, "torture_setup_file"); + + torture_comment(tctx, "Opening not existing AFP_AfpInfo\n"); + + ZERO_STRUCT(create); + create.in.create_disposition = NTCREATEX_DISP_OPEN; + create.in.desired_access = SEC_FILE_READ_ATTRIBUTE; /* stat open */ + create.in.fname = sname; + + status = smb2_create(tree, mem_ctx, &create); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, + ret, done, "Got unexpected AFP_AfpInfo stream"); + +done: + smb2_util_unlink(tree, fname); + smb2_util_rmdir(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 @@ -2794,6 +2831,7 @@ struct torture_suite *torture_vfs_fruit(void) torture_suite_add_1smb2_test(suite, "truncate resource fork to 0 bytes", test_rfork_truncate); torture_suite_add_1smb2_test(suite, "opening and creating resource fork", test_rfork_create); torture_suite_add_1smb2_test(suite, "rename_dir_openfile", test_rename_dir_openfile); + torture_suite_add_1smb2_test(suite, "File without AFP_AfpInfo", test_afpinfo_enoent); return suite; } -- 2.11.4.GIT