]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: hang posix brl per-handle check on the pathname
authorRalph Boehme <slow@samba.org>
Thu, 18 Sep 2025 21:44:34 +0000 (23:44 +0200)
committerJule Anger <janger@samba.org>
Wed, 15 Oct 2025 14:01:04 +0000 (14:01 +0000)
For the SMB3 POSIX client both posix_open=true and (fsp->fsp_name->flags &
SMB_FILENAME_POSIX_PATH) will always be the case, so this is no change in
behaviour for that case.

However, for the macOS client fruit will carefully setup both flags as
posix_open=true but SMB_FILENAME_POSIX_PATH will not be set.

This is a deliberate hack to give the macOS client POSIX behaviour for some
operations, but not for others, while also allowing the POSIX-ified macOS client
to continue to get case insensitive behavour.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15926

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
(cherry picked from commit 75fa416f911f1f30aae8bdf14b423140874acaa0)

selftest/knownfail.d/samba3.vfs.fruit
source3/smbd/smb2_lock.c

index b774b0503e779dcac33cf6456c074bfb894d2b32..b51c887c21290ea16773e7f31306a8acd3974003 100644 (file)
@@ -1,4 +1,3 @@
 ^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion\(nt4_dc\)
 ^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion without embedded xattr\(nt4_dc\)
-^samba3.vfs.fruit.*readonly-exclusive-lock\(.*\)
 ^samba3.vfs.fruit.*case_insensitive_find\(.*\)
index be3f65e3f793a285db9b29886df45803ccb08f65..0a13832307716b2a648d3f8f5247c444c40b2989 100644 (file)
@@ -381,8 +381,22 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
 
        for (i=0; i<in_lock_count; i++) {
                bool invalid = false;
-               bool posix_handle = fsp->fsp_flags.posix_open;
+               bool posix_handle = fsp->fsp_name->flags &
+                       SMB_FILENAME_POSIX_PATH;
 
+               /*
+                * For POSIX clients struct files_struct.fsp_flags.posix_open
+                * and struct smb_filename.flags SMB_FILENAME_POSIX_PATH will
+                * always be set to the same value.
+                *
+                * For macOS clients vfs_fruit with fruit:posix_open=yes, we
+                * deliberately set both flags to fsp_flags.posix_open=true
+                * while SMB_FILENAME_POSIX_PATH will not be set.
+                *
+                * By deliberately checking the fsp_name flag here instead of
+                * the fsp flag, Byterange Lock processing uses Windows
+                * behaviour for macOS clients which is what we want.
+                */
                switch (in_locks[i].flags) {
                case SMB2_LOCK_FLAG_SHARED:
                case SMB2_LOCK_FLAG_EXCLUSIVE: