From a69db298d440f38fdc2e222d01ecf8d52e0dcc0a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 18 Sep 2018 09:55:51 +0200 Subject: [PATCH] smbd: Pass lease parameters explicitly to find_fsp_lease This avoids a use of "struct share_mode_lease" Signed-off-by: Volker Lendecke Reviewed-by: Christof Schmitt --- source3/smbd/durable.c | 7 ++++++- source3/smbd/open.c | 17 ++++++++++++----- source3/smbd/proto.h | 6 ++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index 1f6113e4cc9..719c3f1a5f2 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -709,7 +709,12 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, key.data[0] = l->lease_key.data[0]; key.data[1] = l->lease_key.data[1]; - fsp->lease = find_fsp_lease(fsp, &key, l); + fsp->lease = find_fsp_lease( + fsp, + &key, + l->current_state, + l->lease_version, + l->epoch); if (fsp->lease == NULL) { TALLOC_FREE(lck); fsp_free(fsp); diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 38aaa7d267b..f8833df5745 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1983,7 +1983,9 @@ int find_share_mode_lease(struct share_mode_data *d, struct fsp_lease *find_fsp_lease(struct files_struct *new_fsp, const struct smb2_lease_key *key, - const struct share_mode_lease *l) + uint32_t current_state, + uint16_t lease_version, + uint16_t lease_epoch) { struct files_struct *fsp; @@ -2016,14 +2018,14 @@ struct fsp_lease *find_fsp_lease(struct files_struct *new_fsp, new_fsp->lease->ref_count = 1; new_fsp->lease->sconn = new_fsp->conn->sconn; new_fsp->lease->lease.lease_key = *key; - new_fsp->lease->lease.lease_state = l->current_state; + new_fsp->lease->lease.lease_state = current_state; /* * We internally treat all leases as V2 and update * the epoch, but when sending breaks it matters if * the requesting lease was v1 or v2. */ - new_fsp->lease->lease.lease_version = l->lease_version; - new_fsp->lease->lease.lease_epoch = l->epoch; + new_fsp->lease->lease.lease_version = lease_version; + new_fsp->lease->lease.lease_epoch = lease_epoch; return new_fsp->lease; } @@ -2046,7 +2048,12 @@ static NTSTATUS grant_fsp_lease(struct files_struct *fsp, bool do_upgrade; uint32_t existing, requested; - fsp->lease = find_fsp_lease(fsp, &lease->lease_key, l); + fsp->lease = find_fsp_lease( + fsp, + &lease->lease_key, + l->current_state, + l->lease_version, + l->epoch); if (fsp->lease == NULL) { DEBUG(1, ("Did not find existing lease for file %s\n", fsp_str_dbg(fsp))); diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index fdb0ffabf75..962707007bd 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -695,9 +695,11 @@ int find_share_mode_lease(struct share_mode_data *d, const struct GUID *client_guid, const struct smb2_lease_key *key); struct share_mode_lease; -struct fsp_lease *find_fsp_lease(files_struct *new_fsp, +struct fsp_lease *find_fsp_lease(struct files_struct *new_fsp, const struct smb2_lease_key *key, - const struct share_mode_lease *l); + uint32_t current_state, + uint16_t lease_version, + uint16_t lease_epoch); NTSTATUS create_file_default(connection_struct *conn, struct smb_request *req, uint16_t root_dir_fid, -- 2.34.1