xref: /openssh-portable/match.c (revision 05bcd0ca)
1*05bcd0caSdjm@openbsd.org /* $OpenBSD: match.c,v 1.43 2020/11/03 22:53:12 djm Exp $ */
2d4a8b7e3SDamien Miller /*
395def098SDamien Miller  * Author: Tatu Ylonen <ylo@cs.hut.fi>
495def098SDamien Miller  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
595def098SDamien Miller  *                    All rights reserved
695def098SDamien Miller  * Simple pattern matching, with '*' and '?' as wildcards.
795def098SDamien Miller  *
8e4340be5SDamien Miller  * As far as I am concerned, the code I have written for this software
9e4340be5SDamien Miller  * can be used freely for any purpose.  Any derived versions of this
10e4340be5SDamien Miller  * software must be clearly marked as such, and if the derived work is
11e4340be5SDamien Miller  * incompatible with the protocol description in the RFC file, it must be
12e4340be5SDamien Miller  * called by a name other than "ssh" or "Secure Shell".
13d4a8b7e3SDamien Miller  */
14b9be60a7SBen Lindstrom /*
15b9be60a7SBen Lindstrom  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
16b9be60a7SBen Lindstrom  *
17b9be60a7SBen Lindstrom  * Redistribution and use in source and binary forms, with or without
18b9be60a7SBen Lindstrom  * modification, are permitted provided that the following conditions
19b9be60a7SBen Lindstrom  * are met:
20b9be60a7SBen Lindstrom  * 1. Redistributions of source code must retain the above copyright
21b9be60a7SBen Lindstrom  *    notice, this list of conditions and the following disclaimer.
22b9be60a7SBen Lindstrom  * 2. Redistributions in binary form must reproduce the above copyright
23b9be60a7SBen Lindstrom  *    notice, this list of conditions and the following disclaimer in the
24b9be60a7SBen Lindstrom  *    documentation and/or other materials provided with the distribution.
25b9be60a7SBen Lindstrom  *
26b9be60a7SBen Lindstrom  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27b9be60a7SBen Lindstrom  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28b9be60a7SBen Lindstrom  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29b9be60a7SBen Lindstrom  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30b9be60a7SBen Lindstrom  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31b9be60a7SBen Lindstrom  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32b9be60a7SBen Lindstrom  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33b9be60a7SBen Lindstrom  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34b9be60a7SBen Lindstrom  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35b9be60a7SBen Lindstrom  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36b9be60a7SBen Lindstrom  */
37d4a8b7e3SDamien Miller 
38d4a8b7e3SDamien Miller #include "includes.h"
39c7b06369SDamien Miller 
40d7834353SDamien Miller #include <sys/types.h>
41d7834353SDamien Miller 
42c7b06369SDamien Miller #include <ctype.h>
43a627d42eSDarren Tucker #include <stdlib.h>
44e3476ed0SDamien Miller #include <string.h>
4572687c8eSderaadt@openbsd.org #include <stdarg.h>
46dd3e2298Sdjm@openbsd.org #include <stdio.h>
47d4a8b7e3SDamien Miller 
48b9be60a7SBen Lindstrom #include "xmalloc.h"
49d7834353SDamien Miller #include "match.h"
50dd3e2298Sdjm@openbsd.org #include "misc.h"
51d4a8b7e3SDamien Miller 
525428f646SDamien Miller /*
535428f646SDamien Miller  * Returns true if the given string matches the pattern (which may contain ?
545428f646SDamien Miller  * and * as wildcards), and zero if it does not match.
555428f646SDamien Miller  */
5695def098SDamien Miller int
match_pattern(const char * s,const char * pattern)5795def098SDamien Miller match_pattern(const char *s, const char *pattern)
58d4a8b7e3SDamien Miller {
5995def098SDamien Miller 	for (;;) {
60d4a8b7e3SDamien Miller 		/* If at end of pattern, accept if also at end of string. */
61d4a8b7e3SDamien Miller 		if (!*pattern)
62d4a8b7e3SDamien Miller 			return !*s;
63d4a8b7e3SDamien Miller 
6495def098SDamien Miller 		if (*pattern == '*') {
65*05bcd0caSdjm@openbsd.org 			/* Skip this and any consecutive asterisks. */
66*05bcd0caSdjm@openbsd.org 			while (*pattern == '*')
67d4a8b7e3SDamien Miller 				pattern++;
68d4a8b7e3SDamien Miller 
69d4a8b7e3SDamien Miller 			/* If at end of pattern, accept immediately. */
70d4a8b7e3SDamien Miller 			if (!*pattern)
71d4a8b7e3SDamien Miller 				return 1;
72d4a8b7e3SDamien Miller 
73d4a8b7e3SDamien Miller 			/* If next character in pattern is known, optimize. */
7495def098SDamien Miller 			if (*pattern != '?' && *pattern != '*') {
755428f646SDamien Miller 				/*
765428f646SDamien Miller 				 * Look instances of the next character in
775428f646SDamien Miller 				 * pattern, and try to match starting from
785428f646SDamien Miller 				 * those.
795428f646SDamien Miller 				 */
80d4a8b7e3SDamien Miller 				for (; *s; s++)
81d4a8b7e3SDamien Miller 					if (*s == *pattern &&
82d4a8b7e3SDamien Miller 					    match_pattern(s + 1, pattern + 1))
83d4a8b7e3SDamien Miller 						return 1;
84d4a8b7e3SDamien Miller 				/* Failed. */
85d4a8b7e3SDamien Miller 				return 0;
86d4a8b7e3SDamien Miller 			}
875428f646SDamien Miller 			/*
885428f646SDamien Miller 			 * Move ahead one character at a time and try to
895428f646SDamien Miller 			 * match at each position.
905428f646SDamien Miller 			 */
91d4a8b7e3SDamien Miller 			for (; *s; s++)
92d4a8b7e3SDamien Miller 				if (match_pattern(s, pattern))
93d4a8b7e3SDamien Miller 					return 1;
94d4a8b7e3SDamien Miller 			/* Failed. */
95d4a8b7e3SDamien Miller 			return 0;
96d4a8b7e3SDamien Miller 		}
975428f646SDamien Miller 		/*
985428f646SDamien Miller 		 * There must be at least one more character in the string.
995428f646SDamien Miller 		 * If we are at the end, fail.
1005428f646SDamien Miller 		 */
101d4a8b7e3SDamien Miller 		if (!*s)
102d4a8b7e3SDamien Miller 			return 0;
103d4a8b7e3SDamien Miller 
1045428f646SDamien Miller 		/* Check if the next character of the string is acceptable. */
105d4a8b7e3SDamien Miller 		if (*pattern != '?' && *pattern != *s)
106d4a8b7e3SDamien Miller 			return 0;
107d4a8b7e3SDamien Miller 
1085428f646SDamien Miller 		/* Move to the next character, both in string and in pattern. */
109d4a8b7e3SDamien Miller 		s++;
110d4a8b7e3SDamien Miller 		pattern++;
111d4a8b7e3SDamien Miller 	}
112d4a8b7e3SDamien Miller 	/* NOTREACHED */
113d4a8b7e3SDamien Miller }
114450a7a1fSDamien Miller 
115450a7a1fSDamien Miller /*
1169eab262fSBen Lindstrom  * Tries to match the string against the
117450a7a1fSDamien Miller  * comma-separated sequence of subpatterns (each possibly preceded by ! to
118d3a18570SDamien Miller  * indicate negation).  Returns -1 if negation matches, 1 if there is
119d3a18570SDamien Miller  * a positive match, 0 if there is no match at all.
120450a7a1fSDamien Miller  */
121450a7a1fSDamien Miller int
match_pattern_list(const char * string,const char * pattern,int dolower)122e661a863Sdjm@openbsd.org match_pattern_list(const char *string, const char *pattern, int dolower)
123450a7a1fSDamien Miller {
124450a7a1fSDamien Miller 	char sub[1024];
125450a7a1fSDamien Miller 	int negated;
126450a7a1fSDamien Miller 	int got_positive;
127e661a863Sdjm@openbsd.org 	u_int i, subi, len = strlen(pattern);
128450a7a1fSDamien Miller 
129450a7a1fSDamien Miller 	got_positive = 0;
130450a7a1fSDamien Miller 	for (i = 0; i < len;) {
131450a7a1fSDamien Miller 		/* Check if the subpattern is negated. */
132450a7a1fSDamien Miller 		if (pattern[i] == '!') {
133450a7a1fSDamien Miller 			negated = 1;
134450a7a1fSDamien Miller 			i++;
135450a7a1fSDamien Miller 		} else
136450a7a1fSDamien Miller 			negated = 0;
137450a7a1fSDamien Miller 
138450a7a1fSDamien Miller 		/*
139450a7a1fSDamien Miller 		 * Extract the subpattern up to a comma or end.  Convert the
140450a7a1fSDamien Miller 		 * subpattern to lowercase.
141450a7a1fSDamien Miller 		 */
142450a7a1fSDamien Miller 		for (subi = 0;
143450a7a1fSDamien Miller 		    i < len && subi < sizeof(sub) - 1 && pattern[i] != ',';
144450a7a1fSDamien Miller 		    subi++, i++)
145fdb2306aSDamien Miller 			sub[subi] = dolower && isupper((u_char)pattern[i]) ?
146fdb2306aSDamien Miller 			    tolower((u_char)pattern[i]) : pattern[i];
147450a7a1fSDamien Miller 		/* If subpattern too long, return failure (no match). */
148450a7a1fSDamien Miller 		if (subi >= sizeof(sub) - 1)
149450a7a1fSDamien Miller 			return 0;
150450a7a1fSDamien Miller 
151ec2892b5Sdjm@openbsd.org 		/* If the subpattern was terminated by a comma, then skip it. */
152450a7a1fSDamien Miller 		if (i < len && pattern[i] == ',')
153450a7a1fSDamien Miller 			i++;
154450a7a1fSDamien Miller 
155450a7a1fSDamien Miller 		/* Null-terminate the subpattern. */
156450a7a1fSDamien Miller 		sub[subi] = '\0';
157450a7a1fSDamien Miller 
1589eab262fSBen Lindstrom 		/* Try to match the subpattern against the string. */
1599eab262fSBen Lindstrom 		if (match_pattern(string, sub)) {
160450a7a1fSDamien Miller 			if (negated)
161d3a18570SDamien Miller 				return -1;		/* Negative */
162450a7a1fSDamien Miller 			else
163d3a18570SDamien Miller 				got_positive = 1;	/* Positive */
164a5ad3a9dSdjm@openbsd.org 		}
165450a7a1fSDamien Miller 	}
166450a7a1fSDamien Miller 
167450a7a1fSDamien Miller 	/*
168450a7a1fSDamien Miller 	 * Return success if got a positive match.  If there was a negative
169d3a18570SDamien Miller 	 * match, we have already returned -1 and never get here.
170450a7a1fSDamien Miller 	 */
171450a7a1fSDamien Miller 	return got_positive;
172450a7a1fSDamien Miller }
173b9be60a7SBen Lindstrom 
174fd10cf02Sdtucker@openbsd.org /* Match a list representing users or groups. */
175fd10cf02Sdtucker@openbsd.org int
match_usergroup_pattern_list(const char * string,const char * pattern)176fd10cf02Sdtucker@openbsd.org match_usergroup_pattern_list(const char *string, const char *pattern)
177fd10cf02Sdtucker@openbsd.org {
178daa7505aSDarren Tucker #ifdef HAVE_CYGWIN
179daa7505aSDarren Tucker 	/* Windows usernames may be Unicode and are not case sensitive */
180daa7505aSDarren Tucker 	return cygwin_ug_match_pattern_list(string, pattern);
181fd10cf02Sdtucker@openbsd.org #else
182a4cc579cSDarren Tucker 	/* Case sensitive match */
183daa7505aSDarren Tucker 	return match_pattern_list(string, pattern, 0);
184fd10cf02Sdtucker@openbsd.org #endif
185fd10cf02Sdtucker@openbsd.org }
186fd10cf02Sdtucker@openbsd.org 
187f0c50293SBen Lindstrom /*
1889eab262fSBen Lindstrom  * Tries to match the host name (which must be in all lowercase) against the
1899eab262fSBen Lindstrom  * comma-separated sequence of subpatterns (each possibly preceded by ! to
1909eab262fSBen Lindstrom  * indicate negation).  Returns -1 if negation matches, 1 if there is
1919eab262fSBen Lindstrom  * a positive match, 0 if there is no match at all.
1929eab262fSBen Lindstrom  */
1939eab262fSBen Lindstrom int
match_hostname(const char * host,const char * pattern)194e661a863Sdjm@openbsd.org match_hostname(const char *host, const char *pattern)
1959eab262fSBen Lindstrom {
196dd3e2298Sdjm@openbsd.org 	char *hostcopy = xstrdup(host);
197dd3e2298Sdjm@openbsd.org 	int r;
198dd3e2298Sdjm@openbsd.org 
199dd3e2298Sdjm@openbsd.org 	lowercase(hostcopy);
200dd3e2298Sdjm@openbsd.org 	r = match_pattern_list(hostcopy, pattern, 1);
201dd3e2298Sdjm@openbsd.org 	free(hostcopy);
202dd3e2298Sdjm@openbsd.org 	return r;
2039eab262fSBen Lindstrom }
2049eab262fSBen Lindstrom 
2059eab262fSBen Lindstrom /*
206f0c50293SBen Lindstrom  * returns 0 if we get a negative match for the hostname or the ip
207896ad5a4SDarren Tucker  * or if we get no match at all.  returns -1 on error, or 1 on
208896ad5a4SDarren Tucker  * successful match.
209f0c50293SBen Lindstrom  */
210f0c50293SBen Lindstrom int
match_host_and_ip(const char * host,const char * ipaddr,const char * patterns)211f0c50293SBen Lindstrom match_host_and_ip(const char *host, const char *ipaddr,
212f0c50293SBen Lindstrom     const char *patterns)
213f0c50293SBen Lindstrom {
214f0c50293SBen Lindstrom 	int mhost, mip;
215b9be60a7SBen Lindstrom 
216896ad5a4SDarren Tucker 	if ((mip = addr_match_list(ipaddr, patterns)) == -2)
217010359b3Sdjm@openbsd.org 		return -1; /* error in ipaddr match */
218010359b3Sdjm@openbsd.org 	else if (host == NULL || ipaddr == NULL || mip == -1)
219010359b3Sdjm@openbsd.org 		return 0; /* negative ip address match, or testing pattern */
220896ad5a4SDarren Tucker 
221f0c50293SBen Lindstrom 	/* negative hostname match */
222e661a863Sdjm@openbsd.org 	if ((mhost = match_hostname(host, patterns)) == -1)
223f0c50293SBen Lindstrom 		return 0;
224f0c50293SBen Lindstrom 	/* no match at all */
225f0c50293SBen Lindstrom 	if (mhost == 0 && mip == 0)
226f0c50293SBen Lindstrom 		return 0;
227f0c50293SBen Lindstrom 	return 1;
228f0c50293SBen Lindstrom }
229f0c50293SBen Lindstrom 
230f0c50293SBen Lindstrom /*
231010359b3Sdjm@openbsd.org  * Match user, user@host_or_ip, user@host_or_ip_list against pattern.
232010359b3Sdjm@openbsd.org  * If user, host and ipaddr are all NULL then validate pattern/
233010359b3Sdjm@openbsd.org  * Returns -1 on invalid pattern, 0 on no match, 1 on match.
23460260022SBen Lindstrom  */
23560260022SBen Lindstrom int
match_user(const char * user,const char * host,const char * ipaddr,const char * pattern)2363fb5d00fSBen Lindstrom match_user(const char *user, const char *host, const char *ipaddr,
23760260022SBen Lindstrom     const char *pattern)
23860260022SBen Lindstrom {
23960260022SBen Lindstrom 	char *p, *pat;
24060260022SBen Lindstrom 	int ret;
24160260022SBen Lindstrom 
242010359b3Sdjm@openbsd.org 	/* test mode */
243010359b3Sdjm@openbsd.org 	if (user == NULL && host == NULL && ipaddr == NULL) {
244010359b3Sdjm@openbsd.org 		if ((p = strchr(pattern, '@')) != NULL &&
245010359b3Sdjm@openbsd.org 		    match_host_and_ip(NULL, NULL, p + 1) < 0)
246010359b3Sdjm@openbsd.org 			return -1;
247010359b3Sdjm@openbsd.org 		return 0;
248010359b3Sdjm@openbsd.org 	}
249010359b3Sdjm@openbsd.org 
25060260022SBen Lindstrom 	if ((p = strchr(pattern, '@')) == NULL)
25160260022SBen Lindstrom 		return match_pattern(user, pattern);
25260260022SBen Lindstrom 
25360260022SBen Lindstrom 	pat = xstrdup(pattern);
25460260022SBen Lindstrom 	p = strchr(pat, '@');
25560260022SBen Lindstrom 	*p++ = '\0';
25660260022SBen Lindstrom 
25760260022SBen Lindstrom 	if ((ret = match_pattern(user, pat)) == 1)
2583fb5d00fSBen Lindstrom 		ret = match_host_and_ip(host, ipaddr, p);
259a627d42eSDarren Tucker 	free(pat);
26060260022SBen Lindstrom 
26160260022SBen Lindstrom 	return ret;
26260260022SBen Lindstrom }
26360260022SBen Lindstrom 
26460260022SBen Lindstrom /*
265f0c50293SBen Lindstrom  * Returns first item from client-list that is also supported by server-list,
266a627d42eSDarren Tucker  * caller must free the returned string.
267f0c50293SBen Lindstrom  */
268afc7a5d7SDamien Miller #define	MAX_PROP	40
269b9be60a7SBen Lindstrom #define	SEP	","
270b9be60a7SBen Lindstrom char *
match_list(const char * client,const char * server,u_int * next)271b9be60a7SBen Lindstrom match_list(const char *client, const char *server, u_int *next)
272b9be60a7SBen Lindstrom {
273b9be60a7SBen Lindstrom 	char *sproposals[MAX_PROP];
274b9be60a7SBen Lindstrom 	char *c, *s, *p, *ret, *cp, *sp;
275b9be60a7SBen Lindstrom 	int i, j, nproposals;
276b9be60a7SBen Lindstrom 
277b9be60a7SBen Lindstrom 	c = cp = xstrdup(client);
278b9be60a7SBen Lindstrom 	s = sp = xstrdup(server);
279b9be60a7SBen Lindstrom 
280b9be60a7SBen Lindstrom 	for ((p = strsep(&sp, SEP)), i=0; p && *p != '\0';
281b9be60a7SBen Lindstrom 	    (p = strsep(&sp, SEP)), i++) {
282b9be60a7SBen Lindstrom 		if (i < MAX_PROP)
283b9be60a7SBen Lindstrom 			sproposals[i] = p;
284b9be60a7SBen Lindstrom 		else
285b9be60a7SBen Lindstrom 			break;
286b9be60a7SBen Lindstrom 	}
287b9be60a7SBen Lindstrom 	nproposals = i;
288b9be60a7SBen Lindstrom 
289b9be60a7SBen Lindstrom 	for ((p = strsep(&cp, SEP)), i=0; p && *p != '\0';
290b9be60a7SBen Lindstrom 	    (p = strsep(&cp, SEP)), i++) {
291b9be60a7SBen Lindstrom 		for (j = 0; j < nproposals; j++) {
292b9be60a7SBen Lindstrom 			if (strcmp(p, sproposals[j]) == 0) {
293b9be60a7SBen Lindstrom 				ret = xstrdup(p);
294b9be60a7SBen Lindstrom 				if (next != NULL)
295b9be60a7SBen Lindstrom 					*next = (cp == NULL) ?
296eccb9de7SDamien Miller 					    strlen(c) : (u_int)(cp - c);
297a627d42eSDarren Tucker 				free(c);
298a627d42eSDarren Tucker 				free(s);
299b9be60a7SBen Lindstrom 				return ret;
300b9be60a7SBen Lindstrom 			}
301b9be60a7SBen Lindstrom 		}
302b9be60a7SBen Lindstrom 	}
303b9be60a7SBen Lindstrom 	if (next != NULL)
304b9be60a7SBen Lindstrom 		*next = strlen(c);
305a627d42eSDarren Tucker 	free(c);
306a627d42eSDarren Tucker 	free(s);
307b9be60a7SBen Lindstrom 	return NULL;
308b9be60a7SBen Lindstrom }
30968bc8cfaSdjm@openbsd.org 
31068bc8cfaSdjm@openbsd.org /*
311312d2f28Sdjm@openbsd.org  * Filter proposal using pattern-list filter.
3126d755706Sdjm@openbsd.org  * "denylist" determines sense of filter:
313312d2f28Sdjm@openbsd.org  * non-zero indicates that items matching filter should be excluded.
314312d2f28Sdjm@openbsd.org  * zero indicates that only items matching filter should be included.
315312d2f28Sdjm@openbsd.org  * returns NULL on allocation error, otherwise caller must free result.
31668bc8cfaSdjm@openbsd.org  */
317312d2f28Sdjm@openbsd.org static char *
filter_list(const char * proposal,const char * filter,int denylist)3186d755706Sdjm@openbsd.org filter_list(const char *proposal, const char *filter, int denylist)
31968bc8cfaSdjm@openbsd.org {
32068bc8cfaSdjm@openbsd.org 	size_t len = strlen(proposal) + 1;
32168bc8cfaSdjm@openbsd.org 	char *fix_prop = malloc(len);
32268bc8cfaSdjm@openbsd.org 	char *orig_prop = strdup(proposal);
32368bc8cfaSdjm@openbsd.org 	char *cp, *tmp;
324312d2f28Sdjm@openbsd.org 	int r;
32568bc8cfaSdjm@openbsd.org 
326b2afdaf1Sjsg@openbsd.org 	if (fix_prop == NULL || orig_prop == NULL) {
327b2afdaf1Sjsg@openbsd.org 		free(orig_prop);
328b2afdaf1Sjsg@openbsd.org 		free(fix_prop);
32968bc8cfaSdjm@openbsd.org 		return NULL;
330b2afdaf1Sjsg@openbsd.org 	}
33168bc8cfaSdjm@openbsd.org 
33268bc8cfaSdjm@openbsd.org 	tmp = orig_prop;
33368bc8cfaSdjm@openbsd.org 	*fix_prop = '\0';
33468bc8cfaSdjm@openbsd.org 	while ((cp = strsep(&tmp, ",")) != NULL) {
335312d2f28Sdjm@openbsd.org 		r = match_pattern_list(cp, filter, 0);
3366d755706Sdjm@openbsd.org 		if ((denylist && r != 1) || (!denylist && r == 1)) {
33768bc8cfaSdjm@openbsd.org 			if (*fix_prop != '\0')
33868bc8cfaSdjm@openbsd.org 				strlcat(fix_prop, ",", len);
33968bc8cfaSdjm@openbsd.org 			strlcat(fix_prop, cp, len);
34068bc8cfaSdjm@openbsd.org 		}
34168bc8cfaSdjm@openbsd.org 	}
34268bc8cfaSdjm@openbsd.org 	free(orig_prop);
34368bc8cfaSdjm@openbsd.org 	return fix_prop;
34468bc8cfaSdjm@openbsd.org }
34568bc8cfaSdjm@openbsd.org 
346312d2f28Sdjm@openbsd.org /*
347312d2f28Sdjm@openbsd.org  * Filters a comma-separated list of strings, excluding any entry matching
348312d2f28Sdjm@openbsd.org  * the 'filter' pattern list. Caller must free returned string.
349312d2f28Sdjm@openbsd.org  */
350312d2f28Sdjm@openbsd.org char *
match_filter_denylist(const char * proposal,const char * filter)3516d755706Sdjm@openbsd.org match_filter_denylist(const char *proposal, const char *filter)
352312d2f28Sdjm@openbsd.org {
353312d2f28Sdjm@openbsd.org 	return filter_list(proposal, filter, 1);
354312d2f28Sdjm@openbsd.org }
355312d2f28Sdjm@openbsd.org 
356312d2f28Sdjm@openbsd.org /*
357312d2f28Sdjm@openbsd.org  * Filters a comma-separated list of strings, including only entries matching
358312d2f28Sdjm@openbsd.org  * the 'filter' pattern list. Caller must free returned string.
359312d2f28Sdjm@openbsd.org  */
360312d2f28Sdjm@openbsd.org char *
match_filter_allowlist(const char * proposal,const char * filter)3616d755706Sdjm@openbsd.org match_filter_allowlist(const char *proposal, const char *filter)
362312d2f28Sdjm@openbsd.org {
363312d2f28Sdjm@openbsd.org 	return filter_list(proposal, filter, 0);
364312d2f28Sdjm@openbsd.org }
365