From b853040d5f27f0faf8d9a6071e6e6e6b2f840360 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 15 Mar 2016 09:02:28 +0100 Subject: [PATCH] torture:smb2: for oplocks, durable reconnect works with different client-guid for durable-v2-open.reopen1a Try both different and original client guid. Signed-off-by: Michael Adam Reviewed-by: Jeremy Allison --- source4/torture/smb2/durable_v2_open.c | 54 ++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/source4/torture/smb2/durable_v2_open.c b/source4/torture/smb2/durable_v2_open.c index 2528187f7a9..e48fb9b5f35 100644 --- a/source4/torture/smb2/durable_v2_open.c +++ b/source4/torture/smb2/durable_v2_open.c @@ -592,10 +592,13 @@ bool test_durable_v2_open_reopen1a(struct torture_context *tctx, struct GUID create_guid = GUID_random(); bool ret = true; struct smb2_tree *tree2 = NULL; + struct smb2_tree *tree3 = NULL; uint64_t previous_session_id; struct smbcli_options options; + struct GUID orig_client_guid; options = tree->session->transport->options; + orig_client_guid = options.client_guid; /* Choose a random name in case the state is left a little funky. */ snprintf(fname, 256, "durable_v2_open_reopen1a_%s.dat", @@ -629,6 +632,9 @@ bool test_durable_v2_open_reopen1a(struct torture_context *tctx, previous_session_id = smb2cli_session_current_id(tree->session->smbXcli); + /* for oplocks, the client guid can be different: */ + options.client_guid = GUID_random(); + ret = torture_smb2_connection_ext(tctx, previous_session_id, &options, &tree2); torture_assert_goto(tctx, ret, ret, done, "couldn't reconnect"); @@ -665,11 +671,59 @@ bool test_durable_v2_open_reopen1a(struct torture_context *tctx, _h = io.out.file.handle; h = &_h; + /* + * a session reconnect on a second tcp connection + */ + + previous_session_id = smb2cli_session_current_id(tree2->session->smbXcli); + + /* it works the same with the original guid */ + options.client_guid = orig_client_guid; + + ret = torture_smb2_connection_ext(tctx, previous_session_id, + &options, &tree3); + torture_assert_goto(tctx, ret, ret, done, "couldn't reconnect"); + + /* + * check that this has deleted the old session + */ + + ZERO_STRUCT(io); + io.in.fname = ""; + io.in.durable_handle_v2 = h; + io.in.create_guid = create_guid; + status = smb2_create(tree2, mem_ctx, &io); + CHECK_STATUS(status, NT_STATUS_USER_SESSION_DELETED); + TALLOC_FREE(tree2); + + /* + * but a durable reconnect on the new session succeeds: + */ + + ZERO_STRUCT(io); + io.in.fname = ""; + io.in.durable_handle_v2 = h; + io.in.create_guid = create_guid; + status = smb2_create(tree3, mem_ctx, &io); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE); + CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b")); + CHECK_VAL(io.out.durable_open, false); + CHECK_VAL(io.out.durable_open_v2, false); /* no dh2q response blob */ + CHECK_VAL(io.out.persistent_open, false); + CHECK_VAL(io.out.timeout, io.in.timeout); + _h = io.out.file.handle; + h = &_h; + done: if (tree == NULL) { tree = tree2; } + if (tree == NULL) { + tree = tree3; + } + if (tree != NULL) { if (h != NULL) { smb2_util_close(tree, *h); -- 2.34.1