mirror of
https://github.com/samba-team/samba.git
synced 2025-03-20 22:50:26 +03:00
s4/torture: test for bug 12798
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12798 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> (cherry picked from commit bd43939ec07a2fc6858d1265fc75a68a7cd96f58)
This commit is contained in:
parent
29196ec24a
commit
4fc1e91306
@ -993,6 +993,87 @@ done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool test_lease_statopen2(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}};
|
||||
struct smb2_handle h3 = {{0}};
|
||||
NTSTATUS status;
|
||||
const char *fname = "lease_statopen2.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);
|
||||
|
||||
/* 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");
|
||||
h1 = io.out.file.handle;
|
||||
CHECK_LEASE(&io, "RWH", true, LEASE1, 0);
|
||||
|
||||
/* 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");
|
||||
h2 = 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");
|
||||
h3 = io.out.file.handle;
|
||||
CHECK_LEASE(&io, "RWH", true, LEASE1, 0);
|
||||
|
||||
done:
|
||||
if (!smb2_util_handle_empty(h3)) {
|
||||
smb2_util_close(tree, h3);
|
||||
}
|
||||
if (!smb2_util_handle_empty(h2)) {
|
||||
smb2_util_close(tree, h2);
|
||||
}
|
||||
if (!smb2_util_handle_empty(h1)) {
|
||||
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)
|
||||
{
|
||||
@ -3920,6 +4001,7 @@ struct torture_suite *torture_smb2_lease_init(void)
|
||||
torture_suite_add_1smb2_test(suite, "nobreakself",
|
||||
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, "upgrade", test_lease_upgrade);
|
||||
torture_suite_add_1smb2_test(suite, "upgrade2", test_lease_upgrade2);
|
||||
torture_suite_add_1smb2_test(suite, "upgrade3", test_lease_upgrade3);
|
||||
|
Loading…
x
Reference in New Issue
Block a user