summaryrefslogtreecommitdiff
path: root/readconf.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2011-05-29 21:42:31 +1000
committerDamien Miller <djm@mindrot.org>2011-05-29 21:42:31 +1000
commit295ee63ab2123899fb21f76616ef4dac51515236 (patch)
treeabfdff06f36b5d5cc32296b53e34c8084f342a9a /readconf.c
parent04bb56ef10bca3219010fdb191f1f9941353174b (diff)
- djm@cvs.openbsd.org 2011/05/24 07:15:47
[readconf.c readconf.h ssh.c ssh_config.5 sshconnect.c sshconnect2.c] Remove undocumented legacy options UserKnownHostsFile2 and GlobalKnownHostsFile2 by making UserKnownHostsFile/GlobalKnownHostsFile accept multiple paths per line and making their defaults include known_hosts2; ok markus
Diffstat (limited to 'readconf.c')
-rw-r--r--readconf.c69
1 files changed, 40 insertions, 29 deletions
diff --git a/readconf.c b/readconf.c
index 4780ae289..91dfa566f 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.192 2011/05/06 21:34:32 djm Exp $ */ 1/* $OpenBSD: readconf.c,v 1.193 2011/05/24 07:15:47 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
@@ -193,9 +193,9 @@ static struct {
193 { "host", oHost }, 193 { "host", oHost },
194 { "escapechar", oEscapeChar }, 194 { "escapechar", oEscapeChar },
195 { "globalknownhostsfile", oGlobalKnownHostsFile }, 195 { "globalknownhostsfile", oGlobalKnownHostsFile },
196 { "globalknownhostsfile2", oGlobalKnownHostsFile2 }, /* obsolete */ 196 { "globalknownhostsfile2", oDeprecated },
197 { "userknownhostsfile", oUserKnownHostsFile }, 197 { "userknownhostsfile", oUserKnownHostsFile },
198 { "userknownhostsfile2", oUserKnownHostsFile2 }, /* obsolete */ 198 { "userknownhostsfile2", oDeprecated },
199 { "connectionattempts", oConnectionAttempts }, 199 { "connectionattempts", oConnectionAttempts },
200 { "batchmode", oBatchMode }, 200 { "batchmode", oBatchMode },
201 { "checkhostip", oCheckHostIP }, 201 { "checkhostip", oCheckHostIP },
@@ -354,7 +354,9 @@ process_config_line(Options *options, const char *host,
354 char *line, const char *filename, int linenum, 354 char *line, const char *filename, int linenum,
355 int *activep) 355 int *activep)
356{ 356{
357 char *s, **charptr, *endofnumber, *keyword, *arg, *arg2, fwdarg[256]; 357 char *s, **charptr, *endofnumber, *keyword, *arg, *arg2;
358 char **cpptr, fwdarg[256];
359 u_int *uintptr, max_entries = 0;
358 int negated, opcode, *intptr, value, value2, scale; 360 int negated, opcode, *intptr, value, value2, scale;
359 LogLevel *log_level_ptr; 361 LogLevel *log_level_ptr;
360 long long orig, val64; 362 long long orig, val64;
@@ -598,26 +600,33 @@ parse_yesnoask:
598parse_string: 600parse_string:
599 arg = strdelim(&s); 601 arg = strdelim(&s);
600 if (!arg || *arg == '\0') 602 if (!arg || *arg == '\0')
601 fatal("%.200s line %d: Missing argument.", filename, linenum); 603 fatal("%.200s line %d: Missing argument.",
604 filename, linenum);
602 if (*activep && *charptr == NULL) 605 if (*activep && *charptr == NULL)
603 *charptr = xstrdup(arg); 606 *charptr = xstrdup(arg);
604 break; 607 break;
605 608
606 case oGlobalKnownHostsFile: 609 case oGlobalKnownHostsFile:
607 charptr = &options->system_hostfile; 610 cpptr = (char **)&options->system_hostfiles;
608 goto parse_string; 611 uintptr = &options->num_system_hostfiles;
612 max_entries = SSH_MAX_HOSTS_FILES;
613parse_char_array:
614 if (*activep && *uintptr == 0) {
615 while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
616 if ((*uintptr) >= max_entries)
617 fatal("%s line %d: "
618 "too many authorized keys files.",
619 filename, linenum);
620 cpptr[(*uintptr)++] = xstrdup(arg);
621 }
622 }
623 return 0;
609 624
610 case oUserKnownHostsFile: 625 case oUserKnownHostsFile:
611 charptr = &options->user_hostfile; 626 cpptr = (char **)&options->user_hostfiles;
612 goto parse_string; 627 uintptr = &options->num_user_hostfiles;
613 628 max_entries = SSH_MAX_HOSTS_FILES;
614 case oGlobalKnownHostsFile2: 629 goto parse_char_array;
615 charptr = &options->system_hostfile2;
616 goto parse_string;
617
618 case oUserKnownHostsFile2:
619 charptr = &options->user_hostfile2;
620 goto parse_string;
621 630
622 case oHostName: 631 case oHostName:
623 charptr = &options->hostname; 632 charptr = &options->hostname;
@@ -1158,10 +1167,8 @@ initialize_options(Options * options)
1158 options->proxy_command = NULL; 1167 options->proxy_command = NULL;
1159 options->user = NULL; 1168 options->user = NULL;
1160 options->escape_char = -1; 1169 options->escape_char = -1;
1161 options->system_hostfile = NULL; 1170 options->num_system_hostfiles = 0;
1162 options->user_hostfile = NULL; 1171 options->num_user_hostfiles = 0;
1163 options->system_hostfile2 = NULL;
1164 options->user_hostfile2 = NULL;
1165 options->local_forwards = NULL; 1172 options->local_forwards = NULL;
1166 options->num_local_forwards = 0; 1173 options->num_local_forwards = 0;
1167 options->remote_forwards = NULL; 1174 options->remote_forwards = NULL;
@@ -1301,14 +1308,18 @@ fill_default_options(Options * options)
1301 } 1308 }
1302 if (options->escape_char == -1) 1309 if (options->escape_char == -1)
1303 options->escape_char = '~'; 1310 options->escape_char = '~';
1304 if (options->system_hostfile == NULL) 1311 if (options->num_system_hostfiles == 0) {
1305 options->system_hostfile = _PATH_SSH_SYSTEM_HOSTFILE; 1312 options->system_hostfiles[options->num_system_hostfiles++] =
1306 if (options->user_hostfile == NULL) 1313 xstrdup(_PATH_SSH_SYSTEM_HOSTFILE);
1307 options->user_hostfile = _PATH_SSH_USER_HOSTFILE; 1314 options->system_hostfiles[options->num_system_hostfiles++] =
1308 if (options->system_hostfile2 == NULL) 1315 xstrdup(_PATH_SSH_SYSTEM_HOSTFILE2);
1309 options->system_hostfile2 = _PATH_SSH_SYSTEM_HOSTFILE2; 1316 }
1310 if (options->user_hostfile2 == NULL) 1317 if (options->num_user_hostfiles == 0) {
1311 options->user_hostfile2 = _PATH_SSH_USER_HOSTFILE2; 1318 options->user_hostfiles[options->num_user_hostfiles++] =
1319 xstrdup(_PATH_SSH_USER_HOSTFILE);
1320 options->user_hostfiles[options->num_user_hostfiles++] =
1321 xstrdup(_PATH_SSH_USER_HOSTFILE2);
1322 }
1312 if (options->log_level == SYSLOG_LEVEL_NOT_SET) 1323 if (options->log_level == SYSLOG_LEVEL_NOT_SET)
1313 options->log_level = SYSLOG_LEVEL_INFO; 1324 options->log_level = SYSLOG_LEVEL_INFO;
1314 if (options->clear_forwardings == 1) 1325 if (options->clear_forwardings == 1)