From: Volker Lendecke Date: Tue, 8 Mar 2022 13:31:32 +0000 (+0100) Subject: smbd: No need to set O_DIRECTORY in openat_pathref_fsp() X-Git-Tag: tevent-0.12.0~454 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bbdaca8da8a0f4d4ff6bb5d4a98470db223b265;p=thirdparty%2Fsamba.git smbd: No need to set O_DIRECTORY in openat_pathref_fsp() If I read Linux' man 2 open right (and susv4 agrees), O_DIRECTORY is around to make sure opendir() is not raced against non-directory files. opendir() needs to make sure the underlying object is actually a directory. O_DIRECTORY is not required for opening directories in RDONLY mode, regardless of having O_PATH or not. At this point in openat_pathref_fsp() we don't care about the type of the underlying object, we do fstat() and distinguish between files and directories later according to the mode returned from fstat(). Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 187e0bf6b2d..c6b25cb7a49 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -474,9 +474,6 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp, ZERO_STRUCT(conn->sconn->fsp_fi_cache); fsp->fsp_flags.is_pathref = true; - if (S_ISDIR(smb_fname->st.st_ex_mode)) { - open_flags |= O_DIRECTORY; - } full_fname = full_path_from_dirfsp_atname(fsp, dirfsp,