[Samba] Dotfiles with multiple dots not marked as hidden

Jeremy Allison jra at samba.org
Mon Mar 30 22:05:23 GMT 2009


On Wed, Mar 25, 2009 at 01:45:44PM +0000, Barry Kelly wrote:
> I have "hide dot files" on, but I have noticed that while files with a
> single dot are hidden, files with multiple dots are not:
> 
> ".foo" - hidden
> "...foo" - not hidden
> 
> Is this by design? *nix certainly hide such files by default...
> 

Here's the fix ! Thanks,

Jeremy.
-------------- next part --------------
diff --git a/source/smbd/dosmode.c b/source/smbd/dosmode.c
index 69100bf..8a5a7b0 100644
--- a/source/smbd/dosmode.c
+++ b/source/smbd/dosmode.c
@@ -319,8 +319,10 @@ uint32 dos_mode_msdfs(connection_struct *conn, const char *path,SMB_STRUCT_STAT
 		} else {
 			p = path;
 		}
-		
-		if (p[0] == '.' && p[1] != '.' && p[1] != 0) {
+
+		/* Only . and .. are not hidden. */
+		if (p[0] == '.' && !((p[1] == '\0') ||
+				(p[1] == '.' && p[2] == '\0'))) {
 			result |= aHIDDEN;
 		}
 	}
@@ -371,8 +373,10 @@ uint32 dos_mode(connection_struct *conn, const char *path,SMB_STRUCT_STAT *sbuf)
 		} else {
 			p = path;
 		}
-		
-		if (p[0] == '.' && p[1] != '.' && p[1] != 0) {
+
+		/* Only . and .. are not hidden. */
+		if (p[0] == '.' && !((p[1] == '\0') ||
+				(p[1] == '.' && p[2] == '\0'))) {
 			result |= aHIDDEN;
 		}
 	}


More information about the samba mailing list