s4/torture: add a leases test with stat open
authorRalph Boehme <slow@samba.org>
Fri, 26 May 2017 13:42:46 +0000 (15:42 +0200)
committerRalph Boehme <slow@samba.org>
Sun, 28 May 2017 16:52:52 +0000 (18:52 +0200)
This test passes against Windows 2016 but currently fails against Samba
for some reason. The test does the following:

1. A stat open on a file, then
2. a second open with a RWH-lease request

Windows grants a RWH-lease in step 2, while Samba only grants a
R-lease. Go figure...

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Sun May 28 18:52:52 CEST 2017 on sn-devel-144

selftest/knownfail
source4/torture/smb2/lease.c

index b16ff520e4274f693f690e306d4645f8d9f5a62c..3cc945b4a31128e999f1f3fb4d8fa02bb6418281 100644 (file)
 ^samba3.smb2.replay.replay3
 ^samba3.smb2.replay.replay4
 ^samba3.smb2.lock.*replay
+^samba3.smb2.lease.statopen3
 ^samba4.smb2.ioctl.compress_notsup.*\(ad_dc_ntvfs\)
 ^samba3.raw.session.*reauth2 # maybe fix this?
 ^samba3.rpc.lsa.secrets.seal # This gives NT_STATUS_LOCAL_USER_SESSION_KEY
index 10761b89128fefac884aabf8f0e2a03bf9e79238..6212c08261d2957e65fbfad8f2a5343701fca72a 100644 (file)
@@ -1075,6 +1075,72 @@ done:
        return ret;
 }
 
+static bool test_lease_statopen3(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 = {{0}};
+       struct smb2_handle h2 = {{0}};
+       NTSTATUS status;
+       const char *fname = "lease_statopen3.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);
+       tree->session->transport->lease.handler = torture_lease_handler;
+       tree->session->transport->lease.private_data = tree;
+
+       status = torture_smb2_testfile(tree, fname, &h1);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb2_create failed\n");
+       smb2_util_close(tree, h1);
+       ZERO_STRUCT(h1);
+
+       /* Stat open */
+       ZERO_STRUCT(io);
+       io.in.desired_access = FILE_READ_ATTRIBUTES;
+       io.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
+       io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+       io.in.create_disposition = NTCREATEX_DISP_OPEN;
+       io.in.fname = fname;
+       status = smb2_create(tree, mem_ctx, &io);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb2_create failed\n");
+       h1 = io.out.file.handle;
+
+       /* Open file with RWH lease. */
+       smb2_lease_create_share(&io, &ls, false, fname,
+                               smb2_util_share_access("RWD"),
+                               LEASE1,
+                               smb2_util_lease_state("RWH"));
+       io.in.desired_access = SEC_FILE_WRITE_DATA;
+       status = smb2_create(tree, mem_ctx, &io);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb2_create failed\n");
+       h2 = io.out.file.handle;
+       CHECK_LEASE(&io, "RWH", true, LEASE1, 0);
+
+done:
+       if (!smb2_util_handle_empty(h1)) {
+               smb2_util_close(tree, h1);
+       }
+       if (!smb2_util_handle_empty(h2)) {
+               smb2_util_close(tree, h2);
+       }
+       smb2_util_unlink(tree, fname);
+       talloc_free(mem_ctx);
+       return ret;
+}
+
 static void torture_oplock_break_callback(struct smb2_request *req)
 {
        NTSTATUS status;
@@ -4002,6 +4068,7 @@ struct torture_suite *torture_smb2_lease_init(TALLOC_CTX *ctx)
                                     test_lease_nobreakself);
        torture_suite_add_1smb2_test(suite, "statopen", test_lease_statopen);
        torture_suite_add_1smb2_test(suite, "statopen2", test_lease_statopen2);
+       torture_suite_add_1smb2_test(suite, "statopen3", test_lease_statopen3);
        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);