Ensure dos_mode can return FILE_ATTRIBUTE_NORMAL, then filter the returned attributes...
authorJeremy Allison <jra@samba.org>
Wed, 16 Dec 2009 02:03:47 +0000 (18:03 -0800)
committerJeremy Allison <jra@samba.org>
Wed, 16 Dec 2009 02:06:28 +0000 (18:06 -0800)
This makes us consistant in returning DOS attrs across all replies. Tested on OS/2 by Günter Kukkukk.
Jeremy.
(cherry picked from commit e831e3ee32ba3f1f492f9918d74a302731fa79a9)

source3/smbd/dosmode.c
source3/smbd/trans2.c

index 0f319736758d8662a8d9d16cd9427a5a4a68ad71..aaef09bc85cca8b5b78e7c400ff958d0b7d23dd2 100644 (file)
 #include "includes.h"
 #include "librpc/gen_ndr/ndr_xattr.h"
 
+static uint32_t filter_mode_by_protocol(uint32_t mode)
+{
+       if (get_Protocol() <= PROTOCOL_LANMAN2) {
+               DEBUG(10,("filter_mode_by_protocol: "
+                       "filtering result 0x%x to 0x%x\n",
+                       (unsigned int)mode,
+                       (unsigned int)(mode & 0x3f) ));
+               mode &= 0x3f;
+       }
+       return mode;
+}
+
 static int set_sparse_flag(const SMB_STRUCT_STAT * const sbuf)
 {
 #if defined (HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
@@ -459,12 +471,12 @@ uint32 dos_mode_msdfs(connection_struct *conn,
                result |= aHIDDEN;
        }
 
-       if (get_Protocol() <= PROTOCOL_LANMAN2) {
-               DEBUG(10,("dos_mode_msdfs : filtering result 0x%x\n",
-                       (unsigned int)result ));
-               result &= 0xff;
+       if (result == 0) {
+               result = FILE_ATTRIBUTE_NORMAL;
        }
 
+       result = filter_mode_by_protocol(result);
+
        DEBUG(8,("dos_mode_msdfs returning "));
 
        if (result & aHIDDEN) DEBUG(8, ("h"));
@@ -645,12 +657,12 @@ uint32 dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
                result |= aHIDDEN;
        }
 
-       if (get_Protocol() <= PROTOCOL_LANMAN2) {
-               DEBUG(10,("dos_mode : filtering result 0x%x\n",
-                       (unsigned int)result ));
-               result &= 0xff;
+       if (result == 0) {
+               result = FILE_ATTRIBUTE_NORMAL;
        }
 
+       result = filter_mode_by_protocol(result);
+
        DEBUG(8,("dos_mode returning "));
 
        if (result & aHIDDEN) DEBUG(8, ("h"));
index ca2ff60162dd4037d404afbdb502ecaeca99948a..cbadab70989514669372518e59794b71a30dfe89 100644 (file)
@@ -1484,7 +1484,6 @@ static bool smbd_marshall_dir_entry(TALLOC_CTX *ctx,
        char *nameptr;
        char *last_entry_ptr;
        bool was_8_3;
-       uint32_t nt_extmode; /* Used for NT connections instead of mode */
        off_t off;
        off_t pad = 0;
 
@@ -1535,8 +1534,6 @@ static bool smbd_marshall_dir_entry(TALLOC_CTX *ctx,
        pad = 0;
        off = 0;
 
-       nt_extmode = mode ? mode : FILE_ATTRIBUTE_NORMAL;
-
        switch (info_level) {
        case SMB_FIND_INFO_STANDARD:
                DEBUG(10,("smbd_marshall_dir_entry: SMB_FIND_INFO_STANDARD\n"));
@@ -1684,7 +1681,7 @@ static bool smbd_marshall_dir_entry(TALLOC_CTX *ctx,
                put_long_date_timespec(conn->ts_res,p,cdate_ts); p += 8;
                SOFF_T(p,0,file_size); p += 8;
                SOFF_T(p,0,allocation_size); p += 8;
-               SIVAL(p,0,nt_extmode); p += 4;
+               SIVAL(p,0,mode); p += 4;
                q = p; p += 4; /* q is placeholder for name length. */
                {
                        unsigned int ea_size = estimate_ea_size(conn, NULL,
@@ -1750,7 +1747,7 @@ static bool smbd_marshall_dir_entry(TALLOC_CTX *ctx,
                put_long_date_timespec(conn->ts_res,p,cdate_ts); p += 8;
                SOFF_T(p,0,file_size); p += 8;
                SOFF_T(p,0,allocation_size); p += 8;
-               SIVAL(p,0,nt_extmode); p += 4;
+               SIVAL(p,0,mode); p += 4;
                len = srvstr_push(base_data, flags2,
                                  p + 4, fname, PTR_DIFF(end_data, p+4),
                                  STR_TERMINATE_ASCII);
@@ -1786,7 +1783,7 @@ static bool smbd_marshall_dir_entry(TALLOC_CTX *ctx,
                put_long_date_timespec(conn->ts_res,p,cdate_ts); p += 8;
                SOFF_T(p,0,file_size); p += 8;
                SOFF_T(p,0,allocation_size); p += 8;
-               SIVAL(p,0,nt_extmode); p += 4;
+               SIVAL(p,0,mode); p += 4;
                q = p; p += 4; /* q is placeholder for name length. */
                {
                        unsigned int ea_size = estimate_ea_size(conn, NULL,
@@ -1861,7 +1858,7 @@ static bool smbd_marshall_dir_entry(TALLOC_CTX *ctx,
                put_long_date_timespec(conn->ts_res,p,cdate_ts); p += 8;
                SOFF_T(p,0,file_size); p += 8;
                SOFF_T(p,0,allocation_size); p += 8;
-               SIVAL(p,0,nt_extmode); p += 4;
+               SIVAL(p,0,mode); p += 4;
                q = p; p += 4; /* q is placeholder for name length. */
                {
                        unsigned int ea_size = estimate_ea_size(conn, NULL,
@@ -1908,7 +1905,7 @@ static bool smbd_marshall_dir_entry(TALLOC_CTX *ctx,
                put_long_date_timespec(conn->ts_res,p,cdate_ts); p += 8;
                SOFF_T(p,0,file_size); p += 8;
                SOFF_T(p,0,allocation_size); p += 8;
-               SIVAL(p,0,nt_extmode); p += 4;
+               SIVAL(p,0,mode); p += 4;
                q = p; p += 4; /* q is placeholder for name length */
                {
                        unsigned int ea_size = estimate_ea_size(conn, NULL,
@@ -4187,8 +4184,6 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
        } else {
                mode = dos_mode(conn, smb_fname);
        }
-       if (!mode)
-               mode = FILE_ATTRIBUTE_NORMAL;
 
        nlink = psbuf->st_ex_nlink;