The branch, master has been updated
       via  21d09dc torture4: Add trivial epoch test
       via  8b9f96e torture4: Add smb2.lease.nobreakself
       via  b597d47 torture4: Add a test to break a handle twice
       via  296739d torture4: Make sure we copy the parent_lease_key
       via  618b6fd smbd: Use BVAL
      from  eccce07 ctdb-tests: Add a test for ctdb restoredb

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 21d09dc7b85b57bcfe7cd4f57f7173eb9b3601d4
Author: Volker Lendecke <[email protected]>
Date:   Fri Jul 4 13:27:17 2014 +0000

    torture4: Add trivial epoch test
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>
    
    Autobuild-User(master): Volker Lendecke <[email protected]>
    Autobuild-Date(master): Mon Jul  7 18:36:37 CEST 2014 on sn-devel-104

commit 8b9f96e83b304e291b3f2b7095e9bd9ea2a90981
Author: Volker Lendecke <[email protected]>
Date:   Tue Sep 24 10:26:48 2013 -0700

    torture4: Add smb2.lease.nobreakself
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit b597d47241ed56bcc6000d9397f19431c3cc5b96
Author: Volker Lendecke <[email protected]>
Date:   Tue Sep 24 17:07:54 2013 -0700

    torture4: Add a test to break a handle twice
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit 296739d655db40b8acc68edc3168fb8c81a95c88
Author: Volker Lendecke <[email protected]>
Date:   Mon Sep 23 19:41:13 2013 -0700

    torture4: Make sure we copy the parent_lease_key
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit 618b6fdef85006904370a1a35ba87c70673ee647
Author: Volker Lendecke <[email protected]>
Date:   Thu Jul 3 15:35:33 2014 +0000

    smbd: Use BVAL
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 selftest/knownfail           |    4 +
 source3/smbd/trans2.c        |   12 +--
 source4/torture/smb2/lease.c |  264 +++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 266 insertions(+), 14 deletions(-)


Changeset truncated at 500 lines:

diff --git a/selftest/knownfail b/selftest/knownfail
index 624a5ae..7d1702d 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -200,6 +200,10 @@
 ^samba3.smb2.lease.oplock
 ^samba3.smb2.lease.multibreak
 ^samba3.smb2.lease.v2_request
+^samba3.smb2.lease.v2_request_parent
+^samba3.smb2.lease.break_twice
+^samba3.smb2.lease.nobreakself
+^samba3.smb2.lease.v2_epoch1
 ^samba3.smb2.oplock.batch20
 ^samba3.smb2.oplock.stream1
 ^samba3.smb2.streams.rename
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index a95edf8..9003cc4 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -5167,10 +5167,8 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
 
                        smblctx = (uint64_t)IVAL(pdata, POSIX_LOCK_PID_OFFSET);
 #if defined(HAVE_LONGLONG)
-                       offset = (((uint64_t) 
IVAL(pdata,(POSIX_LOCK_START_OFFSET+4))) << 32) |
-                                       ((uint64_t) 
IVAL(pdata,POSIX_LOCK_START_OFFSET));
-                       count = (((uint64_t) 
IVAL(pdata,(POSIX_LOCK_LEN_OFFSET+4))) << 32) |
-                                       ((uint64_t) 
IVAL(pdata,POSIX_LOCK_LEN_OFFSET));
+                       offset = BVAL(pdata,POSIX_LOCK_START_OFFSET);
+                       count = BVAL(pdata,POSIX_LOCK_LEN_OFFSET);
 #else /* HAVE_LONGLONG */
                        offset = (uint64_t)IVAL(pdata,POSIX_LOCK_START_OFFSET);
                        count = (uint64_t)IVAL(pdata,POSIX_LOCK_LEN_OFFSET);
@@ -5191,10 +5189,8 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                                SSVAL(pdata, POSIX_LOCK_FLAGS_OFFSET, 0);
                                SIVAL(pdata, POSIX_LOCK_PID_OFFSET, 
(uint32_t)smblctx);
 #if defined(HAVE_LONGLONG)
