]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: simplify create_action handling
authorRalph Boehme <slow@samba.org>
Tue, 8 Jul 2025 12:47:24 +0000 (14:47 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 5 Aug 2025 14:52:34 +0000 (14:52 +0000)
(state->info == FILE_WAS_OVERWRITTEN) can only happen when returning
SMB_VFS_CREATE_FILE(), not for a Durable Handle reconnect or Replay, hence we
can move the check and adjustment of state->info to smbd_smb2_create_send()
after the call to SMB_VFS_CREATE_FILE().

This nicely simplifies the logic in smbd_smb2_create_finish() where we can now
just set state->op->create_action and state->out_create_action to the value of
state->info.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/smbd/smb2_create.c

index 12e87ec7b6f02729d772c88e0b46904827dbf537..5623a5a1bdeb445326ac4e5443b315abda807749 100644 (file)
@@ -1325,6 +1325,12 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
        }
        state->op = state->result->op;
 
+       if ((state->in_create_disposition == FILE_SUPERSEDE) &&
+           (state->info == FILE_WAS_OVERWRITTEN))
+       {
+               state->info = FILE_WAS_SUPERSEDED;
+       }
+
        smbd_smb2_create_after_exec(req);
        if (!tevent_req_is_in_progress(req)) {
                return tevent_req_post(req, state->ev);
@@ -1955,13 +1961,8 @@ static void smbd_smb2_create_finish(struct tevent_req *req)
                state->out_oplock_level = map_samba_oplock_levels_to_smb2(result->oplock_type);
        }
 
-       if ((state->in_create_disposition == FILE_SUPERSEDE)
-           && (state->info == FILE_WAS_OVERWRITTEN)) {
-               state->out_create_action = FILE_WAS_SUPERSEDED;
-       } else {
-               state->out_create_action = state->info;
-       }
-       result->op->create_action = state->out_create_action;
+       state->op->create_action = state->info;
+       state->out_create_action = state->info;
 
        state->out_creation_ts = get_create_timespec(smb1req->conn,
                                        result, result->fsp_name);