summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/interface.c2
-rw-r--r--source3/lib/ms_fnmatch.c30
-rw-r--r--source3/lib/util.c9
3 files changed, 26 insertions, 15 deletions
diff --git a/source3/lib/interface.c b/source3/lib/interface.c
index 269e0fa85b..c89c22aa08 100644
--- a/source3/lib/interface.c
+++ b/source3/lib/interface.c
@@ -111,7 +111,7 @@ static void interpret_interface(char *token)
/* first check if it is an interface name */
for (i=0;i<total_probed;i++) {
- if (ms_fnmatch(token, probed_ifaces[i].name) == 0) {
+ if (gen_fnmatch(token, probed_ifaces[i].name) == 0) {
add_interface(probed_ifaces[i].ip,
probed_ifaces[i].netmask);
added = 1;
diff --git a/source3/lib/ms_fnmatch.c b/source3/lib/ms_fnmatch.c
index 39b3e0013c..cc54ffb68e 100644
--- a/source3/lib/ms_fnmatch.c
+++ b/source3/lib/ms_fnmatch.c
@@ -146,13 +146,12 @@ static int ms_fnmatch_lanman1(const smb_ucs2_t *pattern, const smb_ucs2_t *strin
Returns 0 on match, -1 on fail.
*/
-static int ms_fnmatch_w(const smb_ucs2_t *pattern, const smb_ucs2_t *string)
+static int ms_fnmatch_w(const smb_ucs2_t *pattern, const smb_ucs2_t *string, int protocol)
{
const smb_ucs2_t *p = pattern, *n = string;
smb_ucs2_t c;
- extern int Protocol;
- if (Protocol <= PROTOCOL_LANMAN2) {
+ if (protocol <= PROTOCOL_LANMAN2) {
return ms_fnmatch_lanman1(pattern, string);
}
@@ -165,23 +164,23 @@ static int ms_fnmatch_w(const smb_ucs2_t *pattern, const smb_ucs2_t *string)
case UCS2_CHAR('>'):
if (n[0] == UCS2_CHAR('.')) {
- if (! n[1] && ms_fnmatch_w(p, n+1) == 0) return 0;
- if (ms_fnmatch_w(p, n) == 0) return 0;
+ if (! n[1] && ms_fnmatch_w(p, n+1, protocol) == 0) return 0;
+ if (ms_fnmatch_w(p, n, protocol) == 0) return 0;
return -1;
}
- if (! *n) return ms_fnmatch_w(p, n);
+ if (! *n) return ms_fnmatch_w(p, n, protocol);
n++;
break;
case UCS2_CHAR('*'):
for (; *n; n++) {
- if (ms_fnmatch_w(p, n) == 0) return 0;
+ if (ms_fnmatch_w(p, n, protocol) == 0) return 0;
}
break;
case UCS2_CHAR('<'):
for (; *n; n++) {
- if (ms_fnmatch_w(p, n) == 0) return 0;
+ if (ms_fnmatch_w(p, n, protocol) == 0) return 0;
if (*n == UCS2_CHAR('.') && !strchr_wa(n+1,'.')) {
n++;
break;
@@ -190,7 +189,7 @@ static int ms_fnmatch_w(const smb_ucs2_t *pattern, const smb_ucs2_t *string)
break;
case UCS2_CHAR('"'):
- if (*n == 0 && ms_fnmatch_w(p, n) == 0) return 0;
+ if (*n == 0 && ms_fnmatch_w(p, n, protocol) == 0) return 0;
if (*n != UCS2_CHAR('.')) return -1;
n++;
break;
@@ -207,12 +206,21 @@ static int ms_fnmatch_w(const smb_ucs2_t *pattern, const smb_ucs2_t *string)
}
-int ms_fnmatch(const char *pattern, const char *string)
+int ms_fnmatch(const char *pattern, const char *string, int protocol)
{
wpstring p, s;
+ int ret;
pstrcpy_wa(p, pattern);
pstrcpy_wa(s, string);
- return ms_fnmatch_w(p, s);
+ ret = ms_fnmatch_w(p, s, protocol);
+/* DEBUG(0,("ms_fnmatch(%s,%s) -> %d\n", pattern, string, ret)); */
+ return ret;
+}
+
+/* a generic fnmatch function - uses for non-CIFS pattern matching */
+int gen_fnmatch(const char *pattern, const char *string)
+{
+ return ms_fnmatch(pattern, string, PROTOCOL_NT1);
}
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 33d604e85f..3161aba63f 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1782,19 +1782,21 @@ BOOL ms_has_wild(char *s)
*******************************************************************/
BOOL mask_match(char *string, char *pattern, BOOL is_case_sensitive)
{
+ extern int Protocol;
fstring p2, s2;
+
if (strcmp(string,"..") == 0) string = ".";
if (strcmp(pattern,".") == 0) return False;
if (is_case_sensitive) {
- return ms_fnmatch(pattern, string) == 0;
+ return ms_fnmatch(pattern, string, Protocol) == 0;
}
fstrcpy(p2, pattern);
fstrcpy(s2, string);
strlower(p2);
strlower(s2);
- return ms_fnmatch(p2, s2) == 0;
+ return ms_fnmatch(p2, s2, Protocol) == 0;
}
/*******************************************************************
@@ -1804,12 +1806,13 @@ BOOL mask_match(char *string, char *pattern, BOOL is_case_sensitive)
BOOL wild_match(char *string, char *pattern)
{
pstring p2, s2;
+ extern int Protocol;
pstrcpy(p2, pattern);
pstrcpy(s2, string);
strlower(p2);
strlower(s2);
- return ms_fnmatch(p2, s2) == 0;
+ return ms_fnmatch(p2, s2, Protocol) == 0;
}
#ifdef __INSURE__