summaryrefslogtreecommitdiff
path: root/readconf.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2013-04-05 11:13:30 +1100
committerDarren Tucker <dtucker@zip.com.au>2013-04-05 11:13:30 +1100
commit2b3a03ea3f92dce71134b9c2aa90d975dc59bb57 (patch)
treea234e7fd8cb6dde9f7cece91c437f79d6d42fa6e /readconf.c
parent2fefe034731c1a08b9a6b4106df200ad0f0d1ba7 (diff)
- dtucker@cvs.openbsd.org 2013/02/17 23:16:57
[readconf.c ssh.c readconf.h sshconnect2.c] Keep track of which IndentityFile options were manually supplied and which were default options, and don't warn if the latter are missing. ok markus@
Diffstat (limited to 'readconf.c')
-rw-r--r--readconf.c55
1 files changed, 30 insertions, 25 deletions
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 }