summaryrefslogtreecommitdiff
path: root/source4/torture/smb2
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2012-09-11 13:43:17 +0200
committerMichael Adam <obnox@samba.org>2012-09-11 14:29:54 +0200
commit3d7196d0a470d31a531a618f210cd60635361daf (patch)
tree5877d586033b32794d03ea998011d8008350c58f /source4/torture/smb2
parentd237427f18b02958cfcfd6d775ee52231b3d095f (diff)
downloadsamba-3d7196d0a470d31a531a618f210cd60635361daf.tar.gz
samba-3d7196d0a470d31a531a618f210cd60635361daf.tar.bz2
samba-3d7196d0a470d31a531a618f210cd60635361daf.zip
s4:torture:smb2: fix the durable-open.delete_on_close1 test
This test used to flap because there was an invalid check of the file-id. This might or might not be the same after a new open. Hence the flapping. The new version simply opens a file as durable handle with delete_on_close set, writes a byte and closes the file. Then on a new connect, the file is opened again, and it is checked that the file has been created (again) and that it is empty.
Diffstat (limited to 'source4/torture/smb2')
-rw-r--r--source4/torture/smb2/durable_open.c69
1 files changed, 16 insertions, 53 deletions
diff --git a/source4/torture/smb2/durable_open.c b/source4/torture/smb2/durable_open.c
index 1cf183bdb6..e5f23a6acc 100644
--- a/source4/torture/smb2/durable_open.c
+++ b/source4/torture/smb2/durable_open.c
@@ -722,12 +722,9 @@ bool test_durable_open_delete_on_close1(struct torture_context *tctx,
char fname[256];
struct smb2_handle _h;
struct smb2_handle *h = NULL;
- struct smb2_create io1, io2, io3;
+ struct smb2_create io1, io2;
bool ret = true;
- struct smb2_transport *transport;
- struct smb2_session *session2;
- struct smb2_tree *tree2;
- union smb_fileinfo info1, info2;
+ uint8_t b = 0;
/* Choose a random name in case the state is left a little funky. */
snprintf(fname, 256, "durable_open_delete_on_close1_%s.dat",
@@ -749,80 +746,46 @@ bool test_durable_open_delete_on_close1(struct torture_context *tctx,
CHECK_VAL(io1.out.durable_open, true);
CHECK_VAL(io1.out.oplock_level, smb2_util_oplock_level("b"));
- ZERO_STRUCT(info1);
- info1.internal_information.level = RAW_FILEINFO_INTERNAL_INFORMATION;
- info1.internal_information.in.file.handle = _h;
- status = smb2_getinfo_file(tree, tree, &info1);
+ status = smb2_util_write(tree, *h, &b, 0, 1);
CHECK_STATUS(status, NT_STATUS_OK);
- /*
- * do a session logoff, establish a new session and tree
- * connect on the same transport, and try a durable reopen
- */
- transport = tree->session->transport;
- status = smb2_logoff(tree->session);
- CHECK_STATUS(status, NT_STATUS_OK);
+ /* disconnect, leaving the durable handle in place */
+ TALLOC_FREE(tree);
- if (!torture_smb2_session_setup(tctx, transport,
- 0, /* previous_session_id */
- mem_ctx, &session2))
- {
- torture_warning(tctx, "session setup failed.\n");
+ if (!torture_smb2_connection(tctx, &tree)) {
+ torture_warning(tctx, "could not reconnect, bailing\n");
ret = false;
goto done;
}
/*
- * the session setup has talloc-stolen the transport,
- * so we can safely free the old tree+session for clarity
+ * Open the file on the new connection again
+ * and check that it has been newly created,
+ * i.e. delete on close was effective on the disconnected handle.
+ * Also check that the file is really empty,
+ * the previously written byte gone.
*/
- TALLOC_FREE(tree);
-
- if (!torture_smb2_tree_connect(tctx, session2, mem_ctx, &tree2)) {
- torture_warning(tctx, "tree connect failed.\n");
- ret = false;
- goto done;
- }
-
- ZERO_STRUCT(io3);
- io3.in.fname = fname;
- io3.in.durable_handle = h;
- h = NULL;
-
smb2_oplock_create_share(&io2, fname,
smb2_util_share_access(""),
smb2_util_oplock_level("b"));
io2.in.create_options |= NTCREATEX_OPTIONS_DELETE_ON_CLOSE;
- status = smb2_create(tree2, mem_ctx, &io2);
+ status = smb2_create(tree, mem_ctx, &io2);
CHECK_STATUS(status, NT_STATUS_OK);
_h = io2.out.file.handle;
h = &_h;
- CHECK_CREATED(&io2, CREATED, FILE_ATTRIBUTE_ARCHIVE);
+ CHECK_CREATED_SIZE(&io2, CREATED, FILE_ATTRIBUTE_ARCHIVE, 0, 0);
CHECK_VAL(io2.out.durable_open, false);
CHECK_VAL(io2.out.oplock_level, smb2_util_oplock_level("b"));
- ZERO_STRUCT(info2);
- info2.internal_information.level = RAW_FILEINFO_INTERNAL_INFORMATION;
- info2.internal_information.in.file.handle = _h;
- status = smb2_getinfo_file(tree2, tree2, &info2);
- CHECK_STATUS(status, NT_STATUS_OK);
-
- CHECK_NOT_VAL(info1.internal_information.out.file_id,
- info2.internal_information.out.file_id);
-
- status = smb2_create(tree2, mem_ctx, &io3);
- CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
-
done:
if (h != NULL) {
- smb2_util_close(tree2, *h);
+ smb2_util_close(tree, *h);
}
- smb2_util_unlink(tree2, fname);
+ smb2_util_unlink(tree, fname);
talloc_free(tree);
- talloc_free(tree2);
talloc_free(mem_ctx);