From: Ralph Boehme Date: Fri, 10 Oct 2025 13:24:31 +0000 (+0200) Subject: smbd: reshuffle requested/granted lease level logic of Directory Leases X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5af7a7a37183f974868703918b46691ee32d648c;p=thirdparty%2Fsamba.git smbd: reshuffle requested/granted lease level logic of Directory Leases This moves the logic to adjust the lease levels for Directory Leases to the same place where we do it for other cases. Signed-off-by: Ralph Boehme Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Thu Nov 27 10:04:47 UTC 2025 on atb-devel-224 --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 02f3c53598f..83bdf67f671 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -2516,15 +2516,6 @@ static NTSTATUS delay_for_oplock(files_struct *fsp, } requested = lease->lease_state; - if (fsp->fsp_flags.is_directory) { - /* - * According to "MS-FSA 2.1.5.18 Server Requests an - * Oplock" this should fail with - * STATUS_INVALID_PARAMETER, but Windows 2022 just - * ignores the SMB2_LEASE_WRITE bit. - */ - requested &= ~SMB2_LEASE_WRITE; - } } else { requested = map_oplock_to_lease_type( oplock_request & ~SAMBA_PRIVATE_OPLOCK_MASK); @@ -2584,6 +2575,16 @@ grant: granted = requested; + if (fsp->fsp_flags.is_directory) { + /* + * According to "MS-FSA 2.1.5.18 Server Requests an + * Oplock" this should fail with + * STATUS_INVALID_PARAMETER, but Windows 2022 just + * ignores the SMB2_LEASE_WRITE bit. + */ + granted &= ~SMB2_LEASE_WRITE; + } + if (oplock_request == LEASE_OPLOCK) { if (lp_kernel_oplocks(SNUM(fsp->conn))) { DEBUG(10, ("No lease granted because kernel oplocks are enabled\n"));