From 15367ce4b413b6d7c42b6e0a3eac1f42eeedc564 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 26 May 2017 15:42:46 +0200 Subject: [PATCH] s4/torture: add a leases test with stat open MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Ralph Boehme Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Sun May 28 18:52:52 CEST 2017 on sn-devel-144 --- selftest/knownfail | 1 + source4/torture/smb2/lease.c | 67 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/selftest/knownfail b/selftest/knownfail index b16ff520e42..3cc945b4a31 100644 --- a/selftest/knownfail +++ b/selftest/knownfail @@ -174,6 +174,7 @@ ^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 diff --git a/source4/torture/smb2/lease.c b/source4/torture/smb2/lease.c index 10761b89128..6212c08261d 100644 --- a/source4/torture/smb2/lease.c +++ b/source4/torture/smb2/lease.c @@ -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); -- 2.11.4.GIT