From: Ralph Boehme Date: Thu, 14 May 2020 16:38:51 +0000 (+0200) Subject: smbd: remove dirfsp arg from [create|open]_internal_dirfsp_at() X-Git-Tag: ldb-2.2.0~441 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a6344334c07eebe607fc0f2af0673ef3289742bb;p=thirdparty%2Fsamba.git smbd: remove dirfsp arg from [create|open]_internal_dirfsp_at() 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 6fdf1bcfb86..c63d7a7b033 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -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)) { diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 8d9a1fc4bcf..2660718b29b 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -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); diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 8968712fb3f..9f02ddbc6c0 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -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; } diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 9fdd85a3725..1ae80c8da3d 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -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);