mirror of
git://anongit.mindrot.org/openssh.git
synced 2024-12-22 01:50:16 +00:00
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 */
|
||||
}
|
||||
|
||||
#ifndef HAVE_CYGWIN /* Cygwin version in openbsd-compat/bsd-cygwin_util.c */
|
||||
|
||||
/*
|
||||
* Tries to match the string against the
|
||||
* 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;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Match a list representing users or groups. */
|
||||
int
|
||||
match_usergroup_pattern_list(const char *string, const char *pattern)
|
||||
{
|
||||
#ifndef HAVE_CYGWIN
|
||||
/* Case sensitive match */
|
||||
return match_pattern_list(string, pattern, 0);
|
||||
#ifdef HAVE_CYGWIN
|
||||
/* Windows usernames may be Unicode and are not case sensitive */
|
||||
return cygwin_ug_match_pattern_list(string, pattern);
|
||||
#else
|
||||
/* Case insensitive match */
|
||||
return match_pattern_list(string, pattern, 1);
|
||||
return match_pattern_list(string, pattern, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ free_windows_environment(char **p)
|
||||
*/
|
||||
|
||||
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 (;;) {
|
||||
/* 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++)
|
||||
if (*s == *pattern &&
|
||||
__match_pattern(s + 1, pattern + 1,
|
||||
caseinsensitive))
|
||||
__match_pattern(s + 1, pattern + 1))
|
||||
return 1;
|
||||
/* Failed. */
|
||||
return 0;
|
||||
@ -163,7 +162,7 @@ __match_pattern (const wchar_t *s, const wchar_t *pattern, int caseinsensitive)
|
||||
* match at each position.
|
||||
*/
|
||||
for (; *s; s++)
|
||||
if (__match_pattern(s, pattern, caseinsensitive))
|
||||
if (__match_pattern(s, pattern))
|
||||
return 1;
|
||||
/* Failed. */
|
||||
return 0;
|
||||
@ -176,8 +175,7 @@ __match_pattern (const wchar_t *s, const wchar_t *pattern, int caseinsensitive)
|
||||
return 0;
|
||||
|
||||
/* Check if the next character of the string is acceptable. */
|
||||
if (*pattern != '?' && (*pattern != *s &&
|
||||
(!caseinsensitive || towlower(*pattern) != towlower(*s))))
|
||||
if (*pattern != '?' && towlower(*pattern) != towlower(*s))
|
||||
return 0;
|
||||
|
||||
/* 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
|
||||
_match_pattern(const char *s, const char *pattern, int caseinsensitive)
|
||||
_match_pattern(const char *s, const char *pattern)
|
||||
{
|
||||
wchar_t *ws;
|
||||
wchar_t *wpattern;
|
||||
@ -202,7 +200,7 @@ _match_pattern(const char *s, const char *pattern, int caseinsensitive)
|
||||
return 0;
|
||||
wpattern = (wchar_t *) alloca((len + 1) * sizeof (wchar_t));
|
||||
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.
|
||||
*/
|
||||
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];
|
||||
int negated;
|
||||
@ -248,7 +246,7 @@ match_pattern_list(const char *string, const char *pattern, int caseinsensitive)
|
||||
sub[subi] = '\0';
|
||||
|
||||
/* Try to match the subpattern against the string. */
|
||||
if (_match_pattern(string, sub, caseinsensitive)) {
|
||||
if (_match_pattern(string, sub)) {
|
||||
if (negated)
|
||||
return -1; /* Negative */
|
||||
else
|
||||
|
@ -55,6 +55,7 @@ int binary_open(const char *, int , ...);
|
||||
int check_ntsec(const char *);
|
||||
char **fetch_windows_environment(void);
|
||||
void free_windows_environment(char **);
|
||||
int cygwin_ug_match_pattern_list(const char *, const char *);
|
||||
|
||||
#ifndef NO_BINARY_OPEN
|
||||
#define open binary_open
|
||||
|
Loading…
Reference in New Issue
Block a user