blob: 51b23a3b8ebddf0872dfd2dfcf14d9b1117f28f4 [file] [log] [blame]
Darren Tucker07636982013-05-16 20:30:03 +10001/* $OpenBSD: readconf.c,v 1.199 2013/05/16 04:27:50 djm Exp $ */
Damien Millerd4a8b7e1999-10-27 13:42:43 +10002/*
Damien Miller95def091999-11-25 00:26:21 +11003 * Author: Tatu Ylonen <ylo@cs.hut.fi>
Damien Miller95def091999-11-25 00:26:21 +11004 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * All rights reserved
Damien Miller95def091999-11-25 00:26:21 +11006 * Functions for reading the configuration files.
Damien Miller4af51302000-04-16 11:18:38 +10007 *
Damien Millere4340be2000-09-16 13:29:08 +11008 * As far as I am concerned, the code I have written for this software
9 * can be used freely for any purpose. Any derived versions of this
10 * software must be clearly marked as such, and if the derived work is
11 * incompatible with the protocol description in the RFC file, it must be
12 * called by a name other than "ssh" or "Secure Shell".
Damien Miller95def091999-11-25 00:26:21 +110013 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +100014
15#include "includes.h"
Damien Millerf17883e2006-03-15 11:45:54 +110016
17#include <sys/types.h>
18#include <sys/stat.h>
Damien Miller8ec8c3e2006-07-10 20:35:38 +100019#include <sys/socket.h>
20
21#include <netinet/in.h>
Damien Miller0dac6fb2010-11-20 15:19:38 +110022#include <netinet/in_systm.h>
23#include <netinet/ip.h>
Damien Millerd4a8b7e1999-10-27 13:42:43 +100024
Damien Millerc7b06362006-03-15 11:53:45 +110025#include <ctype.h>
Darren Tucker39972492006-07-12 22:22:46 +100026#include <errno.h>
Damien Millerb8fe89c2006-07-24 14:51:00 +100027#include <netdb.h>
Damien Millerd7834352006-08-05 12:39:39 +100028#include <signal.h>
Damien Millerded319c2006-09-01 15:38:36 +100029#include <stdarg.h>
Damien Millera7a73ee2006-08-05 11:37:59 +100030#include <stdio.h>
Damien Millere3476ed2006-07-24 14:13:33 +100031#include <string.h>
Damien Millere6b3b612006-07-24 14:01:23 +100032#include <unistd.h>
Damien Millerc7b06362006-03-15 11:53:45 +110033
Damien Millerd4a8b7e1999-10-27 13:42:43 +100034#include "xmalloc.h"
Damien Millerd7834352006-08-05 12:39:39 +100035#include "ssh.h"
Damien Miller78928792000-04-12 20:17:38 +100036#include "compat.h"
Ben Lindstrom226cfa02001-01-22 05:34:40 +000037#include "cipher.h"
38#include "pathnames.h"
39#include "log.h"
Damien Millerd7834352006-08-05 12:39:39 +100040#include "key.h"
Ben Lindstrom226cfa02001-01-22 05:34:40 +000041#include "readconf.h"
42#include "match.h"
43#include "misc.h"
Damien Millerd7834352006-08-05 12:39:39 +100044#include "buffer.h"
Ben Lindstrom06b33aa2001-02-15 03:01:59 +000045#include "kex.h"
46#include "mac.h"
Damien Millerd4a8b7e1999-10-27 13:42:43 +100047
48/* Format of the configuration file:
49
50 # Configuration data is parsed as follows:
51 # 1. command line options
52 # 2. user-specific file
53 # 3. system-wide file
54 # Any configuration value is only changed the first time it is set.
55 # Thus, host-specific definitions should be at the beginning of the
56 # configuration file, and defaults at the end.
57
58 # Host-specific declarations. These may override anything above. A single
59 # host may match multiple declarations; these are processed in the order
60 # that they are given in.
61
62 Host *.ngs.fi ngs.fi
Ben Lindstrom4daea862002-06-09 20:04:02 +000063 User foo
Damien Millerd4a8b7e1999-10-27 13:42:43 +100064
65 Host fake.com
66 HostName another.host.name.real.org
67 User blaah
68 Port 34289
69 ForwardX11 no
70 ForwardAgent no
71
72 Host books.com
73 RemoteForward 9999 shadows.cs.hut.fi:9999
74 Cipher 3des
75
76 Host fascist.blob.com
77 Port 23123
78 User tylonen
Damien Millerd4a8b7e1999-10-27 13:42:43 +100079 PasswordAuthentication no
80
81 Host puukko.hut.fi
82 User t35124p
83 ProxyCommand ssh-proxy %h %p
84
85 Host *.fr
Ben Lindstrom4daea862002-06-09 20:04:02 +000086 PublicKeyAuthentication no
Damien Millerd4a8b7e1999-10-27 13:42:43 +100087
88 Host *.su
89 Cipher none
90 PasswordAuthentication no
91
Damien Millerd27b9472005-12-13 19:29:02 +110092 Host vpn.fake.com
93 Tunnel yes
94 TunnelDevice 3
95
Damien Millerd4a8b7e1999-10-27 13:42:43 +100096 # Defaults for various options
97 Host *
98 ForwardAgent no
Damien Miller0bc1bd82000-11-13 22:57:25 +110099 ForwardX11 no
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000100 PasswordAuthentication yes
101 RSAAuthentication yes
102 RhostsRSAAuthentication yes
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000103 StrictHostKeyChecking yes
Damien Miller12c150e2003-12-17 16:31:10 +1100104 TcpKeepAlive no
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000105 IdentityFile ~/.ssh/identity
106 Port 22
107 EscapeChar ~
108
109*/
110
111/* Keyword tokens. */
112
Damien Miller95def091999-11-25 00:26:21 +1100113typedef enum {
114 oBadOption,
Damien Miller1ab6a512010-06-26 10:02:24 +1000115 oForwardAgent, oForwardX11, oForwardX11Trusted, oForwardX11Timeout,
116 oGatewayPorts, oExitOnForwardFailure,
Ben Lindstromcb72e4f2002-06-21 00:41:51 +0000117 oPasswordAuthentication, oRSAAuthentication,
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +0000118 oChallengeResponseAuthentication, oXAuthLocation,
Damien Miller95def091999-11-25 00:26:21 +1100119 oIdentityFile, oHostName, oPort, oCipher, oRemoteForward, oLocalForward,
120 oUser, oHost, oEscapeChar, oRhostsRSAAuthentication, oProxyCommand,
121 oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts,
122 oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression,
Damien Miller12c150e2003-12-17 16:31:10 +1100123 oCompressionLevel, oTCPKeepAlive, oNumberOfPasswordPrompts,
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000124 oUsePrivilegedPort, oLogLevel, oCiphers, oProtocol, oMacs,
Damien Miller0bc1bd82000-11-13 22:57:25 +1100125 oGlobalKnownHostsFile2, oUserKnownHostsFile2, oPubkeyAuthentication,
Ben Lindstromb9be60a2001-03-11 01:49:19 +0000126 oKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias,
Ben Lindstrom982dbbc2001-04-17 18:11:36 +0000127 oDynamicForward, oPreferredAuthentications, oHostbasedAuthentication,
Damien Miller7ea845e2010-02-12 09:21:02 +1100128 oHostKeyAlgorithms, oBindAddress, oPKCS11Provider,
Ben Lindstrom4daea862002-06-09 20:04:02 +0000129 oClearAllForwardings, oNoHostAuthenticationForLocalhost,
Damien Millerb78d5eb2003-05-16 11:39:04 +1000130 oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,
Darren Tucker0efd1552003-08-26 11:49:55 +1000131 oAddressFamily, oGssAuthentication, oGssDelegateCreds,
Damien Millerbd394c32004-03-08 23:12:36 +1100132 oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
Damien Millere11e1ea2010-08-03 16:04:46 +1000133 oSendEnv, oControlPath, oControlMaster, oControlPersist,
134 oHashKnownHosts,
Damien Millerd27b9472005-12-13 19:29:02 +1100135 oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand,
Darren Tucker7bd98e72010-01-10 10:31:12 +1100136 oVisualHostKey, oUseRoaming, oZeroKnowledgePasswordAuthentication,
Darren Tucker07636982013-05-16 20:30:03 +1000137 oKexAlgorithms, oIPQoS, oRequestTTY, oIgnoreUnknown,
138 oIgnoredUnknownOption, oDeprecated, oUnsupported
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000139} OpCodes;
140
141/* Textual representations of the tokens. */
142
Damien Miller95def091999-11-25 00:26:21 +1100143static struct {
144 const char *name;
145 OpCodes opcode;
146} keywords[] = {
147 { "forwardagent", oForwardAgent },
148 { "forwardx11", oForwardX11 },
Darren Tucker0a118da2003-10-15 15:54:32 +1000149 { "forwardx11trusted", oForwardX11Trusted },
Damien Miller1ab6a512010-06-26 10:02:24 +1000150 { "forwardx11timeout", oForwardX11Timeout },
Darren Tuckere7d4b192006-07-12 22:17:10 +1000151 { "exitonforwardfailure", oExitOnForwardFailure },
Damien Millerd3a18572000-06-07 19:55:44 +1000152 { "xauthlocation", oXAuthLocation },
Damien Miller95def091999-11-25 00:26:21 +1100153 { "gatewayports", oGatewayPorts },
154 { "useprivilegedport", oUsePrivilegedPort },
Darren Tuckerec960f22003-08-13 20:37:05 +1000155 { "rhostsauthentication", oDeprecated },
Damien Miller95def091999-11-25 00:26:21 +1100156 { "passwordauthentication", oPasswordAuthentication },
Damien Miller874d77b2000-10-14 16:23:11 +1100157 { "kbdinteractiveauthentication", oKbdInteractiveAuthentication },
158 { "kbdinteractivedevices", oKbdInteractiveDevices },
Damien Miller95def091999-11-25 00:26:21 +1100159 { "rsaauthentication", oRSAAuthentication },
Damien Miller0bc1bd82000-11-13 22:57:25 +1100160 { "pubkeyauthentication", oPubkeyAuthentication },
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +0000161 { "dsaauthentication", oPubkeyAuthentication }, /* alias */
Ben Lindstrom5eabda32001-04-12 23:34:34 +0000162 { "rhostsrsaauthentication", oRhostsRSAAuthentication },
Ben Lindstromd69dab32001-04-12 23:36:05 +0000163 { "hostbasedauthentication", oHostbasedAuthentication },
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +0000164 { "challengeresponseauthentication", oChallengeResponseAuthentication },
165 { "skeyauthentication", oChallengeResponseAuthentication }, /* alias */
166 { "tisauthentication", oChallengeResponseAuthentication }, /* alias */
Damien Millerf9b3feb2003-05-16 11:38:32 +1000167 { "kerberosauthentication", oUnsupported },
168 { "kerberostgtpassing", oUnsupported },
Damien Millerf9b3feb2003-05-16 11:38:32 +1000169 { "afstokenpassing", oUnsupported },
Darren Tucker0efd1552003-08-26 11:49:55 +1000170#if defined(GSSAPI)
171 { "gssapiauthentication", oGssAuthentication },
Darren Tucker0efd1552003-08-26 11:49:55 +1000172 { "gssapidelegatecredentials", oGssDelegateCreds },
173#else
174 { "gssapiauthentication", oUnsupported },
175 { "gssapidelegatecredentials", oUnsupported },
176#endif
Ben Lindstrom4daea862002-06-09 20:04:02 +0000177 { "fallbacktorsh", oDeprecated },
178 { "usersh", oDeprecated },
Damien Miller95def091999-11-25 00:26:21 +1100179 { "identityfile", oIdentityFile },
Damien Miller5bc6aae2009-01-28 16:27:31 +1100180 { "identityfile2", oIdentityFile }, /* obsolete */
Damien Millerbd394c32004-03-08 23:12:36 +1100181 { "identitiesonly", oIdentitiesOnly },
Damien Miller95def091999-11-25 00:26:21 +1100182 { "hostname", oHostName },
Ben Lindstrom4dccfa52000-12-28 16:40:05 +0000183 { "hostkeyalias", oHostKeyAlias },
Damien Miller95def091999-11-25 00:26:21 +1100184 { "proxycommand", oProxyCommand },
185 { "port", oPort },
186 { "cipher", oCipher },
Damien Miller78928792000-04-12 20:17:38 +1000187 { "ciphers", oCiphers },
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000188 { "macs", oMacs },
Damien Miller78928792000-04-12 20:17:38 +1000189 { "protocol", oProtocol },
Damien Miller95def091999-11-25 00:26:21 +1100190 { "remoteforward", oRemoteForward },
191 { "localforward", oLocalForward },
192 { "user", oUser },
193 { "host", oHost },
194 { "escapechar", oEscapeChar },
Damien Miller95def091999-11-25 00:26:21 +1100195 { "globalknownhostsfile", oGlobalKnownHostsFile },
Damien Miller295ee632011-05-29 21:42:31 +1000196 { "globalknownhostsfile2", oDeprecated },
Damien Miller5bc6aae2009-01-28 16:27:31 +1100197 { "userknownhostsfile", oUserKnownHostsFile },
Damien Miller295ee632011-05-29 21:42:31 +1000198 { "userknownhostsfile2", oDeprecated },
Damien Miller95def091999-11-25 00:26:21 +1100199 { "connectionattempts", oConnectionAttempts },
200 { "batchmode", oBatchMode },
201 { "checkhostip", oCheckHostIP },
202 { "stricthostkeychecking", oStrictHostKeyChecking },
203 { "compression", oCompression },
204 { "compressionlevel", oCompressionLevel },
Damien Miller12c150e2003-12-17 16:31:10 +1100205 { "tcpkeepalive", oTCPKeepAlive },
206 { "keepalive", oTCPKeepAlive }, /* obsolete */
Damien Miller95def091999-11-25 00:26:21 +1100207 { "numberofpasswordprompts", oNumberOfPasswordPrompts },
Damien Miller95def091999-11-25 00:26:21 +1100208 { "loglevel", oLogLevel },
Ben Lindstrom3bb4f9d2001-04-08 18:30:26 +0000209 { "dynamicforward", oDynamicForward },
Ben Lindstromb9be60a2001-03-11 01:49:19 +0000210 { "preferredauthentications", oPreferredAuthentications },
Ben Lindstrom982dbbc2001-04-17 18:11:36 +0000211 { "hostkeyalgorithms", oHostKeyAlgorithms },
Ben Lindstrome0f88042001-04-30 13:06:24 +0000212 { "bindaddress", oBindAddress },
Damien Miller7ea845e2010-02-12 09:21:02 +1100213#ifdef ENABLE_PKCS11
214 { "smartcarddevice", oPKCS11Provider },
215 { "pkcs11provider", oPKCS11Provider },
Damien Millerf9b3feb2003-05-16 11:38:32 +1000216#else
217 { "smartcarddevice", oUnsupported },
Damien Miller7ea845e2010-02-12 09:21:02 +1100218 { "pkcs11provider", oUnsupported },
Damien Millerf9b3feb2003-05-16 11:38:32 +1000219#endif
Damien Miller9f0f5c62001-12-21 14:45:46 +1100220 { "clearallforwardings", oClearAllForwardings },
Ben Lindstromb6df73b2002-11-09 15:52:31 +0000221 { "enablesshkeysign", oEnableSSHKeysign },
Damien Miller37876e92003-05-15 10:19:46 +1000222 { "verifyhostkeydns", oVerifyHostKeyDNS },
Damien Miller9f0f5c62001-12-21 14:45:46 +1100223 { "nohostauthenticationforlocalhost", oNoHostAuthenticationForLocalhost },
Damien Millera5539d22003-04-09 20:50:06 +1000224 { "rekeylimit", oRekeyLimit },
Damien Millerb78d5eb2003-05-16 11:39:04 +1000225 { "connecttimeout", oConnectTimeout },
Damien Miller20a8f972003-05-18 20:50:30 +1000226 { "addressfamily", oAddressFamily },
Damien Miller509b0102003-12-17 16:33:10 +1100227 { "serveraliveinterval", oServerAliveInterval },
228 { "serveralivecountmax", oServerAliveCountMax },
Darren Tucker46bc0752004-05-02 22:11:30 +1000229 { "sendenv", oSendEnv },
Damien Miller0e220db2004-06-15 10:34:08 +1000230 { "controlpath", oControlPath },
231 { "controlmaster", oControlMaster },
Damien Millere11e1ea2010-08-03 16:04:46 +1000232 { "controlpersist", oControlPersist },
Damien Millere1776152005-03-01 21:47:37 +1100233 { "hashknownhosts", oHashKnownHosts },
Damien Millerd27b9472005-12-13 19:29:02 +1100234 { "tunnel", oTunnel },
235 { "tunneldevice", oTunnelDevice },
236 { "localcommand", oLocalCommand },
237 { "permitlocalcommand", oPermitLocalCommand },
Damien Miller10288242008-06-30 00:04:03 +1000238 { "visualhostkey", oVisualHostKey },
Darren Tucker71e4d542009-07-06 07:12:27 +1000239 { "useroaming", oUseRoaming },
Damien Miller01ed2272008-11-05 16:20:46 +1100240#ifdef JPAKE
241 { "zeroknowledgepasswordauthentication",
242 oZeroKnowledgePasswordAuthentication },
243#else
244 { "zeroknowledgepasswordauthentication", oUnsupported },
245#endif
Damien Millerd5f62bf2010-09-24 22:11:14 +1000246 { "kexalgorithms", oKexAlgorithms },
Damien Miller0dac6fb2010-11-20 15:19:38 +1100247 { "ipqos", oIPQoS },
Damien Miller21771e22011-05-15 08:45:50 +1000248 { "requesttty", oRequestTTY },
Darren Tucker07636982013-05-16 20:30:03 +1000249 { "ignoreunknown", oIgnoreUnknown },
Damien Miller01ed2272008-11-05 16:20:46 +1100250
Ben Lindstrom65366a82001-12-06 16:32:47 +0000251 { NULL, oBadOption }
Damien Miller5ce662a1999-11-11 17:57:39 +1100252};
253
Damien Miller5428f641999-11-25 11:54:57 +1100254/*
255 * Adds a local TCP/IP port forward to options. Never returns if there is an
256 * error.
257 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000258
Damien Miller4af51302000-04-16 11:18:38 +1000259void
Damien Millerf91ee4c2005-03-01 21:24:33 +1100260add_local_forward(Options *options, const Forward *newfwd)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000261{
Damien Miller95def091999-11-25 00:26:21 +1100262 Forward *fwd;
Ben Lindstrom99a4e142002-07-09 14:06:40 +0000263#ifndef NO_IPPORT_RESERVED_CONCEPT
Damien Miller95def091999-11-25 00:26:21 +1100264 extern uid_t original_real_uid;
Damien Millerf91ee4c2005-03-01 21:24:33 +1100265 if (newfwd->listen_port < IPPORT_RESERVED && original_real_uid != 0)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000266 fatal("Privileged ports can only be forwarded by root.");
Damien Millerbac2d8a2000-09-05 16:13:06 +1100267#endif
Damien Miller232cfb12010-06-26 09:50:30 +1000268 options->local_forwards = xrealloc(options->local_forwards,
269 options->num_local_forwards + 1,
270 sizeof(*options->local_forwards));
Damien Miller95def091999-11-25 00:26:21 +1100271 fwd = &options->local_forwards[options->num_local_forwards++];
Damien Millerf91ee4c2005-03-01 21:24:33 +1100272
Damien Miller1a0442f2008-11-05 16:30:06 +1100273 fwd->listen_host = newfwd->listen_host;
Damien Millerf91ee4c2005-03-01 21:24:33 +1100274 fwd->listen_port = newfwd->listen_port;
Damien Miller1a0442f2008-11-05 16:30:06 +1100275 fwd->connect_host = newfwd->connect_host;
Damien Millerf91ee4c2005-03-01 21:24:33 +1100276 fwd->connect_port = newfwd->connect_port;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000277}
278
Damien Miller5428f641999-11-25 11:54:57 +1100279/*
280 * Adds a remote TCP/IP port forward to options. Never returns if there is
281 * an error.
282 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000283
Damien Miller4af51302000-04-16 11:18:38 +1000284void
Damien Millerf91ee4c2005-03-01 21:24:33 +1100285add_remote_forward(Options *options, const Forward *newfwd)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000286{
Damien Miller95def091999-11-25 00:26:21 +1100287 Forward *fwd;
Damien Miller232cfb12010-06-26 09:50:30 +1000288
289 options->remote_forwards = xrealloc(options->remote_forwards,
290 options->num_remote_forwards + 1,
291 sizeof(*options->remote_forwards));
Damien Miller95def091999-11-25 00:26:21 +1100292 fwd = &options->remote_forwards[options->num_remote_forwards++];
Damien Millerf91ee4c2005-03-01 21:24:33 +1100293
Damien Miller1a0442f2008-11-05 16:30:06 +1100294 fwd->listen_host = newfwd->listen_host;
Damien Millerf91ee4c2005-03-01 21:24:33 +1100295 fwd->listen_port = newfwd->listen_port;
Damien Miller1a0442f2008-11-05 16:30:06 +1100296 fwd->connect_host = newfwd->connect_host;
Damien Millerf91ee4c2005-03-01 21:24:33 +1100297 fwd->connect_port = newfwd->connect_port;
Darren Tucker68afb8c2011-10-02 18:59:03 +1100298 fwd->handle = newfwd->handle;
Damien Miller388f6fc2010-05-21 14:57:35 +1000299 fwd->allocated_port = 0;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000300}
301
Ben Lindstrom2b7a0e92001-09-20 00:57:55 +0000302static void
303clear_forwardings(Options *options)
304{
305 int i;
306
Damien Millerf91ee4c2005-03-01 21:24:33 +1100307 for (i = 0; i < options->num_local_forwards; i++) {
Darren Tucker1d55ca72005-03-14 22:58:40 +1100308 if (options->local_forwards[i].listen_host != NULL)
309 xfree(options->local_forwards[i].listen_host);
Damien Millerf91ee4c2005-03-01 21:24:33 +1100310 xfree(options->local_forwards[i].connect_host);
311 }
Damien Miller232cfb12010-06-26 09:50:30 +1000312 if (options->num_local_forwards > 0) {
313 xfree(options->local_forwards);
314 options->local_forwards = NULL;
315 }
Ben Lindstrom2b7a0e92001-09-20 00:57:55 +0000316 options->num_local_forwards = 0;
Damien Millerf91ee4c2005-03-01 21:24:33 +1100317 for (i = 0; i < options->num_remote_forwards; i++) {
Darren Tucker1d55ca72005-03-14 22:58:40 +1100318 if (options->remote_forwards[i].listen_host != NULL)
319 xfree(options->remote_forwards[i].listen_host);
Damien Millerf91ee4c2005-03-01 21:24:33 +1100320 xfree(options->remote_forwards[i].connect_host);
321 }
Damien Miller232cfb12010-06-26 09:50:30 +1000322 if (options->num_remote_forwards > 0) {
323 xfree(options->remote_forwards);
324 options->remote_forwards = NULL;
325 }
Ben Lindstrom2b7a0e92001-09-20 00:57:55 +0000326 options->num_remote_forwards = 0;
Damien Miller7b58e802005-12-13 19:33:19 +1100327 options->tun_open = SSH_TUNMODE_NO;
Ben Lindstrom2b7a0e92001-09-20 00:57:55 +0000328}
329
Darren Tucker19104782013-04-05 11:13:08 +1100330void
331add_identity_file(Options *options, const char *dir, const char *filename,
332 int userprovided)
333{
334 char *path;
335
336 if (options->num_identity_files >= SSH_MAX_IDENTITY_FILES)
337 fatal("Too many identity files specified (max %d)",
338 SSH_MAX_IDENTITY_FILES);
339
340 if (dir == NULL) /* no dir, filename is absolute */
341 path = xstrdup(filename);
342 else
343 (void)xasprintf(&path, "%.100s%.100s", dir, filename);
344
345 options->identity_file_userprovided[options->num_identity_files] =
346 userprovided;
347 options->identity_files[options->num_identity_files++] = path;
348}
349
Damien Miller5428f641999-11-25 11:54:57 +1100350/*
Ben Lindstrom3704c262001-04-02 18:20:03 +0000351 * Returns the number of the token pointed to by cp or oBadOption.
Damien Miller5428f641999-11-25 11:54:57 +1100352 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000353
Damien Miller4af51302000-04-16 11:18:38 +1000354static OpCodes
Darren Tucker07636982013-05-16 20:30:03 +1000355parse_token(const char *cp, const char *filename, int linenum,
356 const char *ignored_unknown)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000357{
Darren Tucker07636982013-05-16 20:30:03 +1000358 int i;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000359
Damien Miller95def091999-11-25 00:26:21 +1100360 for (i = 0; keywords[i].name; i++)
Darren Tucker07636982013-05-16 20:30:03 +1000361 if (strcmp(cp, keywords[i].name) == 0)
Damien Miller95def091999-11-25 00:26:21 +1100362 return keywords[i].opcode;
Darren Tucker07636982013-05-16 20:30:03 +1000363 if (ignored_unknown != NULL && match_pattern_list(cp, ignored_unknown,
364 strlen(ignored_unknown), 1) == 1)
365 return oIgnoredUnknownOption;
Ben Lindstromb5cdc662001-04-16 02:13:26 +0000366 error("%s: line %d: Bad configuration option: %s",
367 filename, linenum, cp);
Damien Miller95def091999-11-25 00:26:21 +1100368 return oBadOption;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000369}
370
Damien Miller5428f641999-11-25 11:54:57 +1100371/*
372 * Processes a single option line as used in the configuration files. This
373 * only sets those values that have not already been set.
374 */
Damien Miller61f08ac2003-02-24 11:56:27 +1100375#define WHITESPACE " \t\r\n"
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000376
Damien Miller2ccf6611999-11-15 15:25:10 +1100377int
378process_config_line(Options *options, const char *host,
Damien Miller95def091999-11-25 00:26:21 +1100379 char *line, const char *filename, int linenum,
Darren Tuckeraefa3682013-04-05 11:18:35 +1100380 int *activep, int userconfig)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000381{
Damien Miller295ee632011-05-29 21:42:31 +1000382 char *s, **charptr, *endofnumber, *keyword, *arg, *arg2;
383 char **cpptr, fwdarg[256];
Darren Tucker07636982013-05-16 20:30:03 +1000384 u_int i, *uintptr, max_entries = 0;
Damien Millerfe924212011-05-15 08:44:45 +1000385 int negated, opcode, *intptr, value, value2, scale;
Darren Tucker1e44c5d2008-01-01 20:32:26 +1100386 LogLevel *log_level_ptr;
Damien Millerb59d4fe2006-03-15 11:30:38 +1100387 long long orig, val64;
Damien Miller61f08ac2003-02-24 11:56:27 +1100388 size_t len;
Damien Millerf91ee4c2005-03-01 21:24:33 +1100389 Forward fwd;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000390
Damien Millerc652cac2003-05-14 13:40:54 +1000391 /* Strip trailing whitespace */
Darren Tucker47eede72005-03-14 23:08:12 +1100392 for (len = strlen(line) - 1; len > 0; len--) {
Damien Millerc652cac2003-05-14 13:40:54 +1000393 if (strchr(WHITESPACE, line[len]) == NULL)
394 break;
395 line[len] = '\0';
396 }
397
Damien Millerbe484b52000-07-15 14:14:16 +1000398 s = line;
399 /* Get the keyword. (Each line is supposed to begin with a keyword). */
Damien Miller928b2362006-03-26 13:53:32 +1100400 if ((keyword = strdelim(&s)) == NULL)
401 return 0;
Damien Millerbe484b52000-07-15 14:14:16 +1000402 /* Ignore leading whitespace. */
403 if (*keyword == '\0')
404 keyword = strdelim(&s);
Ben Lindstrom226cfa02001-01-22 05:34:40 +0000405 if (keyword == NULL || !*keyword || *keyword == '\n' || *keyword == '#')
Damien Miller95def091999-11-25 00:26:21 +1100406 return 0;
Darren Tucker07636982013-05-16 20:30:03 +1000407 /* Match lowercase keyword */
408 for (i = 0; i < strlen(keyword); i++)
409 keyword[i] = tolower(keyword[i]);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000410
Darren Tucker07636982013-05-16 20:30:03 +1000411 opcode = parse_token(keyword, filename, linenum,
412 options->ignored_unknown);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000413
Damien Miller95def091999-11-25 00:26:21 +1100414 switch (opcode) {
415 case oBadOption:
Damien Miller5428f641999-11-25 11:54:57 +1100416 /* don't panic, but count bad options */
417 return -1;
Damien Miller95def091999-11-25 00:26:21 +1100418 /* NOTREACHED */
Darren Tucker07636982013-05-16 20:30:03 +1000419 case oIgnoredUnknownOption:
420 debug("%s line %d: Ignored unknown option \"%s\"",
421 filename, linenum, keyword);
422 return 0;
Damien Millerb78d5eb2003-05-16 11:39:04 +1000423 case oConnectTimeout:
424 intptr = &options->connection_timeout;
Damien Miller509b0102003-12-17 16:33:10 +1100425parse_time:
Damien Millerb78d5eb2003-05-16 11:39:04 +1000426 arg = strdelim(&s);
427 if (!arg || *arg == '\0')
428 fatal("%s line %d: missing time value.",
429 filename, linenum);
430 if ((value = convtime(arg)) == -1)
431 fatal("%s line %d: invalid time value.",
432 filename, linenum);
Darren Tuckera52c5b62007-02-19 22:09:45 +1100433 if (*activep && *intptr == -1)
Damien Millerb78d5eb2003-05-16 11:39:04 +1000434 *intptr = value;
435 break;
436
Damien Miller95def091999-11-25 00:26:21 +1100437 case oForwardAgent:
438 intptr = &options->forward_agent;
439parse_flag:
Damien Millerbe484b52000-07-15 14:14:16 +1000440 arg = strdelim(&s);
Damien Miller37023962000-07-11 17:31:38 +1000441 if (!arg || *arg == '\0')
Damien Miller95def091999-11-25 00:26:21 +1100442 fatal("%.200s line %d: Missing yes/no argument.", filename, linenum);
443 value = 0; /* To avoid compiler warning... */
Damien Miller37023962000-07-11 17:31:38 +1000444 if (strcmp(arg, "yes") == 0 || strcmp(arg, "true") == 0)
Damien Miller95def091999-11-25 00:26:21 +1100445 value = 1;
Damien Miller37023962000-07-11 17:31:38 +1000446 else if (strcmp(arg, "no") == 0 || strcmp(arg, "false") == 0)
Damien Miller95def091999-11-25 00:26:21 +1100447 value = 0;
448 else
449 fatal("%.200s line %d: Bad yes/no argument.", filename, linenum);
450 if (*activep && *intptr == -1)
451 *intptr = value;
452 break;
453
454 case oForwardX11:
455 intptr = &options->forward_x11;
456 goto parse_flag;
457
Darren Tucker0a118da2003-10-15 15:54:32 +1000458 case oForwardX11Trusted:
459 intptr = &options->forward_x11_trusted;
460 goto parse_flag;
Damien Miller1ab6a512010-06-26 10:02:24 +1000461
462 case oForwardX11Timeout:
463 intptr = &options->forward_x11_timeout;
464 goto parse_time;
Darren Tucker0a118da2003-10-15 15:54:32 +1000465
Damien Miller95def091999-11-25 00:26:21 +1100466 case oGatewayPorts:
467 intptr = &options->gateway_ports;
468 goto parse_flag;
469
Darren Tuckere7d4b192006-07-12 22:17:10 +1000470 case oExitOnForwardFailure:
471 intptr = &options->exit_on_forward_failure;
472 goto parse_flag;
473
Damien Miller95def091999-11-25 00:26:21 +1100474 case oUsePrivilegedPort:
475 intptr = &options->use_privileged_port;
476 goto parse_flag;
477
Damien Miller95def091999-11-25 00:26:21 +1100478 case oPasswordAuthentication:
479 intptr = &options->password_authentication;
480 goto parse_flag;
481
Damien Miller01ed2272008-11-05 16:20:46 +1100482 case oZeroKnowledgePasswordAuthentication:
483 intptr = &options->zero_knowledge_password_authentication;
484 goto parse_flag;
485
Damien Miller874d77b2000-10-14 16:23:11 +1100486 case oKbdInteractiveAuthentication:
487 intptr = &options->kbd_interactive_authentication;
488 goto parse_flag;
489
490 case oKbdInteractiveDevices:
491 charptr = &options->kbd_interactive_devices;
492 goto parse_string;
493
Damien Miller0bc1bd82000-11-13 22:57:25 +1100494 case oPubkeyAuthentication:
495 intptr = &options->pubkey_authentication;
Damien Millere247cc42000-05-07 12:03:14 +1000496 goto parse_flag;
497
Damien Miller95def091999-11-25 00:26:21 +1100498 case oRSAAuthentication:
499 intptr = &options->rsa_authentication;
500 goto parse_flag;
501
502 case oRhostsRSAAuthentication:
503 intptr = &options->rhosts_rsa_authentication;
504 goto parse_flag;
505
Ben Lindstrom5eabda32001-04-12 23:34:34 +0000506 case oHostbasedAuthentication:
507 intptr = &options->hostbased_authentication;
508 goto parse_flag;
509
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +0000510 case oChallengeResponseAuthentication:
Ben Lindstrom551ea372001-06-05 18:56:16 +0000511 intptr = &options->challenge_response_authentication;
Damien Miller95def091999-11-25 00:26:21 +1100512 goto parse_flag;
Damien Miller2aa0ab42003-05-15 12:05:28 +1000513
Darren Tucker0efd1552003-08-26 11:49:55 +1000514 case oGssAuthentication:
515 intptr = &options->gss_authentication;
516 goto parse_flag;
517
518 case oGssDelegateCreds:
519 intptr = &options->gss_deleg_creds;
520 goto parse_flag;
521
Damien Miller95def091999-11-25 00:26:21 +1100522 case oBatchMode:
523 intptr = &options->batch_mode;
524 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000525
Damien Miller95def091999-11-25 00:26:21 +1100526 case oCheckHostIP:
527 intptr = &options->check_host_ip;
Damien Miller10288242008-06-30 00:04:03 +1000528 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000529
Damien Miller37876e92003-05-15 10:19:46 +1000530 case oVerifyHostKeyDNS:
531 intptr = &options->verify_host_key_dns;
Damien Miller150b5572003-11-17 21:19:29 +1100532 goto parse_yesnoask;
Damien Miller37876e92003-05-15 10:19:46 +1000533
Damien Miller95def091999-11-25 00:26:21 +1100534 case oStrictHostKeyChecking:
535 intptr = &options->strict_host_key_checking;
Damien Miller150b5572003-11-17 21:19:29 +1100536parse_yesnoask:
Damien Millerbe484b52000-07-15 14:14:16 +1000537 arg = strdelim(&s);
Damien Miller37023962000-07-11 17:31:38 +1000538 if (!arg || *arg == '\0')
Ben Lindstrom5ed8acd2001-01-29 08:00:54 +0000539 fatal("%.200s line %d: Missing yes/no/ask argument.",
Damien Miller9f0f5c62001-12-21 14:45:46 +1100540 filename, linenum);
Damien Miller95def091999-11-25 00:26:21 +1100541 value = 0; /* To avoid compiler warning... */
Damien Miller37023962000-07-11 17:31:38 +1000542 if (strcmp(arg, "yes") == 0 || strcmp(arg, "true") == 0)
Damien Miller95def091999-11-25 00:26:21 +1100543 value = 1;
Damien Miller37023962000-07-11 17:31:38 +1000544 else if (strcmp(arg, "no") == 0 || strcmp(arg, "false") == 0)
Damien Miller95def091999-11-25 00:26:21 +1100545 value = 0;
Damien Miller37023962000-07-11 17:31:38 +1000546 else if (strcmp(arg, "ask") == 0)
Damien Miller95def091999-11-25 00:26:21 +1100547 value = 2;
548 else
549 fatal("%.200s line %d: Bad yes/no/ask argument.", filename, linenum);
550 if (*activep && *intptr == -1)
551 *intptr = value;
552 break;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000553
Damien Miller95def091999-11-25 00:26:21 +1100554 case oCompression:
555 intptr = &options->compression;
556 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000557
Damien Miller12c150e2003-12-17 16:31:10 +1100558 case oTCPKeepAlive:
559 intptr = &options->tcp_keep_alive;
Damien Miller95def091999-11-25 00:26:21 +1100560 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000561
Ben Lindstrom3cecc9a2001-10-03 17:39:38 +0000562 case oNoHostAuthenticationForLocalhost:
563 intptr = &options->no_host_authentication_for_localhost;
564 goto parse_flag;
565
Damien Miller95def091999-11-25 00:26:21 +1100566 case oNumberOfPasswordPrompts:
567 intptr = &options->number_of_password_prompts;
568 goto parse_int;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000569
Damien Miller95def091999-11-25 00:26:21 +1100570 case oCompressionLevel:
571 intptr = &options->compression_level;
572 goto parse_int;
573
Damien Millera5539d22003-04-09 20:50:06 +1000574 case oRekeyLimit:
Damien Millera5539d22003-04-09 20:50:06 +1000575 arg = strdelim(&s);
576 if (!arg || *arg == '\0')
Darren Tuckerc53c2af2013-05-16 20:28:16 +1000577 fatal("%.200s line %d: Missing argument.", filename,
578 linenum);
579 if (strcmp(arg, "default") == 0) {
580 val64 = 0;
581 } else {
582 if (arg[0] < '0' || arg[0] > '9')
583 fatal("%.200s line %d: Bad number.", filename,
584 linenum);
585 orig = val64 = strtoll(arg, &endofnumber, 10);
586 if (arg == endofnumber)
587 fatal("%.200s line %d: Bad number.", filename,
588 linenum);
589 switch (toupper(*endofnumber)) {
590 case '\0':
591 scale = 1;
592 break;
593 case 'K':
594 scale = 1<<10;
595 break;
596 case 'M':
597 scale = 1<<20;
598 break;
599 case 'G':
600 scale = 1<<30;
601 break;
602 default:
603 fatal("%.200s line %d: Invalid RekeyLimit "
604 "suffix", filename, linenum);
605 }
606 val64 *= scale;
607 /* detect integer wrap and too-large limits */
608 if ((val64 / scale) != orig || val64 > UINT_MAX)
609 fatal("%.200s line %d: RekeyLimit too large",
610 filename, linenum);
611 if (val64 != 0 && val64 < 16)
612 fatal("%.200s line %d: RekeyLimit too small",
613 filename, linenum);
Damien Millera5539d22003-04-09 20:50:06 +1000614 }
Damien Miller3dff1762008-02-10 22:25:52 +1100615 if (*activep && options->rekey_limit == -1)
616 options->rekey_limit = (u_int32_t)val64;
Darren Tuckerc53c2af2013-05-16 20:28:16 +1000617 if (s != NULL) { /* optional rekey interval present */
618 if (strcmp(s, "none") == 0) {
619 (void)strdelim(&s); /* discard */
620 break;
621 }
622 intptr = &options->rekey_interval;
623 goto parse_time;
624 }
Damien Millera5539d22003-04-09 20:50:06 +1000625 break;
626
Damien Miller95def091999-11-25 00:26:21 +1100627 case oIdentityFile:
Damien Millerbe484b52000-07-15 14:14:16 +1000628 arg = strdelim(&s);
Damien Miller37023962000-07-11 17:31:38 +1000629 if (!arg || *arg == '\0')
Damien Miller95def091999-11-25 00:26:21 +1100630 fatal("%.200s line %d: Missing argument.", filename, linenum);
631 if (*activep) {
Damien Miller0bc1bd82000-11-13 22:57:25 +1100632 intptr = &options->num_identity_files;
Damien Millereba71ba2000-04-29 23:57:08 +1000633 if (*intptr >= SSH_MAX_IDENTITY_FILES)
Damien Miller95def091999-11-25 00:26:21 +1100634 fatal("%.200s line %d: Too many identity files specified (max %d).",
Damien Miller9f0f5c62001-12-21 14:45:46 +1100635 filename, linenum, SSH_MAX_IDENTITY_FILES);
Darren Tuckeraefa3682013-04-05 11:18:35 +1100636 add_identity_file(options, NULL, arg, userconfig);
Damien Miller95def091999-11-25 00:26:21 +1100637 }
638 break;
639
Damien Millerd3a18572000-06-07 19:55:44 +1000640 case oXAuthLocation:
641 charptr=&options->xauth_location;
642 goto parse_string;
643
Damien Miller95def091999-11-25 00:26:21 +1100644 case oUser:
645 charptr = &options->user;
646parse_string:
Damien Millerbe484b52000-07-15 14:14:16 +1000647 arg = strdelim(&s);
Damien Miller37023962000-07-11 17:31:38 +1000648 if (!arg || *arg == '\0')
Damien Miller295ee632011-05-29 21:42:31 +1000649 fatal("%.200s line %d: Missing argument.",
650 filename, linenum);
Damien Miller95def091999-11-25 00:26:21 +1100651 if (*activep && *charptr == NULL)
Damien Miller37023962000-07-11 17:31:38 +1000652 *charptr = xstrdup(arg);
Damien Miller95def091999-11-25 00:26:21 +1100653 break;
654
655 case oGlobalKnownHostsFile:
Damien Miller295ee632011-05-29 21:42:31 +1000656 cpptr = (char **)&options->system_hostfiles;
657 uintptr = &options->num_system_hostfiles;
658 max_entries = SSH_MAX_HOSTS_FILES;
659parse_char_array:
660 if (*activep && *uintptr == 0) {
661 while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
662 if ((*uintptr) >= max_entries)
663 fatal("%s line %d: "
664 "too many authorized keys files.",
665 filename, linenum);
666 cpptr[(*uintptr)++] = xstrdup(arg);
667 }
668 }
669 return 0;
Damien Miller95def091999-11-25 00:26:21 +1100670
671 case oUserKnownHostsFile:
Damien Miller295ee632011-05-29 21:42:31 +1000672 cpptr = (char **)&options->user_hostfiles;
673 uintptr = &options->num_user_hostfiles;
674 max_entries = SSH_MAX_HOSTS_FILES;
675 goto parse_char_array;
Damien Millereba71ba2000-04-29 23:57:08 +1000676
Damien Miller95def091999-11-25 00:26:21 +1100677 case oHostName:
678 charptr = &options->hostname;
679 goto parse_string;
680
Ben Lindstrom4dccfa52000-12-28 16:40:05 +0000681 case oHostKeyAlias:
682 charptr = &options->host_key_alias;
683 goto parse_string;
684
Ben Lindstromb9be60a2001-03-11 01:49:19 +0000685 case oPreferredAuthentications:
686 charptr = &options->preferred_authentications;
687 goto parse_string;
688
Ben Lindstrome0f88042001-04-30 13:06:24 +0000689 case oBindAddress:
690 charptr = &options->bind_address;
691 goto parse_string;
692
Damien Miller7ea845e2010-02-12 09:21:02 +1100693 case oPKCS11Provider:
694 charptr = &options->pkcs11_provider;
Ben Lindstromf7db3bb2001-08-06 21:35:51 +0000695 goto parse_string;
Ben Lindstromae996bf2001-08-06 21:27:53 +0000696
Damien Miller95def091999-11-25 00:26:21 +1100697 case oProxyCommand:
Damien Millerd27b9472005-12-13 19:29:02 +1100698 charptr = &options->proxy_command;
699parse_command:
Darren Tuckera99c1b72003-06-28 12:40:12 +1000700 if (s == NULL)
701 fatal("%.200s line %d: Missing argument.", filename, linenum);
Damien Miller61f08ac2003-02-24 11:56:27 +1100702 len = strspn(s, WHITESPACE "=");
Damien Miller95def091999-11-25 00:26:21 +1100703 if (*activep && *charptr == NULL)
Damien Miller61f08ac2003-02-24 11:56:27 +1100704 *charptr = xstrdup(s + len);
Damien Miller95def091999-11-25 00:26:21 +1100705 return 0;
706
707 case oPort:
708 intptr = &options->port;
709parse_int:
Damien Millerbe484b52000-07-15 14:14:16 +1000710 arg = strdelim(&s);
Damien Miller37023962000-07-11 17:31:38 +1000711 if (!arg || *arg == '\0')
Damien Miller95def091999-11-25 00:26:21 +1100712 fatal("%.200s line %d: Missing argument.", filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000713 if (arg[0] < '0' || arg[0] > '9')
Damien Miller95def091999-11-25 00:26:21 +1100714 fatal("%.200s line %d: Bad number.", filename, linenum);
Damien Miller5428f641999-11-25 11:54:57 +1100715
716 /* Octal, decimal, or hex format? */
Damien Miller37023962000-07-11 17:31:38 +1000717 value = strtol(arg, &endofnumber, 0);
718 if (arg == endofnumber)
Damien Miller5428f641999-11-25 11:54:57 +1100719 fatal("%.200s line %d: Bad number.", filename, linenum);
Damien Miller95def091999-11-25 00:26:21 +1100720 if (*activep && *intptr == -1)
721 *intptr = value;
722 break;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000723
Damien Miller95def091999-11-25 00:26:21 +1100724 case oConnectionAttempts:
725 intptr = &options->connection_attempts;
726 goto parse_int;
Damien Miller5ce662a1999-11-11 17:57:39 +1100727
Damien Miller95def091999-11-25 00:26:21 +1100728 case oCipher:
729 intptr = &options->cipher;
Damien Millerbe484b52000-07-15 14:14:16 +1000730 arg = strdelim(&s);
Damien Miller37023962000-07-11 17:31:38 +1000731 if (!arg || *arg == '\0')
Damien Millerb1715dc2000-05-30 13:44:51 +1000732 fatal("%.200s line %d: Missing argument.", filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000733 value = cipher_number(arg);
Damien Miller95def091999-11-25 00:26:21 +1100734 if (value == -1)
735 fatal("%.200s line %d: Bad cipher '%s'.",
Damien Miller9f0f5c62001-12-21 14:45:46 +1100736 filename, linenum, arg ? arg : "<NONE>");
Damien Miller95def091999-11-25 00:26:21 +1100737 if (*activep && *intptr == -1)
738 *intptr = value;
739 break;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000740
Damien Miller78928792000-04-12 20:17:38 +1000741 case oCiphers:
Damien Millerbe484b52000-07-15 14:14:16 +1000742 arg = strdelim(&s);
Damien Miller37023962000-07-11 17:31:38 +1000743 if (!arg || *arg == '\0')
Damien Millerb1715dc2000-05-30 13:44:51 +1000744 fatal("%.200s line %d: Missing argument.", filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000745 if (!ciphers_valid(arg))
Damien Miller30c3d422000-05-09 11:02:59 +1000746 fatal("%.200s line %d: Bad SSH2 cipher spec '%s'.",
Damien Miller9f0f5c62001-12-21 14:45:46 +1100747 filename, linenum, arg ? arg : "<NONE>");
Damien Miller78928792000-04-12 20:17:38 +1000748 if (*activep && options->ciphers == NULL)
Damien Miller37023962000-07-11 17:31:38 +1000749 options->ciphers = xstrdup(arg);
Damien Miller78928792000-04-12 20:17:38 +1000750 break;
751
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000752 case oMacs:
753 arg = strdelim(&s);
754 if (!arg || *arg == '\0')
755 fatal("%.200s line %d: Missing argument.", filename, linenum);
756 if (!mac_valid(arg))
757 fatal("%.200s line %d: Bad SSH2 Mac spec '%s'.",
Damien Miller9f0f5c62001-12-21 14:45:46 +1100758 filename, linenum, arg ? arg : "<NONE>");
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000759 if (*activep && options->macs == NULL)
760 options->macs = xstrdup(arg);
761 break;
762
Damien Millerd5f62bf2010-09-24 22:11:14 +1000763 case oKexAlgorithms:
764 arg = strdelim(&s);
765 if (!arg || *arg == '\0')
766 fatal("%.200s line %d: Missing argument.",
767 filename, linenum);
768 if (!kex_names_valid(arg))
769 fatal("%.200s line %d: Bad SSH2 KexAlgorithms '%s'.",
770 filename, linenum, arg ? arg : "<NONE>");
771 if (*activep && options->kex_algorithms == NULL)
772 options->kex_algorithms = xstrdup(arg);
773 break;
774
Ben Lindstrom982dbbc2001-04-17 18:11:36 +0000775 case oHostKeyAlgorithms:
776 arg = strdelim(&s);
777 if (!arg || *arg == '\0')
778 fatal("%.200s line %d: Missing argument.", filename, linenum);
779 if (!key_names_valid2(arg))
780 fatal("%.200s line %d: Bad protocol 2 host key algorithms '%s'.",
Damien Miller9f0f5c62001-12-21 14:45:46 +1100781 filename, linenum, arg ? arg : "<NONE>");
Ben Lindstrom982dbbc2001-04-17 18:11:36 +0000782 if (*activep && options->hostkeyalgorithms == NULL)
783 options->hostkeyalgorithms = xstrdup(arg);
784 break;
785
Damien Miller78928792000-04-12 20:17:38 +1000786 case oProtocol:
787 intptr = &options->protocol;
Damien Millerbe484b52000-07-15 14:14:16 +1000788 arg = strdelim(&s);
Damien Miller37023962000-07-11 17:31:38 +1000789 if (!arg || *arg == '\0')
Damien Millerb1715dc2000-05-30 13:44:51 +1000790 fatal("%.200s line %d: Missing argument.", filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000791 value = proto_spec(arg);
Damien Miller78928792000-04-12 20:17:38 +1000792 if (value == SSH_PROTO_UNKNOWN)
793 fatal("%.200s line %d: Bad protocol spec '%s'.",
Damien Miller9f0f5c62001-12-21 14:45:46 +1100794 filename, linenum, arg ? arg : "<NONE>");
Damien Miller78928792000-04-12 20:17:38 +1000795 if (*activep && *intptr == SSH_PROTO_UNKNOWN)
796 *intptr = value;
797 break;
798
Damien Miller95def091999-11-25 00:26:21 +1100799 case oLogLevel:
Darren Tucker1e44c5d2008-01-01 20:32:26 +1100800 log_level_ptr = &options->log_level;
Damien Millerbe484b52000-07-15 14:14:16 +1000801 arg = strdelim(&s);
Damien Miller37023962000-07-11 17:31:38 +1000802 value = log_level_number(arg);
Damien Millerfcd93202002-02-05 12:26:34 +1100803 if (value == SYSLOG_LEVEL_NOT_SET)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000804 fatal("%.200s line %d: unsupported log level '%s'",
Damien Miller9f0f5c62001-12-21 14:45:46 +1100805 filename, linenum, arg ? arg : "<NONE>");
Darren Tucker1e44c5d2008-01-01 20:32:26 +1100806 if (*activep && *log_level_ptr == SYSLOG_LEVEL_NOT_SET)
807 *log_level_ptr = (LogLevel) value;
Damien Miller95def091999-11-25 00:26:21 +1100808 break;
809
Ben Lindstrom62c25a42001-09-12 18:01:59 +0000810 case oLocalForward:
Damien Miller95def091999-11-25 00:26:21 +1100811 case oRemoteForward:
Damien Millera699d952008-11-03 19:27:34 +1100812 case oDynamicForward:
Damien Millerbe484b52000-07-15 14:14:16 +1000813 arg = strdelim(&s);
Damien Millerf91ee4c2005-03-01 21:24:33 +1100814 if (arg == NULL || *arg == '\0')
Ben Lindstrom62c25a42001-09-12 18:01:59 +0000815 fatal("%.200s line %d: Missing port argument.",
816 filename, linenum);
Damien Millerf91ee4c2005-03-01 21:24:33 +1100817
Damien Millera699d952008-11-03 19:27:34 +1100818 if (opcode == oLocalForward ||
819 opcode == oRemoteForward) {
820 arg2 = strdelim(&s);
821 if (arg2 == NULL || *arg2 == '\0')
822 fatal("%.200s line %d: Missing target argument.",
823 filename, linenum);
Damien Millerf91ee4c2005-03-01 21:24:33 +1100824
Damien Millera699d952008-11-03 19:27:34 +1100825 /* construct a string for parse_forward */
826 snprintf(fwdarg, sizeof(fwdarg), "%s:%s", arg, arg2);
827 } else if (opcode == oDynamicForward) {
828 strlcpy(fwdarg, arg, sizeof(fwdarg));
829 }
830
831 if (parse_forward(&fwd, fwdarg,
Damien Miller4bf648f2009-02-14 16:28:21 +1100832 opcode == oDynamicForward ? 1 : 0,
833 opcode == oRemoteForward ? 1 : 0) == 0)
Ben Lindstrom62c25a42001-09-12 18:01:59 +0000834 fatal("%.200s line %d: Bad forwarding specification.",
835 filename, linenum);
Damien Millerf91ee4c2005-03-01 21:24:33 +1100836
Ben Lindstrom62c25a42001-09-12 18:01:59 +0000837 if (*activep) {
Damien Millera699d952008-11-03 19:27:34 +1100838 if (opcode == oLocalForward ||
839 opcode == oDynamicForward)
Damien Millerf91ee4c2005-03-01 21:24:33 +1100840 add_local_forward(options, &fwd);
Ben Lindstrom62c25a42001-09-12 18:01:59 +0000841 else if (opcode == oRemoteForward)
Damien Millerf91ee4c2005-03-01 21:24:33 +1100842 add_remote_forward(options, &fwd);
Ben Lindstrom62c25a42001-09-12 18:01:59 +0000843 }
Damien Miller95def091999-11-25 00:26:21 +1100844 break;
845
Ben Lindstrom2b7a0e92001-09-20 00:57:55 +0000846 case oClearAllForwardings:
847 intptr = &options->clear_forwardings;
848 goto parse_flag;
849
Damien Miller95def091999-11-25 00:26:21 +1100850 case oHost:
851 *activep = 0;
Damien Millerfe924212011-05-15 08:44:45 +1000852 arg2 = NULL;
853 while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
854 negated = *arg == '!';
855 if (negated)
856 arg++;
Damien Miller37023962000-07-11 17:31:38 +1000857 if (match_pattern(host, arg)) {
Damien Millerfe924212011-05-15 08:44:45 +1000858 if (negated) {
859 debug("%.200s line %d: Skipping Host "
860 "block because of negated match "
861 "for %.100s", filename, linenum,
862 arg);
863 *activep = 0;
864 break;
865 }
866 if (!*activep)
867 arg2 = arg; /* logged below */
Damien Miller95def091999-11-25 00:26:21 +1100868 *activep = 1;
Damien Miller95def091999-11-25 00:26:21 +1100869 }
Damien Millerfe924212011-05-15 08:44:45 +1000870 }
871 if (*activep)
872 debug("%.200s line %d: Applying options for %.100s",
873 filename, linenum, arg2);
Damien Millerbe484b52000-07-15 14:14:16 +1000874 /* Avoid garbage check below, as strdelim is done. */
Damien Miller95def091999-11-25 00:26:21 +1100875 return 0;
876
877 case oEscapeChar:
878 intptr = &options->escape_char;
Damien Millerbe484b52000-07-15 14:14:16 +1000879 arg = strdelim(&s);
Damien Miller37023962000-07-11 17:31:38 +1000880 if (!arg || *arg == '\0')
Damien Miller95def091999-11-25 00:26:21 +1100881 fatal("%.200s line %d: Missing argument.", filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000882 if (arg[0] == '^' && arg[2] == 0 &&
Ben Lindstrom46c16222000-12-22 01:43:59 +0000883 (u_char) arg[1] >= 64 && (u_char) arg[1] < 128)
884 value = (u_char) arg[1] & 31;
Damien Miller37023962000-07-11 17:31:38 +1000885 else if (strlen(arg) == 1)
Ben Lindstrom46c16222000-12-22 01:43:59 +0000886 value = (u_char) arg[0];
Damien Miller37023962000-07-11 17:31:38 +1000887 else if (strcmp(arg, "none") == 0)
Ben Lindstrom2b1f71b2001-06-05 20:32:21 +0000888 value = SSH_ESCAPECHAR_NONE;
Damien Miller95def091999-11-25 00:26:21 +1100889 else {
890 fatal("%.200s line %d: Bad escape character.",
Damien Miller9f0f5c62001-12-21 14:45:46 +1100891 filename, linenum);
Damien Miller95def091999-11-25 00:26:21 +1100892 /* NOTREACHED */
893 value = 0; /* Avoid compiler warning. */
894 }
895 if (*activep && *intptr == -1)
896 *intptr = value;
897 break;
898
Damien Miller20a8f972003-05-18 20:50:30 +1000899 case oAddressFamily:
900 arg = strdelim(&s);
Damien Miller17b23d82005-05-26 12:11:56 +1000901 if (!arg || *arg == '\0')
902 fatal("%s line %d: missing address family.",
903 filename, linenum);
Darren Tucker0a4f04b2003-07-03 20:37:47 +1000904 intptr = &options->address_family;
Damien Miller20a8f972003-05-18 20:50:30 +1000905 if (strcasecmp(arg, "inet") == 0)
Darren Tucker0a4f04b2003-07-03 20:37:47 +1000906 value = AF_INET;
Damien Miller20a8f972003-05-18 20:50:30 +1000907 else if (strcasecmp(arg, "inet6") == 0)
Darren Tucker0a4f04b2003-07-03 20:37:47 +1000908 value = AF_INET6;
Damien Miller20a8f972003-05-18 20:50:30 +1000909 else if (strcasecmp(arg, "any") == 0)
Darren Tucker0a4f04b2003-07-03 20:37:47 +1000910 value = AF_UNSPEC;
Damien Miller20a8f972003-05-18 20:50:30 +1000911 else
912 fatal("Unsupported AddressFamily \"%s\"", arg);
Darren Tucker0a4f04b2003-07-03 20:37:47 +1000913 if (*activep && *intptr == -1)
914 *intptr = value;
Damien Miller20a8f972003-05-18 20:50:30 +1000915 break;
916
Ben Lindstromb6df73b2002-11-09 15:52:31 +0000917 case oEnableSSHKeysign:
918 intptr = &options->enable_ssh_keysign;
919 goto parse_flag;
920
Damien Millerbd394c32004-03-08 23:12:36 +1100921 case oIdentitiesOnly:
922 intptr = &options->identities_only;
923 goto parse_flag;
924
Damien Miller509b0102003-12-17 16:33:10 +1100925 case oServerAliveInterval:
926 intptr = &options->server_alive_interval;
927 goto parse_time;
928
929 case oServerAliveCountMax:
930 intptr = &options->server_alive_count_max;
931 goto parse_int;
932
Darren Tucker46bc0752004-05-02 22:11:30 +1000933 case oSendEnv:
934 while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
935 if (strchr(arg, '=') != NULL)
936 fatal("%s line %d: Invalid environment name.",
937 filename, linenum);
Damien Millerf8e7acc2005-03-05 11:22:50 +1100938 if (!*activep)
939 continue;
Darren Tucker46bc0752004-05-02 22:11:30 +1000940 if (options->num_send_env >= MAX_SEND_ENV)
941 fatal("%s line %d: too many send env.",
942 filename, linenum);
943 options->send_env[options->num_send_env++] =
944 xstrdup(arg);
945 }
946 break;
947
Damien Miller0e220db2004-06-15 10:34:08 +1000948 case oControlPath:
949 charptr = &options->control_path;
950 goto parse_string;
951
952 case oControlMaster:
953 intptr = &options->control_master;
Damien Millerd14b1e72005-06-16 13:19:41 +1000954 arg = strdelim(&s);
955 if (!arg || *arg == '\0')
956 fatal("%.200s line %d: Missing ControlMaster argument.",
957 filename, linenum);
958 value = 0; /* To avoid compiler warning... */
959 if (strcmp(arg, "yes") == 0 || strcmp(arg, "true") == 0)
960 value = SSHCTL_MASTER_YES;
961 else if (strcmp(arg, "no") == 0 || strcmp(arg, "false") == 0)
962 value = SSHCTL_MASTER_NO;
963 else if (strcmp(arg, "auto") == 0)
964 value = SSHCTL_MASTER_AUTO;
965 else if (strcmp(arg, "ask") == 0)
966 value = SSHCTL_MASTER_ASK;
967 else if (strcmp(arg, "autoask") == 0)
968 value = SSHCTL_MASTER_AUTO_ASK;
969 else
970 fatal("%.200s line %d: Bad ControlMaster argument.",
971 filename, linenum);
972 if (*activep && *intptr == -1)
973 *intptr = value;
974 break;
Damien Miller0e220db2004-06-15 10:34:08 +1000975
Damien Millere11e1ea2010-08-03 16:04:46 +1000976 case oControlPersist:
977 /* no/false/yes/true, or a time spec */
978 intptr = &options->control_persist;
979 arg = strdelim(&s);
980 if (!arg || *arg == '\0')
981 fatal("%.200s line %d: Missing ControlPersist"
982 " argument.", filename, linenum);
983 value = 0;
984 value2 = 0; /* timeout */
985 if (strcmp(arg, "no") == 0 || strcmp(arg, "false") == 0)
986 value = 0;
987 else if (strcmp(arg, "yes") == 0 || strcmp(arg, "true") == 0)
988 value = 1;
989 else if ((value2 = convtime(arg)) >= 0)
990 value = 1;
991 else
992 fatal("%.200s line %d: Bad ControlPersist argument.",
993 filename, linenum);
994 if (*activep && *intptr == -1) {
995 *intptr = value;
996 options->control_persist_timeout = value2;
997 }
998 break;
999
Damien Millere1776152005-03-01 21:47:37 +11001000 case oHashKnownHosts:
1001 intptr = &options->hash_known_hosts;
1002 goto parse_flag;
1003
Damien Millerd27b9472005-12-13 19:29:02 +11001004 case oTunnel:
1005 intptr = &options->tun_open;
Damien Miller7b58e802005-12-13 19:33:19 +11001006 arg = strdelim(&s);
1007 if (!arg || *arg == '\0')
1008 fatal("%s line %d: Missing yes/point-to-point/"
1009 "ethernet/no argument.", filename, linenum);
1010 value = 0; /* silence compiler */
1011 if (strcasecmp(arg, "ethernet") == 0)
1012 value = SSH_TUNMODE_ETHERNET;
1013 else if (strcasecmp(arg, "point-to-point") == 0)
1014 value = SSH_TUNMODE_POINTOPOINT;
1015 else if (strcasecmp(arg, "yes") == 0)
1016 value = SSH_TUNMODE_DEFAULT;
1017 else if (strcasecmp(arg, "no") == 0)
1018 value = SSH_TUNMODE_NO;
1019 else
1020 fatal("%s line %d: Bad yes/point-to-point/ethernet/"
1021 "no argument: %s", filename, linenum, arg);
1022 if (*activep)
1023 *intptr = value;
1024 break;
Damien Millerd27b9472005-12-13 19:29:02 +11001025
1026 case oTunnelDevice:
1027 arg = strdelim(&s);
1028 if (!arg || *arg == '\0')
1029 fatal("%.200s line %d: Missing argument.", filename, linenum);
1030 value = a2tun(arg, &value2);
Damien Miller7b58e802005-12-13 19:33:19 +11001031 if (value == SSH_TUNID_ERR)
Damien Millerd27b9472005-12-13 19:29:02 +11001032 fatal("%.200s line %d: Bad tun device.", filename, linenum);
1033 if (*activep) {
1034 options->tun_local = value;
1035 options->tun_remote = value2;
1036 }
1037 break;
1038
1039 case oLocalCommand:
1040 charptr = &options->local_command;
1041 goto parse_command;
1042
1043 case oPermitLocalCommand:
1044 intptr = &options->permit_local_command;
1045 goto parse_flag;
1046
Damien Miller10288242008-06-30 00:04:03 +10001047 case oVisualHostKey:
1048 intptr = &options->visual_host_key;
1049 goto parse_flag;
1050
Damien Miller0dac6fb2010-11-20 15:19:38 +11001051 case oIPQoS:
1052 arg = strdelim(&s);
1053 if ((value = parse_ipqos(arg)) == -1)
1054 fatal("%s line %d: Bad IPQoS value: %s",
1055 filename, linenum, arg);
1056 arg = strdelim(&s);
1057 if (arg == NULL)
1058 value2 = value;
1059 else if ((value2 = parse_ipqos(arg)) == -1)
1060 fatal("%s line %d: Bad IPQoS value: %s",
1061 filename, linenum, arg);
1062 if (*activep) {
1063 options->ip_qos_interactive = value;
1064 options->ip_qos_bulk = value2;
1065 }
1066 break;
1067
Darren Tucker71e4d542009-07-06 07:12:27 +10001068 case oUseRoaming:
1069 intptr = &options->use_roaming;
1070 goto parse_flag;
1071
Damien Miller21771e22011-05-15 08:45:50 +10001072 case oRequestTTY:
1073 arg = strdelim(&s);
1074 if (!arg || *arg == '\0')
1075 fatal("%s line %d: missing argument.",
1076 filename, linenum);
1077 intptr = &options->request_tty;
1078 if (strcasecmp(arg, "yes") == 0)
1079 value = REQUEST_TTY_YES;
1080 else if (strcasecmp(arg, "no") == 0)
1081 value = REQUEST_TTY_NO;
1082 else if (strcasecmp(arg, "force") == 0)
1083 value = REQUEST_TTY_FORCE;
1084 else if (strcasecmp(arg, "auto") == 0)
1085 value = REQUEST_TTY_AUTO;
1086 else
1087 fatal("Unsupported RequestTTY \"%s\"", arg);
1088 if (*activep && *intptr == -1)
1089 *intptr = value;
1090 break;
1091
Darren Tucker07636982013-05-16 20:30:03 +10001092 case oIgnoreUnknown:
1093 charptr = &options->ignored_unknown;
1094 goto parse_string;
1095
Ben Lindstrom4daea862002-06-09 20:04:02 +00001096 case oDeprecated:
Ben Lindstrom2e17b082002-06-09 20:13:27 +00001097 debug("%s line %d: Deprecated option \"%s\"",
Ben Lindstrom4daea862002-06-09 20:04:02 +00001098 filename, linenum, keyword);
Ben Lindstrom2e17b082002-06-09 20:13:27 +00001099 return 0;
Ben Lindstrom4daea862002-06-09 20:04:02 +00001100
Damien Millerf9b3feb2003-05-16 11:38:32 +10001101 case oUnsupported:
1102 error("%s line %d: Unsupported option \"%s\"",
1103 filename, linenum, keyword);
1104 return 0;
1105
Damien Miller95def091999-11-25 00:26:21 +11001106 default:
1107 fatal("process_config_line: Unimplemented opcode %d", opcode);
1108 }
1109
1110 /* Check that there is no garbage at end of line. */
Ben Lindstrom226cfa02001-01-22 05:34:40 +00001111 if ((arg = strdelim(&s)) != NULL && *arg != '\0') {
Damien Miller37023962000-07-11 17:31:38 +10001112 fatal("%.200s line %d: garbage at end of line; \"%.200s\".",
Damien Miller0dc1bef2005-07-17 17:22:45 +10001113 filename, linenum, arg);
Damien Miller37023962000-07-11 17:31:38 +10001114 }
Damien Miller95def091999-11-25 00:26:21 +11001115 return 0;
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001116}
1117
1118
Damien Miller5428f641999-11-25 11:54:57 +11001119/*
1120 * Reads the config file and modifies the options accordingly. Options
1121 * should already be initialized before this call. This never returns if
Ben Lindstromedc0cf22001-09-12 18:32:20 +00001122 * there is an error. If the file does not exist, this returns 0.
Damien Miller5428f641999-11-25 11:54:57 +11001123 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001124
Ben Lindstromedc0cf22001-09-12 18:32:20 +00001125int
Darren Tuckerfc959702004-07-17 16:12:08 +10001126read_config_file(const char *filename, const char *host, Options *options,
Darren Tuckeraefa3682013-04-05 11:18:35 +11001127 int flags)
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001128{
Damien Miller95def091999-11-25 00:26:21 +11001129 FILE *f;
1130 char line[1024];
1131 int active, linenum;
1132 int bad_options = 0;
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001133
Damien Miller57a44762004-04-20 20:11:57 +10001134 if ((f = fopen(filename, "r")) == NULL)
Ben Lindstromedc0cf22001-09-12 18:32:20 +00001135 return 0;
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001136
Darren Tuckeraefa3682013-04-05 11:18:35 +11001137 if (flags & SSHCONF_CHECKPERM) {
Damien Miller57a44762004-04-20 20:11:57 +10001138 struct stat sb;
Darren Tuckerfc959702004-07-17 16:12:08 +10001139
Damien Miller33793852004-06-15 10:27:55 +10001140 if (fstat(fileno(f), &sb) == -1)
Damien Miller57a44762004-04-20 20:11:57 +10001141 fatal("fstat %s: %s", filename, strerror(errno));
Damien Miller57a44762004-04-20 20:11:57 +10001142 if (((sb.st_uid != 0 && sb.st_uid != getuid()) ||
Damien Miller33793852004-06-15 10:27:55 +10001143 (sb.st_mode & 022) != 0))
Damien Miller57a44762004-04-20 20:11:57 +10001144 fatal("Bad owner or permissions on %s", filename);
Damien Miller57a44762004-04-20 20:11:57 +10001145 }
1146
Damien Miller95def091999-11-25 00:26:21 +11001147 debug("Reading configuration data %.200s", filename);
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001148
Damien Miller5428f641999-11-25 11:54:57 +11001149 /*
1150 * Mark that we are now processing the options. This flag is turned
1151 * on/off by Host specifications.
1152 */
Damien Miller95def091999-11-25 00:26:21 +11001153 active = 1;
1154 linenum = 0;
1155 while (fgets(line, sizeof(line), f)) {
1156 /* Update line number counter. */
1157 linenum++;
Darren Tuckeraefa3682013-04-05 11:18:35 +11001158 if (process_config_line(options, host, line, filename, linenum,
1159 &active, flags & SSHCONF_USERCONF) != 0)
Damien Miller95def091999-11-25 00:26:21 +11001160 bad_options++;
1161 }
1162 fclose(f);
1163 if (bad_options > 0)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +00001164 fatal("%s: terminating, %d bad configuration options",
Damien Miller9f0f5c62001-12-21 14:45:46 +11001165 filename, bad_options);
Ben Lindstromedc0cf22001-09-12 18:32:20 +00001166 return 1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001167}
1168
Damien Miller5428f641999-11-25 11:54:57 +11001169/*
1170 * Initializes options to special values that indicate that they have not yet
1171 * been set. Read_config_file will only set options with this value. Options
1172 * are processed in the following order: command line, user config file,
1173 * system config file. Last, fill_default_options is called.
1174 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001175
Damien Miller4af51302000-04-16 11:18:38 +10001176void
Damien Miller95def091999-11-25 00:26:21 +11001177initialize_options(Options * options)
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001178{
Damien Miller95def091999-11-25 00:26:21 +11001179 memset(options, 'X', sizeof(*options));
1180 options->forward_agent = -1;
1181 options->forward_x11 = -1;
Darren Tucker0a118da2003-10-15 15:54:32 +10001182 options->forward_x11_trusted = -1;
Damien Miller1ab6a512010-06-26 10:02:24 +10001183 options->forward_x11_timeout = -1;
Darren Tuckere7d4b192006-07-12 22:17:10 +10001184 options->exit_on_forward_failure = -1;
Damien Millerd3a18572000-06-07 19:55:44 +10001185 options->xauth_location = NULL;
Damien Miller95def091999-11-25 00:26:21 +11001186 options->gateway_ports = -1;
1187 options->use_privileged_port = -1;
Damien Miller95def091999-11-25 00:26:21 +11001188 options->rsa_authentication = -1;
Damien Miller0bc1bd82000-11-13 22:57:25 +11001189 options->pubkey_authentication = -1;
Ben Lindstrom551ea372001-06-05 18:56:16 +00001190 options->challenge_response_authentication = -1;
Darren Tucker0efd1552003-08-26 11:49:55 +10001191 options->gss_authentication = -1;
1192 options->gss_deleg_creds = -1;
Damien Miller95def091999-11-25 00:26:21 +11001193 options->password_authentication = -1;
Damien Miller874d77b2000-10-14 16:23:11 +11001194 options->kbd_interactive_authentication = -1;
1195 options->kbd_interactive_devices = NULL;
Damien Miller95def091999-11-25 00:26:21 +11001196 options->rhosts_rsa_authentication = -1;
Ben Lindstrom5eabda32001-04-12 23:34:34 +00001197 options->hostbased_authentication = -1;
Damien Miller95def091999-11-25 00:26:21 +11001198 options->batch_mode = -1;
1199 options->check_host_ip = -1;
1200 options->strict_host_key_checking = -1;
1201 options->compression = -1;
Damien Miller12c150e2003-12-17 16:31:10 +11001202 options->tcp_keep_alive = -1;
Damien Miller95def091999-11-25 00:26:21 +11001203 options->compression_level = -1;
1204 options->port = -1;
Darren Tucker0a4f04b2003-07-03 20:37:47 +10001205 options->address_family = -1;
Damien Miller95def091999-11-25 00:26:21 +11001206 options->connection_attempts = -1;
Damien Millerb78d5eb2003-05-16 11:39:04 +10001207 options->connection_timeout = -1;
Damien Miller95def091999-11-25 00:26:21 +11001208 options->number_of_password_prompts = -1;
1209 options->cipher = -1;
Damien Miller78928792000-04-12 20:17:38 +10001210 options->ciphers = NULL;
Ben Lindstrom06b33aa2001-02-15 03:01:59 +00001211 options->macs = NULL;
Damien Millerd5f62bf2010-09-24 22:11:14 +10001212 options->kex_algorithms = NULL;
Ben Lindstrom982dbbc2001-04-17 18:11:36 +00001213 options->hostkeyalgorithms = NULL;
Damien Miller78928792000-04-12 20:17:38 +10001214 options->protocol = SSH_PROTO_UNKNOWN;
Damien Miller95def091999-11-25 00:26:21 +11001215 options->num_identity_files = 0;
1216 options->hostname = NULL;
Ben Lindstrom4dccfa52000-12-28 16:40:05 +00001217 options->host_key_alias = NULL;
Damien Miller95def091999-11-25 00:26:21 +11001218 options->proxy_command = NULL;
1219 options->user = NULL;
1220 options->escape_char = -1;
Damien Miller295ee632011-05-29 21:42:31 +10001221 options->num_system_hostfiles = 0;
1222 options->num_user_hostfiles = 0;
Damien Miller232cfb12010-06-26 09:50:30 +10001223 options->local_forwards = NULL;
Damien Miller95def091999-11-25 00:26:21 +11001224 options->num_local_forwards = 0;
Damien Miller232cfb12010-06-26 09:50:30 +10001225 options->remote_forwards = NULL;
Damien Miller95def091999-11-25 00:26:21 +11001226 options->num_remote_forwards = 0;
Ben Lindstrom2b7a0e92001-09-20 00:57:55 +00001227 options->clear_forwardings = -1;
Damien Millerfcd93202002-02-05 12:26:34 +11001228 options->log_level = SYSLOG_LEVEL_NOT_SET;
Ben Lindstromb9be60a2001-03-11 01:49:19 +00001229 options->preferred_authentications = NULL;
Ben Lindstrome0f88042001-04-30 13:06:24 +00001230 options->bind_address = NULL;
Damien Miller7ea845e2010-02-12 09:21:02 +11001231 options->pkcs11_provider = NULL;
Ben Lindstromb6df73b2002-11-09 15:52:31 +00001232 options->enable_ssh_keysign = - 1;
Ben Lindstrom3cecc9a2001-10-03 17:39:38 +00001233 options->no_host_authentication_for_localhost = - 1;
Damien Millerbd394c32004-03-08 23:12:36 +11001234 options->identities_only = - 1;
Damien Millera5539d22003-04-09 20:50:06 +10001235 options->rekey_limit = - 1;
Darren Tuckerc53c2af2013-05-16 20:28:16 +10001236 options->rekey_interval = -1;
Damien Miller37876e92003-05-15 10:19:46 +10001237 options->verify_host_key_dns = -1;
Damien Miller509b0102003-12-17 16:33:10 +11001238 options->server_alive_interval = -1;
1239 options->server_alive_count_max = -1;
Darren Tucker46bc0752004-05-02 22:11:30 +10001240 options->num_send_env = 0;
Damien Miller0e220db2004-06-15 10:34:08 +10001241 options->control_path = NULL;
1242 options->control_master = -1;
Damien Millere11e1ea2010-08-03 16:04:46 +10001243 options->control_persist = -1;
1244 options->control_persist_timeout = 0;
Damien Millere1776152005-03-01 21:47:37 +11001245 options->hash_known_hosts = -1;
Damien Millerd27b9472005-12-13 19:29:02 +11001246 options->tun_open = -1;
1247 options->tun_local = -1;
1248 options->tun_remote = -1;
1249 options->local_command = NULL;
1250 options->permit_local_command = -1;
Darren Tucker71e4d542009-07-06 07:12:27 +10001251 options->use_roaming = -1;
Damien Miller10288242008-06-30 00:04:03 +10001252 options->visual_host_key = -1;
Damien Miller01ed2272008-11-05 16:20:46 +11001253 options->zero_knowledge_password_authentication = -1;
Damien Miller0dac6fb2010-11-20 15:19:38 +11001254 options->ip_qos_interactive = -1;
1255 options->ip_qos_bulk = -1;
Damien Miller21771e22011-05-15 08:45:50 +10001256 options->request_tty = -1;
Darren Tucker07636982013-05-16 20:30:03 +10001257 options->ignored_unknown = NULL;
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001258}
1259
Damien Miller5428f641999-11-25 11:54:57 +11001260/*
1261 * Called after processing other sources of option data, this fills those
1262 * options for which no value has been specified with their default values.
1263 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001264
Damien Miller4af51302000-04-16 11:18:38 +10001265void
Damien Miller95def091999-11-25 00:26:21 +11001266fill_default_options(Options * options)
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001267{
Damien Miller95def091999-11-25 00:26:21 +11001268 if (options->forward_agent == -1)
Damien Millerb1715dc2000-05-30 13:44:51 +10001269 options->forward_agent = 0;
Damien Miller95def091999-11-25 00:26:21 +11001270 if (options->forward_x11 == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +11001271 options->forward_x11 = 0;
Darren Tucker0a118da2003-10-15 15:54:32 +10001272 if (options->forward_x11_trusted == -1)
1273 options->forward_x11_trusted = 0;
Damien Miller1ab6a512010-06-26 10:02:24 +10001274 if (options->forward_x11_timeout == -1)
1275 options->forward_x11_timeout = 1200;
Darren Tuckere7d4b192006-07-12 22:17:10 +10001276 if (options->exit_on_forward_failure == -1)
1277 options->exit_on_forward_failure = 0;
Damien Millerd3a18572000-06-07 19:55:44 +10001278 if (options->xauth_location == NULL)
Ben Lindstrom1bf11f62001-06-09 01:48:01 +00001279 options->xauth_location = _PATH_XAUTH;
Damien Miller95def091999-11-25 00:26:21 +11001280 if (options->gateway_ports == -1)
1281 options->gateway_ports = 0;
1282 if (options->use_privileged_port == -1)
Ben Lindstromcebc8582001-03-08 03:39:10 +00001283 options->use_privileged_port = 0;
Damien Miller95def091999-11-25 00:26:21 +11001284 if (options->rsa_authentication == -1)
1285 options->rsa_authentication = 1;
Damien Miller0bc1bd82000-11-13 22:57:25 +11001286 if (options->pubkey_authentication == -1)
1287 options->pubkey_authentication = 1;
Ben Lindstrom551ea372001-06-05 18:56:16 +00001288 if (options->challenge_response_authentication == -1)
Ben Lindstrom0076d752001-08-06 20:53:26 +00001289 options->challenge_response_authentication = 1;
Darren Tucker0efd1552003-08-26 11:49:55 +10001290 if (options->gss_authentication == -1)
Darren Tuckera044f472003-10-15 15:52:03 +10001291 options->gss_authentication = 0;
Darren Tucker0efd1552003-08-26 11:49:55 +10001292 if (options->gss_deleg_creds == -1)
1293 options->gss_deleg_creds = 0;
Damien Miller95def091999-11-25 00:26:21 +11001294 if (options->password_authentication == -1)
1295 options->password_authentication = 1;
Damien Miller874d77b2000-10-14 16:23:11 +11001296 if (options->kbd_interactive_authentication == -1)
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +00001297 options->kbd_interactive_authentication = 1;
Damien Miller95def091999-11-25 00:26:21 +11001298 if (options->rhosts_rsa_authentication == -1)
Ben Lindstrom2bf82762002-06-11 15:53:05 +00001299 options->rhosts_rsa_authentication = 0;
Ben Lindstrom5eabda32001-04-12 23:34:34 +00001300 if (options->hostbased_authentication == -1)
1301 options->hostbased_authentication = 0;
Damien Miller95def091999-11-25 00:26:21 +11001302 if (options->batch_mode == -1)
1303 options->batch_mode = 0;
1304 if (options->check_host_ip == -1)
1305 options->check_host_ip = 1;
1306 if (options->strict_host_key_checking == -1)
1307 options->strict_host_key_checking = 2; /* 2 is default */
1308 if (options->compression == -1)
1309 options->compression = 0;
Damien Miller12c150e2003-12-17 16:31:10 +11001310 if (options->tcp_keep_alive == -1)
1311 options->tcp_keep_alive = 1;
Damien Miller95def091999-11-25 00:26:21 +11001312 if (options->compression_level == -1)
1313 options->compression_level = 6;
1314 if (options->port == -1)
1315 options->port = 0; /* Filled in ssh_connect. */
Darren Tucker0a4f04b2003-07-03 20:37:47 +10001316 if (options->address_family == -1)
1317 options->address_family = AF_UNSPEC;
Damien Miller95def091999-11-25 00:26:21 +11001318 if (options->connection_attempts == -1)
Ben Lindstromf9cedb92001-08-06 21:07:11 +00001319 options->connection_attempts = 1;
Damien Miller95def091999-11-25 00:26:21 +11001320 if (options->number_of_password_prompts == -1)
1321 options->number_of_password_prompts = 3;
1322 /* Selected in ssh_login(). */
1323 if (options->cipher == -1)
1324 options->cipher = SSH_CIPHER_NOT_SET;
Damien Miller30c3d422000-05-09 11:02:59 +10001325 /* options->ciphers, default set in myproposals.h */
Ben Lindstrom06b33aa2001-02-15 03:01:59 +00001326 /* options->macs, default set in myproposals.h */
Damien Millerd5f62bf2010-09-24 22:11:14 +10001327 /* options->kex_algorithms, default set in myproposals.h */
Ben Lindstrom982dbbc2001-04-17 18:11:36 +00001328 /* options->hostkeyalgorithms, default set in myproposals.h */
Damien Miller78928792000-04-12 20:17:38 +10001329 if (options->protocol == SSH_PROTO_UNKNOWN)
Darren Tuckerbad50762009-10-11 21:51:08 +11001330 options->protocol = SSH_PROTO_2;
Damien Miller95def091999-11-25 00:26:21 +11001331 if (options->num_identity_files == 0) {
Damien Miller0bc1bd82000-11-13 22:57:25 +11001332 if (options->protocol & SSH_PROTO_1) {
Darren Tucker19104782013-04-05 11:13:08 +11001333 add_identity_file(options, "~/",
1334 _PATH_SSH_CLIENT_IDENTITY, 0);
Damien Miller0bc1bd82000-11-13 22:57:25 +11001335 }
1336 if (options->protocol & SSH_PROTO_2) {
Darren Tucker19104782013-04-05 11:13:08 +11001337 add_identity_file(options, "~/",
1338 _PATH_SSH_CLIENT_ID_RSA, 0);
1339 add_identity_file(options, "~/",
1340 _PATH_SSH_CLIENT_ID_DSA, 0);
Damien Miller6af914a2010-09-10 11:39:26 +10001341#ifdef OPENSSL_HAS_ECC
Darren Tucker19104782013-04-05 11:13:08 +11001342 add_identity_file(options, "~/",
1343 _PATH_SSH_CLIENT_ID_ECDSA, 0);
Damien Miller6af914a2010-09-10 11:39:26 +10001344#endif
Damien Miller0bc1bd82000-11-13 22:57:25 +11001345 }
Damien Millereba71ba2000-04-29 23:57:08 +10001346 }
Damien Miller95def091999-11-25 00:26:21 +11001347 if (options->escape_char == -1)
1348 options->escape_char = '~';
Damien Miller295ee632011-05-29 21:42:31 +10001349 if (options->num_system_hostfiles == 0) {
1350 options->system_hostfiles[options->num_system_hostfiles++] =
1351 xstrdup(_PATH_SSH_SYSTEM_HOSTFILE);
1352 options->system_hostfiles[options->num_system_hostfiles++] =
1353 xstrdup(_PATH_SSH_SYSTEM_HOSTFILE2);
1354 }
1355 if (options->num_user_hostfiles == 0) {
1356 options->user_hostfiles[options->num_user_hostfiles++] =
1357 xstrdup(_PATH_SSH_USER_HOSTFILE);
1358 options->user_hostfiles[options->num_user_hostfiles++] =
1359 xstrdup(_PATH_SSH_USER_HOSTFILE2);
1360 }
Damien Millerfcd93202002-02-05 12:26:34 +11001361 if (options->log_level == SYSLOG_LEVEL_NOT_SET)
Ben Lindstromdb65e8f2001-01-19 04:26:52 +00001362 options->log_level = SYSLOG_LEVEL_INFO;
Ben Lindstrom2b7a0e92001-09-20 00:57:55 +00001363 if (options->clear_forwardings == 1)
1364 clear_forwardings(options);
Ben Lindstrom3cecc9a2001-10-03 17:39:38 +00001365 if (options->no_host_authentication_for_localhost == - 1)
1366 options->no_host_authentication_for_localhost = 0;
Damien Millerbd394c32004-03-08 23:12:36 +11001367 if (options->identities_only == -1)
1368 options->identities_only = 0;
Ben Lindstromb6df73b2002-11-09 15:52:31 +00001369 if (options->enable_ssh_keysign == -1)
1370 options->enable_ssh_keysign = 0;
Damien Millera5539d22003-04-09 20:50:06 +10001371 if (options->rekey_limit == -1)
1372 options->rekey_limit = 0;
Darren Tuckerc53c2af2013-05-16 20:28:16 +10001373 if (options->rekey_interval == -1)
1374 options->rekey_interval = 0;
Damien Miller37876e92003-05-15 10:19:46 +10001375 if (options->verify_host_key_dns == -1)
1376 options->verify_host_key_dns = 0;
Damien Miller509b0102003-12-17 16:33:10 +11001377 if (options->server_alive_interval == -1)
1378 options->server_alive_interval = 0;
1379 if (options->server_alive_count_max == -1)
1380 options->server_alive_count_max = 3;
Damien Miller0e220db2004-06-15 10:34:08 +10001381 if (options->control_master == -1)
1382 options->control_master = 0;
Damien Millere11e1ea2010-08-03 16:04:46 +10001383 if (options->control_persist == -1) {
1384 options->control_persist = 0;
1385 options->control_persist_timeout = 0;
1386 }
Damien Millere1776152005-03-01 21:47:37 +11001387 if (options->hash_known_hosts == -1)
1388 options->hash_known_hosts = 0;
Damien Millerd27b9472005-12-13 19:29:02 +11001389 if (options->tun_open == -1)
Damien Miller7b58e802005-12-13 19:33:19 +11001390 options->tun_open = SSH_TUNMODE_NO;
1391 if (options->tun_local == -1)
1392 options->tun_local = SSH_TUNID_ANY;
1393 if (options->tun_remote == -1)
1394 options->tun_remote = SSH_TUNID_ANY;
Damien Millerd27b9472005-12-13 19:29:02 +11001395 if (options->permit_local_command == -1)
1396 options->permit_local_command = 0;
Darren Tucker71e4d542009-07-06 07:12:27 +10001397 if (options->use_roaming == -1)
1398 options->use_roaming = 1;
Damien Miller10288242008-06-30 00:04:03 +10001399 if (options->visual_host_key == -1)
1400 options->visual_host_key = 0;
Damien Miller01ed2272008-11-05 16:20:46 +11001401 if (options->zero_knowledge_password_authentication == -1)
1402 options->zero_knowledge_password_authentication = 0;
Damien Miller0dac6fb2010-11-20 15:19:38 +11001403 if (options->ip_qos_interactive == -1)
1404 options->ip_qos_interactive = IPTOS_LOWDELAY;
1405 if (options->ip_qos_bulk == -1)
1406 options->ip_qos_bulk = IPTOS_THROUGHPUT;
Damien Miller21771e22011-05-15 08:45:50 +10001407 if (options->request_tty == -1)
1408 options->request_tty = REQUEST_TTY_AUTO;
Damien Millerd27b9472005-12-13 19:29:02 +11001409 /* options->local_command should not be set by default */
Damien Miller95def091999-11-25 00:26:21 +11001410 /* options->proxy_command should not be set by default */
1411 /* options->user will be set in the main program if appropriate */
1412 /* options->hostname will be set in the main program if appropriate */
Ben Lindstrom4dccfa52000-12-28 16:40:05 +00001413 /* options->host_key_alias should not be set by default */
Ben Lindstromb9be60a2001-03-11 01:49:19 +00001414 /* options->preferred_authentications will be set in ssh */
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001415}
Damien Millerf91ee4c2005-03-01 21:24:33 +11001416
1417/*
1418 * parse_forward
1419 * parses a string containing a port forwarding specification of the form:
Damien Millera699d952008-11-03 19:27:34 +11001420 * dynamicfwd == 0
Damien Millerf91ee4c2005-03-01 21:24:33 +11001421 * [listenhost:]listenport:connecthost:connectport
Damien Millera699d952008-11-03 19:27:34 +11001422 * dynamicfwd == 1
1423 * [listenhost:]listenport
Damien Millerf91ee4c2005-03-01 21:24:33 +11001424 * returns number of arguments parsed or zero on error
1425 */
1426int
Damien Miller4bf648f2009-02-14 16:28:21 +11001427parse_forward(Forward *fwd, const char *fwdspec, int dynamicfwd, int remotefwd)
Damien Millerf91ee4c2005-03-01 21:24:33 +11001428{
1429 int i;
1430 char *p, *cp, *fwdarg[4];
1431
1432 memset(fwd, '\0', sizeof(*fwd));
1433
1434 cp = p = xstrdup(fwdspec);
1435
1436 /* skip leading spaces */
Darren Tucker03b1cdb2007-03-21 20:46:03 +11001437 while (isspace(*cp))
Damien Millerf91ee4c2005-03-01 21:24:33 +11001438 cp++;
1439
1440 for (i = 0; i < 4; ++i)
1441 if ((fwdarg[i] = hpdelim(&cp)) == NULL)
1442 break;
1443
Damien Millerf4b39532008-11-03 19:28:21 +11001444 /* Check for trailing garbage */
Damien Millerf91ee4c2005-03-01 21:24:33 +11001445 if (cp != NULL)
1446 i = 0; /* failure */
1447
1448 switch (i) {
Damien Millera699d952008-11-03 19:27:34 +11001449 case 1:
1450 fwd->listen_host = NULL;
1451 fwd->listen_port = a2port(fwdarg[0]);
1452 fwd->connect_host = xstrdup("socks");
1453 break;
1454
1455 case 2:
1456 fwd->listen_host = xstrdup(cleanhostname(fwdarg[0]));
1457 fwd->listen_port = a2port(fwdarg[1]);
1458 fwd->connect_host = xstrdup("socks");
1459 break;
1460
Damien Millerf91ee4c2005-03-01 21:24:33 +11001461 case 3:
1462 fwd->listen_host = NULL;
1463 fwd->listen_port = a2port(fwdarg[0]);
1464 fwd->connect_host = xstrdup(cleanhostname(fwdarg[1]));
1465 fwd->connect_port = a2port(fwdarg[2]);
1466 break;
1467
1468 case 4:
1469 fwd->listen_host = xstrdup(cleanhostname(fwdarg[0]));
1470 fwd->listen_port = a2port(fwdarg[1]);
1471 fwd->connect_host = xstrdup(cleanhostname(fwdarg[2]));
1472 fwd->connect_port = a2port(fwdarg[3]);
1473 break;
1474 default:
1475 i = 0; /* failure */
1476 }
1477
1478 xfree(p);
1479
Damien Millera699d952008-11-03 19:27:34 +11001480 if (dynamicfwd) {
1481 if (!(i == 1 || i == 2))
1482 goto fail_free;
1483 } else {
1484 if (!(i == 3 || i == 4))
1485 goto fail_free;
Damien Miller3dc71ad2009-01-28 16:31:22 +11001486 if (fwd->connect_port <= 0)
Damien Millera699d952008-11-03 19:27:34 +11001487 goto fail_free;
1488 }
1489
Damien Miller4bf648f2009-02-14 16:28:21 +11001490 if (fwd->listen_port < 0 || (!remotefwd && fwd->listen_port == 0))
Damien Millerf91ee4c2005-03-01 21:24:33 +11001491 goto fail_free;
1492
1493 if (fwd->connect_host != NULL &&
1494 strlen(fwd->connect_host) >= NI_MAXHOST)
1495 goto fail_free;
Damien Miller4bf648f2009-02-14 16:28:21 +11001496 if (fwd->listen_host != NULL &&
1497 strlen(fwd->listen_host) >= NI_MAXHOST)
1498 goto fail_free;
1499
Damien Millerf91ee4c2005-03-01 21:24:33 +11001500
1501 return (i);
1502
1503 fail_free:
Damien Miller0d772d92008-12-09 14:12:05 +11001504 if (fwd->connect_host != NULL) {
Damien Millerf91ee4c2005-03-01 21:24:33 +11001505 xfree(fwd->connect_host);
Damien Miller0d772d92008-12-09 14:12:05 +11001506 fwd->connect_host = NULL;
1507 }
1508 if (fwd->listen_host != NULL) {
Damien Millerf91ee4c2005-03-01 21:24:33 +11001509 xfree(fwd->listen_host);
Damien Miller0d772d92008-12-09 14:12:05 +11001510 fwd->listen_host = NULL;
1511 }
Damien Millerf91ee4c2005-03-01 21:24:33 +11001512 return (0);
1513}