Deleted Added
full compact
auth2-pubkey.c (126274) auth2-pubkey.c (137015)
1/*
2 * Copyright (c) 2000 Markus Friedl. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 9 unchanged lines hidden (view full) ---

18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#include "includes.h"
1/*
2 * Copyright (c) 2000 Markus Friedl. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 9 unchanged lines hidden (view full) ---

18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#include "includes.h"
26RCSID("$OpenBSD: auth2-pubkey.c,v 1.6 2004/01/19 21:25:15 markus Exp $");
26RCSID("$OpenBSD: auth2-pubkey.c,v 1.7 2004/06/21 17:36:31 avsm Exp $");
27
28#include "ssh2.h"
29#include "xmalloc.h"
30#include "packet.h"
31#include "buffer.h"
32#include "log.h"
33#include "servconf.h"
34#include "compat.h"

--- 165 unchanged lines hidden (view full) ---

200 restore_uid();
201 return 0;
202 }
203
204 found_key = 0;
205 found = key_new(key->type);
206
207 while (fgets(line, sizeof(line), f)) {
27
28#include "ssh2.h"
29#include "xmalloc.h"
30#include "packet.h"
31#include "buffer.h"
32#include "log.h"
33#include "servconf.h"
34#include "compat.h"

--- 165 unchanged lines hidden (view full) ---

200 restore_uid();
201 return 0;
202 }
203
204 found_key = 0;
205 found = key_new(key->type);
206
207 while (fgets(line, sizeof(line), f)) {
208 char *cp, *options = NULL;
208 char *cp, *key_options = NULL;
209 linenum++;
210 /* Skip leading whitespace, empty and comment lines. */
211 for (cp = line; *cp == ' ' || *cp == '\t'; cp++)
212 ;
213 if (!*cp || *cp == '\n' || *cp == '#')
214 continue;
215
216 if (key_read(found, &cp) != 1) {
217 /* no key? check if there are options for this key */
218 int quoted = 0;
219 debug2("user_key_allowed: check options: '%s'", cp);
209 linenum++;
210 /* Skip leading whitespace, empty and comment lines. */
211 for (cp = line; *cp == ' ' || *cp == '\t'; cp++)
212 ;
213 if (!*cp || *cp == '\n' || *cp == '#')
214 continue;
215
216 if (key_read(found, &cp) != 1) {
217 /* no key? check if there are options for this key */
218 int quoted = 0;
219 debug2("user_key_allowed: check options: '%s'", cp);
220 options = cp;
220 key_options = cp;
221 for (; *cp && (quoted || (*cp != ' ' && *cp != '\t')); cp++) {
222 if (*cp == '\\' && cp[1] == '"')
223 cp++; /* Skip both */
224 else if (*cp == '"')
225 quoted = !quoted;
226 }
227 /* Skip remaining whitespace. */
228 for (; *cp == ' ' || *cp == '\t'; cp++)
229 ;
230 if (key_read(found, &cp) != 1) {
231 debug2("user_key_allowed: advance: '%s'", cp);
232 /* still no key? advance to next line*/
233 continue;
234 }
235 }
236 if (key_equal(found, key) &&
221 for (; *cp && (quoted || (*cp != ' ' && *cp != '\t')); cp++) {
222 if (*cp == '\\' && cp[1] == '"')
223 cp++; /* Skip both */
224 else if (*cp == '"')
225 quoted = !quoted;
226 }
227 /* Skip remaining whitespace. */
228 for (; *cp == ' ' || *cp == '\t'; cp++)
229 ;
230 if (key_read(found, &cp) != 1) {
231 debug2("user_key_allowed: advance: '%s'", cp);
232 /* still no key? advance to next line*/
233 continue;
234 }
235 }
236 if (key_equal(found, key) &&
237 auth_parse_options(pw, options, file, linenum) == 1) {
237 auth_parse_options(pw, key_options, file, linenum) == 1) {
238 found_key = 1;
239 debug("matching key found: file %s, line %lu",
240 file, linenum);
241 fp = key_fingerprint(found, SSH_FP_MD5, SSH_FP_HEX);
242 verbose("Found matching %s key: %s",
243 key_type(found), fp);
244 xfree(fp);
245 break;

--- 35 unchanged lines hidden ---
238 found_key = 1;
239 debug("matching key found: file %s, line %lu",
240 file, linenum);
241 fp = key_fingerprint(found, SSH_FP_MD5, SSH_FP_HEX);
242 verbose("Found matching %s key: %s",
243 key_type(found), fp);
244 xfree(fp);
245 break;

--- 35 unchanged lines hidden ---