summaryrefslogtreecommitdiff
path: root/readconf.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-09-24 06:15:11 +0000
committerDamien Miller <djm@mindrot.org>2015-10-06 12:21:54 +1100
commit4e44a79a07d4b88b6a4e5e8c1bed5f58c841b1b8 (patch)
tree7ef647dabf413a83da2f0c26917a8e0b5e1d2145 /readconf.c
parente3cbb06ade83c72b640a53728d362bbefa0008e2 (diff)
upstream commit
add ssh_config CertificateFile option to explicitly list a certificate; patch from Meghana Bhat on bz#2436; ok markus@ Upstream-ID: 58648ec53c510b41c1f46d8fe293aadc87229ab8
Diffstat (limited to 'readconf.c')
-rw-r--r--readconf.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/readconf.c b/readconf.c
index 354e292d3..09888b14d 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.240 2015/08/21 23:53:08 djm Exp $ */ 1/* $OpenBSD: readconf.c,v 1.241 2015/09/24 06:15:11 djm 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
@@ -135,6 +135,7 @@ typedef enum {
135 oPasswordAuthentication, oRSAAuthentication, 135 oPasswordAuthentication, oRSAAuthentication,
136 oChallengeResponseAuthentication, oXAuthLocation, 136 oChallengeResponseAuthentication, oXAuthLocation,
137 oIdentityFile, oHostName, oPort, oCipher, oRemoteForward, oLocalForward, 137 oIdentityFile, oHostName, oPort, oCipher, oRemoteForward, oLocalForward,
138 oCertificateFile,
138 oUser, oEscapeChar, oRhostsRSAAuthentication, oProxyCommand, 139 oUser, oEscapeChar, oRhostsRSAAuthentication, oProxyCommand,
139 oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts, 140 oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts,
140 oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression, 141 oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression,
@@ -202,6 +203,7 @@ static struct {
202 { "identityfile", oIdentityFile }, 203 { "identityfile", oIdentityFile },
203 { "identityfile2", oIdentityFile }, /* obsolete */ 204 { "identityfile2", oIdentityFile }, /* obsolete */
204 { "identitiesonly", oIdentitiesOnly }, 205 { "identitiesonly", oIdentitiesOnly },
206 { "certificatefile", oCertificateFile },
205 { "hostname", oHostName }, 207 { "hostname", oHostName },
206 { "hostkeyalias", oHostKeyAlias }, 208 { "hostkeyalias", oHostKeyAlias },
207 { "proxycommand", oProxyCommand }, 209 { "proxycommand", oProxyCommand },
@@ -366,6 +368,30 @@ clear_forwardings(Options *options)
366} 368}
367 369
368void 370void
371add_certificate_file(Options *options, const char *path, int userprovided)
372{
373 int i;
374
375 if (options->num_certificate_files >= SSH_MAX_CERTIFICATE_FILES)
376 fatal("Too many certificate files specified (max %d)",
377 SSH_MAX_CERTIFICATE_FILES);
378
379 /* Avoid registering duplicates */
380 for (i = 0; i < options->num_certificate_files; i++) {
381 if (options->certificate_file_userprovided[i] == userprovided &&
382 strcmp(options->certificate_files[i], path) == 0) {
383 debug2("%s: ignoring duplicate key %s", __func__, path);
384 return;
385 }
386 }
387
388 options->certificate_file_userprovided[options->num_certificate_files] =
389 userprovided;
390 options->certificate_files[options->num_certificate_files++] =
391 xstrdup(path);
392}
393
394void
369add_identity_file(Options *options, const char *dir, const char *filename, 395add_identity_file(Options *options, const char *dir, const char *filename,
370 int userprovided) 396 int userprovided)
371{ 397{
@@ -981,6 +1007,24 @@ parse_time:
981 } 1007 }
982 break; 1008 break;
983 1009
1010 case oCertificateFile:
1011 arg = strdelim(&s);
1012 if (!arg || *arg == '\0')
1013 fatal("%.200s line %d: Missing argument.",
1014 filename, linenum);
1015 if (*activep) {
1016 intptr = &options->num_certificate_files;
1017 if (*intptr >= SSH_MAX_CERTIFICATE_FILES) {
1018 fatal("%.200s line %d: Too many certificate "
1019 "files specified (max %d).",
1020 filename, linenum,
1021 SSH_MAX_CERTIFICATE_FILES);
1022 }
1023 add_certificate_file(options, arg,
1024 flags & SSHCONF_USERCONF);
1025 }
1026 break;
1027
984 case oXAuthLocation: 1028 case oXAuthLocation:
985 charptr=&options->xauth_location; 1029 charptr=&options->xauth_location;
986 goto parse_string; 1030 goto parse_string;
@@ -1625,6 +1669,7 @@ initialize_options(Options * options)
1625 options->hostkeyalgorithms = NULL; 1669 options->hostkeyalgorithms = NULL;
1626 options->protocol = SSH_PROTO_UNKNOWN; 1670 options->protocol = SSH_PROTO_UNKNOWN;
1627 options->num_identity_files = 0; 1671 options->num_identity_files = 0;
1672 options->num_certificate_files = 0;
1628 options->hostname = NULL; 1673 options->hostname = NULL;
1629 options->host_key_alias = NULL; 1674 options->host_key_alias = NULL;
1630 options->proxy_command = NULL; 1675 options->proxy_command = NULL;