]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: pass O_DIRECTORY to fd_openat() for directories
authorRalph Boehme <slow@samba.org>
Mon, 11 Jan 2021 08:58:58 +0000 (09:58 +0100)
committerRalph Boehme <slow@samba.org>
Mon, 11 Jan 2021 20:25:32 +0000 (20:25 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/smbd/files.c

index dff6780259b28e39bcc20ec8fd3e0aaefc6cd9df..e19c11883eb32ab422dacedcfc2f7dfab885bf30 100644 (file)
@@ -410,6 +410,7 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
        struct smb_filename *full_fname = NULL;
        bool file_existed = VALID_STAT(smb_fname->st);
        struct files_struct *fsp = NULL;
+       int open_flags = O_RDONLY;
        NTSTATUS status;
 
        DBG_DEBUG("smb_fname [%s]\n", smb_fname_str_dbg(smb_fname));
@@ -437,6 +438,7 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
        fsp->fsp_flags.is_pathref = true;
        if (S_ISDIR(smb_fname->st.st_ex_mode)) {
                fsp->fsp_flags.is_directory = true;
+               open_flags |= O_DIRECTORY;
        }
 
        full_fname = full_path_from_dirfsp_atname(talloc_tos(),
@@ -469,7 +471,7 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
                }
        }
 
-       status = fd_openat(dirfsp, smb_fname, fsp, O_RDONLY, 0);
+       status = fd_openat(dirfsp, smb_fname, fsp, open_flags, 0);
        if (!NT_STATUS_IS_OK(status)) {
                DBG_DEBUG("Could not open fd for [%s]: %s\n",
                          fsp_str_dbg(fsp),