From e751c6237b750adb4cb59df4a42bb9f39354e7e4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 9 Feb 2022 17:23:03 +0100 Subject: [PATCH] smbd: Factor out fsp_unbind_smb() from file_free() For example, remove our entry from smbXsrv_open_global.tdb Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/smbd/files.c | 16 ++++++++++++---- source3/smbd/proto.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 917f854aa7e..3fc1992ce4d 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -1224,11 +1224,11 @@ static void fsp_free(files_struct *fsp) TALLOC_FREE(fsp); } -void file_free(struct smb_request *req, files_struct *fsp) +/* + * Rundown of all smb-related sub-structures of an fsp + */ +void fsp_unbind_smb(struct smb_request *req, files_struct *fsp) { - struct smbd_server_connection *sconn = fsp->conn->sconn; - uint64_t fnum = fsp->fnum; - if (fsp == fsp->conn->cwd_fsp) { return; } @@ -1269,6 +1269,14 @@ void file_free(struct smb_request *req, files_struct *fsp) * pointers in the SMB2 request queue. */ remove_smb2_chained_fsp(fsp); +} + +void file_free(struct smb_request *req, files_struct *fsp) +{ + struct smbd_server_connection *sconn = fsp->conn->sconn; + uint64_t fnum = fsp->fnum; + + fsp_unbind_smb(req, fsp); /* Drop all remaining extensions. */ vfs_remove_all_fsp_extensions(fsp); diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index e1443c1186f..008de8baf37 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -412,6 +412,7 @@ struct files_struct *file_find_one_fsp_from_lease_key( struct smbd_server_connection *sconn, const struct smb2_lease_key *lease_key); bool file_find_subpath(files_struct *dir_fsp); +void fsp_unbind_smb(struct smb_request *req, files_struct *fsp); void file_free(struct smb_request *req, files_struct *fsp); files_struct *file_fsp(struct smb_request *req, uint16_t fid); struct files_struct *file_fsp_get(struct smbd_smb2_request *smb2req,