summaryrefslogtreecommitdiff
path: root/readconf.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2017-03-29 01:35:00 +0100
committerColin Watson <cjwatson@debian.org>2017-03-29 01:35:00 +0100
commit6fabaf6fd9b07cc8bc6a17c9c4a5b76849cfc874 (patch)
treeb4377d09196e24e2c6f2c2128f66f92cf7891105 /readconf.c
parent971a7653746a6972b907dfe0ce139c06e4a6f482 (diff)
parentd38f05dbdd291212bc95ea80648b72b7177e9f4e (diff)
Import openssh_7.5p1.orig.tar.gz
Diffstat (limited to 'readconf.c')
-rw-r--r--readconf.c104
1 files changed, 66 insertions, 38 deletions
diff --git a/readconf.c b/readconf.c
index fa3fab8f0..9d59493f0 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.262 2016/10/25 04:08:13 jsg Exp $ */ 1/* $OpenBSD: readconf.c,v 1.270 2017/03/10 04:27:32 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
@@ -93,7 +93,7 @@
93 93
94 Host books.com 94 Host books.com
95 RemoteForward 9999 shadows.cs.hut.fi:9999 95 RemoteForward 9999 shadows.cs.hut.fi:9999
96 Cipher 3des 96 Ciphers 3des-cbc
97 97
98 Host fascist.blob.com 98 Host fascist.blob.com
99 Port 23123 99 Port 23123
@@ -108,7 +108,7 @@
108 PublicKeyAuthentication no 108 PublicKeyAuthentication no
109 109
110 Host *.su 110 Host *.su
111 Cipher none 111 Ciphers aes128-ctr
112 PasswordAuthentication no 112 PasswordAuthentication no
113 113
114 Host vpn.fake.com 114 Host vpn.fake.com
@@ -180,6 +180,44 @@ static struct {
180 const char *name; 180 const char *name;
181 OpCodes opcode; 181 OpCodes opcode;
182} keywords[] = { 182} keywords[] = {
183 /* Deprecated options */
184 { "fallbacktorsh", oDeprecated },
185 { "globalknownhostsfile2", oDeprecated },
186 { "rhostsauthentication", oDeprecated },
187 { "userknownhostsfile2", oDeprecated },
188 { "useroaming", oDeprecated },
189 { "usersh", oDeprecated },
190
191 /* Unsupported options */
192 { "afstokenpassing", oUnsupported },
193 { "kerberosauthentication", oUnsupported },
194 { "kerberostgtpassing", oUnsupported },
195
196 /* Sometimes-unsupported options */
197#if defined(GSSAPI)
198 { "gssapiauthentication", oGssAuthentication },
199 { "gssapidelegatecredentials", oGssDelegateCreds },
200# else
201 { "gssapiauthentication", oUnsupported },
202 { "gssapidelegatecredentials", oUnsupported },
203#endif
204#ifdef ENABLE_PKCS11
205 { "smartcarddevice", oPKCS11Provider },
206 { "pkcs11provider", oPKCS11Provider },
207# else
208 { "smartcarddevice", oUnsupported },
209 { "pkcs11provider", oUnsupported },
210#endif
211#ifdef WITH_SSH1
212 { "rsaauthentication", oRSAAuthentication },
213 { "rhostsrsaauthentication", oRhostsRSAAuthentication },
214 { "compressionlevel", oCompressionLevel },
215# else
216 { "rsaauthentication", oUnsupported },
217 { "rhostsrsaauthentication", oUnsupported },
218 { "compressionlevel", oUnsupported },
219#endif
220
183 { "forwardagent", oForwardAgent }, 221 { "forwardagent", oForwardAgent },
184 { "forwardx11", oForwardX11 }, 222 { "forwardx11", oForwardX11 },
185 { "forwardx11trusted", oForwardX11Trusted }, 223 { "forwardx11trusted", oForwardX11Trusted },
@@ -188,30 +226,15 @@ static struct {
188 { "xauthlocation", oXAuthLocation }, 226 { "xauthlocation", oXAuthLocation },
189 { "gatewayports", oGatewayPorts }, 227 { "gatewayports", oGatewayPorts },
190 { "useprivilegedport", oUsePrivilegedPort }, 228 { "useprivilegedport", oUsePrivilegedPort },
191 { "rhostsauthentication", oDeprecated },
192 { "passwordauthentication", oPasswordAuthentication }, 229 { "passwordauthentication", oPasswordAuthentication },
193 { "kbdinteractiveauthentication", oKbdInteractiveAuthentication }, 230 { "kbdinteractiveauthentication", oKbdInteractiveAuthentication },
194 { "kbdinteractivedevices", oKbdInteractiveDevices }, 231 { "kbdinteractivedevices", oKbdInteractiveDevices },
195 { "rsaauthentication", oRSAAuthentication },
196 { "pubkeyauthentication", oPubkeyAuthentication }, 232 { "pubkeyauthentication", oPubkeyAuthentication },
197 { "dsaauthentication", oPubkeyAuthentication }, /* alias */ 233 { "dsaauthentication", oPubkeyAuthentication }, /* alias */
198 { "rhostsrsaauthentication", oRhostsRSAAuthentication },
199 { "hostbasedauthentication", oHostbasedAuthentication }, 234 { "hostbasedauthentication", oHostbasedAuthentication },
200 { "challengeresponseauthentication", oChallengeResponseAuthentication }, 235 { "challengeresponseauthentication", oChallengeResponseAuthentication },
201 { "skeyauthentication", oChallengeResponseAuthentication }, /* alias */ 236 { "skeyauthentication", oChallengeResponseAuthentication }, /* alias */
202 { "tisauthentication", oChallengeResponseAuthentication }, /* alias */ 237 { "tisauthentication", oChallengeResponseAuthentication }, /* alias */
203 { "kerberosauthentication", oUnsupported },
204 { "kerberostgtpassing", oUnsupported },
205 { "afstokenpassing", oUnsupported },
206#if defined(GSSAPI)
207 { "gssapiauthentication", oGssAuthentication },
208 { "gssapidelegatecredentials", oGssDelegateCreds },
209#else
210 { "gssapiauthentication", oUnsupported },
211 { "gssapidelegatecredentials", oUnsupported },
212#endif
213 { "fallbacktorsh", oDeprecated },
214 { "usersh", oDeprecated },
215 { "identityfile", oIdentityFile }, 238 { "identityfile", oIdentityFile },
216 { "identityfile2", oIdentityFile }, /* obsolete */ 239 { "identityfile2", oIdentityFile }, /* obsolete */
217 { "identitiesonly", oIdentitiesOnly }, 240 { "identitiesonly", oIdentitiesOnly },
@@ -233,15 +256,12 @@ static struct {
233 { "match", oMatch }, 256 { "match", oMatch },
234 { "escapechar", oEscapeChar }, 257 { "escapechar", oEscapeChar },
235 { "globalknownhostsfile", oGlobalKnownHostsFile }, 258 { "globalknownhostsfile", oGlobalKnownHostsFile },
236 { "globalknownhostsfile2", oDeprecated },
237 { "userknownhostsfile", oUserKnownHostsFile }, 259 { "userknownhostsfile", oUserKnownHostsFile },
238 { "userknownhostsfile2", oDeprecated },
239 { "connectionattempts", oConnectionAttempts }, 260 { "connectionattempts", oConnectionAttempts },
240 { "batchmode", oBatchMode }, 261 { "batchmode", oBatchMode },
241 { "checkhostip", oCheckHostIP }, 262 { "checkhostip", oCheckHostIP },
242 { "stricthostkeychecking", oStrictHostKeyChecking }, 263 { "stricthostkeychecking", oStrictHostKeyChecking },
243 { "compression", oCompression }, 264 { "compression", oCompression },
244 { "compressionlevel", oCompressionLevel },
245 { "tcpkeepalive", oTCPKeepAlive }, 265 { "tcpkeepalive", oTCPKeepAlive },
246 { "keepalive", oTCPKeepAlive }, /* obsolete */ 266 { "keepalive", oTCPKeepAlive }, /* obsolete */
247 { "numberofpasswordprompts", oNumberOfPasswordPrompts }, 267 { "numberofpasswordprompts", oNumberOfPasswordPrompts },
@@ -250,13 +270,6 @@ static struct {
250 { "preferredauthentications", oPreferredAuthentications }, 270 { "preferredauthentications", oPreferredAuthentications },
251 { "hostkeyalgorithms", oHostKeyAlgorithms }, 271 { "hostkeyalgorithms", oHostKeyAlgorithms },
252 { "bindaddress", oBindAddress }, 272 { "bindaddress", oBindAddress },
253#ifdef ENABLE_PKCS11
254 { "smartcarddevice", oPKCS11Provider },
255 { "pkcs11provider", oPKCS11Provider },
256#else
257 { "smartcarddevice", oUnsupported },
258 { "pkcs11provider", oUnsupported },
259#endif
260 { "clearallforwardings", oClearAllForwardings }, 273 { "clearallforwardings", oClearAllForwardings },
261 { "enablesshkeysign", oEnableSSHKeysign }, 274 { "enablesshkeysign", oEnableSSHKeysign },
262 { "verifyhostkeydns", oVerifyHostKeyDNS }, 275 { "verifyhostkeydns", oVerifyHostKeyDNS },
@@ -277,7 +290,6 @@ static struct {
277 { "localcommand", oLocalCommand }, 290 { "localcommand", oLocalCommand },
278 { "permitlocalcommand", oPermitLocalCommand }, 291 { "permitlocalcommand", oPermitLocalCommand },
279 { "visualhostkey", oVisualHostKey }, 292 { "visualhostkey", oVisualHostKey },
280 { "useroaming", oDeprecated },
281 { "kexalgorithms", oKexAlgorithms }, 293 { "kexalgorithms", oKexAlgorithms },
282 { "ipqos", oIPQoS }, 294 { "ipqos", oIPQoS },
283 { "requesttty", oRequestTTY }, 295 { "requesttty", oRequestTTY },
@@ -830,11 +842,11 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
830 activep = &cmdline; 842 activep = &cmdline;
831 } 843 }
832 844
833 /* Strip trailing whitespace */ 845 /* Strip trailing whitespace. Allow \f (form feed) at EOL only */
834 if ((len = strlen(line)) == 0) 846 if ((len = strlen(line)) == 0)
835 return 0; 847 return 0;
836 for (len--; len > 0; len--) { 848 for (len--; len > 0; len--) {
837 if (strchr(WHITESPACE, line[len]) == NULL) 849 if (strchr(WHITESPACE "\f", line[len]) == NULL)
838 break; 850 break;
839 line[len] = '\0'; 851 line[len] = '\0';
840 } 852 }
@@ -1182,7 +1194,7 @@ parse_int:
1182 arg = strdelim(&s); 1194 arg = strdelim(&s);
1183 if (!arg || *arg == '\0') 1195 if (!arg || *arg == '\0')
1184 fatal("%.200s line %d: Missing argument.", filename, linenum); 1196 fatal("%.200s line %d: Missing argument.", filename, linenum);
1185 if (!ciphers_valid(*arg == '+' ? arg + 1 : arg)) 1197 if (*arg != '-' && !ciphers_valid(*arg == '+' ? arg + 1 : arg))
1186 fatal("%.200s line %d: Bad SSH2 cipher spec '%s'.", 1198 fatal("%.200s line %d: Bad SSH2 cipher spec '%s'.",
1187 filename, linenum, arg ? arg : "<NONE>"); 1199 filename, linenum, arg ? arg : "<NONE>");
1188 if (*activep && options->ciphers == NULL) 1200 if (*activep && options->ciphers == NULL)
@@ -1193,7 +1205,7 @@ parse_int:
1193 arg = strdelim(&s); 1205 arg = strdelim(&s);
1194 if (!arg || *arg == '\0') 1206 if (!arg || *arg == '\0')
1195 fatal("%.200s line %d: Missing argument.", filename, linenum); 1207 fatal("%.200s line %d: Missing argument.", filename, linenum);
1196 if (!mac_valid(*arg == '+' ? arg + 1 : arg)) 1208 if (*arg != '-' && !mac_valid(*arg == '+' ? arg + 1 : arg))
1197 fatal("%.200s line %d: Bad SSH2 Mac spec '%s'.", 1209 fatal("%.200s line %d: Bad SSH2 Mac spec '%s'.",
1198 filename, linenum, arg ? arg : "<NONE>"); 1210 filename, linenum, arg ? arg : "<NONE>");
1199 if (*activep && options->macs == NULL) 1211 if (*activep && options->macs == NULL)
@@ -1205,7 +1217,8 @@ parse_int:
1205 if (!arg || *arg == '\0') 1217 if (!arg || *arg == '\0')
1206 fatal("%.200s line %d: Missing argument.", 1218 fatal("%.200s line %d: Missing argument.",
1207 filename, linenum); 1219 filename, linenum);
1208 if (!kex_names_valid(*arg == '+' ? arg + 1 : arg)) 1220 if (*arg != '-' &&
1221 !kex_names_valid(*arg == '+' ? arg + 1 : arg))
1209 fatal("%.200s line %d: Bad SSH2 KexAlgorithms '%s'.", 1222 fatal("%.200s line %d: Bad SSH2 KexAlgorithms '%s'.",
1210 filename, linenum, arg ? arg : "<NONE>"); 1223 filename, linenum, arg ? arg : "<NONE>");
1211 if (*activep && options->kex_algorithms == NULL) 1224 if (*activep && options->kex_algorithms == NULL)
@@ -1219,7 +1232,8 @@ parse_keytypes:
1219 if (!arg || *arg == '\0') 1232 if (!arg || *arg == '\0')
1220 fatal("%.200s line %d: Missing argument.", 1233 fatal("%.200s line %d: Missing argument.",
1221 filename, linenum); 1234 filename, linenum);
1222 if (!sshkey_names_valid2(*arg == '+' ? arg + 1 : arg, 1)) 1235 if (*arg != '-' &&
1236 !sshkey_names_valid2(*arg == '+' ? arg + 1 : arg, 1))
1223 fatal("%s line %d: Bad key types '%s'.", 1237 fatal("%s line %d: Bad key types '%s'.",
1224 filename, linenum, arg ? arg : "<NONE>"); 1238 filename, linenum, arg ? arg : "<NONE>");
1225 if (*activep && *charptr == NULL) 1239 if (*activep && *charptr == NULL)
@@ -1486,6 +1500,7 @@ parse_keytypes:
1486 if (r == GLOB_NOMATCH) { 1500 if (r == GLOB_NOMATCH) {
1487 debug("%.200s line %d: include %s matched no " 1501 debug("%.200s line %d: include %s matched no "
1488 "files",filename, linenum, arg2); 1502 "files",filename, linenum, arg2);
1503 free(arg2);
1489 continue; 1504 continue;
1490 } else if (r != 0 || gl.gl_pathc < 0) 1505 } else if (r != 0 || gl.gl_pathc < 0)
1491 fatal("%.200s line %d: glob failed for %s.", 1506 fatal("%.200s line %d: glob failed for %s.",
@@ -1502,6 +1517,11 @@ parse_keytypes:
1502 flags | SSHCONF_CHECKPERM | 1517 flags | SSHCONF_CHECKPERM |
1503 (oactive ? 0 : SSHCONF_NEVERMATCH), 1518 (oactive ? 0 : SSHCONF_NEVERMATCH),
1504 activep, depth + 1); 1519 activep, depth + 1);
1520 if (r != 1 && errno != ENOENT) {
1521 fatal("Can't open user config file "
1522 "%.100s: %.100s", gl.gl_pathv[i],
1523 strerror(errno));
1524 }
1505 /* 1525 /*
1506 * don't let Match in includes clobber the 1526 * don't let Match in includes clobber the
1507 * containing file's Match state. 1527 * containing file's Match state.
@@ -1700,7 +1720,7 @@ read_config_file_depth(const char *filename, struct passwd *pw,
1700 int flags, int *activep, int depth) 1720 int flags, int *activep, int depth)
1701{ 1721{
1702 FILE *f; 1722 FILE *f;
1703 char line[1024]; 1723 char line[4096];
1704 int linenum; 1724 int linenum;
1705 int bad_options = 0; 1725 int bad_options = 0;
1706 1726
@@ -1730,6 +1750,8 @@ read_config_file_depth(const char *filename, struct passwd *pw,
1730 while (fgets(line, sizeof(line), f)) { 1750 while (fgets(line, sizeof(line), f)) {
1731 /* Update line number counter. */ 1751 /* Update line number counter. */
1732 linenum++; 1752 linenum++;
1753 if (strlen(line) == sizeof(line) - 1)
1754 fatal("%s line %d too long", filename, linenum);
1733 if (process_config_line_depth(options, pw, host, original_host, 1755 if (process_config_line_depth(options, pw, host, original_host,
1734 line, filename, linenum, activep, flags, depth) != 0) 1756 line, filename, linenum, activep, flags, depth) != 0)
1735 bad_options++; 1757 bad_options++;
@@ -2446,10 +2468,10 @@ dump_cfg_forwards(OpCodes code, u_int count, const struct Forward *fwds)
2446 /* oDynamicForward */ 2468 /* oDynamicForward */
2447 for (i = 0; i < count; i++) { 2469 for (i = 0; i < count; i++) {
2448 fwd = &fwds[i]; 2470 fwd = &fwds[i];
2449 if (code == oDynamicForward && 2471 if (code == oDynamicForward && fwd->connect_host != NULL &&
2450 strcmp(fwd->connect_host, "socks") != 0) 2472 strcmp(fwd->connect_host, "socks") != 0)
2451 continue; 2473 continue;
2452 if (code == oLocalForward && 2474 if (code == oLocalForward && fwd->connect_host != NULL &&
2453 strcmp(fwd->connect_host, "socks") == 0) 2475 strcmp(fwd->connect_host, "socks") == 0)
2454 continue; 2476 continue;
2455 printf("%s", lookup_opcode_name(code)); 2477 printf("%s", lookup_opcode_name(code));
@@ -2522,8 +2544,10 @@ dump_client_config(Options *o, const char *host)
2522 dump_cfg_fmtint(oProxyUseFdpass, o->proxy_use_fdpass); 2544 dump_cfg_fmtint(oProxyUseFdpass, o->proxy_use_fdpass);
2523 dump_cfg_fmtint(oPubkeyAuthentication, o->pubkey_authentication); 2545 dump_cfg_fmtint(oPubkeyAuthentication, o->pubkey_authentication);
2524 dump_cfg_fmtint(oRequestTTY, o->request_tty); 2546 dump_cfg_fmtint(oRequestTTY, o->request_tty);
2547#ifdef WITH_RSA1
2525 dump_cfg_fmtint(oRhostsRSAAuthentication, o->rhosts_rsa_authentication); 2548 dump_cfg_fmtint(oRhostsRSAAuthentication, o->rhosts_rsa_authentication);
2526 dump_cfg_fmtint(oRSAAuthentication, o->rsa_authentication); 2549 dump_cfg_fmtint(oRSAAuthentication, o->rsa_authentication);
2550#endif
2527 dump_cfg_fmtint(oStreamLocalBindUnlink, o->fwd_opts.streamlocal_bind_unlink); 2551 dump_cfg_fmtint(oStreamLocalBindUnlink, o->fwd_opts.streamlocal_bind_unlink);
2528 dump_cfg_fmtint(oStrictHostKeyChecking, o->strict_host_key_checking); 2552 dump_cfg_fmtint(oStrictHostKeyChecking, o->strict_host_key_checking);
2529 dump_cfg_fmtint(oTCPKeepAlive, o->tcp_keep_alive); 2553 dump_cfg_fmtint(oTCPKeepAlive, o->tcp_keep_alive);
@@ -2535,7 +2559,9 @@ dump_client_config(Options *o, const char *host)
2535 2559
2536 /* Integer options */ 2560 /* Integer options */
2537 dump_cfg_int(oCanonicalizeMaxDots, o->canonicalize_max_dots); 2561 dump_cfg_int(oCanonicalizeMaxDots, o->canonicalize_max_dots);
2562#ifdef WITH_SSH1
2538 dump_cfg_int(oCompressionLevel, o->compression_level); 2563 dump_cfg_int(oCompressionLevel, o->compression_level);
2564#endif
2539 dump_cfg_int(oConnectionAttempts, o->connection_attempts); 2565 dump_cfg_int(oConnectionAttempts, o->connection_attempts);
2540 dump_cfg_int(oForwardX11Timeout, o->forward_x11_timeout); 2566 dump_cfg_int(oForwardX11Timeout, o->forward_x11_timeout);
2541 dump_cfg_int(oNumberOfPasswordPrompts, o->number_of_password_prompts); 2567 dump_cfg_int(oNumberOfPasswordPrompts, o->number_of_password_prompts);
@@ -2555,7 +2581,9 @@ dump_client_config(Options *o, const char *host)
2555 dump_cfg_string(oLocalCommand, o->local_command); 2581 dump_cfg_string(oLocalCommand, o->local_command);
2556 dump_cfg_string(oLogLevel, log_level_name(o->log_level)); 2582 dump_cfg_string(oLogLevel, log_level_name(o->log_level));
2557 dump_cfg_string(oMacs, o->macs ? o->macs : KEX_CLIENT_MAC); 2583 dump_cfg_string(oMacs, o->macs ? o->macs : KEX_CLIENT_MAC);
2584#ifdef ENABLE_PKCS11
2558 dump_cfg_string(oPKCS11Provider, o->pkcs11_provider); 2585 dump_cfg_string(oPKCS11Provider, o->pkcs11_provider);
2586#endif
2559 dump_cfg_string(oPreferredAuthentications, o->preferred_authentications); 2587 dump_cfg_string(oPreferredAuthentications, o->preferred_authentications);
2560 dump_cfg_string(oPubkeyAcceptedKeyTypes, o->pubkey_key_types); 2588 dump_cfg_string(oPubkeyAcceptedKeyTypes, o->pubkey_key_types);
2561 dump_cfg_string(oRevokedHostKeys, o->revoked_host_keys); 2589 dump_cfg_string(oRevokedHostKeys, o->revoked_host_keys);