summaryrefslogtreecommitdiff
path: root/source4/torture/smb2
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2017-01-11 17:09:54 +0100
committerJeremy Allison <jra@samba.org>2017-04-18 22:54:16 +0200
commit26018947f9b2b1e7d45b54738710fb1d7a6a5ec6 (patch)
tree22944886690d3bccfd5a3c05f47da9ac2bc32dca /source4/torture/smb2
parent9c95eca0f4116d52c8522a2066783e4722b21337 (diff)
downloadsamba-26018947f9b2b1e7d45b54738710fb1d7a6a5ec6.tar.gz
s4/torture: add a test for compound SMB2 FIND requests
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/torture/smb2')
-rw-r--r--source4/torture/smb2/compound.c123
-rw-r--r--source4/torture/smb2/smb2.c1
2 files changed, 124 insertions, 0 deletions
diff --git a/source4/torture/smb2/compound.c b/source4/torture/smb2/compound.c
index a502103be68..14805760bd4 100644
--- a/source4/torture/smb2/compound.c
+++ b/source4/torture/smb2/compound.c
@@ -1103,6 +1103,117 @@ done:
return ret;
}
+/* Test compound related finds */
+static bool test_compound_find_related(struct torture_context *tctx,
+ struct smb2_tree *tree)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(tctx);
+ const char *dname = "compound_find_dir";
+ struct smb2_create create;
+ struct smb2_find f;
+ struct smb2_handle h;
+ struct smb2_request *req[2];
+ NTSTATUS status;
+ bool ret = true;
+
+ smb2_deltree(tree, dname);
+
+ ZERO_STRUCT(create);
+ create.in.desired_access = SEC_RIGHTS_DIR_ALL;
+ create.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ create.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
+ 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.fname = dname;
+
+ status = smb2_create(tree, mem_ctx, &create);
+ h = create.out.file.handle;
+
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_create failed\n");
+
+ smb2_transport_compound_start(tree->session->transport, 2);
+
+ ZERO_STRUCT(f);
+ f.in.file.handle = h;
+ f.in.pattern = "*";
+ f.in.max_response_size = 0x100;
+ f.in.level = SMB2_FIND_BOTH_DIRECTORY_INFO;
+
+ req[0] = smb2_find_send(tree, &f);
+
+ smb2_transport_compound_set_related(tree->session->transport, true);
+
+ req[1] = smb2_find_send(tree, &f);
+
+ status = smb2_find_recv(req[0], mem_ctx, &f);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_find_recv failed\n");
+
+ status = smb2_find_recv(req[1], mem_ctx, &f);
+ torture_assert_ntstatus_equal_goto(tctx, status, STATUS_NO_MORE_FILES, ret, done, "smb2_find_recv failed\n");
+
+done:
+ smb2_util_close(tree, h);
+ smb2_deltree(tree, dname);
+ TALLOC_FREE(mem_ctx);
+ return ret;
+}
+
+/* Test compound unrelated finds */
+static bool test_compound_find_unrelated(struct torture_context *tctx,
+ struct smb2_tree *tree)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(tctx);
+ const char *dname = "compound_find_dir";
+ struct smb2_create create;
+ struct smb2_find f;
+ struct smb2_handle h;
+ struct smb2_request *req[2];
+ NTSTATUS status;
+ bool ret = true;
+
+ smb2_deltree(tree, dname);
+
+ ZERO_STRUCT(create);
+ create.in.desired_access = SEC_RIGHTS_DIR_ALL;
+ create.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ create.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
+ 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.fname = dname;
+
+ status = smb2_create(tree, mem_ctx, &create);
+ h = create.out.file.handle;
+
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_create failed\n");
+
+ smb2_transport_compound_start(tree->session->transport, 2);
+
+ ZERO_STRUCT(f);
+ f.in.file.handle = h;
+ f.in.pattern = "*";
+ f.in.max_response_size = 0x100;
+ f.in.level = SMB2_FIND_BOTH_DIRECTORY_INFO;
+
+ req[0] = smb2_find_send(tree, &f);
+ req[1] = smb2_find_send(tree, &f);
+
+ status = smb2_find_recv(req[0], mem_ctx, &f);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_find_recv failed\n");
+
+ status = smb2_find_recv(req[1], mem_ctx, &f);
+ torture_assert_ntstatus_equal_goto(tctx, status, STATUS_NO_MORE_FILES, ret, done, "smb2_find_recv failed\n");
+
+done:
+ smb2_util_close(tree, h);
+ smb2_deltree(tree, dname);
+ TALLOC_FREE(mem_ctx);
+ return ret;
+}
+
struct torture_suite *torture_smb2_compound_init(void)
{
struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "compound");
@@ -1124,3 +1235,15 @@ struct torture_suite *torture_smb2_compound_init(void)
return suite;
}
+
+struct torture_suite *torture_smb2_compound_find_init(void)
+{
+ struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "compound_find");
+
+ torture_suite_add_1smb2_test(suite, "compound_find_related", test_compound_find_related);
+ torture_suite_add_1smb2_test(suite, "compound_find_unrelated", test_compound_find_unrelated);
+
+ suite->description = talloc_strdup(suite, "SMB2-COMPOUND-FIND tests");
+
+ return suite;
+}
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 9f8cbe73b05..d8e3a066ced 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -162,6 +162,7 @@ NTSTATUS torture_smb2_init(void)
torture_suite_add_suite(suite, torture_smb2_dir_init());
torture_suite_add_suite(suite, torture_smb2_lease_init());
torture_suite_add_suite(suite, torture_smb2_compound_init());
+ torture_suite_add_suite(suite, torture_smb2_compound_find_init());
torture_suite_add_suite(suite, torture_smb2_oplocks_init());
torture_suite_add_suite(suite, torture_smb2_kernel_oplocks_init());
torture_suite_add_suite(suite, torture_smb2_streams_init());