1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-08 04:58:40 +03:00

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 <jra@samba.org>
Reivewed-by: Noel Power <npower@samba.org>

Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Thu Aug 18 14:10:18 UTC 2022 on sn-devel-184
This commit is contained in:
Jeremy Allison 2022-08-17 11:43:47 -07:00 committed by Noel Power
parent 7005a6354d
commit cf5f7b1489

View File

@ -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;
}