summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--readconf.c55
-rw-r--r--readconf.h4
-rw-r--r--ssh.c9
-rw-r--r--sshconnect2.c4
5 files changed, 45 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index 9668465b5..abcc11ad4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
120130404
2 - (dtucker) OpenBSD CVS Sync
3 - dtucker@cvs.openbsd.org 2013/02/17 23:16:57
4 [readconf.c ssh.c readconf.h sshconnect2.c]
5 Keep track of which IndentityFile options were manually supplied and which
6 were default options, and don't warn if the latter are missing.
7 ok markus@
8
120130401 920130401
2 - (dtucker) [openbsd-compat/bsd-cygwin_util.{c,h}] Don't include windows.h 10 - (dtucker) [openbsd-compat/bsd-cygwin_util.{c,h}] Don't include windows.h
3 to avoid conflicting definitions of __int64, adding the required bits. 11 to avoid conflicting definitions of __int64, adding the required bits.
diff --git a/readconf.c b/readconf.c
index 097bb0515..6f978f828 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.194 2011/09/23 07:45:05 markus Exp $ */ 1/* $OpenBSD: readconf.c,v 1.195 2013/02/17 23:16:57 dtucker Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -326,6 +326,26 @@ clear_forwardings(Options *options)
326 options->tun_open = SSH_TUNMODE_NO; 326 options->tun_open = SSH_TUNMODE_NO;
327} 327}
328 328
329void
330add_identity_file(Options *options, const char *dir, const char *filename,
331 int userprovided)
332{
333 char *path;
334
335 if (options->num_identity_files >= SSH_MAX_IDENTITY_FILES)
336 fatal("Too many identity files specified (max %d)",
337 SSH_MAX_IDENTITY_FILES);
338
339 if (dir == NULL) /* no dir, filename is absolute */
340 path = xstrdup(filename);
341 else
342 (void)xasprintf(&path, "%.100s%.100s", dir, filename);
343
344 options->identity_file_userprovided[options->num_identity_files] =
345 userprovided;
346 options->identity_files[options->num_identity_files++] = path;
347}
348
329/* 349/*
330 * Returns the number of the token pointed to by cp or oBadOption. 350 * Returns the number of the token pointed to by cp or oBadOption.
331 */ 351 */
@@ -586,9 +606,7 @@ parse_yesnoask:
586 if (*intptr >= SSH_MAX_IDENTITY_FILES) 606 if (*intptr >= SSH_MAX_IDENTITY_FILES)
587 fatal("%.200s line %d: Too many identity files specified (max %d).", 607 fatal("%.200s line %d: Too many identity files specified (max %d).",
588 filename, linenum, SSH_MAX_IDENTITY_FILES); 608 filename, linenum, SSH_MAX_IDENTITY_FILES);
589 charptr = &options->identity_files[*intptr]; 609 add_identity_file(options, NULL, arg, 1);
590 *charptr = xstrdup(arg);
591 *intptr = *intptr + 1;
592 } 610 }
593 break; 611 break;
594 612
@@ -1280,30 +1298,17 @@ fill_default_options(Options * options)
1280 options->protocol = SSH_PROTO_2; 1298 options->protocol = SSH_PROTO_2;
1281 if (options->num_identity_files == 0) { 1299 if (options->num_identity_files == 0) {
1282 if (options->protocol & SSH_PROTO_1) { 1300 if (options->protocol & SSH_PROTO_1) {
1283 len = 2 + strlen(_PATH_SSH_CLIENT_IDENTITY) + 1; 1301 add_identity_file(options, "~/",
1284 options->identity_files[options->num_identity_files] = 1302 _PATH_SSH_CLIENT_IDENTITY, 0);
1285 xmalloc(len);
1286 snprintf(options->identity_files[options->num_identity_files++],
1287 len, "~/%.100s", _PATH_SSH_CLIENT_IDENTITY);
1288 } 1303 }
1289 if (options->protocol & SSH_PROTO_2) { 1304 if (options->protocol & SSH_PROTO_2) {
1290 len = 2 + strlen(_PATH_SSH_CLIENT_ID_RSA) + 1; 1305 add_identity_file(options, "~/",
1291 options->identity_files[options->num_identity_files] = 1306 _PATH_SSH_CLIENT_ID_RSA, 0);
1292 xmalloc(len); 1307 add_identity_file(options, "~/",
1293 snprintf(options->identity_files[options->num_identity_files++], 1308 _PATH_SSH_CLIENT_ID_DSA, 0);
1294 len, "~/%.100s", _PATH_SSH_CLIENT_ID_RSA);
1295
1296 len = 2 + strlen(_PATH_SSH_CLIENT_ID_DSA) + 1;
1297 options->identity_files[options->num_identity_files] =
1298 xmalloc(len);
1299 snprintf(options->identity_files[options->num_identity_files++],
1300 len, "~/%.100s", _PATH_SSH_CLIENT_ID_DSA);
1301#ifdef OPENSSL_HAS_ECC 1309#ifdef OPENSSL_HAS_ECC
1302 len = 2 + strlen(_PATH_SSH_CLIENT_ID_ECDSA) + 1; 1310 add_identity_file(options, "~/",
1303 options->identity_files[options->num_identity_files] = 1311 _PATH_SSH_CLIENT_ID_ECDSA, 0);
1304 xmalloc(len);
1305 snprintf(options->identity_files[options->num_identity_files++],
1306 len, "~/%.100s", _PATH_SSH_CLIENT_ID_ECDSA);
1307#endif 1312#endif
1308 } 1313 }
1309 } 1314 }
diff --git a/readconf.h b/readconf.h
index be30ee0e1..35f596626 100644
--- a/readconf.h
+++ b/readconf.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.h,v 1.91 2011/09/23 07:45:05 markus Exp $ */ 1/* $OpenBSD: readconf.h,v 1.92 2013/02/17 23:16:57 dtucker Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -96,6 +96,7 @@ typedef struct {
96 96
97 int num_identity_files; /* Number of files for RSA/DSA identities. */ 97 int num_identity_files; /* Number of files for RSA/DSA identities. */
98 char *identity_files[SSH_MAX_IDENTITY_FILES]; 98 char *identity_files[SSH_MAX_IDENTITY_FILES];
99 int identity_file_userprovided[SSH_MAX_IDENTITY_FILES];
99 Key *identity_keys[SSH_MAX_IDENTITY_FILES]; 100 Key *identity_keys[SSH_MAX_IDENTITY_FILES];
100 101
101 /* Local TCP/IP forward requests. */ 102 /* Local TCP/IP forward requests. */
@@ -158,5 +159,6 @@ process_config_line(Options *, const char *, char *, const char *, int, int *);
158 159
159void add_local_forward(Options *, const Forward *); 160void add_local_forward(Options *, const Forward *);
160void add_remote_forward(Options *, const Forward *); 161void add_remote_forward(Options *, const Forward *);
162void add_identity_file(Options *, const char *, const char *, int);
161 163
162#endif /* READCONF_H */ 164#endif /* READCONF_H */
diff --git a/ssh.c b/ssh.c
index 3f61eb028..8a7aea09f 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.370 2012/07/06 01:47:38 djm Exp $ */ 1/* $OpenBSD: ssh.c,v 1.371 2013/02/17 23:16:57 dtucker Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -405,12 +405,7 @@ main(int ac, char **av)
405 strerror(errno)); 405 strerror(errno));
406 break; 406 break;
407 } 407 }
408 if (options.num_identity_files >= 408 add_identity_file(&options, NULL, optarg, 1);
409 SSH_MAX_IDENTITY_FILES)
410 fatal("Too many identity files specified "
411 "(max %d)", SSH_MAX_IDENTITY_FILES);
412 options.identity_files[options.num_identity_files++] =
413 xstrdup(optarg);
414 break; 409 break;
415 case 'I': 410 case 'I':
416#ifdef ENABLE_PKCS11 411#ifdef ENABLE_PKCS11
diff --git a/sshconnect2.c b/sshconnect2.c
index d6af0b940..58015c0d3 100644
--- a/sshconnect2.c
+++ b/sshconnect2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect2.c,v 1.191 2013/02/15 00:21:01 dtucker Exp $ */ 1/* $OpenBSD: sshconnect2.c,v 1.192 2013/02/17 23:16:57 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2008 Damien Miller. All rights reserved. 4 * Copyright (c) 2008 Damien Miller. All rights reserved.
@@ -1384,7 +1384,7 @@ pubkey_prepare(Authctxt *authctxt)
1384 id = xcalloc(1, sizeof(*id)); 1384 id = xcalloc(1, sizeof(*id));
1385 id->key = key; 1385 id->key = key;
1386 id->filename = xstrdup(options.identity_files[i]); 1386 id->filename = xstrdup(options.identity_files[i]);
1387 id->userprovided = 1; 1387 id->userprovided = options.identity_file_userprovided[i];
1388 TAILQ_INSERT_TAIL(&files, id, next); 1388 TAILQ_INSERT_TAIL(&files, id, next);
1389 } 1389 }
1390 /* Prefer PKCS11 keys that are explicitly listed */ 1390 /* Prefer PKCS11 keys that are explicitly listed */