summaryrefslogtreecommitdiff
path: root/match.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-03-11 01:49:19 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-03-11 01:49:19 +0000
commitb9be60a722a8ae24affe68e07ef8557d00992648 (patch)
treeabbd82106ed9c6278bd49e357f74193036241bdd /match.c
parent7f283fcc944a8726ec610d5a11339b28fa75cd94 (diff)
- markus@cvs.openbsd.org 2001/03/10 17:51:04
[kex.c match.c match.h readconf.c readconf.h sshconnect2.c] add PreferredAuthentications
Diffstat (limited to 'match.c')
-rw-r--r--match.c69
1 files changed, 68 insertions, 1 deletions
diff --git a/match.c b/match.c
index 81030da6a..ebb562ab3 100644
--- a/match.c
+++ b/match.c
@@ -10,11 +10,35 @@
10 * incompatible with the protocol description in the RFC file, it must be 10 * incompatible with the protocol description in the RFC file, it must be
11 * called by a name other than "ssh" or "Secure Shell". 11 * called by a name other than "ssh" or "Secure Shell".
12 */ 12 */
13/*
14 * Copyright (c) 2000 Markus Friedl. All rights reserved.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
13 36
14#include "includes.h" 37#include "includes.h"
15RCSID("$OpenBSD: match.c,v 1.11 2001/01/21 19:05:52 markus Exp $"); 38RCSID("$OpenBSD: match.c,v 1.12 2001/03/10 17:51:04 markus Exp $");
16 39
17#include "match.h" 40#include "match.h"
41#include "xmalloc.h"
18 42
19/* 43/*
20 * Returns true if the given string matches the pattern (which may contain ? 44 * Returns true if the given string matches the pattern (which may contain ?
@@ -137,3 +161,46 @@ match_hostname(const char *host, const char *pattern, u_int len)
137 */ 161 */
138 return got_positive; 162 return got_positive;
139} 163}
164
165
166#define MAX_PROP 20
167#define SEP ","
168char *
169match_list(const char *client, const char *server, u_int *next)
170{
171 char *sproposals[MAX_PROP];
172 char *c, *s, *p, *ret, *cp, *sp;
173 int i, j, nproposals;
174
175 c = cp = xstrdup(client);
176 s = sp = xstrdup(server);
177
178 for ((p = strsep(&sp, SEP)), i=0; p && *p != '\0';
179 (p = strsep(&sp, SEP)), i++) {
180 if (i < MAX_PROP)
181 sproposals[i] = p;
182 else
183 break;
184 }
185 nproposals = i;
186
187 for ((p = strsep(&cp, SEP)), i=0; p && *p != '\0';
188 (p = strsep(&cp, SEP)), i++) {
189 for (j = 0; j < nproposals; j++) {
190 if (strcmp(p, sproposals[j]) == 0) {
191 ret = xstrdup(p);
192 if (next != NULL)
193 *next = (cp == NULL) ?
194 strlen(c) : cp - c;
195 xfree(c);
196 xfree(s);
197 return ret;
198 }
199 }
200 }
201 if (next != NULL)
202 *next = strlen(c);
203 xfree(c);
204 xfree(s);
205 return NULL;
206}