[RFC] incorrect dosmode on stream associated with dir
Jeremy Allison
jra at samba.org
Wed Apr 11 00:10:00 UTC 2018
On Tue, Apr 10, 2018 at 07:34:42PM -0400, Andrew Walker via samba-technical wrote:
>
> Great! This is turning out to be more interesting than I thought :)
>
> I had same result as you when I first generated the ADS and output allinfo:
>
> smb: \> allinfo test35:ADS
> altname: test35
> create_time: Tue Apr 10 13:45:00 2018 EDT
> access_time: Tue Apr 10 13:45:00 2018 EDT
> write_time: Tue Apr 10 13:45:00 2018 EDT
> change_time: Tue Apr 10 13:45:00 2018 EDT
> attributes: A (20)
>
> Then I removed the "archive" bit from the directory.
> setmode test35 -a
>
> Then I repeat the test
>
> smb: \> allinfo test35:ADS
> altname: test35
> create_time: Tue Apr 10 13:45:00 2018 EDT
> access_time: Tue Apr 10 13:45:00 2018 EDT
> write_time: Tue Apr 10 13:45:00 2018 EDT
> change_time: Tue Apr 10 13:45:00 2018 EDT
> attributes: D (10)
> NT_STATUS_INVALID_PARAMETER getting streams for \test35:ADS
>
> The stream is now reported as a directory. It looks like
> FILE_ATTRIBUTE_DIRECTORY gets written to the dir's DOSATTRIB whenever we
> modify it.
OK, I think the following is the "minimal" correct fix.
Turns out vfs_streams_xattr.c:streams_xattr_fstat() and
vfs_streams_xattr.c:streams_xattr_stat() re-use the base
file stat info an plonk a S_IFREG bit in there without
clearing the S_IFDIR bit :-).
However I'm tempted to add your change also as a "belt and braces"
protection :-).
Now I need to go create a bug report and then add
a test script the reproduces this :-).
Thanks a *LOT* for tracking this down.
Cheers,
Jeremy.
-------------- next part --------------
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index 580ecd0e5ff..c653656e5f8 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;
More information about the samba-technical
mailing list