smbd: remember and reuse dirfsp in smbd_smb2_create_send() for smbd_calculate_access_...
authorRalph Boehme <slow@samba.org>
Fri, 13 Oct 2023 13:49:55 +0000 (15:49 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 28 Nov 2023 06:38:59 +0000 (07:38 +0100)
source3/smbd/smb2_create.c

index 0f18d5594a46f6541ce3d36fe007a7e93ede15c4..72fcb6b36cf8ef0739569048b9d112fe245fb6c8 100644 (file)
@@ -505,6 +505,7 @@ struct smbd_smb2_create_state {
        struct timeval request_time;
        struct file_id id;
        struct deferred_open_record *open_rec;
+       struct files_struct *dirfsp;
        files_struct *result;
        bool replay_operation;
        uint8_t in_oplock_level;
@@ -717,7 +718,6 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
        struct smbd_smb2_create_state *state = NULL;
        NTSTATUS status;
        struct smb_request *smb1req = NULL;
-       struct files_struct *dirfsp = NULL;
        struct smb_filename *smb_fname = NULL;
        uint32_t ucf_flags;
        bool is_dfs = false;
@@ -986,7 +986,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
                state->fname,
                ucf_flags,
                state->twrp_time,
-               &dirfsp,
+               &state->dirfsp,
                &smb_fname);
        if (tevent_req_nterror(req, status)) {
                return tevent_req_post(req, state->ev);
@@ -1028,7 +1028,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 
        status = SMB_VFS_CREATE_FILE(smb1req->conn,
                                     smb1req,
-                                    dirfsp,
+                                    state->dirfsp,
                                     smb_fname,
                                     in_desired_access,
                                     in_share_access,
@@ -1424,7 +1424,7 @@ static void smbd_smb2_create_after_exec(struct tevent_req *req)
                        DATA_BLOB blob = data_blob_const(p, sizeof(p));
 
                        status = smbd_calculate_access_mask_fsp(
-                                       conn->cwd_fsp,
+                                       state->dirfsp,
                                        state->result,
                                        false,
                                        SEC_FLAG_MAXIMUM_ALLOWED,