-                               SIVAL(pdata, POSIX_LOCK_START_OFFSET, 
(uint32)(offset & 0xFFFFFFFF));
-                               SIVAL(pdata, POSIX_LOCK_START_OFFSET + 4, 
(uint32)((offset >> 32) & 0xFFFFFFFF));
-                               SIVAL(pdata, POSIX_LOCK_LEN_OFFSET, 
(uint32)(count & 0xFFFFFFFF));
-                               SIVAL(pdata, POSIX_LOCK_LEN_OFFSET + 4, 
(uint32)((count >> 32) & 0xFFFFFFFF));
+                               SBVAL(pdata, POSIX_LOCK_START_OFFSET, offset);
+                               SBVAL(pdata, POSIX_LOCK_LEN_OFFSET, count);
 #else /* HAVE_LONGLONG */
                                SIVAL(pdata, POSIX_LOCK_START_OFFSET, offset);
                                SIVAL(pdata, POSIX_LOCK_LEN_OFFSET, count);
diff --git a/source4/torture/smb2/lease.c b/source4/torture/smb2/lease.c
index 045f994..4326958 100644
--- a/source4/torture/smb2/lease.c
+++ b/source4/torture/smb2/lease.c
@@ -69,7 +69,7 @@
                CHECK_VAL((__io)->out.lease_response.lease_duration, 0); \
        } while(0)
 
-#define CHECK_LEASE_V2(__io, __state, __oplevel, __key, __flags)       \
+#define CHECK_LEASE_V2(__io, __state, __oplevel, __key, __flags, __parent) \
        do {                                                            \
                if (__oplevel) {                                        \
                        CHECK_VAL((__io)->out.oplock_level, 
SMB2_OPLOCK_LEVEL_LEASE); \
@@ -84,6 +84,10 @@
                }                                                       \
                                                                        \
                CHECK_VAL((__io)->out.lease_response_v2.lease_flags, __flags); \
+               if (__flags & SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET) { \
+                       
CHECK_VAL((__io)->out.lease_response_v2.parent_lease_key.data[0], (__parent)); \
+                       
CHECK_VAL((__io)->out.lease_response_v2.parent_lease_key.data[1], ~(__parent)); 
\
+               } \
                CHECK_VAL((__io)->out.lease_response_v2.lease_duration, 0); \
        } while(0)
 
@@ -768,6 +772,91 @@ static bool test_lease_break(struct torture_context *tctx,
        return ret;
 }
 
