]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Don't require a valid stat for openat_pathref_fsp()
authorVolker Lendecke <vl@samba.org>
Thu, 30 Dec 2021 15:49:45 +0000 (16:49 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 11 Mar 2022 18:22:28 +0000 (18:22 +0000)
With the simplifications in non_widelink_open() (don't depend on the
is_directory fsp flag) the main reason for requiring a valid stat
struct in openat_pathref_fsp() is gone. With this change
openat_pathref_fsp() is now capable of being the very first (and
authoritative) name-referencing operation with openat(O_PATH) for a
name.

Without having the stat information around before calling
openat_pathref_fsp(), the call to check_same_dev_ino() becomes
obsolete here.

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

index c6b25cb7a499bdb9b96b2f3aa7311ab102bfd2a8..e9cb34797e0f0d5f6edba47ad3f6aeef52e0b834 100644 (file)
@@ -456,14 +456,6 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
                return NT_STATUS_OK;
        }
 
-       if (!VALID_STAT(smb_fname->st)) {
-               return NT_STATUS_OBJECT_NAME_NOT_FOUND;
-       }
-
-       if (S_ISLNK(smb_fname->st.st_ex_mode)) {
-               return NT_STATUS_OBJECT_NAME_NOT_FOUND;
-       }
-
        status = fsp_new(conn, conn, &fsp);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
@@ -535,19 +527,6 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
                goto fail;
        }
 
-       if (!check_same_dev_ino(&smb_fname->st, &fsp->fsp_name->st)) {
-               DBG_DEBUG("file [%s] - dev/ino mismatch. "
-                         "Old (dev=%ju, ino=%ju). "
-                         "New (dev=%ju, ino=%ju).\n",
-                         smb_fname_str_dbg(smb_fname),
-                         (uintmax_t)smb_fname->st.st_ex_dev,
-                         (uintmax_t)smb_fname->st.st_ex_ino,
-                         (uintmax_t)fsp->fsp_name->st.st_ex_dev,
-                         (uintmax_t)fsp->fsp_name->st.st_ex_ino);
-               status = NT_STATUS_ACCESS_DENIED;
-               goto fail;
-       }
-
        /*
         * fd_openat() has done an FSTAT on the handle
         * so update the smb_fname stat info with "truth".