From: Ralph Boehme Date: Tue, 23 Sep 2025 12:14:22 +0000 (+0200) Subject: smbd: only increment lease epoch if a lease was granted X-Git-Tag: tdb-1.4.15~531 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f45eae2928bd2cb46fc827a348531acb471a549;p=thirdparty%2Fsamba.git smbd: only increment lease epoch if a lease was granted From MS-SMB2 3.3.5.9.11 "Handling the SMB2_CREATE_REQUEST_LEASE_V2 Create Context": If the object store succeeds this request, Lease.LeaseState MUST be set to the new caching state. The server MUST increment Lease.Epoch by 1. try_lease_upgrade() already has the same logic when checking for a possible upgrade of an exisiting lease. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15933 Signed-off-by: Ralph Boehme Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Fri Oct 10 17:02:26 UTC 2025 on atb-devel-224 --- diff --git a/selftest/knownfail.d/samba3.smb2.lease b/selftest/knownfail.d/samba3.smb2.lease deleted file mode 100644 index d1bc4209385..00000000000 --- a/selftest/knownfail.d/samba3.smb2.lease +++ /dev/null @@ -1 +0,0 @@ -^samba3.smb2.lease.lease-epoch\(fileserver\) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 91abe9a5c24..a26cf653612 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -2045,7 +2045,10 @@ static NTSTATUS grant_new_fsp_lease(struct files_struct *fsp, fsp->lease->lease.parent_lease_key = lease->parent_lease_key; fsp->lease->lease.lease_flags = lease->lease_flags; fsp->lease->lease.lease_state = granted; - fsp->lease->lease.lease_epoch = lease->lease_epoch + 1; + fsp->lease->lease.lease_epoch = lease->lease_epoch; + if (granted != 0) { + fsp->lease->lease.lease_epoch++; + } status = leases_db_add(client_guid, &lease->lease_key,