summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2015-08-07 15:48:33 +0200
committerKarolin Seeger <kseeger@samba.org>2015-09-04 15:24:26 +0200
commite806635294d5211f5cfe7ea833384d3e6503f0c4 (patch)
tree25c060258e2ea83fb123fa274c41405f0b223e32 /source4
parent1f796a53bd5dd767a921eee8ea794bf3169a993f (diff)
downloadsamba-e806635294d5211f5cfe7ea833384d3e6503f0c4.tar.gz
s4:torture:vfs_fruit: created empty resourceforks
Check for opens and creates, created empty resourceforks result in ENOENT in subsequent opens. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11467 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): Wed Sep 2 06:50:16 CEST 2015 on sn-devel-104 Autobuild-User(v4-2-test): Karolin Seeger <kseeger@samba.org> Autobuild-Date(v4-2-test): Fri Sep 4 15:24:26 CEST 2015 on sn-devel-104
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/vfs/fruit.c129
1 files changed, 129 insertions, 0 deletions
diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c
index d549b8f434f..5ca55e73f89 100644
--- a/source4/torture/vfs/fruit.c
+++ b/source4/torture/vfs/fruit.c
@@ -59,6 +59,13 @@
goto done; \
}} while (0)
+static bool check_stream_list(struct smb2_tree *tree,
+ struct torture_context *tctx,
+ const char *fname,
+ int num_exp,
+ const char **exp,
+ struct smb2_handle h);
+
static int qsort_string(char * const *s1, char * const *s2)
{
return strcmp(*s1, *s2);
@@ -1538,6 +1545,127 @@ done:
return ret;
}
+static bool test_rfork_create(struct torture_context *tctx,
+ struct smb2_tree *tree1,
+ struct smb2_tree *tree2)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(tctx);
+ const char *fname = BASEDIR "\\torture_rfork_create";
+ const char *rfork = BASEDIR "\\torture_rfork_create" AFPRESOURCE_STREAM;
+ NTSTATUS status;
+ struct smb2_handle testdirh;
+ bool ret = true;
+ struct smb2_create create;
+ struct smb2_handle fh1;
+ const char *streams[] = {
+ "::$DATA"
+ };
+ union smb_fileinfo finfo;
+
+ smb2_util_unlink(tree1, fname);
+
+ status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "torture_smb2_testdir");
+ smb2_util_close(tree1, testdirh);
+
+ ret = torture_setup_file(mem_ctx, tree1, fname, false);
+ if (ret == false) {
+ goto done;
+ }
+
+ torture_comment(tctx, "(%s) open rfork, should return ENOENT\n",
+ __location__);
+
+ ZERO_STRUCT(create);
+ create.in.create_disposition = NTCREATEX_DISP_OPEN;
+ create.in.desired_access = SEC_STD_READ_CONTROL | SEC_FILE_ALL;
+ create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ create.in.fname = rfork;
+ create.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE |
+ NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ status = smb2_create(tree1, mem_ctx, &create);
+ torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, ret, done, "smb2_create");
+
+ torture_comment(tctx, "(%s) create resource fork\n", __location__);
+
+ ZERO_STRUCT(create);
+ create.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
+ create.in.desired_access = SEC_STD_READ_CONTROL | SEC_FILE_ALL;
+ create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ create.in.fname = rfork;
+ create.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE |
+ NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ status = smb2_create(tree1, mem_ctx, &create);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_create");
+ fh1 = create.out.file.handle;
+
+ torture_comment(tctx, "(%s) getinfo on create handle\n",
+ __location__);
+
+ ZERO_STRUCT(finfo);
+ finfo.generic.level = RAW_FILEINFO_ALL_INFORMATION;
+ finfo.generic.in.file.handle = fh1;
+ status = smb2_getinfo_file(tree1, mem_ctx, &finfo);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_getinfo_file");
+ if (finfo.all_info.out.size != 0) {
+ torture_result(tctx, TORTURE_FAIL,
+ "(%s) Incorrect resource fork size\n",
+ __location__);
+ ret = false;
+ smb2_util_close(tree1, fh1);
+ goto done;
+ }
+
+ torture_comment(tctx, "(%s) open rfork, should still return ENOENT\n",
+ __location__);
+
+ ZERO_STRUCT(create);
+ create.in.create_disposition = NTCREATEX_DISP_OPEN;
+ create.in.desired_access = SEC_STD_READ_CONTROL | SEC_FILE_ALL;
+ create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ create.in.fname = rfork;
+ create.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE |
+ NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ status = smb2_create(tree1, mem_ctx, &create);
+ torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, ret, done, "smb2_create");
+
+ ZERO_STRUCT(create);
+ create.in.fname = fname;
+ create.in.create_disposition = NTCREATEX_DISP_OPEN;
+ create.in.desired_access = SEC_STD_READ_CONTROL | SEC_FILE_ALL;
+ create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ status = smb2_create(tree1, mem_ctx, &create);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_create");
+
+ ret = check_stream_list(tree1, tctx, fname, 1, streams,
+ create.out.file.handle);
+ torture_assert_goto(tctx, ret == true, ret, done, "check_stream_list");
+ smb2_util_close(tree1, create.out.file.handle);
+
+ torture_comment(tctx, "(%s) close empty created rfork, open should return ENOENT\n",
+ __location__);
+ smb2_util_close(tree1, fh1);
+ ZERO_STRUCT(create);
+ create.in.create_disposition = NTCREATEX_DISP_OPEN;
+ create.in.desired_access = SEC_STD_READ_CONTROL | SEC_FILE_ALL;
+ create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ create.in.fname = rfork;
+ create.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE |
+ NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ status = smb2_create(tree1, mem_ctx, &create);
+ torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, ret, done, "smb2_create");
+
+done:
+ smb2_util_unlink(tree1, fname);
+ smb2_deltree(tree1, BASEDIR);
+ talloc_free(mem_ctx);
+ return ret;
+}
+
static bool test_adouble_conversion(struct torture_context *tctx,
struct smb2_tree *tree1,
struct smb2_tree *tree2)
@@ -2448,6 +2576,7 @@ struct torture_suite *torture_vfs_fruit(void)
torture_suite_add_2ns_smb2_test(suite, "SMB2/CREATE context AAPL", test_aapl);
torture_suite_add_2ns_smb2_test(suite, "stream names", test_stream_names);
torture_suite_add_2ns_smb2_test(suite, "truncate resource fork to 0 bytes", test_rfork_truncate);
+ torture_suite_add_2ns_smb2_test(suite, "opening and creating resource fork", test_rfork_create);
return suite;
}