From: Volker Lendecke Date: Thu, 30 Dec 2021 15:49:45 +0000 (+0100) Subject: smbd: Don't require a valid stat for openat_pathref_fsp() X-Git-Tag: tevent-0.12.0~453 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7b933100ee487ae19cd2b3938f58056dca2115a;p=thirdparty%2Fsamba.git smbd: Don't require a valid stat for openat_pathref_fsp() 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 Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/files.c b/source3/smbd/files.c index c6b25cb7a49..e9cb34797e0 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -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".