s3/smbd: call dos_mode_from_name after SMB_VFS_GET_DOS_ATTRIBUTES()
authorRalph Boehme <slow@samba.org>
Thu, 23 Jun 2016 14:40:15 +0000 (16:40 +0200)
committerRalph Boehme <slow@samba.org>
Sat, 25 Jun 2016 16:47:17 +0000 (18:47 +0200)
This doesn't change overall behaviour in any way, it just prepares for
the next step where the IS_HIDDEN_PATH() stuff will be moved to the
function dos_mode_from_name().

It allows an optimisation by not checking "hide to files" patch if
FILE_ATTRIBUTE_HIDDEN was already set in the DOS xattr.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/dosmode.c

index 463c43e66c235f03be3b859c1502a337a12c924d..f59ed79d3f81b03da293cb2a7b056db5b2b0267b 100644 (file)
@@ -563,12 +563,15 @@ err_out:
 }
 
 static uint32_t dos_mode_from_name(connection_struct *conn,
-                                  const struct smb_filename *smb_fname)
+                                  const struct smb_filename *smb_fname,
+                                  uint32_t dosmode)
 {
        const char *p = NULL;
-       uint32_t result = 0;
+       uint32_t result = dosmode;
 
-       if (lp_hide_dot_files(SNUM(conn))) {
+       if (!(result & FILE_ATTRIBUTE_HIDDEN) &&
+           lp_hide_dot_files(SNUM(conn)))
+       {
                p = strrchr_m(smb_fname->base_name, '/');
                if (p) {
                        p++;
@@ -605,8 +608,6 @@ uint32_t dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
                return 0;
        }
 
-       result |= dos_mode_from_name(conn, smb_fname);
-
        /* Get the DOS attributes via the VFS if we can */
        status = SMB_VFS_GET_DOS_ATTRIBUTES(conn, smb_fname, &result);
        if (!NT_STATUS_IS_OK(status)) {
@@ -627,6 +628,8 @@ uint32_t dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
                }
        }
 
+       result |= dos_mode_from_name(conn, smb_fname, result);
+
        /* Optimization : Only call is_hidden_path if it's not already
           hidden. */
        if (!(result & FILE_ATTRIBUTE_HIDDEN) &&