]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Fix for #1064 - ensure truncate attribute checking is done correctly on "hidden"...
authorJeremy Allison <jra@samba.org>
Fri, 19 Mar 2004 23:46:48 +0000 (23:46 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 19 Mar 2004 23:46:48 +0000 (23:46 +0000)
Jeremy.
(This used to be commit a6045c904fbe7df111c520134581bfd4f1ca67a8)

source3/smbd/dosmode.c
source3/smbd/open.c

index fb72a2eafc893ed4eb95388a299b8e98b0e5459b..8353baeb21bdc4af9e2a107dd96d16013c233abe 100644 (file)
@@ -111,16 +111,14 @@ mode_t unix_mode(connection_struct *conn,int dosmode,const char *fname)
   return(result);
 }
 
-
 /****************************************************************************
   change a unix mode to a dos mode
 ****************************************************************************/
-uint32 dos_mode(connection_struct *conn,char *path,SMB_STRUCT_STAT *sbuf)
+
+uint32 dos_mode_from_sbuf(connection_struct *conn, SMB_STRUCT_STAT *sbuf)
 {
        int result = 0;
 
-       DEBUG(8,("dos_mode: %s\n", path));
-
        if ((sbuf->st_mode & S_IWUSR) == 0)
                result |= aRONLY;
        
@@ -149,6 +147,30 @@ uint32 dos_mode(connection_struct *conn,char *path,SMB_STRUCT_STAT *sbuf)
 #endif
 #endif
 
+       DEBUG(8,("dos_mode_from_sbuf returning "));
+
+       if (result & aHIDDEN) DEBUG(8, ("h"));
+       if (result & aRONLY ) DEBUG(8, ("r"));
+       if (result & aSYSTEM) DEBUG(8, ("s"));
+       if (result & aDIR   ) DEBUG(8, ("d"));
+       if (result & aARCH  ) DEBUG(8, ("a"));
+       
+       DEBUG(8,("\n"));
+       return result;
+}
+
+/****************************************************************************
+  change a unix mode to a dos mode
+****************************************************************************/
+uint32 dos_mode(connection_struct *conn,char *path,SMB_STRUCT_STAT *sbuf)
+{
+       int result = 0;
+
+       DEBUG(8,("dos_mode: %s\n", path));
+
+       result = dos_mode_from_sbuf(conn, sbuf);
+
+       /* Now do any modifications that depend on the path name. */
        /* hide files with a name starting with a . */
        if (lp_hide_dot_files(SNUM(conn))) {
                char *p = strrchr_m(path,'/');
index e688f8de485971cfb9447ca3254377ecebb751e5..084ae9a1bf2aaed31645e0995967e6996a3d86c6 100644 (file)
@@ -754,7 +754,8 @@ static BOOL open_match_attributes(connection_struct *conn, char *path, mode_t ex
        old_dos_mode = dos_mode(conn, path, &sbuf);
 
        sbuf.st_mode = new_mode;
-       new_dos_mode = dos_mode(conn, path, &sbuf);
+       /* The new mode conversion shouldn't look at pathname. */
+       new_dos_mode = dos_mode_from_sbuf(conn, &sbuf);
 
        noarch_old_dos_mode = (old_dos_mode & ~FILE_ATTRIBUTE_ARCHIVE);
        noarch_new_dos_mode = (new_dos_mode & ~FILE_ATTRIBUTE_ARCHIVE);