The branch, v4-22-test has been updated
       via  a2f2a714848 smbd: fix handling of directory leases and oplock levels
       via  400ac7b108d smbtorture: add test smb2.dirlease.oplocks
      from  2871634a9f3 vfs_ceph_new: Add path based fallback for 
SMB_VFS_FNTIMES

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-22-test


- Log -----------------------------------------------------------------
commit a2f2a714848d2257a7abe1e487b455e0caeb7526
Author: Ralph Boehme <s...@samba.org>
Date:   Sat Mar 22 16:59:07 2025 +0100

    smbd: fix handling of directory leases and oplock levels
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15836
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Stefan Metzmacher <me...@samba.org>
    
    Autobuild-User(master): Ralph Böhme <s...@samba.org>
    Autobuild-Date(master): Fri Mar 28 07:53:25 UTC 2025 on atb-devel-224
    
    (cherry picked from commit 4b3f45e13f9c11920924c034a457ea2cb8e15e18)
    
    Autobuild-User(v4-22-test): Jule Anger <jan...@samba.org>
    Autobuild-Date(v4-22-test): Fri Mar 28 14:53:26 UTC 2025 on atb-devel-224

commit 400ac7b108d49629b030b6600f0c4193b4c952d4
Author: Ralph Boehme <s...@samba.org>
Date:   Sat Mar 22 16:57:13 2025 +0100

    smbtorture: add test smb2.dirlease.oplocks
    
    Verifies server correctly ignores oplock on directories and only grants 
leases.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15836
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Stefan Metzmacher <me...@samba.org>
    (cherry picked from commit 9ecaa4095643729bf5f9c93316d577b603190449)

-----------------------------------------------------------------------

Summary of changes:
 source3/smbd/open.c          |  7 ++++++
 source4/torture/smb2/lease.c | 58 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 771734f6203..540dc7a0c60 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -5191,6 +5191,13 @@ static NTSTATUS open_directory(connection_struct *conn,
                keep_locked = true;
        }
 
+       if ((oplock_request != NO_OPLOCK) && (oplock_request != LEASE_OPLOCK)) {
+               /*
+                * No oplocks on directories, only leases
+                */
+               oplock_request = NO_OPLOCK;
+       }
+
        lck_state = (struct open_ntcreate_lock_state) {
                .fsp                    = fsp,
                .object_type            = "directory",
diff --git a/source4/torture/smb2/lease.c b/source4/torture/smb2/lease.c
index 6966f97ccb4..60d5f81ae80 100644
--- a/source4/torture/smb2/lease.c
+++ b/source4/torture/smb2/lease.c
@@ -1492,6 +1492,63 @@ static bool test_lease_v2_request_parent(struct 
torture_context *tctx,
        return ret;
 }
 
+static bool test_dirlease_oplocks(struct torture_context *tctx,
+                                 struct smb2_tree *tree)
+{
+       const char *dname = "test_dirlease_leases_dir";
+       struct smb2_create c;
+       struct smb2_handle h = {};
+       uint16_t levels[] = {
+               SMB2_OPLOCK_LEVEL_NONE,
+               SMB2_OPLOCK_LEVEL_II,
+               SMB2_OPLOCK_LEVEL_EXCLUSIVE,
+               SMB2_OPLOCK_LEVEL_BATCH
+       };
+       uint32_t caps;
+       int i;
+       NTSTATUS status;
+       bool ret = true;
+
+       caps = smb2cli_conn_server_capabilities(tree->session->transport->conn);
+       torture_assert_goto(tctx, caps & SMB2_CAP_LEASING, ret, done, "leases 
are not supported");
+       torture_assert_goto(tctx, caps & SMB2_CAP_DIRECTORY_LEASING, ret, done,
+               "SMB3 Directory Leases are not supported\n");
+
+       smb2_deltree(tree, dname);
+
+       for (i = 0; i < sizeof(levels); i++) {
+               c = (struct smb2_create) {
+                       .in.oplock_level = levels[i],
+                       .in.desired_access = SEC_RIGHTS_DIR_READ,
+                       .in.create_options = NTCREATEX_OPTIONS_DIRECTORY,
+                       .in.file_attributes = FILE_ATTRIBUTE_DIRECTORY,
+                       .in.share_access = NTCREATEX_SHARE_ACCESS_MASK,
+                       .in.create_disposition = NTCREATEX_DISP_OPEN_IF,
+                       .in.fname = dname,
+               };
+
+               status = smb2_create(tree, tree, &c);
+               torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                               "smb2_create failed\n");
+               h = c.out.file.handle;
+               status = smb2_util_close(tree, h);
+               torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                               "smb2_util_close failed\n");
+
+               torture_assert_int_equal_goto(
+                       tctx,
+                       c.out.oplock_level,
+                       SMB2_OPLOCK_LEVEL_NONE,
+                       ret, done, "bad level");
+       }
+
+done:
+       smb2_util_close(tree, h);
+       smb2_deltree(tree, dname);
+
+       return ret;
+}
+
 /*
  * Checks server accepts "RWH", "RH" and "R" lease request and grants at most
  * (lease_request & "RH"), so no "W", but "R" without "H" if requested.
@@ -7558,6 +7615,7 @@ struct torture_suite 
*torture_smb2_dirlease_init(TALLOC_CTX *ctx)
 
        torture_suite_add_1smb2_test(suite, "v2_request_parent", 
test_lease_v2_request_parent);
        torture_suite_add_2smb2_test(suite, "v2_request", 
test_lease_v2_request);
+       torture_suite_add_1smb2_test(suite, "oplocks", test_dirlease_oplocks);
        torture_suite_add_1smb2_test(suite, "leases", test_dirlease_leases);
        torture_suite_add_2smb2_test(suite, "seteof", test_dirlease_seteof);
        torture_suite_add_2smb2_test(suite, "setdos", test_dirlease_setdos);


-- 
Samba Shared Repository

Reply via email to