torture:smb2: for oplocks, durable reconnect works with different client guid
authorMichael Adam <obnox@samba.org>
Tue, 15 Mar 2016 07:59:53 +0000 (08:59 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 21 Mar 2016 23:23:22 +0000 (00:23 +0100)
in durabble-open.reopen1a test

Try both original and a different client guid.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/torture/smb2/durable_open.c

index 584f04690c5a416eb2c822c834c6c3a6cef58485..b74b5c58a6453b49175b65b879a0ddd790d0d024 100644 (file)
@@ -434,10 +434,13 @@ static bool test_durable_open_reopen1a(struct torture_context *tctx,
        struct smb2_create io;
        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_open_reopen1a_%s.dat",
@@ -464,6 +467,9 @@ static bool test_durable_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, "could not reconnect");
@@ -496,11 +502,56 @@ static bool test_durable_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);
+
+       /* the original client_guid works just the same */
+       options.client_guid = orig_client_guid;
+
+       ret = torture_smb2_connection_ext(tctx, previous_session_id,
+                                         &options, &tree3);
+       torture_assert_goto(tctx, ret, ret, done, "could not reconnect");
+
+       /*
+        * check that this has deleted the old session
+        */
+
+       ZERO_STRUCT(io);
+       io.in.fname = fname;
+       io.in.durable_handle = h;
+
+       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 = fname;
+       io.in.durable_handle = h;
+
+       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"));
+       _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);