From: Ralph Boehme Date: Thu, 18 Sep 2025 21:44:34 +0000 (+0200) Subject: smbd: hang posix brl per-handle check on the pathname X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75fa416f911f1f30aae8bdf14b423140874acaa0;p=thirdparty%2Fsamba.git smbd: hang posix brl per-handle check on the pathname 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 Reviewed-by: Volker Lendecke --- diff --git a/selftest/knownfail.d/samba3.vfs.fruit b/selftest/knownfail.d/samba3.vfs.fruit index b774b0503e7..b51c887c212 100644 --- a/selftest/knownfail.d/samba3.vfs.fruit +++ b/selftest/knownfail.d/samba3.vfs.fruit @@ -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\(.*\) diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c index be3f65e3f79..0a138323077 100644 --- a/source3/smbd/smb2_lock.c +++ b/source3/smbd/smb2_lock.c @@ -381,8 +381,22 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx, for (i=0; ifsp_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: