]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Pass up stat-info from openat_pathref_fsp() on error
authorVolker Lendecke <vl@samba.org>
Mon, 14 Mar 2022 21:52:11 +0000 (22:52 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 28 Apr 2022 13:12:33 +0000 (13:12 +0000)
If openat_pathref_fsp() fails, callers might want to inspect the stat
info. If we really failed on STOPPED_ON_SYMLINK, the caller might need
to know this, although openat_pathref_fsp() masked this error.

As there is no smb_fname->fsp returned from openat_pathref_fsp() on
error, we need to pass this up in smb_fname itself.

This essentially reverts de439cd03047, which does basically the same
thing but is too specific. We need to cover the general !O_PATH case
more broadly.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/files.c
source3/smbd/open.c

index 0c82de8b48cac77516cd2df87e0e93a0838875b6..542f1fe4181522a6bfecede767419cb16e1d5278 100644 (file)
@@ -493,6 +493,9 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
 
        status = fd_openat(dirfsp, smb_fname, fsp, open_flags, 0);
        if (!NT_STATUS_IS_OK(status)) {
+
+               smb_fname->st = fsp->fsp_name->st;
+
                if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND) ||
                    NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_NOT_FOUND) ||
                    NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK))
index 8048063dd0a38bb74147d11bb8a7a53557bbbcd7..056fa470b0daacb33752c3ede209d6c182889850 100644 (file)
@@ -807,6 +807,7 @@ static NTSTATUS non_widelink_open(const struct files_struct *dirfsp,
                                  strerror(errno));
                        goto out;
                }
+               orig_fsp_name->st = fsp->fsp_name->st;
        }
 
        if (fd != -1) {
@@ -856,11 +857,7 @@ 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, .. but
-                        * pass the fact it's a symlink in
-                        * smb_fname->st
-                        */
-                       smb_fname->st = fsp->fsp_name->st;
+                       /* Never follow symlinks on posix open. */
                        goto out;
                }
                if (!lp_follow_symlinks(SNUM(conn))) {