s3/smbd: set FILE_ATTRIBUTE_DIRECTORY as necessary
authorRalph Boehme <slow@samba.org>
Wed, 14 Sep 2016 10:52:48 +0000 (12:52 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 15 Sep 2016 22:34:42 +0000 (00:34 +0200)
Some VFS modules like GPFS will always return success from
SMB_VFS_GET_DOS_ATTRIBUTES() but only set a subset of the attributes. It
neither sets FILE_ATTRIBUTE_NORMAL nor FILE_ATTRIBUTE_DIRECTORY.

We already handle the case that the VFS stack returns with result==0 and
then add the FILE_ATTRIBUTE_NORMAL, regardless of the type of the
filesystem object. If we want to handle result==0 situation in the
SMB_VFS_GET_DOS_ATTRIBUTES() caller, then do it right by either setting
FILE_ATTRIBUTE_NORMAL or FILE_ATTRIBUTE_DIRECTORY.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12261

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Sep 16 00:34:43 CEST 2016 on sn-devel-144

source3/smbd/dosmode.c

index ef880e5100571ff280006437205de46915a3efd9..a376cbc0f38bc2fcaf1bad24652dc2334827db8f 100644 (file)
@@ -637,7 +637,11 @@ uint32_t dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
        result |= dos_mode_from_name(conn, smb_fname, result);
 
        if (result == 0) {
-               result = FILE_ATTRIBUTE_NORMAL;
+               if (S_ISDIR(smb_fname->st.st_ex_mode)) {
+                       result = FILE_ATTRIBUTE_DIRECTORY;
+               } else {
+                       result = FILE_ATTRIBUTE_NORMAL;
+               }
        }
 
        result = filter_mode_by_protocol(result);