summaryrefslogtreecommitdiffstats
path: root/source3/utils
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-02-27 06:11:59 +0000
committerAndrew Tridgell <tridge@samba.org>2001-02-27 06:11:59 +0000
commitdccf44d752604d877a379290bda10644e0844682 (patch)
tree4edf9fcf4246a199d47738f681c3fb61d4108397 /source3/utils
parent54f5661b439af0ab86cce0d5bf8dc79faec7d7ac (diff)
downloadsamba-dccf44d752604d877a379290bda10644e0844682.tar.gz
samba-dccf44d752604d877a379290bda10644e0844682.tar.xz
samba-dccf44d752604d877a379290bda10644e0844682.zip
almost there with lanman1 wildcards. We now seem to correctly handle
'<', '>', '"' and '?' when combined with '.'. The '*' character is proving troublesome. (This used to be commit 0a55d9a17b5d98c7e151bb2ee014cfb0b3660400)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/masktest.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/source3/utils/masktest.c b/source3/utils/masktest.c
index a5b4888b0e0..072f9eb16f8 100644
--- a/source3/utils/masktest.c
+++ b/source3/utils/masktest.c
@@ -40,11 +40,12 @@ int ms_fnmatch_lanman_core(char *pattern, char *string)
char *p = pattern, *n = string;
char c;
+ if (strcmp(p,"?")==0 && strcmp(n,".")==0) return 0;
+
while ((c = *p++)) {
switch (c) {
case '?':
- //if (! *n) return -1;
- if (! *n) return ms_fnmatch_lanman_core(p, n);
+ if (*n == '.' || ! *n) return ms_fnmatch_lanman_core(p, n);
n++;
break;
@@ -101,7 +102,19 @@ int ms_fnmatch_lanman_core(char *pattern, char *string)
int ms_fnmatch_lanman(char *pattern, char *string)
{
- return ms_fnmatch_lanman_core(pattern, string);
+ int ret;
+ pattern = strdup(pattern);
+
+ /* it appears that '.' at the end of a pattern is stripped if the
+ pattern contains any wildcard characters. Bizarre */
+ if (strpbrk(pattern, "?*<>\"")) {
+ int len = strlen(pattern);
+ if (len > 0 && pattern[len-1] == '.') pattern[len-1] = 0;
+ }
+
+ ret = ms_fnmatch_lanman_core(pattern, string);
+ free(pattern);
+ return ret;
}
static BOOL reg_match_one(char *pattern, char *file)
@@ -293,7 +306,7 @@ static void testpair(struct cli_state *cli, char *mask, char *file)
res2 = reg_test(mask, long_name, short_name);
- if (showall || strcmp(res1, res2)) {
+ if (showall || strcmp(res1+2, res2+2)) {
DEBUG(0,("%s %s %d mask=[%s] file=[%s] rfile=[%s/%s]\n",
res1, res2, count, mask, file, long_name, short_name));
}