From: Ralph Boehme Date: Tue, 8 Jul 2025 12:47:24 +0000 (+0200) Subject: smbd: simplify create_action handling X-Git-Tag: tdb-1.4.14~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=93c1f55917ee0500b3c9fc169063cb3a5a492983;p=thirdparty%2Fsamba.git smbd: simplify create_action handling (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 Reviewed-by: Stefan Metzmacher --- diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c index 12e87ec7b6f..5623a5a1bde 100644 --- a/source3/smbd/smb2_create.c +++ b/source3/smbd/smb2_create.c @@ -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);