smbd: Pass lease parameters explicitly to find_fsp_lease
authorVolker Lendecke <vl@samba.org>
Tue, 18 Sep 2018 07:55:51 +0000 (09:55 +0200)
committerChristof Schmitt <cs@samba.org>
Sun, 14 Apr 2019 04:01:30 +0000 (04:01 +0000)
This avoids a use of "struct share_mode_lease"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
source3/smbd/durable.c
source3/smbd/open.c
source3/smbd/proto.h

index 1f6113e..719c3f1 100644 (file)
@@ -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);
index 38aaa7d..f8833df 100644 (file)
@@ -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)));
index fdb0ffa..9627070 100644 (file)
@@ -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,