]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: No need to set O_DIRECTORY in openat_pathref_fsp()
authorVolker Lendecke <vl@samba.org>
Tue, 8 Mar 2022 13:31:32 +0000 (14:31 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 11 Mar 2022 18:22:28 +0000 (18:22 +0000)
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 <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/files.c

index 187e0bf6b2d6eea74843fc5e2a2a56a8224d1b1b..c6b25cb7a499bdb9b96b2f3aa7311ab102bfd2a8 100644 (file)
@@ -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,