summaryrefslogtreecommitdiff
path: root/openbsd-compat
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@dtucker.net>2019-03-12 09:19:19 +1100
committerDarren Tucker <dtucker@dtucker.net>2019-03-12 09:19:19 +1100
commitdaa7505aadca68ba1a2c70cbdfce423208eb91ee (patch)
tree5a928d2516bac7be6f0fde98dfdb7eb7b266dec9 /openbsd-compat
parentfd10cf027b56f9aaa80c9e3844626a05066589a4 (diff)
Use Cygwin-specific matching only for users+groups.
Patch from vinschen at redhat.com, updated a little by me.
Diffstat (limited to 'openbsd-compat')
-rw-r--r--openbsd-compat/bsd-cygwin_util.c18
-rw-r--r--openbsd-compat/bsd-cygwin_util.h1
2 files changed, 9 insertions, 10 deletions
diff --git a/openbsd-compat/bsd-cygwin_util.c b/openbsd-compat/bsd-cygwin_util.c
index f721fca9d..1e4cdc928 100644
--- a/openbsd-compat/bsd-cygwin_util.c
+++ b/openbsd-compat/bsd-cygwin_util.c
@@ -128,7 +128,7 @@ free_windows_environment(char **p)
128 */ 128 */
129 129
130static int 130static int
131__match_pattern (const wchar_t *s, const wchar_t *pattern, int caseinsensitive) 131__match_pattern (const wchar_t *s, const wchar_t *pattern)
132{ 132{
133 for (;;) { 133 for (;;) {
134 /* If at end of pattern, accept if also at end of string. */ 134 /* 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)
152 */ 152 */
153 for (; *s; s++) 153 for (; *s; s++)
154 if (*s == *pattern && 154 if (*s == *pattern &&
155 __match_pattern(s + 1, pattern + 1, 155 __match_pattern(s + 1, pattern + 1))
156 caseinsensitive))
157 return 1; 156 return 1;
158 /* Failed. */ 157 /* Failed. */
159 return 0; 158 return 0;
@@ -163,7 +162,7 @@ __match_pattern (const wchar_t *s, const wchar_t *pattern, int caseinsensitive)
163 * match at each position. 162 * match at each position.
164 */ 163 */
165 for (; *s; s++) 164 for (; *s; s++)
166 if (__match_pattern(s, pattern, caseinsensitive)) 165 if (__match_pattern(s, pattern))
167 return 1; 166 return 1;
168 /* Failed. */ 167 /* Failed. */
169 return 0; 168 return 0;
@@ -176,8 +175,7 @@ __match_pattern (const wchar_t *s, const wchar_t *pattern, int caseinsensitive)
176 return 0; 175 return 0;
177 176
178 /* Check if the next character of the string is acceptable. */ 177 /* Check if the next character of the string is acceptable. */
179 if (*pattern != '?' && (*pattern != *s && 178 if (*pattern != '?' && towlower(*pattern) != towlower(*s))
180 (!caseinsensitive || towlower(*pattern) != towlower(*s))))
181 return 0; 179 return 0;
182 180
183 /* Move to the next character, both in string and in pattern. */ 181 /* 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)
188} 186}
189 187
190static int 188static int
191_match_pattern(const char *s, const char *pattern, int caseinsensitive) 189_match_pattern(const char *s, const char *pattern)
192{ 190{
193 wchar_t *ws; 191 wchar_t *ws;
194 wchar_t *wpattern; 192 wchar_t *wpattern;
@@ -202,7 +200,7 @@ _match_pattern(const char *s, const char *pattern, int caseinsensitive)
202 return 0; 200 return 0;
203 wpattern = (wchar_t *) alloca((len + 1) * sizeof (wchar_t)); 201 wpattern = (wchar_t *) alloca((len + 1) * sizeof (wchar_t));
204 mbstowcs(wpattern, pattern, len + 1); 202 mbstowcs(wpattern, pattern, len + 1);
205 return __match_pattern (ws, wpattern, caseinsensitive); 203 return __match_pattern (ws, wpattern);
206} 204}
207 205
208/* 206/*
@@ -212,7 +210,7 @@ _match_pattern(const char *s, const char *pattern, int caseinsensitive)
212 * a positive match, 0 if there is no match at all. 210 * a positive match, 0 if there is no match at all.
213 */ 211 */
214int 212int
215match_pattern_list(const char *string, const char *pattern, int caseinsensitive) 213cygwin_ug_match_pattern_list(const char *string, const char *pattern)
216{ 214{
217 char sub[1024]; 215 char sub[1024];
218 int negated; 216 int negated;
@@ -248,7 +246,7 @@ match_pattern_list(const char *string, const char *pattern, int caseinsensitive)
248 sub[subi] = '\0'; 246 sub[subi] = '\0';
249 247
250 /* Try to match the subpattern against the string. */ 248 /* Try to match the subpattern against the string. */
251 if (_match_pattern(string, sub, caseinsensitive)) { 249 if (_match_pattern(string, sub)) {
252 if (negated) 250 if (negated)
253 return -1; /* Negative */ 251 return -1; /* Negative */
254 else 252 else
diff --git a/openbsd-compat/bsd-cygwin_util.h b/openbsd-compat/bsd-cygwin_util.h
index 202c055db..55c5a5b81 100644
--- a/openbsd-compat/bsd-cygwin_util.h
+++ b/openbsd-compat/bsd-cygwin_util.h
@@ -55,6 +55,7 @@ int binary_open(const char *, int , ...);
55int check_ntsec(const char *); 55int check_ntsec(const char *);
56char **fetch_windows_environment(void); 56char **fetch_windows_environment(void);
57void free_windows_environment(char **); 57void free_windows_environment(char **);
58int cygwin_ug_match_pattern_list(const char *, const char *);
58 59
59#ifndef NO_BINARY_OPEN 60#ifndef NO_BINARY_OPEN
60#define open binary_open 61#define open binary_open