Use Cygwin-specific matching only for users+groups.
Patch from vinschen at redhat.com, updated a little by me.
This commit is contained in:
parent
fd10cf027b
commit
daa7505aad
12
match.c
12
match.c
|
@ -111,8 +111,6 @@ match_pattern(const char *s, const char *pattern)
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_CYGWIN /* Cygwin version in openbsd-compat/bsd-cygwin_util.c */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tries to match the string against the
|
* Tries to match the string against the
|
||||||
* comma-separated sequence of subpatterns (each possibly preceded by ! to
|
* comma-separated sequence of subpatterns (each possibly preceded by ! to
|
||||||
|
@ -172,18 +170,16 @@ match_pattern_list(const char *string, const char *pattern, int dolower)
|
||||||
return got_positive;
|
return got_positive;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Match a list representing users or groups. */
|
/* Match a list representing users or groups. */
|
||||||
int
|
int
|
||||||
match_usergroup_pattern_list(const char *string, const char *pattern)
|
match_usergroup_pattern_list(const char *string, const char *pattern)
|
||||||
{
|
{
|
||||||
#ifndef HAVE_CYGWIN
|
#ifdef HAVE_CYGWIN
|
||||||
/* Case sensitive match */
|
/* Windows usernames may be Unicode and are not case sensitive */
|
||||||
return match_pattern_list(string, pattern, 0);
|
return cygwin_ug_match_pattern_list(string, pattern);
|
||||||
#else
|
#else
|
||||||
/* Case insensitive match */
|
/* Case insensitive match */
|
||||||
return match_pattern_list(string, pattern, 1);
|
return match_pattern_list(string, pattern, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ free_windows_environment(char **p)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
__match_pattern (const wchar_t *s, const wchar_t *pattern, int caseinsensitive)
|
__match_pattern (const wchar_t *s, const wchar_t *pattern)
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* If at end of pattern, accept if also at end of string. */
|
/* If at end of pattern, accept if also at end of string. */
|
||||||
|
@ -152,8 +152,7 @@ __match_pattern (const wchar_t *s, const wchar_t *pattern, int caseinsensitive)
|
||||||
*/
|
*/
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
if (*s == *pattern &&
|
if (*s == *pattern &&
|
||||||
__match_pattern(s + 1, pattern + 1,
|
__match_pattern(s + 1, pattern + 1))
|
||||||
caseinsensitive))
|
|
||||||
return 1;
|
return 1;
|
||||||
/* Failed. */
|
/* Failed. */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -163,7 +162,7 @@ __match_pattern (const wchar_t *s, const wchar_t *pattern, int caseinsensitive)
|
||||||
* match at each position.
|
* match at each position.
|
||||||
*/
|
*/
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
if (__match_pattern(s, pattern, caseinsensitive))
|
if (__match_pattern(s, pattern))
|
||||||
return 1;
|
return 1;
|
||||||
/* Failed. */
|
/* Failed. */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -176,8 +175,7 @@ __match_pattern (const wchar_t *s, const wchar_t *pattern, int caseinsensitive)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Check if the next character of the string is acceptable. */
|
/* Check if the next character of the string is acceptable. */
|
||||||
if (*pattern != '?' && (*pattern != *s &&
|
if (*pattern != '?' && towlower(*pattern) != towlower(*s))
|
||||||
(!caseinsensitive || towlower(*pattern) != towlower(*s))))
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Move to the next character, both in string and in pattern. */
|
/* Move to the next character, both in string and in pattern. */
|
||||||
|
@ -188,7 +186,7 @@ __match_pattern (const wchar_t *s, const wchar_t *pattern, int caseinsensitive)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_match_pattern(const char *s, const char *pattern, int caseinsensitive)
|
_match_pattern(const char *s, const char *pattern)
|
||||||
{
|
{
|
||||||
wchar_t *ws;
|
wchar_t *ws;
|
||||||
wchar_t *wpattern;
|
wchar_t *wpattern;
|
||||||
|
@ -202,7 +200,7 @@ _match_pattern(const char *s, const char *pattern, int caseinsensitive)
|
||||||
return 0;
|
return 0;
|
||||||
wpattern = (wchar_t *) alloca((len + 1) * sizeof (wchar_t));
|
wpattern = (wchar_t *) alloca((len + 1) * sizeof (wchar_t));
|
||||||
mbstowcs(wpattern, pattern, len + 1);
|
mbstowcs(wpattern, pattern, len + 1);
|
||||||
return __match_pattern (ws, wpattern, caseinsensitive);
|
return __match_pattern (ws, wpattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -212,7 +210,7 @@ _match_pattern(const char *s, const char *pattern, int caseinsensitive)
|
||||||
* a positive match, 0 if there is no match at all.
|
* a positive match, 0 if there is no match at all.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
match_pattern_list(const char *string, const char *pattern, int caseinsensitive)
|
cygwin_ug_match_pattern_list(const char *string, const char *pattern)
|
||||||
{
|
{
|
||||||
char sub[1024];
|
char sub[1024];
|
||||||
int negated;
|
int negated;
|
||||||
|
@ -248,7 +246,7 @@ match_pattern_list(const char *string, const char *pattern, int caseinsensitive)
|
||||||
sub[subi] = '\0';
|
sub[subi] = '\0';
|
||||||
|
|
||||||
/* Try to match the subpattern against the string. */
|
/* Try to match the subpattern against the string. */
|
||||||
if (_match_pattern(string, sub, caseinsensitive)) {
|
if (_match_pattern(string, sub)) {
|
||||||
if (negated)
|
if (negated)
|
||||||
return -1; /* Negative */
|
return -1; /* Negative */
|
||||||
else
|
else
|
||||||
|
|
|
@ -55,6 +55,7 @@ int binary_open(const char *, int , ...);
|
||||||
int check_ntsec(const char *);
|
int check_ntsec(const char *);
|
||||||
char **fetch_windows_environment(void);
|
char **fetch_windows_environment(void);
|
||||||
void free_windows_environment(char **);
|
void free_windows_environment(char **);
|
||||||
|
int cygwin_ug_match_pattern_list(const char *, const char *);
|
||||||
|
|
||||||
#ifndef NO_BINARY_OPEN
|
#ifndef NO_BINARY_OPEN
|
||||||
#define open binary_open
|
#define open binary_open
|
||||||
|
|
Loading…
Reference in New Issue