]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbd: make use of fsp_set_base_fsp() when changing fsp->base_fsp
authorStefan Metzmacher <metze@samba.org>
Mon, 21 Dec 2020 15:35:11 +0000 (16:35 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 14 Jan 2021 11:30:38 +0000 (11:30 +0000)
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>
source3/smbd/files.c
source3/smbd/open.c

index 42a631872eafd5c30acd9c68d70c5a7c91015136..39dc7b657d2afc1e7754fe7c73e45e10d93a410f 100644 (file)
@@ -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);
index 4f6140deccd45203e8b3cd40b0c7ec421c76b9b5..cb76d8ae8c0ffbde0f129048c8c3c65c7e74f91c 100644 (file)
@@ -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;
        }