diff options
author | Volker Lendecke <vl@samba.org> | 2022-02-02 08:58:15 +0100 |
---|---|---|
committer | Jule Anger <janger@samba.org> | 2022-02-14 17:46:14 +0000 |
commit | e8d165da42a89093b629d20fd4064b82100cc9b3 (patch) | |
tree | 01ffd3fdb26a9eea8596a077c9be461859f9f3ab | |
parent | 9794341b29e68726f6c4c8989b0a1e0db913d815 (diff) | |
download | samba-e8d165da42a89093b629d20fd4064b82100cc9b3.tar.gz |
smbd: No base fsps to close_file_free() from file_close_user()
Same logic as the change for file_close_conn()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14975
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 1fbd9877fead466a17d697c143cd370c0b27f610)
-rw-r--r-- | source3/smbd/files.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 1d03fa82076..be93d0e884e 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -905,15 +905,40 @@ bool file_init(struct smbd_server_connection *sconn) Close files open by a specified vuid. ****************************************************************************/ +struct file_close_user_state { + uint64_t vuid; + bool fsp_left_behind; +}; + +static struct files_struct *file_close_user_fn( + struct files_struct *fsp, + void *private_data) +{ + struct file_close_user_state *state = private_data; + bool did_close; + + if (fsp->vuid != state->vuid) { + return NULL; + } + + did_close = close_file_in_loop(fsp); + if (!did_close) { + state->fsp_left_behind = true; + } + + return NULL; +} + void file_close_user(struct smbd_server_connection *sconn, uint64_t vuid) { - files_struct *fsp, *next; + struct file_close_user_state state = { .vuid = vuid }; - for (fsp=sconn->files; fsp; fsp=next) { - next=fsp->next; - if (fsp->vuid == vuid) { - close_file_free(NULL, &fsp, SHUTDOWN_CLOSE); - } + files_forall(sconn, file_close_user_fn, &state); + + if (state.fsp_left_behind) { + state.fsp_left_behind = false; + files_forall(sconn, file_close_user_fn, &state); + SMB_ASSERT(!state.fsp_left_behind); } } |