]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Return ISLNK from non_widelink_open() in smb_fname
authorVolker Lendecke <vl@samba.org>
Sat, 8 Jan 2022 09:08:16 +0000 (10:08 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 11 Mar 2022 18:22:28 +0000 (18:22 +0000)
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 <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/open.c

index dcfde4e7c27077d04a9c0a7ff4a6b6e897e5aee5..eb0058550360bc2a0d6c939a868e656395cb324f 100644 (file)
@@ -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))) {