]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: remove dirfsp arg from [create|open]_internal_dirfsp_at()
authorRalph Boehme <slow@samba.org>
Thu, 14 May 2020 16:38:51 +0000 (18:38 +0200)
committerRalph Boehme <slow@samba.org>
Thu, 21 May 2020 05:23:30 +0000 (05:23 +0000)
These are the functions that *create* dirfsps, they can't *take* dirfsps as that
would be recursive...

Both functions just take a pathname and the internal opening of the underlying
fd is secured from symlink races by our chdir("p/a/t/h") ; open(".", O_RDONLY);
logic in non_widelink_open().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_shadow_copy2.c
source3/smbd/dir.c
source3/smbd/files.c
source3/smbd/proto.h

index 6fdf1bcfb863ac81a828043c734cb2ea65fad5b7..c63d7a7b033e02d2ce6074364b4c495dccdf5aa8 100644 (file)
@@ -1957,7 +1957,6 @@ static int shadow_copy2_get_shadow_copy_data(
        }
 
        status = create_internal_dirfsp_at(handle->conn,
-                                          handle->conn->cwd_fsp,
                                           snapdir_smb_fname,
                                           &dirfsp);
        if (!NT_STATUS_IS_OK(status)) {
index 8d9a1fc4bcfba64ea90f82de7f434c4599a3eee7..2660718b29b44a1acb8432bffc7bad6b31650362 100644 (file)
@@ -1370,7 +1370,6 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx,
        NTSTATUS status;
 
        status = open_internal_dirfsp_at(conn,
-                                        conn->cwd_fsp,
                                         smb_dname,
                                         O_RDONLY,
                                         &fsp);
index 8968712fb3fe0d375c5ccb11cb6f7b01dec49858..9f02ddbc6c0c5baf1ce5ecae685e7601c4fb53cd 100644 (file)
@@ -177,15 +177,12 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
  * opening of the directory. Otherwise use open_internal_dirfsp_at().
  */
 NTSTATUS create_internal_dirfsp_at(connection_struct *conn,
-                                  struct files_struct *dirfsp,
                                   const struct smb_filename *smb_dname,
                                   struct files_struct **_fsp)
 {
        struct files_struct *fsp = NULL;
        NTSTATUS status;
 
-       SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
-
        status = file_new(NULL, conn, &fsp);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
@@ -223,7 +220,6 @@ NTSTATUS create_internal_dirfsp_at(connection_struct *conn,
  * Open an internal fsp for an *existing* directory.
  */
 NTSTATUS open_internal_dirfsp_at(connection_struct *conn,
-                                struct files_struct *dirfsp,
                                 const struct smb_filename *smb_dname,
                                 int open_flags,
                                 struct files_struct **_fsp)
@@ -231,9 +227,7 @@ NTSTATUS open_internal_dirfsp_at(connection_struct *conn,
        struct files_struct *fsp = NULL;
        NTSTATUS status;
 
-       SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
-
-       status = create_internal_dirfsp_at(conn, dirfsp, smb_dname, &fsp);
+       status = create_internal_dirfsp_at(conn, smb_dname, &fsp);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
index 9fdd85a37256c434ec50c1ed075ba00c493522fb..1ae80c8da3d51ce387644c60abd31147ab057ce3 100644 (file)
@@ -448,12 +448,10 @@ NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
 size_t fsp_fullbasepath(struct files_struct *fsp, char *buf, size_t buflen);
 
 NTSTATUS create_internal_dirfsp_at(connection_struct *conn,
-                                  struct files_struct *dirfsp,
                                   const struct smb_filename *smb_dname,
                                   struct files_struct **_fsp);
 
 NTSTATUS open_internal_dirfsp_at(connection_struct *conn,
-                                struct files_struct *dirfsp,
                                 const struct smb_filename *smb_dname,
                                 int open_flags,
                                 struct files_struct **_fsp);