From: Jeremy Allison Date: Wed, 17 Aug 2022 18:43:47 +0000 (-0700) Subject: s3: smbd: Plumb close_type parameter through close_file_in_loop(), file_close_conn() X-Git-Tag: talloc-2.4.0~1403 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cf5f7b1489930f6d64c3e3512f116ccf286d4605;p=thirdparty%2Fsamba.git s3: smbd: Plumb close_type parameter through close_file_in_loop(), file_close_conn() Allows close_file_in_loop() to differentiate between SHUTDOWN_CLOSE (previously it only used this close type) and ERROR_CLOSE - called on error from smbXsrv_tcon_disconnect() in the error path. In that case we want to close the fd, but not run any delete-on-close actions. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15128 Signed-off-by: Jeremy Allison Reivewed-by: Noel Power Autobuild-User(master): Noel Power Autobuild-Date(master): Thu Aug 18 14:10:18 UTC 2022 on sn-devel-184 --- diff --git a/source3/smbd/files.c b/source3/smbd/files.c index fb9454b015d..b494a8b789a 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -1258,7 +1258,8 @@ NTSTATUS parent_pathref(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } -static bool close_file_in_loop(struct files_struct *fsp) +static bool close_file_in_loop(struct files_struct *fsp, + enum file_close_type close_type) { if (fsp_is_alternate_stream(fsp)) { /* @@ -1276,7 +1277,7 @@ static bool close_file_in_loop(struct files_struct *fsp) fsp->base_fsp->stream_fsp = NULL; fsp->base_fsp = NULL; - close_file_free(NULL, &fsp, SHUTDOWN_CLOSE); + close_file_free(NULL, &fsp, close_type); return NULL; } @@ -1300,7 +1301,7 @@ static bool close_file_in_loop(struct files_struct *fsp) return false; } - close_file_free(NULL, &fsp, SHUTDOWN_CLOSE); + close_file_free(NULL, &fsp, close_type); return true; } @@ -1310,6 +1311,7 @@ static bool close_file_in_loop(struct files_struct *fsp) struct file_close_conn_state { struct connection_struct *conn; + enum file_close_type close_type; bool fsp_left_behind; }; @@ -1331,7 +1333,7 @@ static struct files_struct *file_close_conn_fn( fsp->op->global->durable = false; } - did_close = close_file_in_loop(fsp); + did_close = close_file_in_loop(fsp, state->close_type); if (!did_close) { state->fsp_left_behind = true; } @@ -1341,7 +1343,8 @@ static struct files_struct *file_close_conn_fn( void file_close_conn(connection_struct *conn, enum file_close_type close_type) { - struct file_close_conn_state state = { .conn = conn }; + struct file_close_conn_state state = { .conn = conn, + .close_type = close_type }; files_forall(conn->sconn, file_close_conn_fn, &state); @@ -1427,7 +1430,7 @@ static struct files_struct *file_close_user_fn( return NULL; } - did_close = close_file_in_loop(fsp); + did_close = close_file_in_loop(fsp, SHUTDOWN_CLOSE); if (!did_close) { state->fsp_left_behind = true; }