From: Ralph Boehme Date: Tue, 19 May 2020 19:30:24 +0000 (+0200) Subject: smbd: use SMB_VFS_OPENAT() in non_widelink_open() X-Git-Tag: ldb-2.2.0~371 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c57d76ec1a9ce26bfab1c4c4c3ac130c15fb71f2;p=thirdparty%2Fsamba.git smbd: use SMB_VFS_OPENAT() in non_widelink_open() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index e4628a75e72..cbcebe71e73 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -632,6 +632,7 @@ static int non_widelink_open(files_struct *fsp, int saved_errno = 0; struct smb_filename *oldwd_fname = NULL; struct smb_filename *parent_dir_fname = NULL; + struct files_struct *cwdfsp = NULL; bool ok; if (fsp->fsp_flags.is_directory) { @@ -679,12 +680,28 @@ static int non_widelink_open(files_struct *fsp, goto out; } + status = vfs_at_fspcwd(talloc_tos(), + conn, + &cwdfsp); + if (!NT_STATUS_IS_OK(status)) { + saved_errno = map_errno_from_nt_status(status); + goto out; + } + flags |= O_NOFOLLOW; { struct smb_filename *tmp_name = fsp->fsp_name; + fsp->fsp_name = smb_fname_rel; - fd = SMB_VFS_OPEN(conn, smb_fname_rel, fsp, flags, mode); + + fd = SMB_VFS_OPENAT(conn, + cwdfsp, + smb_fname_rel, + fsp, + flags, + mode); + fsp->fsp_name = tmp_name; } @@ -739,6 +756,7 @@ static int non_widelink_open(files_struct *fsp, out: TALLOC_FREE(parent_dir_fname); + TALLOC_FREE(cwdfsp); if (oldwd_fname != NULL) { int ret = vfs_ChDir(conn, oldwd_fname);