From: Stefan Metzmacher Date: Mon, 21 Dec 2020 15:35:11 +0000 (+0100) Subject: s3:smbd: make use of fsp_set_base_fsp() when changing fsp->base_fsp X-Git-Tag: samba-4.14.0rc1~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=930b6bb3b87f600757266b34a9bb1ca3764177fd;p=thirdparty%2Fsamba.git s3:smbd: make use of fsp_set_base_fsp() when changing fsp->base_fsp This allows us to add some more logic for bi-directional linking between base and stream fsp in the next commits. Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 42a631872ea..39dc7b657d2 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -366,10 +366,13 @@ static int smb_fname_fsp_destructor(struct smb_filename *smb_fname) } if (fsp->base_fsp != NULL) { - status = fd_close(fsp->base_fsp); + struct files_struct *tmp_base_fsp = fsp->base_fsp; + + fsp_set_base_fsp(fsp, NULL); + + status = fd_close(tmp_base_fsp); SMB_ASSERT(NT_STATUS_IS_OK(status)); - file_free(NULL, fsp->base_fsp); - fsp->base_fsp = NULL; + file_free(NULL, tmp_base_fsp); } status = fd_close(fsp); @@ -411,7 +414,7 @@ static NTSTATUS open_pathref_base_fsp(const struct files_struct *dirfsp, return NT_STATUS_OBJECT_NAME_NOT_FOUND; } - fsp->base_fsp = smb_fname_base->fsp; + fsp_set_base_fsp(fsp, smb_fname_base->fsp); smb_fname_fsp_unlink(smb_fname_base); TALLOC_FREE(smb_fname_base); @@ -495,9 +498,12 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp, nt_errstr(status)); if (fsp->base_fsp != NULL) { - fd_close(fsp->base_fsp); - file_free(NULL, fsp->base_fsp); - fsp->base_fsp = NULL; + struct files_struct *tmp_base_fsp = fsp->base_fsp; + + fsp_set_base_fsp(fsp, NULL); + + fd_close(tmp_base_fsp); + file_free(NULL, tmp_base_fsp); } file_free(NULL, fsp); fsp = NULL; @@ -563,9 +569,12 @@ fail: return status; } if (fsp->base_fsp != NULL) { - fd_close(fsp->base_fsp); - file_free(NULL, fsp->base_fsp); - fsp->base_fsp = NULL; + struct files_struct *tmp_base_fsp = fsp->base_fsp; + + fsp_set_base_fsp(fsp, NULL); + + fd_close(tmp_base_fsp); + file_free(NULL, tmp_base_fsp); } fd_close(fsp); file_free(NULL, fsp); diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 4f6140deccd..cb76d8ae8c0 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -5820,9 +5820,12 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, } if (fsp->base_fsp != NULL) { - fd_close(fsp->base_fsp); - file_free(NULL, fsp->base_fsp); - fsp->base_fsp = NULL; + struct files_struct *tmp_base_fsp = fsp->base_fsp; + + fsp_set_base_fsp(fsp, NULL); + + fd_close(tmp_base_fsp); + file_free(NULL, tmp_base_fsp); } } @@ -5845,7 +5848,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, * base_fsp we already opened. Set up the * base_fsp pointer. */ - fsp->base_fsp = base_fsp; + fsp_set_base_fsp(fsp, base_fsp); } /* @@ -5942,7 +5945,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, * We have to reset the already set base_fsp * in order to close it in the error cleanup */ - fsp->base_fsp = NULL; + fsp_set_base_fsp(fsp, NULL); goto fail; }