summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/torture/raw/oplock.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c
index 962235cdcd..b120dad85b 100644
--- a/source4/torture/raw/oplock.c
+++ b/source4/torture/raw/oplock.c
@@ -3856,6 +3856,100 @@ done:
}
/*
+ * Open a file with an exclusive oplock from the 1st client and acquire a
+ * brl. Then open the same file from the 2nd client that should give oplock
+ * break with level2 to the 1st and return no oplock to the 2nd.
+ */
+static bool test_raw_oplock_brl4(struct torture_context *tctx,
+ struct smbcli_state *cli1,
+ struct smbcli_state *cli2)
+{
+ const char *fname = BASEDIR "\\test_batch_brl.dat";
+ bool ret = true;
+ uint8_t buf[1000];
+ bool correct = true;
+ union smb_open io;
+ NTSTATUS status;
+ uint16_t fnum = 0;
+ uint16_t 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);
+
+ /*
+ base ntcreatex parms
+ */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid.fnum = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_READ |
+ SEC_RIGHTS_FILE_WRITE;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ 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;
+
+ torture_comment(tctx, "open with exclusive oplock\n");
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK;
+
+ 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);
+
+ /* create a file with bogus data */
+ memset(buf, 0, sizeof(buf));
+
+ if (smbcli_write(cli1->tree, fnum, 0, buf, 0, sizeof(buf)) !=
+ sizeof(buf))
+ {
+ torture_comment(tctx, "Failed to create file\n");
+ correct = false;
+ goto done;
+ }
+
+ status = smbcli_lock(cli1->tree, fnum, 0, 1, 0, WRITE_LOCK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+
+ torture_comment(tctx, "a 2nd open should give a break to the 1st\n");
+ ZERO_STRUCT(break_info);
+
+ status = smb_raw_open(cli2->tree, tctx, &io);
+
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
+ CHECK_VAL(break_info.failures, 0);
+ CHECK_VAL(break_info.fnum, fnum);
+
+ torture_comment(tctx, "and return no oplock to the 2nd\n");
+ fnum2 = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN);
+
+ smbcli_close(cli1->tree, fnum);
+ smbcli_close(cli2->tree, fnum2);
+
+done:
+ smb_raw_exit(cli1->session);
+ smb_raw_exit(cli2->session);
+ smbcli_deltree(cli1->tree, BASEDIR);
+ return ret;
+}
+
+/*
basic testing of oplocks
*/
struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx)
@@ -3900,6 +3994,7 @@ struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx)
torture_suite_add_2smb_test(suite, "brl1", test_raw_oplock_brl1);
torture_suite_add_1smb_test(suite, "brl2", test_raw_oplock_brl2);
torture_suite_add_1smb_test(suite, "brl3", test_raw_oplock_brl3);
+ torture_suite_add_2smb_test(suite, "brl4", test_raw_oplock_brl4);
return suite;
}