From: Volker Lendecke Date: Mon, 13 Jun 2022 15:31:16 +0000 (+0200) Subject: smbd: open_stream_pathref_fsp() does not need a dirfsp X-Git-Tag: tevent-0.13.0~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=348f19d35b3c12ee67cc262614d41a2f165e1f7d;p=thirdparty%2Fsamba.git smbd: open_stream_pathref_fsp() does not need a dirfsp It opens relative to fsp->base_fsp Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 7042503eee1..e24fd698744 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -2834,8 +2834,7 @@ NTSTATUS filename_convert_dirfsp( smb_fname_rel->stream_name = saved_streamname; - status = open_stream_pathref_fsp( - smb_dirname->fsp, &base_fsp, smb_fname_rel); + status = open_stream_pathref_fsp(&base_fsp, smb_fname_rel); if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND) && !conn->case_sensitive) { @@ -2851,7 +2850,7 @@ NTSTATUS filename_convert_dirfsp( smb_fname_rel->stream_name = found; found = NULL; status = open_stream_pathref_fsp( - smb_dirname->fsp, &base_fsp, smb_fname_rel); + &base_fsp, smb_fname_rel); } } diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 84ac80851f4..46207bd7c90 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -603,7 +603,7 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp, goto fail; } - status = open_stream_pathref_fsp(dirfsp, &base_fname->fsp, smb_fname); + status = open_stream_pathref_fsp(&base_fname->fsp, smb_fname); if (!NT_STATUS_IS_OK(status)) { DBG_DEBUG("open_stream_pathref_fsp failed: %s\n", nt_errstr(status)); @@ -622,20 +622,19 @@ fail: * valid non-cwd_fsp dirfsp that we can pass to SMB_VFS_OPENAT() */ NTSTATUS open_stream_pathref_fsp( - const struct files_struct *dirfsp, struct files_struct **_base_fsp, struct smb_filename *smb_fname) { - connection_struct *conn = dirfsp->conn; + struct files_struct *base_fsp = *_base_fsp; + connection_struct *conn = base_fsp->conn; + struct smb_filename *base_fname = base_fsp->fsp_name; struct smb_filename *full_fname = NULL; struct files_struct *fsp = NULL; int ret, fd; NTSTATUS status; SMB_ASSERT(smb_fname->fsp == NULL); - SMB_ASSERT(*_base_fsp != NULL); SMB_ASSERT(is_named_stream(smb_fname)); - SMB_ASSERT(dirfsp != conn->cwd_fsp); status = fsp_new(conn, conn, &fsp); if (!NT_STATUS_IS_OK(status)) { @@ -648,7 +647,13 @@ NTSTATUS open_stream_pathref_fsp( fsp->fsp_flags.is_pathref = true; - full_fname = full_path_from_dirfsp_atname(fsp, dirfsp, smb_fname); + full_fname = synthetic_smb_fname( + fsp, + base_fname->base_name, + smb_fname->stream_name, + &smb_fname->st, + smb_fname->twrp, + smb_fname->flags); if (full_fname == NULL) { status = NT_STATUS_NO_MEMORY; goto fail; @@ -663,8 +668,7 @@ NTSTATUS open_stream_pathref_fsp( /* * non_widelink_open() not required: See the asserts above, - * this will only open the stream relative to - * dirfsp!=conn->cwd_fsp and fsp->base_fsp!=NULL. + * this will only open the stream relative to. */ fd = SMB_VFS_OPENAT( diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 64653976e22..cddfb6eac78 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -458,7 +458,6 @@ NTSTATUS openat_internal_dir_from_pathref( NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp, struct smb_filename *smb_fname); NTSTATUS open_stream_pathref_fsp( - const struct files_struct *dirfsp, struct files_struct **_base_fsp, struct smb_filename *smb_fname);