summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2020-12-21 16:35:11 +0100
committerStefan Metzmacher <metze@samba.org>2021-01-14 11:30:38 +0000
commit930b6bb3b87f600757266b34a9bb1ca3764177fd (patch)
treebf6abbfc43f390d2d263f1b6ae4e666c0b17a2c1 /source3
parent928382f27000ce93aa29080f06cb7445b0b8c281 (diff)
downloadsamba-930b6bb3b87f600757266b34a9bb1ca3764177fd.tar.gz
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 <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/files.c29
-rw-r--r--source3/smbd/open.c13
2 files changed, 27 insertions, 15 deletions
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;
}