r6044: Ensure the old search calls always ask mask_match to translate
authorJeremy Allison <jra@samba.org>
Thu, 24 Mar 2005 19:33:02 +0000 (19:33 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:56:18 +0000 (10:56 -0500)
patterns like ????????.??? - even if using an NT1 protocol.
Matches W2K3 behavior.
Jeremy.
(This used to be commit 67f6473f50f3284b9ccbe6f983f23cd42b3b7c9f)

source3/lib/ms_fnmatch.c
source3/lib/util.c
source3/smbd/dir.c

index a0cbfd2ee21cbad8cdcbe119524727484420e93c..c7cf54d26b5426af80c9cc035c83efabae0a6734 100644 (file)
@@ -146,7 +146,7 @@ static int ms_fnmatch_core(const smb_ucs2_t *p, const smb_ucs2_t *n,
        return -1;
 }
 
-int ms_fnmatch(const char *pattern, const char *string, enum protocol_types protocol, 
+int ms_fnmatch(const char *pattern, const char *string, BOOL translate_pattern,
               BOOL is_case_sensitive)
 {
        wpstring p, s;
@@ -179,7 +179,7 @@ int ms_fnmatch(const char *pattern, const char *string, enum protocol_types prot
                return -1;
        }
 
-       if (protocol <= PROTOCOL_LANMAN2) {
+       if (translate_pattern) {
                /*
                  for older negotiated protocols it is possible to
                  translate the pattern to produce a "new style"
index cd30ef9814b7f29fab46cd33cf3f384f406c3895..265302d2d4f8be86d5260f31a278e3aae6a4715f 100644 (file)
@@ -2475,7 +2475,23 @@ BOOL mask_match(const char *string, char *pattern, BOOL is_case_sensitive)
        if (strcmp(pattern,".") == 0)
                return False;
        
-       return ms_fnmatch(pattern, string, Protocol, is_case_sensitive) == 0;
+       return ms_fnmatch(pattern, string, Protocol <= PROTOCOL_LANMAN2, is_case_sensitive) == 0;
+}
+
+/*******************************************************************
+ A wrapper that handles case sensitivity and the special handling
+ of the ".." name. Varient that is only called by old search code which requires
+ pattern translation.
+*******************************************************************/
+
+BOOL mask_match_search(const char *string, char *pattern, BOOL is_case_sensitive)
+{
+       if (strcmp(string,"..") == 0)
+               string = ".";
+       if (strcmp(pattern,".") == 0)
+               return False;
+       
+       return ms_fnmatch(pattern, string, True, is_case_sensitive) == 0;
 }
 
 /*******************************************************************
index 6ecdcec461f924cada570a2ced35fbfad863bbd4..55f152386528345bbbd5254cd458a16fb0aec4de 100644 (file)
@@ -698,7 +698,7 @@ BOOL dir_check_ftype(connection_struct *conn,int mode,int dirtype)
 static BOOL mangle_mask_match(connection_struct *conn, fstring filename, char *mask)
 {
        mangle_map(filename,True,False,SNUM(conn));
-       return mask_match(filename,mask,False);
+       return mask_match_search(filename,mask,False);
 }
 
 /****************************************************************************
@@ -740,7 +740,7 @@ BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype, pstring fname
                        see masktest for a demo
                */
                if ((strcmp(mask,"*.*") == 0) ||
-                   mask_match(filename,mask,False) ||
+                   mask_match_search(filename,mask,False) ||
                    mangle_mask_match(conn,filename,mask)) {
 
                        if (!mangle_is_8_3(filename, False))