From db8296bc1ba91afee9103165ff9dde49e2be87ab Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 11 Apr 2018 08:41:00 -0700 Subject: s3: vfs: vfs_streams_xattr: Don't blindly re-use the base file mode bits. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When returning the stat struct for an xattr stream, we originally base the st_ex_mode field on the value from the base file containing the xattr. If the base file is a directory, it will have S_IFDIR set in st_ex_mode, but streams can never be directories, they must be reported as regular files. The original code OR'ed in S_IFREG, but neglected to AND out S_IFDIR. Note this is not a complete to fix bug 13380 as it doesn't fix the generic case with all streams modules. See later fix and regression test. Found in real-world use case by Andrew Walker . BUG: https://bugzilla.samba.org/show_bug.cgi?id=13380 Signed-off-by: Jeremy Allison Reviewed-by: Volker Lendecke Reviewed-by: Ralph Böhme (cherry picked from commit 4d839d0f46b723ed6809bb932b9ebe4ead2cec82) --- source3/modules/vfs_streams_xattr.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index f75f6a18dd6..1340d0421f4 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -277,6 +277,7 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp, sbuf->st_ex_ino = stream_inode(sbuf, io->xattr_name); sbuf->st_ex_mode &= ~S_IFMT; + sbuf->st_ex_mode &= ~S_IFDIR; sbuf->st_ex_mode |= S_IFREG; sbuf->st_ex_blocks = sbuf->st_ex_size / STAT_ST_BLOCKSIZE + 1; @@ -331,6 +332,7 @@ static int streams_xattr_stat(vfs_handle_struct *handle, smb_fname->st.st_ex_ino = stream_inode(&smb_fname->st, xattr_name); smb_fname->st.st_ex_mode &= ~S_IFMT; + smb_fname->st.st_ex_mode &= ~S_IFDIR; smb_fname->st.st_ex_mode |= S_IFREG; smb_fname->st.st_ex_blocks = smb_fname->st.st_ex_size / STAT_ST_BLOCKSIZE + 1; -- cgit v1.2.1