summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2013-10-15 15:22:06 +0000
committerStefan Metzmacher <metze@samba.org>2013-10-23 11:59:58 +0200
commit64e734019f5d0691017a592e78e6cac793875e4a (patch)
treeb97bbfbdcaa9da2e2cb329266c457b4098667d72
parent20669d4a75386eef4fdcea07fb99812c4e09de13 (diff)
downloadsamba-64e734019f5d0691017a592e78e6cac793875e4a.tar.gz
samba-64e734019f5d0691017a592e78e6cac793875e4a.tar.bz2
samba-64e734019f5d0691017a592e78e6cac793875e4a.zip
torture: Add a test showing we have to break L2 at open time
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r--selftest/knownfail2
-rw-r--r--source4/torture/raw/oplock.c105
2 files changed, 107 insertions, 0 deletions
diff --git a/selftest/knownfail b/selftest/knownfail
index cfa8b4b273..25289d2850 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -61,6 +61,7 @@
^samba3.raw.acls nfs4acl_xattr-special.inheritance\(s3dc\)
^samba3.raw.acls nfs4acl_xattr-special.inherit_creator_owner\(s3dc\)
^samba3.raw.acls nfs4acl_xattr-special.inherit_creator_group\(s3dc\)
+^samba3.raw.oplock.level_ii_1
^samba3.base.delete.deltest16a
^samba3.base.delete.deltest17a
^samba3.unix.whoami anonymous connection.whoami\(plugin_s4_dc\) # We need to resolve if we should be including SID_NT_WORLD and SID_NT_NETWORK in this token
@@ -142,6 +143,7 @@
^samba4.raw.oplock.*.doc1
^samba4.raw.oplock.*.exclusive5
^samba4.raw.oplock.*.exclusive9
+^samba4.raw.oplock.*.level_ii_1
^samba4.raw.lock.*.zerobyteread # bug 6974
^samba4.smb2.lock.*.zerobyteread # bug 6974
^samba4.raw.streams.*.delete
diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c
index 11e325e955..26baabc984 100644
--- a/source4/torture/raw/oplock.c
+++ b/source4/torture/raw/oplock.c
@@ -1065,6 +1065,109 @@ done:
return ret;
}
+static bool test_raw_oplock_level_ii_1(struct torture_context *tctx,
+ struct smbcli_state *cli1,
+ struct smbcli_state *cli2)
+{
+ const char *fname = BASEDIR "\\test_level_ii_1.dat";
+ NTSTATUS status;
+ bool ret = true;
+ union smb_open io;
+ uint16_t fnum=0, fnum2=0;
+
+ if (!torture_setup_dir(cli1, BASEDIR)) {
+ return false;
+ }
+
+ /* cleanup */
+ smbcli_unlink(cli1->tree, fname);
+
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given,
+ cli1->tree);
+ smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given,
+ cli1->tree);
+
+ /*
+ base ntcreatex parms
+ */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid.fnum = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname;
+
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ status = smb_raw_open(cli1->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN);
+
+ ZERO_STRUCT(break_info);
+
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK;
+ io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ status = smb_raw_open(cli2->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum2 = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
+ torture_wait_for_oplock_break(tctx);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
+ CHECK_VAL(break_info.failures, 0);
+
+ status = smbcli_close(cli2->tree, fnum2);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+
+ /*
+ * fnum1 has a level2 oplock now
+ */
+
+ ZERO_STRUCT(break_info);
+
+ /*
+ * Don't answer the break to none that will come in
+ */
+
+ smbcli_oplock_handler(cli1->transport, oplock_handler_timeout,
+ cli1->tree);
+
+ io.ntcreatex.in.flags = 0;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF;
+
+ status = smb_raw_open(cli2->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum2 = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN);
+ torture_wait_for_oplock_break(tctx);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_NONE);
+ CHECK_VAL(break_info.failures, 0);
+
+ status = smbcli_close(cli2->tree, fnum2);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ status = smbcli_close(cli1->tree, fnum);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+
+done:
+ smb_raw_exit(cli1->session);
+ smb_raw_exit(cli2->session);
+ smbcli_deltree(cli1->tree, BASEDIR);
+ return ret;
+}
+
static bool test_raw_oplock_batch1(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
{
const char *fname = BASEDIR "\\test_batch1.dat";
@@ -4183,6 +4286,8 @@ struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx)
test_raw_oplock_exclusive8);
torture_suite_add_2smb_test(suite, "exclusive9",
test_raw_oplock_exclusive9);
+ torture_suite_add_2smb_test(suite, "level_ii_1",
+ test_raw_oplock_level_ii_1);
torture_suite_add_2smb_test(suite, "batch1", test_raw_oplock_batch1);
torture_suite_add_2smb_test(suite, "batch2", test_raw_oplock_batch2);
torture_suite_add_2smb_test(suite, "batch3", test_raw_oplock_batch3);