+static bool test_lease_nobreakself(struct torture_context *tctx,
+                                  struct smb2_tree *tree)
+{
+       TALLOC_CTX *mem_ctx = talloc_new(tctx);
+       struct smb2_create io;
+       struct smb2_lease ls;
+       struct smb2_handle h1, h2;
+       NTSTATUS status;
+       const char *fname = "lease.dat";
+       bool ret = true;
+       uint32_t caps;
+       char c = 0;
+
+       caps = smb2cli_conn_server_capabilities(
+               tree->session->transport->conn);
+       if (!(caps & SMB2_CAP_LEASING)) {
+               torture_skip(tctx, "leases are not supported");
+       }
+
+       smb2_util_unlink(tree, fname);
+
+       /* Win7 is happy to grant RHW leases on files. */
+       smb2_lease_create(&io, &ls, false, fname, LEASE1,
+                         smb2_util_lease_state("R"));
+       status = smb2_create(tree, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       h1 = io.out.file.handle;
+       CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
+       CHECK_LEASE(&io, "R", true, LEASE1);
+
+       smb2_lease_create(&io, &ls, false, fname, LEASE2,
+                         smb2_util_lease_state("R"));
+       status = smb2_create(tree, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       h2 = io.out.file.handle;
+       CHECK_LEASE(&io, "R", true, LEASE2);
+
+       ZERO_STRUCT(break_info);
+
+       tree->session->transport->lease.handler = torture_lease_handler;
+       tree->session->transport->lease.private_data = tree;
+
+       /* Make sure we don't break ourselves on write */
+
+       status = smb2_util_write(tree, h1, &c, 0, 1);
+       torture_wait_for_lease_break(tctx);
+       CHECK_VAL(break_info.count, 1);
+       CHECK_VAL(break_info.failures, 0);
+       CHECK_BREAK_INFO("R", "", LEASE2);
+
+       /* Try the other way round. First, upgrade LEASE2 to R again */
+
+       smb2_lease_create(&io, &ls, false, fname, LEASE2,
+                         smb2_util_lease_state("R"));
+       status = smb2_create(tree, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       CHECK_LEASE(&io, "R", true, LEASE2);
+       smb2_util_close(tree, io.out.file.handle);
+
+       /* Now break LEASE1 via h2 */
+
+       ZERO_STRUCT(break_info);
+       status = smb2_util_write(tree, h2, &c, 0, 1);
+       torture_wait_for_lease_break(tctx);
+       CHECK_VAL(break_info.count, 1);
+       CHECK_VAL(break_info.failures, 0);
+       CHECK_BREAK_INFO("R", "", LEASE1);
+
+       /* .. and break LEASE2 via h1 */
+
+       ZERO_STRUCT(break_info);
+       status = smb2_util_write(tree, h1, &c, 0, 1);
+       torture_wait_for_lease_break(tctx);
+       CHECK_VAL(break_info.count, 1);
+       CHECK_VAL(break_info.failures, 0);
+       CHECK_BREAK_INFO("R", "", LEASE2);
+
+done:
+       smb2_util_close(tree, h2);
+       smb2_util_close(tree, h1);
+       smb2_util_unlink(tree, fname);
+       talloc_free(mem_ctx);
+       return ret;
+}
+
 static void torture_oplock_break_callback(struct smb2_request *req)
 {
        NTSTATUS status;
@@ -1091,6 +1180,109 @@ static bool test_lease_multibreak(struct 
torture_context *tctx,
        return ret;
 }
 
+static bool test_lease_v2_request_parent(struct torture_context *tctx,
+                                        struct smb2_tree *tree)
+{
+       TALLOC_CTX *mem_ctx = talloc_new(tctx);
+       struct smb2_create io;
+       struct smb2_lease ls;
+       struct smb2_handle h1;
+       uint64_t parent = LEASE2;
+       NTSTATUS status;
+       const char *fname = "lease.dat";
+       bool ret = true;
+
+       smb2_util_unlink(tree, fname);
+
+       ZERO_STRUCT(break_info);
+
+       ZERO_STRUCT(io);
+       smb2_lease_v2_create_share(&io, &ls, false, fname,
+                                  smb2_util_share_access("RWD"),
+                                  LEASE1, &parent,
+                                  smb2_util_lease_state("RHW"),
+                                  0);
+
+       status = smb2_create(tree, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       h1 = io.out.file.handle;
+       CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
+       CHECK_LEASE_V2(&io, "RHW", true, LEASE1,
+                      SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET, LEASE2);
+
+ done:
+       smb2_util_close(tree, h1);
+       smb2_util_unlink(tree, fname);
+
+       talloc_free(mem_ctx);
+
+       return ret;
+}
+
+static bool test_lease_break_twice(struct torture_context *tctx,
+                                  struct smb2_tree *tree)
+{
+       TALLOC_CTX *mem_ctx = talloc_new(tctx);
+       struct smb2_create io;
+       struct smb2_lease ls;
+       struct smb2_handle h1;
+       NTSTATUS status;
+       const char *fname = "lease.dat";
+       bool ret = true;
+       uint32_t caps;
+
+       caps = smb2cli_conn_server_capabilities(
+               tree->session->transport->conn);
+       if (!(caps & SMB2_CAP_LEASING)) {
+               torture_skip(tctx, "leases are not supported");
+       }
+
+       smb2_util_unlink(tree, fname);
+
+       ZERO_STRUCT(break_info);
+       ZERO_STRUCT(io);
+       ZERO_STRUCT(ls);
+
+       smb2_lease_v2_create_share(
+               &io, &ls, false, fname, smb2_util_share_access("RWD"),
+               LEASE1, NULL, smb2_util_lease_state("RWH"), 0);
+
+       status = smb2_create(tree, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       h1 = io.out.file.handle;
+       CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
+       CHECK_LEASE_V2(&io, "RHW", true, LEASE1, 0, 0);
+
+       tree->session->transport->lease.handler = torture_lease_handler;
+       tree->session->transport->lease.private_data = tree;
+
+       ZERO_STRUCT(break_info);
+
+       smb2_lease_v2_create_share(
+               &io, &ls, false, fname, smb2_util_share_access("R"),
+               LEASE2, NULL, smb2_util_lease_state("RWH"), 0);
+
+       status = smb2_create(tree, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+       CHECK_BREAK_INFO("RWH", "RW", LEASE1);
+
+       smb2_lease_v2_create_share(
+               &io, &ls, false, fname, smb2_util_share_access("RWD"),
+               LEASE2, NULL, smb2_util_lease_state("RWH"), 0);
+
+       ZERO_STRUCT(break_info);
+
+       status = smb2_create(tree, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       CHECK_BREAK_INFO("RW", "R", LEASE1);
+
+done:
+       smb2_util_close(tree, h1);
+       smb2_util_unlink(tree, fname);
+       talloc_free(mem_ctx);
+       return ret;
+}
+
 static bool test_lease_v2_request(struct torture_context *tctx,
                                  struct smb2_tree *tree)
 {
@@ -1127,7 +1319,7 @@ static bool test_lease_v2_request(struct torture_context 
*tctx,
        CHECK_STATUS(status, NT_STATUS_OK);
        h1 = io.out.file.handle;
        CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
-       CHECK_LEASE_V2(&io, "RHW", true, LEASE1, 0);
+       CHECK_LEASE_V2(&io, "RHW", true, LEASE1, 0, 0);
 
        ZERO_STRUCT(io);
        smb2_lease_v2_create_share(&io, &ls, true, dname,
@@ -1139,7 +1331,7 @@ static bool test_lease_v2_request(struct torture_context 
*tctx,
        CHECK_STATUS(status, NT_STATUS_OK);
        h2 = io.out.file.handle;
        CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_DIRECTORY);
-       CHECK_LEASE_V2(&io, "RH", true, LEASE2, 0);
+       CHECK_LEASE_V2(&io, "RH", true, LEASE2, 0, 0);
 
        ZERO_STRUCT(io);
        smb2_lease_v2_create_share(&io, &ls, false, dnamefname,
@@ -1152,7 +1344,7 @@ static bool test_lease_v2_request(struct torture_context 
*tctx,
        h3 = io.out.file.handle;
        CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
        CHECK_LEASE_V2(&io, "RHW", true, LEASE3,
-                      SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET);
+                      SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET, LEASE2);
 
        torture_wait_for_lease_break(tctx);
        CHECK_VAL(break_info.count, 0);
@@ -1168,7 +1360,7 @@ static bool test_lease_v2_request(struct torture_context 
*tctx,
        CHECK_STATUS(status, NT_STATUS_OK);
        h4 = io.out.file.handle;
        CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
-       CHECK_LEASE_V2(&io, "RHW", true, LEASE4, 0);
+       CHECK_LEASE_V2(&io, "RHW", true, LEASE4, 0, 0);
 
        torture_wait_for_lease_break(tctx);
        torture_wait_for_lease_break(tctx);
@@ -1188,7 +1380,7 @@ static bool test_lease_v2_request(struct torture_context 
*tctx,
        CHECK_STATUS(status, NT_STATUS_OK);
        h5 = io.out.file.handle;
        CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_DIRECTORY);
-       CHECK_LEASE_V2(&io, "RH", true, LEASE2, 0);
+       CHECK_LEASE_V2(&io, "RH", true, LEASE2, 0, 0);
        smb2_util_close(tree, h5);
 
        ZERO_STRUCT(w);
@@ -1225,19 +1417,79 @@ static bool test_lease_v2_request(struct 
torture_context *tctx,
        return ret;
 }
 
+static bool test_lease_v2_epoch1(struct torture_context *tctx,
+                                struct smb2_tree *tree)
+{
+       TALLOC_CTX *mem_ctx = talloc_new(tctx);
+       struct smb2_create io;
+       struct smb2_lease ls;
+       struct smb2_handle h;
+       const char *fname = "lease.dat";
+       bool ret = true;
+       NTSTATUS status;
+
+       smb2_util_unlink(tree, fname);
+
+       tree->session->transport->lease.handler = torture_lease_handler;
+       tree->session->transport->lease.private_data = tree;
+       tree->session->transport->oplock.handler = torture_oplock_handler;
+       tree->session->transport->oplock.private_data = tree;
+
+       ZERO_STRUCT(break_info);
+
+       ZERO_STRUCT(io);
+       smb2_lease_v2_create_share(&io, &ls, false, fname,
+                                  smb2_util_share_access("RWD"),
+                                  LEASE1, NULL,
+                                  smb2_util_lease_state("RHW"),
+                                  0);
+       ls.lease_epoch = 0x4711;
+
+       status = smb2_create(tree, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       h = io.out.file.handle;
+       CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
+       CHECK_LEASE_V2(&io, "RHW", true, LEASE1, 0, 0);
+       CHECK_VAL(io.out.lease_response_v2.lease_epoch, ls.lease_epoch + 1);
+       smb2_util_close(tree, h);
+       smb2_util_unlink(tree, fname);
+
+       ls.lease_state = smb2_util_lease_state("RH");
+
+       status = smb2_create(tree, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       h = io.out.file.handle;
+       CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
+       CHECK_LEASE_V2(&io, "RH", true, LEASE1, 0, 0);
+       CHECK_VAL(io.out.lease_response_v2.lease_epoch, ls.lease_epoch + 1);
+       smb2_util_close(tree, h);
+
+done:
+       smb2_util_unlink(tree, fname);
+       talloc_free(mem_ctx);
+       return ret;
+}
+
 struct torture_suite *torture_smb2_lease_init(void)
 {
        struct torture_suite *suite =
            torture_suite_create(talloc_autofree_context(), "lease");
 
        torture_suite_add_1smb2_test(suite, "request", test_lease_request);
+       torture_suite_add_1smb2_test(suite, "break_twice",
+                                    test_lease_break_twice);
+       torture_suite_add_1smb2_test(suite, "nobreakself",
+                                    test_lease_nobreakself);
        torture_suite_add_1smb2_test(suite, "upgrade", test_lease_upgrade);
        torture_suite_add_1smb2_test(suite, "upgrade2", test_lease_upgrade2);
        torture_suite_add_1smb2_test(suite, "upgrade3", test_lease_upgrade3);
        torture_suite_add_1smb2_test(suite, "break", test_lease_break);
        torture_suite_add_1smb2_test(suite, "oplock", test_lease_oplock);
        torture_suite_add_1smb2_test(suite, "multibreak", 
test_lease_multibreak);
+       torture_suite_add_1smb2_test(suite, "v2_request_parent",
+                                    test_lease_v2_request_parent);
        torture_suite_add_1smb2_test(suite, "v2_request", 
test_lease_v2_request);
+       torture_suite_add_1smb2_test(suite, "v2_epoch1", test_lease_v2_epoch1);
 
        suite->description = talloc_strdup(suite, "SMB2-LEASE tests");
 


-- 
Samba Shared Repository

Reply via email to