From: Volker Lendecke Date: Sat, 8 Jan 2022 09:08:16 +0000 (+0100) Subject: smbd: Return ISLNK from non_widelink_open() in smb_fname X-Git-Tag: tevent-0.12.0~452 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de439cd0304773c59ebd33ddeddf675dd611944c;p=thirdparty%2Fsamba.git smbd: Return ISLNK from non_widelink_open() in smb_fname Soon we want to not require stat() calls before entering openat_pathref_fsp() anymore but rely on the fstat on the O_PATH file handle (alternatively the call to fstatat(AT_SYMLINK_NOFOLLOW)) done properly from within fd_openat(). The callers of non_widelink_open() expect the stat information to be correct in "smb_fname". Copy it in case of not opening a symlink in the posix case. Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index dcfde4e7c27..eb005855036 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -858,7 +858,11 @@ static NTSTATUS non_widelink_open(const struct files_struct *dirfsp, saved_status = status; if (fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH) { - /* Never follow symlinks on posix open. */ + /* Never follow symlinks on posix open, .. but + * pass the fact it's a symlink in + * smb_fname->st + */ + smb_fname->st = fsp->fsp_name->st; goto out; } if (!lp_follow_symlinks(SNUM(conn))) {