Damien Miller | e9fc72e | 2013-10-15 12:14:12 +1100 | [diff] [blame^] | 1 | /* $OpenBSD: readconf.c,v 1.207 2013/10/14 23:28:23 djm Exp $ */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 2 | /* |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
| 5 | * All rights reserved |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 6 | * Functions for reading the configuration files. |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 7 | * |
Damien Miller | e4340be | 2000-09-16 13:29:08 +1100 | [diff] [blame] | 8 | * 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 Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 13 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 14 | |
| 15 | #include "includes.h" |
Damien Miller | f17883e | 2006-03-15 11:45:54 +1100 | [diff] [blame] | 16 | |
| 17 | #include <sys/types.h> |
| 18 | #include <sys/stat.h> |
Damien Miller | 8ec8c3e | 2006-07-10 20:35:38 +1000 | [diff] [blame] | 19 | #include <sys/socket.h> |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 20 | #include <sys/wait.h> |
Damien Miller | 8ec8c3e | 2006-07-10 20:35:38 +1000 | [diff] [blame] | 21 | |
| 22 | #include <netinet/in.h> |
Damien Miller | 0dac6fb | 2010-11-20 15:19:38 +1100 | [diff] [blame] | 23 | #include <netinet/in_systm.h> |
| 24 | #include <netinet/ip.h> |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 25 | |
Damien Miller | c7b0636 | 2006-03-15 11:53:45 +1100 | [diff] [blame] | 26 | #include <ctype.h> |
Darren Tucker | 3997249 | 2006-07-12 22:22:46 +1000 | [diff] [blame] | 27 | #include <errno.h> |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 28 | #include <fcntl.h> |
Damien Miller | b8fe89c | 2006-07-24 14:51:00 +1000 | [diff] [blame] | 29 | #include <netdb.h> |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 30 | #include <paths.h> |
| 31 | #include <pwd.h> |
Damien Miller | d783435 | 2006-08-05 12:39:39 +1000 | [diff] [blame] | 32 | #include <signal.h> |
Damien Miller | ded319c | 2006-09-01 15:38:36 +1000 | [diff] [blame] | 33 | #include <stdarg.h> |
Damien Miller | a7a73ee | 2006-08-05 11:37:59 +1000 | [diff] [blame] | 34 | #include <stdio.h> |
Damien Miller | e3476ed | 2006-07-24 14:13:33 +1000 | [diff] [blame] | 35 | #include <string.h> |
Damien Miller | e6b3b61 | 2006-07-24 14:01:23 +1000 | [diff] [blame] | 36 | #include <unistd.h> |
Darren Tucker | e194ba4 | 2013-05-16 20:47:31 +1000 | [diff] [blame] | 37 | #ifdef HAVE_UTIL_H |
Darren Tucker | b7ee852 | 2013-05-16 20:33:10 +1000 | [diff] [blame] | 38 | #include <util.h> |
Darren Tucker | e194ba4 | 2013-05-16 20:47:31 +1000 | [diff] [blame] | 39 | #endif |
Damien Miller | c7b0636 | 2006-03-15 11:53:45 +1100 | [diff] [blame] | 40 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 41 | #include "xmalloc.h" |
Damien Miller | d783435 | 2006-08-05 12:39:39 +1000 | [diff] [blame] | 42 | #include "ssh.h" |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 43 | #include "compat.h" |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 44 | #include "cipher.h" |
| 45 | #include "pathnames.h" |
| 46 | #include "log.h" |
Damien Miller | d783435 | 2006-08-05 12:39:39 +1000 | [diff] [blame] | 47 | #include "key.h" |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 48 | #include "readconf.h" |
| 49 | #include "match.h" |
| 50 | #include "misc.h" |
Damien Miller | d783435 | 2006-08-05 12:39:39 +1000 | [diff] [blame] | 51 | #include "buffer.h" |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 52 | #include "kex.h" |
| 53 | #include "mac.h" |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 54 | #include "uidswap.h" |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 55 | |
| 56 | /* Format of the configuration file: |
| 57 | |
| 58 | # Configuration data is parsed as follows: |
| 59 | # 1. command line options |
| 60 | # 2. user-specific file |
| 61 | # 3. system-wide file |
| 62 | # Any configuration value is only changed the first time it is set. |
| 63 | # Thus, host-specific definitions should be at the beginning of the |
| 64 | # configuration file, and defaults at the end. |
| 65 | |
| 66 | # Host-specific declarations. These may override anything above. A single |
| 67 | # host may match multiple declarations; these are processed in the order |
| 68 | # that they are given in. |
| 69 | |
| 70 | Host *.ngs.fi ngs.fi |
Ben Lindstrom | 4daea86 | 2002-06-09 20:04:02 +0000 | [diff] [blame] | 71 | User foo |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 72 | |
| 73 | Host fake.com |
| 74 | HostName another.host.name.real.org |
| 75 | User blaah |
| 76 | Port 34289 |
| 77 | ForwardX11 no |
| 78 | ForwardAgent no |
| 79 | |
| 80 | Host books.com |
| 81 | RemoteForward 9999 shadows.cs.hut.fi:9999 |
| 82 | Cipher 3des |
| 83 | |
| 84 | Host fascist.blob.com |
| 85 | Port 23123 |
| 86 | User tylonen |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 87 | PasswordAuthentication no |
| 88 | |
| 89 | Host puukko.hut.fi |
| 90 | User t35124p |
| 91 | ProxyCommand ssh-proxy %h %p |
| 92 | |
| 93 | Host *.fr |
Ben Lindstrom | 4daea86 | 2002-06-09 20:04:02 +0000 | [diff] [blame] | 94 | PublicKeyAuthentication no |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 95 | |
| 96 | Host *.su |
| 97 | Cipher none |
| 98 | PasswordAuthentication no |
| 99 | |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 100 | Host vpn.fake.com |
| 101 | Tunnel yes |
| 102 | TunnelDevice 3 |
| 103 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 104 | # Defaults for various options |
| 105 | Host * |
| 106 | ForwardAgent no |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 107 | ForwardX11 no |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 108 | PasswordAuthentication yes |
| 109 | RSAAuthentication yes |
| 110 | RhostsRSAAuthentication yes |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 111 | StrictHostKeyChecking yes |
Damien Miller | 12c150e | 2003-12-17 16:31:10 +1100 | [diff] [blame] | 112 | TcpKeepAlive no |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 113 | IdentityFile ~/.ssh/identity |
| 114 | Port 22 |
| 115 | EscapeChar ~ |
| 116 | |
| 117 | */ |
| 118 | |
| 119 | /* Keyword tokens. */ |
| 120 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 121 | typedef enum { |
| 122 | oBadOption, |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 123 | oHost, oMatch, |
Damien Miller | 1ab6a51 | 2010-06-26 10:02:24 +1000 | [diff] [blame] | 124 | oForwardAgent, oForwardX11, oForwardX11Trusted, oForwardX11Timeout, |
| 125 | oGatewayPorts, oExitOnForwardFailure, |
Ben Lindstrom | cb72e4f | 2002-06-21 00:41:51 +0000 | [diff] [blame] | 126 | oPasswordAuthentication, oRSAAuthentication, |
Ben Lindstrom | 95fb2dd | 2001-01-23 03:12:10 +0000 | [diff] [blame] | 127 | oChallengeResponseAuthentication, oXAuthLocation, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 128 | oIdentityFile, oHostName, oPort, oCipher, oRemoteForward, oLocalForward, |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 129 | oUser, oEscapeChar, oRhostsRSAAuthentication, oProxyCommand, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 130 | oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts, |
| 131 | oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression, |
Damien Miller | 12c150e | 2003-12-17 16:31:10 +1100 | [diff] [blame] | 132 | oCompressionLevel, oTCPKeepAlive, oNumberOfPasswordPrompts, |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 133 | oUsePrivilegedPort, oLogLevel, oCiphers, oProtocol, oMacs, |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 134 | oGlobalKnownHostsFile2, oUserKnownHostsFile2, oPubkeyAuthentication, |
Ben Lindstrom | b9be60a | 2001-03-11 01:49:19 +0000 | [diff] [blame] | 135 | oKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias, |
Ben Lindstrom | 982dbbc | 2001-04-17 18:11:36 +0000 | [diff] [blame] | 136 | oDynamicForward, oPreferredAuthentications, oHostbasedAuthentication, |
Damien Miller | 7ea845e | 2010-02-12 09:21:02 +1100 | [diff] [blame] | 137 | oHostKeyAlgorithms, oBindAddress, oPKCS11Provider, |
Ben Lindstrom | 4daea86 | 2002-06-09 20:04:02 +0000 | [diff] [blame] | 138 | oClearAllForwardings, oNoHostAuthenticationForLocalhost, |
Damien Miller | b78d5eb | 2003-05-16 11:39:04 +1000 | [diff] [blame] | 139 | oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout, |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 140 | oAddressFamily, oGssAuthentication, oGssDelegateCreds, |
Damien Miller | bd394c3 | 2004-03-08 23:12:36 +1100 | [diff] [blame] | 141 | oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly, |
Damien Miller | e11e1ea | 2010-08-03 16:04:46 +1000 | [diff] [blame] | 142 | oSendEnv, oControlPath, oControlMaster, oControlPersist, |
| 143 | oHashKnownHosts, |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 144 | oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand, |
Darren Tucker | 7bd98e7 | 2010-01-10 10:31:12 +1100 | [diff] [blame] | 145 | oVisualHostKey, oUseRoaming, oZeroKnowledgePasswordAuthentication, |
Damien Miller | 1262b66 | 2013-08-21 02:44:24 +1000 | [diff] [blame] | 146 | oKexAlgorithms, oIPQoS, oRequestTTY, oIgnoreUnknown, oProxyUseFdpass, |
Darren Tucker | 0763698 | 2013-05-16 20:30:03 +1000 | [diff] [blame] | 147 | oIgnoredUnknownOption, oDeprecated, oUnsupported |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 148 | } OpCodes; |
| 149 | |
| 150 | /* Textual representations of the tokens. */ |
| 151 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 152 | static struct { |
| 153 | const char *name; |
| 154 | OpCodes opcode; |
| 155 | } keywords[] = { |
| 156 | { "forwardagent", oForwardAgent }, |
| 157 | { "forwardx11", oForwardX11 }, |
Darren Tucker | 0a118da | 2003-10-15 15:54:32 +1000 | [diff] [blame] | 158 | { "forwardx11trusted", oForwardX11Trusted }, |
Damien Miller | 1ab6a51 | 2010-06-26 10:02:24 +1000 | [diff] [blame] | 159 | { "forwardx11timeout", oForwardX11Timeout }, |
Darren Tucker | e7d4b19 | 2006-07-12 22:17:10 +1000 | [diff] [blame] | 160 | { "exitonforwardfailure", oExitOnForwardFailure }, |
Damien Miller | d3a1857 | 2000-06-07 19:55:44 +1000 | [diff] [blame] | 161 | { "xauthlocation", oXAuthLocation }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 162 | { "gatewayports", oGatewayPorts }, |
| 163 | { "useprivilegedport", oUsePrivilegedPort }, |
Darren Tucker | ec960f2 | 2003-08-13 20:37:05 +1000 | [diff] [blame] | 164 | { "rhostsauthentication", oDeprecated }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 165 | { "passwordauthentication", oPasswordAuthentication }, |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 166 | { "kbdinteractiveauthentication", oKbdInteractiveAuthentication }, |
| 167 | { "kbdinteractivedevices", oKbdInteractiveDevices }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 168 | { "rsaauthentication", oRSAAuthentication }, |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 169 | { "pubkeyauthentication", oPubkeyAuthentication }, |
Ben Lindstrom | 95fb2dd | 2001-01-23 03:12:10 +0000 | [diff] [blame] | 170 | { "dsaauthentication", oPubkeyAuthentication }, /* alias */ |
Ben Lindstrom | 5eabda3 | 2001-04-12 23:34:34 +0000 | [diff] [blame] | 171 | { "rhostsrsaauthentication", oRhostsRSAAuthentication }, |
Ben Lindstrom | d69dab3 | 2001-04-12 23:36:05 +0000 | [diff] [blame] | 172 | { "hostbasedauthentication", oHostbasedAuthentication }, |
Ben Lindstrom | 95fb2dd | 2001-01-23 03:12:10 +0000 | [diff] [blame] | 173 | { "challengeresponseauthentication", oChallengeResponseAuthentication }, |
| 174 | { "skeyauthentication", oChallengeResponseAuthentication }, /* alias */ |
| 175 | { "tisauthentication", oChallengeResponseAuthentication }, /* alias */ |
Damien Miller | f9b3feb | 2003-05-16 11:38:32 +1000 | [diff] [blame] | 176 | { "kerberosauthentication", oUnsupported }, |
| 177 | { "kerberostgtpassing", oUnsupported }, |
Damien Miller | f9b3feb | 2003-05-16 11:38:32 +1000 | [diff] [blame] | 178 | { "afstokenpassing", oUnsupported }, |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 179 | #if defined(GSSAPI) |
| 180 | { "gssapiauthentication", oGssAuthentication }, |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 181 | { "gssapidelegatecredentials", oGssDelegateCreds }, |
| 182 | #else |
| 183 | { "gssapiauthentication", oUnsupported }, |
| 184 | { "gssapidelegatecredentials", oUnsupported }, |
| 185 | #endif |
Ben Lindstrom | 4daea86 | 2002-06-09 20:04:02 +0000 | [diff] [blame] | 186 | { "fallbacktorsh", oDeprecated }, |
| 187 | { "usersh", oDeprecated }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 188 | { "identityfile", oIdentityFile }, |
Damien Miller | 5bc6aae | 2009-01-28 16:27:31 +1100 | [diff] [blame] | 189 | { "identityfile2", oIdentityFile }, /* obsolete */ |
Damien Miller | bd394c3 | 2004-03-08 23:12:36 +1100 | [diff] [blame] | 190 | { "identitiesonly", oIdentitiesOnly }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 191 | { "hostname", oHostName }, |
Ben Lindstrom | 4dccfa5 | 2000-12-28 16:40:05 +0000 | [diff] [blame] | 192 | { "hostkeyalias", oHostKeyAlias }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 193 | { "proxycommand", oProxyCommand }, |
| 194 | { "port", oPort }, |
| 195 | { "cipher", oCipher }, |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 196 | { "ciphers", oCiphers }, |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 197 | { "macs", oMacs }, |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 198 | { "protocol", oProtocol }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 199 | { "remoteforward", oRemoteForward }, |
| 200 | { "localforward", oLocalForward }, |
| 201 | { "user", oUser }, |
| 202 | { "host", oHost }, |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 203 | { "match", oMatch }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 204 | { "escapechar", oEscapeChar }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 205 | { "globalknownhostsfile", oGlobalKnownHostsFile }, |
Damien Miller | 295ee63 | 2011-05-29 21:42:31 +1000 | [diff] [blame] | 206 | { "globalknownhostsfile2", oDeprecated }, |
Damien Miller | 5bc6aae | 2009-01-28 16:27:31 +1100 | [diff] [blame] | 207 | { "userknownhostsfile", oUserKnownHostsFile }, |
Damien Miller | 295ee63 | 2011-05-29 21:42:31 +1000 | [diff] [blame] | 208 | { "userknownhostsfile2", oDeprecated }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 209 | { "connectionattempts", oConnectionAttempts }, |
| 210 | { "batchmode", oBatchMode }, |
| 211 | { "checkhostip", oCheckHostIP }, |
| 212 | { "stricthostkeychecking", oStrictHostKeyChecking }, |
| 213 | { "compression", oCompression }, |
| 214 | { "compressionlevel", oCompressionLevel }, |
Damien Miller | 12c150e | 2003-12-17 16:31:10 +1100 | [diff] [blame] | 215 | { "tcpkeepalive", oTCPKeepAlive }, |
| 216 | { "keepalive", oTCPKeepAlive }, /* obsolete */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 217 | { "numberofpasswordprompts", oNumberOfPasswordPrompts }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 218 | { "loglevel", oLogLevel }, |
Ben Lindstrom | 3bb4f9d | 2001-04-08 18:30:26 +0000 | [diff] [blame] | 219 | { "dynamicforward", oDynamicForward }, |
Ben Lindstrom | b9be60a | 2001-03-11 01:49:19 +0000 | [diff] [blame] | 220 | { "preferredauthentications", oPreferredAuthentications }, |
Ben Lindstrom | 982dbbc | 2001-04-17 18:11:36 +0000 | [diff] [blame] | 221 | { "hostkeyalgorithms", oHostKeyAlgorithms }, |
Ben Lindstrom | e0f8804 | 2001-04-30 13:06:24 +0000 | [diff] [blame] | 222 | { "bindaddress", oBindAddress }, |
Damien Miller | 7ea845e | 2010-02-12 09:21:02 +1100 | [diff] [blame] | 223 | #ifdef ENABLE_PKCS11 |
| 224 | { "smartcarddevice", oPKCS11Provider }, |
| 225 | { "pkcs11provider", oPKCS11Provider }, |
Damien Miller | f9b3feb | 2003-05-16 11:38:32 +1000 | [diff] [blame] | 226 | #else |
| 227 | { "smartcarddevice", oUnsupported }, |
Damien Miller | 7ea845e | 2010-02-12 09:21:02 +1100 | [diff] [blame] | 228 | { "pkcs11provider", oUnsupported }, |
Damien Miller | f9b3feb | 2003-05-16 11:38:32 +1000 | [diff] [blame] | 229 | #endif |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 230 | { "clearallforwardings", oClearAllForwardings }, |
Ben Lindstrom | b6df73b | 2002-11-09 15:52:31 +0000 | [diff] [blame] | 231 | { "enablesshkeysign", oEnableSSHKeysign }, |
Damien Miller | 37876e9 | 2003-05-15 10:19:46 +1000 | [diff] [blame] | 232 | { "verifyhostkeydns", oVerifyHostKeyDNS }, |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 233 | { "nohostauthenticationforlocalhost", oNoHostAuthenticationForLocalhost }, |
Damien Miller | a5539d2 | 2003-04-09 20:50:06 +1000 | [diff] [blame] | 234 | { "rekeylimit", oRekeyLimit }, |
Damien Miller | b78d5eb | 2003-05-16 11:39:04 +1000 | [diff] [blame] | 235 | { "connecttimeout", oConnectTimeout }, |
Damien Miller | 20a8f97 | 2003-05-18 20:50:30 +1000 | [diff] [blame] | 236 | { "addressfamily", oAddressFamily }, |
Damien Miller | 509b010 | 2003-12-17 16:33:10 +1100 | [diff] [blame] | 237 | { "serveraliveinterval", oServerAliveInterval }, |
| 238 | { "serveralivecountmax", oServerAliveCountMax }, |
Darren Tucker | 46bc075 | 2004-05-02 22:11:30 +1000 | [diff] [blame] | 239 | { "sendenv", oSendEnv }, |
Damien Miller | 0e220db | 2004-06-15 10:34:08 +1000 | [diff] [blame] | 240 | { "controlpath", oControlPath }, |
| 241 | { "controlmaster", oControlMaster }, |
Damien Miller | e11e1ea | 2010-08-03 16:04:46 +1000 | [diff] [blame] | 242 | { "controlpersist", oControlPersist }, |
Damien Miller | e177615 | 2005-03-01 21:47:37 +1100 | [diff] [blame] | 243 | { "hashknownhosts", oHashKnownHosts }, |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 244 | { "tunnel", oTunnel }, |
| 245 | { "tunneldevice", oTunnelDevice }, |
| 246 | { "localcommand", oLocalCommand }, |
| 247 | { "permitlocalcommand", oPermitLocalCommand }, |
Damien Miller | 1028824 | 2008-06-30 00:04:03 +1000 | [diff] [blame] | 248 | { "visualhostkey", oVisualHostKey }, |
Darren Tucker | 71e4d54 | 2009-07-06 07:12:27 +1000 | [diff] [blame] | 249 | { "useroaming", oUseRoaming }, |
Damien Miller | 01ed227 | 2008-11-05 16:20:46 +1100 | [diff] [blame] | 250 | #ifdef JPAKE |
| 251 | { "zeroknowledgepasswordauthentication", |
| 252 | oZeroKnowledgePasswordAuthentication }, |
| 253 | #else |
| 254 | { "zeroknowledgepasswordauthentication", oUnsupported }, |
| 255 | #endif |
Damien Miller | d5f62bf | 2010-09-24 22:11:14 +1000 | [diff] [blame] | 256 | { "kexalgorithms", oKexAlgorithms }, |
Damien Miller | 0dac6fb | 2010-11-20 15:19:38 +1100 | [diff] [blame] | 257 | { "ipqos", oIPQoS }, |
Damien Miller | 21771e2 | 2011-05-15 08:45:50 +1000 | [diff] [blame] | 258 | { "requesttty", oRequestTTY }, |
Damien Miller | 1262b66 | 2013-08-21 02:44:24 +1000 | [diff] [blame] | 259 | { "proxyusefdpass", oProxyUseFdpass }, |
Darren Tucker | 0763698 | 2013-05-16 20:30:03 +1000 | [diff] [blame] | 260 | { "ignoreunknown", oIgnoreUnknown }, |
Damien Miller | 01ed227 | 2008-11-05 16:20:46 +1100 | [diff] [blame] | 261 | |
Ben Lindstrom | 65366a8 | 2001-12-06 16:32:47 +0000 | [diff] [blame] | 262 | { NULL, oBadOption } |
Damien Miller | 5ce662a | 1999-11-11 17:57:39 +1100 | [diff] [blame] | 263 | }; |
| 264 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 265 | /* |
| 266 | * Adds a local TCP/IP port forward to options. Never returns if there is an |
| 267 | * error. |
| 268 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 269 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 270 | void |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 271 | add_local_forward(Options *options, const Forward *newfwd) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 272 | { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 273 | Forward *fwd; |
Ben Lindstrom | 99a4e14 | 2002-07-09 14:06:40 +0000 | [diff] [blame] | 274 | #ifndef NO_IPPORT_RESERVED_CONCEPT |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 275 | extern uid_t original_real_uid; |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 276 | if (newfwd->listen_port < IPPORT_RESERVED && original_real_uid != 0) |
Ben Lindstrom | 6df8ef4 | 2001-03-05 07:47:23 +0000 | [diff] [blame] | 277 | fatal("Privileged ports can only be forwarded by root."); |
Damien Miller | bac2d8a | 2000-09-05 16:13:06 +1100 | [diff] [blame] | 278 | #endif |
Damien Miller | 232cfb1 | 2010-06-26 09:50:30 +1000 | [diff] [blame] | 279 | options->local_forwards = xrealloc(options->local_forwards, |
| 280 | options->num_local_forwards + 1, |
| 281 | sizeof(*options->local_forwards)); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 282 | fwd = &options->local_forwards[options->num_local_forwards++]; |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 283 | |
Damien Miller | 1a0442f | 2008-11-05 16:30:06 +1100 | [diff] [blame] | 284 | fwd->listen_host = newfwd->listen_host; |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 285 | fwd->listen_port = newfwd->listen_port; |
Damien Miller | 1a0442f | 2008-11-05 16:30:06 +1100 | [diff] [blame] | 286 | fwd->connect_host = newfwd->connect_host; |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 287 | fwd->connect_port = newfwd->connect_port; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 288 | } |
| 289 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 290 | /* |
| 291 | * Adds a remote TCP/IP port forward to options. Never returns if there is |
| 292 | * an error. |
| 293 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 294 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 295 | void |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 296 | add_remote_forward(Options *options, const Forward *newfwd) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 297 | { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 298 | Forward *fwd; |
Damien Miller | 232cfb1 | 2010-06-26 09:50:30 +1000 | [diff] [blame] | 299 | |
| 300 | options->remote_forwards = xrealloc(options->remote_forwards, |
| 301 | options->num_remote_forwards + 1, |
| 302 | sizeof(*options->remote_forwards)); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 303 | fwd = &options->remote_forwards[options->num_remote_forwards++]; |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 304 | |
Damien Miller | 1a0442f | 2008-11-05 16:30:06 +1100 | [diff] [blame] | 305 | fwd->listen_host = newfwd->listen_host; |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 306 | fwd->listen_port = newfwd->listen_port; |
Damien Miller | 1a0442f | 2008-11-05 16:30:06 +1100 | [diff] [blame] | 307 | fwd->connect_host = newfwd->connect_host; |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 308 | fwd->connect_port = newfwd->connect_port; |
Darren Tucker | 68afb8c | 2011-10-02 18:59:03 +1100 | [diff] [blame] | 309 | fwd->handle = newfwd->handle; |
Damien Miller | 388f6fc | 2010-05-21 14:57:35 +1000 | [diff] [blame] | 310 | fwd->allocated_port = 0; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 311 | } |
| 312 | |
Ben Lindstrom | 2b7a0e9 | 2001-09-20 00:57:55 +0000 | [diff] [blame] | 313 | static void |
| 314 | clear_forwardings(Options *options) |
| 315 | { |
| 316 | int i; |
| 317 | |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 318 | for (i = 0; i < options->num_local_forwards; i++) { |
Darren Tucker | a627d42 | 2013-06-02 07:31:17 +1000 | [diff] [blame] | 319 | free(options->local_forwards[i].listen_host); |
| 320 | free(options->local_forwards[i].connect_host); |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 321 | } |
Damien Miller | 232cfb1 | 2010-06-26 09:50:30 +1000 | [diff] [blame] | 322 | if (options->num_local_forwards > 0) { |
Darren Tucker | a627d42 | 2013-06-02 07:31:17 +1000 | [diff] [blame] | 323 | free(options->local_forwards); |
Damien Miller | 232cfb1 | 2010-06-26 09:50:30 +1000 | [diff] [blame] | 324 | options->local_forwards = NULL; |
| 325 | } |
Ben Lindstrom | 2b7a0e9 | 2001-09-20 00:57:55 +0000 | [diff] [blame] | 326 | options->num_local_forwards = 0; |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 327 | for (i = 0; i < options->num_remote_forwards; i++) { |
Darren Tucker | a627d42 | 2013-06-02 07:31:17 +1000 | [diff] [blame] | 328 | free(options->remote_forwards[i].listen_host); |
| 329 | free(options->remote_forwards[i].connect_host); |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 330 | } |
Damien Miller | 232cfb1 | 2010-06-26 09:50:30 +1000 | [diff] [blame] | 331 | if (options->num_remote_forwards > 0) { |
Darren Tucker | a627d42 | 2013-06-02 07:31:17 +1000 | [diff] [blame] | 332 | free(options->remote_forwards); |
Damien Miller | 232cfb1 | 2010-06-26 09:50:30 +1000 | [diff] [blame] | 333 | options->remote_forwards = NULL; |
| 334 | } |
Ben Lindstrom | 2b7a0e9 | 2001-09-20 00:57:55 +0000 | [diff] [blame] | 335 | options->num_remote_forwards = 0; |
Damien Miller | 7b58e80 | 2005-12-13 19:33:19 +1100 | [diff] [blame] | 336 | options->tun_open = SSH_TUNMODE_NO; |
Ben Lindstrom | 2b7a0e9 | 2001-09-20 00:57:55 +0000 | [diff] [blame] | 337 | } |
| 338 | |
Darren Tucker | 1910478 | 2013-04-05 11:13:08 +1100 | [diff] [blame] | 339 | void |
| 340 | add_identity_file(Options *options, const char *dir, const char *filename, |
| 341 | int userprovided) |
| 342 | { |
| 343 | char *path; |
| 344 | |
| 345 | if (options->num_identity_files >= SSH_MAX_IDENTITY_FILES) |
| 346 | fatal("Too many identity files specified (max %d)", |
| 347 | SSH_MAX_IDENTITY_FILES); |
| 348 | |
| 349 | if (dir == NULL) /* no dir, filename is absolute */ |
| 350 | path = xstrdup(filename); |
| 351 | else |
| 352 | (void)xasprintf(&path, "%.100s%.100s", dir, filename); |
| 353 | |
| 354 | options->identity_file_userprovided[options->num_identity_files] = |
| 355 | userprovided; |
| 356 | options->identity_files[options->num_identity_files++] = path; |
| 357 | } |
| 358 | |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 359 | int |
| 360 | default_ssh_port(void) |
| 361 | { |
| 362 | static int port; |
| 363 | struct servent *sp; |
| 364 | |
| 365 | if (port == 0) { |
| 366 | sp = getservbyname(SSH_SERVICE_NAME, "tcp"); |
| 367 | port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT; |
| 368 | } |
| 369 | return port; |
| 370 | } |
| 371 | |
| 372 | /* |
| 373 | * Execute a command in a shell. |
| 374 | * Return its exit status or -1 on abnormal exit. |
| 375 | */ |
| 376 | static int |
| 377 | execute_in_shell(const char *cmd) |
| 378 | { |
| 379 | char *shell, *command_string; |
| 380 | pid_t pid; |
| 381 | int devnull, status; |
| 382 | extern uid_t original_real_uid; |
| 383 | |
| 384 | if ((shell = getenv("SHELL")) == NULL) |
| 385 | shell = _PATH_BSHELL; |
| 386 | |
| 387 | /* |
| 388 | * Use "exec" to avoid "sh -c" processes on some platforms |
| 389 | * (e.g. Solaris) |
| 390 | */ |
| 391 | xasprintf(&command_string, "exec %s", cmd); |
| 392 | |
| 393 | /* Need this to redirect subprocess stdin/out */ |
| 394 | if ((devnull = open(_PATH_DEVNULL, O_RDWR)) == -1) |
| 395 | fatal("open(/dev/null): %s", strerror(errno)); |
| 396 | |
| 397 | debug("Executing command: '%.500s'", cmd); |
| 398 | |
| 399 | /* Fork and execute the command. */ |
| 400 | if ((pid = fork()) == 0) { |
| 401 | char *argv[4]; |
| 402 | |
| 403 | /* Child. Permanently give up superuser privileges. */ |
| 404 | permanently_drop_suid(original_real_uid); |
| 405 | |
| 406 | /* Redirect child stdin and stdout. Leave stderr */ |
| 407 | if (dup2(devnull, STDIN_FILENO) == -1) |
| 408 | fatal("dup2: %s", strerror(errno)); |
| 409 | if (dup2(devnull, STDOUT_FILENO) == -1) |
| 410 | fatal("dup2: %s", strerror(errno)); |
| 411 | if (devnull > STDERR_FILENO) |
| 412 | close(devnull); |
| 413 | closefrom(STDERR_FILENO + 1); |
| 414 | |
| 415 | argv[0] = shell; |
| 416 | argv[1] = "-c"; |
| 417 | argv[2] = command_string; |
| 418 | argv[3] = NULL; |
| 419 | |
| 420 | execv(argv[0], argv); |
| 421 | error("Unable to execute '%.100s': %s", cmd, strerror(errno)); |
| 422 | /* Die with signal to make this error apparent to parent. */ |
| 423 | signal(SIGTERM, SIG_DFL); |
| 424 | kill(getpid(), SIGTERM); |
| 425 | _exit(1); |
| 426 | } |
| 427 | /* Parent. */ |
| 428 | if (pid < 0) |
| 429 | fatal("%s: fork: %.100s", __func__, strerror(errno)); |
| 430 | |
| 431 | close(devnull); |
| 432 | free(command_string); |
| 433 | |
| 434 | while (waitpid(pid, &status, 0) == -1) { |
| 435 | if (errno != EINTR && errno != EAGAIN) |
| 436 | fatal("%s: waitpid: %s", __func__, strerror(errno)); |
| 437 | } |
| 438 | if (!WIFEXITED(status)) { |
| 439 | error("command '%.100s' exited abnormally", cmd); |
| 440 | return -1; |
| 441 | } |
| 442 | debug3("command returned status %d", WEXITSTATUS(status)); |
| 443 | return WEXITSTATUS(status); |
| 444 | } |
| 445 | |
| 446 | /* |
| 447 | * Parse and execute a Match directive. |
| 448 | */ |
| 449 | static int |
| 450 | match_cfg_line(Options *options, char **condition, struct passwd *pw, |
| 451 | const char *host_arg, const char *filename, int linenum) |
| 452 | { |
| 453 | char *arg, *attrib, *cmd, *cp = *condition; |
| 454 | const char *ruser, *host; |
| 455 | int r, port, result = 1; |
| 456 | size_t len; |
| 457 | char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; |
| 458 | |
| 459 | /* |
| 460 | * Configuration is likely to be incomplete at this point so we |
| 461 | * must be prepared to use default values. |
| 462 | */ |
| 463 | port = options->port <= 0 ? default_ssh_port() : options->port; |
| 464 | ruser = options->user == NULL ? pw->pw_name : options->user; |
| 465 | host = options->hostname == NULL ? host_arg : options->hostname; |
| 466 | |
| 467 | debug3("checking match for '%s' host %s", cp, host); |
| 468 | while ((attrib = strdelim(&cp)) && *attrib != '\0') { |
| 469 | if ((arg = strdelim(&cp)) == NULL || *arg == '\0') { |
| 470 | error("Missing Match criteria for %s", attrib); |
| 471 | return -1; |
| 472 | } |
| 473 | len = strlen(arg); |
| 474 | if (strcasecmp(attrib, "host") == 0) { |
| 475 | if (match_hostname(host, arg, len) != 1) |
| 476 | result = 0; |
| 477 | else |
| 478 | debug("%.200s line %d: matched 'Host %.100s' ", |
| 479 | filename, linenum, host); |
| 480 | } else if (strcasecmp(attrib, "originalhost") == 0) { |
| 481 | if (match_hostname(host_arg, arg, len) != 1) |
| 482 | result = 0; |
| 483 | else |
| 484 | debug("%.200s line %d: matched " |
| 485 | "'OriginalHost %.100s' ", |
| 486 | filename, linenum, host_arg); |
| 487 | } else if (strcasecmp(attrib, "user") == 0) { |
| 488 | if (match_pattern_list(ruser, arg, len, 0) != 1) |
| 489 | result = 0; |
| 490 | else |
| 491 | debug("%.200s line %d: matched 'User %.100s' ", |
| 492 | filename, linenum, ruser); |
| 493 | } else if (strcasecmp(attrib, "localuser") == 0) { |
| 494 | if (match_pattern_list(pw->pw_name, arg, len, 0) != 1) |
| 495 | result = 0; |
| 496 | else |
| 497 | debug("%.200s line %d: matched " |
| 498 | "'LocalUser %.100s' ", |
| 499 | filename, linenum, pw->pw_name); |
| 500 | } else if (strcasecmp(attrib, "command") == 0) { |
| 501 | if (gethostname(thishost, sizeof(thishost)) == -1) |
| 502 | fatal("gethostname: %s", strerror(errno)); |
| 503 | strlcpy(shorthost, thishost, sizeof(shorthost)); |
| 504 | shorthost[strcspn(thishost, ".")] = '\0'; |
| 505 | snprintf(portstr, sizeof(portstr), "%d", port); |
| 506 | |
| 507 | cmd = percent_expand(arg, |
| 508 | "L", shorthost, |
| 509 | "d", pw->pw_dir, |
| 510 | "h", host, |
| 511 | "l", thishost, |
| 512 | "n", host_arg, |
| 513 | "p", portstr, |
| 514 | "r", ruser, |
| 515 | "u", pw->pw_name, |
| 516 | (char *)NULL); |
| 517 | r = execute_in_shell(cmd); |
| 518 | if (r == -1) { |
| 519 | fatal("%.200s line %d: match command '%.100s' " |
| 520 | "error", filename, linenum, cmd); |
| 521 | } else if (r == 0) { |
| 522 | debug("%.200s line %d: matched " |
| 523 | "'Command \"%.100s\"' ", |
| 524 | filename, linenum, cmd); |
| 525 | } else |
| 526 | result = 0; |
| 527 | free(cmd); |
| 528 | } else { |
| 529 | error("Unsupported Match attribute %s", attrib); |
| 530 | return -1; |
| 531 | } |
| 532 | } |
| 533 | debug3("match %sfound", result ? "" : "not "); |
| 534 | *condition = cp; |
| 535 | return result; |
| 536 | } |
| 537 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 538 | /* |
Ben Lindstrom | 3704c26 | 2001-04-02 18:20:03 +0000 | [diff] [blame] | 539 | * Returns the number of the token pointed to by cp or oBadOption. |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 540 | */ |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 541 | static OpCodes |
Darren Tucker | 0763698 | 2013-05-16 20:30:03 +1000 | [diff] [blame] | 542 | parse_token(const char *cp, const char *filename, int linenum, |
| 543 | const char *ignored_unknown) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 544 | { |
Darren Tucker | 0763698 | 2013-05-16 20:30:03 +1000 | [diff] [blame] | 545 | int i; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 546 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 547 | for (i = 0; keywords[i].name; i++) |
Darren Tucker | 0763698 | 2013-05-16 20:30:03 +1000 | [diff] [blame] | 548 | if (strcmp(cp, keywords[i].name) == 0) |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 549 | return keywords[i].opcode; |
Darren Tucker | 0763698 | 2013-05-16 20:30:03 +1000 | [diff] [blame] | 550 | if (ignored_unknown != NULL && match_pattern_list(cp, ignored_unknown, |
| 551 | strlen(ignored_unknown), 1) == 1) |
| 552 | return oIgnoredUnknownOption; |
Ben Lindstrom | b5cdc66 | 2001-04-16 02:13:26 +0000 | [diff] [blame] | 553 | error("%s: line %d: Bad configuration option: %s", |
| 554 | filename, linenum, cp); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 555 | return oBadOption; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 556 | } |
| 557 | |
Damien Miller | e9fc72e | 2013-10-15 12:14:12 +1100 | [diff] [blame^] | 558 | /* Multistate option parsing */ |
| 559 | struct multistate { |
| 560 | char *key; |
| 561 | int value; |
| 562 | }; |
| 563 | static const struct multistate multistate_flag[] = { |
| 564 | { "true", 1 }, |
| 565 | { "false", 0 }, |
| 566 | { "yes", 1 }, |
| 567 | { "no", 0 }, |
| 568 | { NULL, -1 } |
| 569 | }; |
| 570 | static const struct multistate multistate_yesnoask[] = { |
| 571 | { "true", 1 }, |
| 572 | { "false", 0 }, |
| 573 | { "yes", 1 }, |
| 574 | { "no", 0 }, |
| 575 | { "ask", 2 }, |
| 576 | { NULL, -1 } |
| 577 | }; |
| 578 | static const struct multistate multistate_addressfamily[] = { |
| 579 | { "inet", AF_INET }, |
| 580 | { "inet6", AF_INET6 }, |
| 581 | { "any", AF_UNSPEC }, |
| 582 | { NULL, -1 } |
| 583 | }; |
| 584 | static const struct multistate multistate_controlmaster[] = { |
| 585 | { "true", SSHCTL_MASTER_YES }, |
| 586 | { "yes", SSHCTL_MASTER_YES }, |
| 587 | { "false", SSHCTL_MASTER_NO }, |
| 588 | { "no", SSHCTL_MASTER_NO }, |
| 589 | { "auto", SSHCTL_MASTER_AUTO }, |
| 590 | { "ask", SSHCTL_MASTER_ASK }, |
| 591 | { "autoask", SSHCTL_MASTER_AUTO_ASK }, |
| 592 | { NULL, -1 } |
| 593 | }; |
| 594 | static const struct multistate multistate_tunnel[] = { |
| 595 | { "ethernet", SSH_TUNMODE_ETHERNET }, |
| 596 | { "point-to-point", SSH_TUNMODE_POINTOPOINT }, |
| 597 | { "true", SSH_TUNMODE_DEFAULT }, |
| 598 | { "yes", SSH_TUNMODE_DEFAULT }, |
| 599 | { "false", SSH_TUNMODE_NO }, |
| 600 | { "no", SSH_TUNMODE_NO }, |
| 601 | { NULL, -1 } |
| 602 | }; |
| 603 | static const struct multistate multistate_requesttty[] = { |
| 604 | { "true", REQUEST_TTY_YES }, |
| 605 | { "yes", REQUEST_TTY_YES }, |
| 606 | { "false", REQUEST_TTY_NO }, |
| 607 | { "no", REQUEST_TTY_NO }, |
| 608 | { "force", REQUEST_TTY_FORCE }, |
| 609 | { "auto", REQUEST_TTY_AUTO }, |
| 610 | { NULL, -1 } |
| 611 | }; |
| 612 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 613 | /* |
| 614 | * Processes a single option line as used in the configuration files. This |
| 615 | * only sets those values that have not already been set. |
| 616 | */ |
Damien Miller | 61f08ac | 2003-02-24 11:56:27 +1100 | [diff] [blame] | 617 | #define WHITESPACE " \t\r\n" |
Damien Miller | 2ccf661 | 1999-11-15 15:25:10 +1100 | [diff] [blame] | 618 | int |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 619 | process_config_line(Options *options, struct passwd *pw, const char *host, |
| 620 | char *line, const char *filename, int linenum, int *activep, int userconfig) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 621 | { |
Damien Miller | 295ee63 | 2011-05-29 21:42:31 +1000 | [diff] [blame] | 622 | char *s, **charptr, *endofnumber, *keyword, *arg, *arg2; |
| 623 | char **cpptr, fwdarg[256]; |
Darren Tucker | 0763698 | 2013-05-16 20:30:03 +1000 | [diff] [blame] | 624 | u_int i, *uintptr, max_entries = 0; |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 625 | int negated, opcode, *intptr, value, value2, cmdline = 0; |
Darren Tucker | 1e44c5d | 2008-01-01 20:32:26 +1100 | [diff] [blame] | 626 | LogLevel *log_level_ptr; |
Darren Tucker | 9113d0c | 2013-05-16 20:48:14 +1000 | [diff] [blame] | 627 | long long val64; |
Damien Miller | 61f08ac | 2003-02-24 11:56:27 +1100 | [diff] [blame] | 628 | size_t len; |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 629 | Forward fwd; |
Damien Miller | e9fc72e | 2013-10-15 12:14:12 +1100 | [diff] [blame^] | 630 | const struct multistate *multistate_ptr; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 631 | |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 632 | if (activep == NULL) { /* We are processing a command line directive */ |
| 633 | cmdline = 1; |
| 634 | activep = &cmdline; |
| 635 | } |
| 636 | |
Damien Miller | c652cac | 2003-05-14 13:40:54 +1000 | [diff] [blame] | 637 | /* Strip trailing whitespace */ |
Darren Tucker | 47eede7 | 2005-03-14 23:08:12 +1100 | [diff] [blame] | 638 | for (len = strlen(line) - 1; len > 0; len--) { |
Damien Miller | c652cac | 2003-05-14 13:40:54 +1000 | [diff] [blame] | 639 | if (strchr(WHITESPACE, line[len]) == NULL) |
| 640 | break; |
| 641 | line[len] = '\0'; |
| 642 | } |
| 643 | |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 644 | s = line; |
| 645 | /* Get the keyword. (Each line is supposed to begin with a keyword). */ |
Damien Miller | 928b236 | 2006-03-26 13:53:32 +1100 | [diff] [blame] | 646 | if ((keyword = strdelim(&s)) == NULL) |
| 647 | return 0; |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 648 | /* Ignore leading whitespace. */ |
| 649 | if (*keyword == '\0') |
| 650 | keyword = strdelim(&s); |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 651 | if (keyword == NULL || !*keyword || *keyword == '\n' || *keyword == '#') |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 652 | return 0; |
Darren Tucker | 0763698 | 2013-05-16 20:30:03 +1000 | [diff] [blame] | 653 | /* Match lowercase keyword */ |
Damien Miller | e9fc72e | 2013-10-15 12:14:12 +1100 | [diff] [blame^] | 654 | lowercase(keyword); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 655 | |
Darren Tucker | 0763698 | 2013-05-16 20:30:03 +1000 | [diff] [blame] | 656 | opcode = parse_token(keyword, filename, linenum, |
| 657 | options->ignored_unknown); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 658 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 659 | switch (opcode) { |
| 660 | case oBadOption: |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 661 | /* don't panic, but count bad options */ |
| 662 | return -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 663 | /* NOTREACHED */ |
Darren Tucker | 0763698 | 2013-05-16 20:30:03 +1000 | [diff] [blame] | 664 | case oIgnoredUnknownOption: |
| 665 | debug("%s line %d: Ignored unknown option \"%s\"", |
| 666 | filename, linenum, keyword); |
| 667 | return 0; |
Damien Miller | b78d5eb | 2003-05-16 11:39:04 +1000 | [diff] [blame] | 668 | case oConnectTimeout: |
| 669 | intptr = &options->connection_timeout; |
Damien Miller | 509b010 | 2003-12-17 16:33:10 +1100 | [diff] [blame] | 670 | parse_time: |
Damien Miller | b78d5eb | 2003-05-16 11:39:04 +1000 | [diff] [blame] | 671 | arg = strdelim(&s); |
| 672 | if (!arg || *arg == '\0') |
| 673 | fatal("%s line %d: missing time value.", |
| 674 | filename, linenum); |
| 675 | if ((value = convtime(arg)) == -1) |
| 676 | fatal("%s line %d: invalid time value.", |
| 677 | filename, linenum); |
Darren Tucker | a52c5b6 | 2007-02-19 22:09:45 +1100 | [diff] [blame] | 678 | if (*activep && *intptr == -1) |
Damien Miller | b78d5eb | 2003-05-16 11:39:04 +1000 | [diff] [blame] | 679 | *intptr = value; |
| 680 | break; |
| 681 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 682 | case oForwardAgent: |
| 683 | intptr = &options->forward_agent; |
Damien Miller | e9fc72e | 2013-10-15 12:14:12 +1100 | [diff] [blame^] | 684 | parse_flag: |
| 685 | multistate_ptr = multistate_flag; |
| 686 | parse_multistate: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 687 | arg = strdelim(&s); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 688 | if (!arg || *arg == '\0') |
Damien Miller | e9fc72e | 2013-10-15 12:14:12 +1100 | [diff] [blame^] | 689 | fatal("%s line %d: missing argument.", |
| 690 | filename, linenum); |
| 691 | value = -1; |
| 692 | for (i = 0; multistate_ptr[i].key != NULL; i++) { |
| 693 | if (strcasecmp(arg, multistate_ptr[i].key) == 0) { |
| 694 | value = multistate_ptr[i].value; |
| 695 | break; |
| 696 | } |
| 697 | } |
| 698 | if (value == -1) |
| 699 | fatal("%s line %d: unsupported option \"%s\".", |
| 700 | filename, linenum, arg); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 701 | if (*activep && *intptr == -1) |
| 702 | *intptr = value; |
| 703 | break; |
| 704 | |
| 705 | case oForwardX11: |
| 706 | intptr = &options->forward_x11; |
| 707 | goto parse_flag; |
| 708 | |
Darren Tucker | 0a118da | 2003-10-15 15:54:32 +1000 | [diff] [blame] | 709 | case oForwardX11Trusted: |
| 710 | intptr = &options->forward_x11_trusted; |
| 711 | goto parse_flag; |
Damien Miller | 1ab6a51 | 2010-06-26 10:02:24 +1000 | [diff] [blame] | 712 | |
| 713 | case oForwardX11Timeout: |
| 714 | intptr = &options->forward_x11_timeout; |
| 715 | goto parse_time; |
Darren Tucker | 0a118da | 2003-10-15 15:54:32 +1000 | [diff] [blame] | 716 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 717 | case oGatewayPorts: |
| 718 | intptr = &options->gateway_ports; |
| 719 | goto parse_flag; |
| 720 | |
Darren Tucker | e7d4b19 | 2006-07-12 22:17:10 +1000 | [diff] [blame] | 721 | case oExitOnForwardFailure: |
| 722 | intptr = &options->exit_on_forward_failure; |
| 723 | goto parse_flag; |
| 724 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 725 | case oUsePrivilegedPort: |
| 726 | intptr = &options->use_privileged_port; |
| 727 | goto parse_flag; |
| 728 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 729 | case oPasswordAuthentication: |
| 730 | intptr = &options->password_authentication; |
| 731 | goto parse_flag; |
| 732 | |
Damien Miller | 01ed227 | 2008-11-05 16:20:46 +1100 | [diff] [blame] | 733 | case oZeroKnowledgePasswordAuthentication: |
| 734 | intptr = &options->zero_knowledge_password_authentication; |
| 735 | goto parse_flag; |
| 736 | |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 737 | case oKbdInteractiveAuthentication: |
| 738 | intptr = &options->kbd_interactive_authentication; |
| 739 | goto parse_flag; |
| 740 | |
| 741 | case oKbdInteractiveDevices: |
| 742 | charptr = &options->kbd_interactive_devices; |
| 743 | goto parse_string; |
| 744 | |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 745 | case oPubkeyAuthentication: |
| 746 | intptr = &options->pubkey_authentication; |
Damien Miller | e247cc4 | 2000-05-07 12:03:14 +1000 | [diff] [blame] | 747 | goto parse_flag; |
| 748 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 749 | case oRSAAuthentication: |
| 750 | intptr = &options->rsa_authentication; |
| 751 | goto parse_flag; |
| 752 | |
| 753 | case oRhostsRSAAuthentication: |
| 754 | intptr = &options->rhosts_rsa_authentication; |
| 755 | goto parse_flag; |
| 756 | |
Ben Lindstrom | 5eabda3 | 2001-04-12 23:34:34 +0000 | [diff] [blame] | 757 | case oHostbasedAuthentication: |
| 758 | intptr = &options->hostbased_authentication; |
| 759 | goto parse_flag; |
| 760 | |
Ben Lindstrom | 95fb2dd | 2001-01-23 03:12:10 +0000 | [diff] [blame] | 761 | case oChallengeResponseAuthentication: |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 762 | intptr = &options->challenge_response_authentication; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 763 | goto parse_flag; |
Damien Miller | 2aa0ab4 | 2003-05-15 12:05:28 +1000 | [diff] [blame] | 764 | |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 765 | case oGssAuthentication: |
| 766 | intptr = &options->gss_authentication; |
| 767 | goto parse_flag; |
| 768 | |
| 769 | case oGssDelegateCreds: |
| 770 | intptr = &options->gss_deleg_creds; |
| 771 | goto parse_flag; |
| 772 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 773 | case oBatchMode: |
| 774 | intptr = &options->batch_mode; |
| 775 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 776 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 777 | case oCheckHostIP: |
| 778 | intptr = &options->check_host_ip; |
Damien Miller | 1028824 | 2008-06-30 00:04:03 +1000 | [diff] [blame] | 779 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 780 | |
Damien Miller | 37876e9 | 2003-05-15 10:19:46 +1000 | [diff] [blame] | 781 | case oVerifyHostKeyDNS: |
| 782 | intptr = &options->verify_host_key_dns; |
Damien Miller | e9fc72e | 2013-10-15 12:14:12 +1100 | [diff] [blame^] | 783 | multistate_ptr = multistate_yesnoask; |
| 784 | goto parse_multistate; |
Damien Miller | 37876e9 | 2003-05-15 10:19:46 +1000 | [diff] [blame] | 785 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 786 | case oStrictHostKeyChecking: |
| 787 | intptr = &options->strict_host_key_checking; |
Damien Miller | e9fc72e | 2013-10-15 12:14:12 +1100 | [diff] [blame^] | 788 | multistate_ptr = multistate_yesnoask; |
| 789 | goto parse_multistate; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 790 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 791 | case oCompression: |
| 792 | intptr = &options->compression; |
| 793 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 794 | |
Damien Miller | 12c150e | 2003-12-17 16:31:10 +1100 | [diff] [blame] | 795 | case oTCPKeepAlive: |
| 796 | intptr = &options->tcp_keep_alive; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 797 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 798 | |
Ben Lindstrom | 3cecc9a | 2001-10-03 17:39:38 +0000 | [diff] [blame] | 799 | case oNoHostAuthenticationForLocalhost: |
| 800 | intptr = &options->no_host_authentication_for_localhost; |
| 801 | goto parse_flag; |
| 802 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 803 | case oNumberOfPasswordPrompts: |
| 804 | intptr = &options->number_of_password_prompts; |
| 805 | goto parse_int; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 806 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 807 | case oCompressionLevel: |
| 808 | intptr = &options->compression_level; |
| 809 | goto parse_int; |
| 810 | |
Damien Miller | a5539d2 | 2003-04-09 20:50:06 +1000 | [diff] [blame] | 811 | case oRekeyLimit: |
Damien Miller | a5539d2 | 2003-04-09 20:50:06 +1000 | [diff] [blame] | 812 | arg = strdelim(&s); |
| 813 | if (!arg || *arg == '\0') |
Darren Tucker | c53c2af | 2013-05-16 20:28:16 +1000 | [diff] [blame] | 814 | fatal("%.200s line %d: Missing argument.", filename, |
| 815 | linenum); |
| 816 | if (strcmp(arg, "default") == 0) { |
| 817 | val64 = 0; |
| 818 | } else { |
Darren Tucker | b7ee852 | 2013-05-16 20:33:10 +1000 | [diff] [blame] | 819 | if (scan_scaled(arg, &val64) == -1) |
| 820 | fatal("%.200s line %d: Bad number '%s': %s", |
| 821 | filename, linenum, arg, strerror(errno)); |
| 822 | /* check for too-large or too-small limits */ |
| 823 | if (val64 > UINT_MAX) |
Darren Tucker | c53c2af | 2013-05-16 20:28:16 +1000 | [diff] [blame] | 824 | fatal("%.200s line %d: RekeyLimit too large", |
| 825 | filename, linenum); |
| 826 | if (val64 != 0 && val64 < 16) |
| 827 | fatal("%.200s line %d: RekeyLimit too small", |
| 828 | filename, linenum); |
Damien Miller | a5539d2 | 2003-04-09 20:50:06 +1000 | [diff] [blame] | 829 | } |
Damien Miller | 3dff176 | 2008-02-10 22:25:52 +1100 | [diff] [blame] | 830 | if (*activep && options->rekey_limit == -1) |
| 831 | options->rekey_limit = (u_int32_t)val64; |
Darren Tucker | c53c2af | 2013-05-16 20:28:16 +1000 | [diff] [blame] | 832 | if (s != NULL) { /* optional rekey interval present */ |
| 833 | if (strcmp(s, "none") == 0) { |
| 834 | (void)strdelim(&s); /* discard */ |
| 835 | break; |
| 836 | } |
| 837 | intptr = &options->rekey_interval; |
| 838 | goto parse_time; |
| 839 | } |
Damien Miller | a5539d2 | 2003-04-09 20:50:06 +1000 | [diff] [blame] | 840 | break; |
| 841 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 842 | case oIdentityFile: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 843 | arg = strdelim(&s); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 844 | if (!arg || *arg == '\0') |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 845 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
| 846 | if (*activep) { |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 847 | intptr = &options->num_identity_files; |
Damien Miller | eba71ba | 2000-04-29 23:57:08 +1000 | [diff] [blame] | 848 | if (*intptr >= SSH_MAX_IDENTITY_FILES) |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 849 | fatal("%.200s line %d: Too many identity files specified (max %d).", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 850 | filename, linenum, SSH_MAX_IDENTITY_FILES); |
Darren Tucker | aefa368 | 2013-04-05 11:18:35 +1100 | [diff] [blame] | 851 | add_identity_file(options, NULL, arg, userconfig); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 852 | } |
| 853 | break; |
| 854 | |
Damien Miller | d3a1857 | 2000-06-07 19:55:44 +1000 | [diff] [blame] | 855 | case oXAuthLocation: |
| 856 | charptr=&options->xauth_location; |
| 857 | goto parse_string; |
| 858 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 859 | case oUser: |
| 860 | charptr = &options->user; |
| 861 | parse_string: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 862 | arg = strdelim(&s); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 863 | if (!arg || *arg == '\0') |
Damien Miller | 295ee63 | 2011-05-29 21:42:31 +1000 | [diff] [blame] | 864 | fatal("%.200s line %d: Missing argument.", |
| 865 | filename, linenum); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 866 | if (*activep && *charptr == NULL) |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 867 | *charptr = xstrdup(arg); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 868 | break; |
| 869 | |
| 870 | case oGlobalKnownHostsFile: |
Damien Miller | 295ee63 | 2011-05-29 21:42:31 +1000 | [diff] [blame] | 871 | cpptr = (char **)&options->system_hostfiles; |
| 872 | uintptr = &options->num_system_hostfiles; |
| 873 | max_entries = SSH_MAX_HOSTS_FILES; |
| 874 | parse_char_array: |
| 875 | if (*activep && *uintptr == 0) { |
| 876 | while ((arg = strdelim(&s)) != NULL && *arg != '\0') { |
| 877 | if ((*uintptr) >= max_entries) |
| 878 | fatal("%s line %d: " |
| 879 | "too many authorized keys files.", |
| 880 | filename, linenum); |
| 881 | cpptr[(*uintptr)++] = xstrdup(arg); |
| 882 | } |
| 883 | } |
| 884 | return 0; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 885 | |
| 886 | case oUserKnownHostsFile: |
Damien Miller | 295ee63 | 2011-05-29 21:42:31 +1000 | [diff] [blame] | 887 | cpptr = (char **)&options->user_hostfiles; |
| 888 | uintptr = &options->num_user_hostfiles; |
| 889 | max_entries = SSH_MAX_HOSTS_FILES; |
| 890 | goto parse_char_array; |
Damien Miller | eba71ba | 2000-04-29 23:57:08 +1000 | [diff] [blame] | 891 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 892 | case oHostName: |
| 893 | charptr = &options->hostname; |
| 894 | goto parse_string; |
| 895 | |
Ben Lindstrom | 4dccfa5 | 2000-12-28 16:40:05 +0000 | [diff] [blame] | 896 | case oHostKeyAlias: |
| 897 | charptr = &options->host_key_alias; |
| 898 | goto parse_string; |
| 899 | |
Ben Lindstrom | b9be60a | 2001-03-11 01:49:19 +0000 | [diff] [blame] | 900 | case oPreferredAuthentications: |
| 901 | charptr = &options->preferred_authentications; |
| 902 | goto parse_string; |
| 903 | |
Ben Lindstrom | e0f8804 | 2001-04-30 13:06:24 +0000 | [diff] [blame] | 904 | case oBindAddress: |
| 905 | charptr = &options->bind_address; |
| 906 | goto parse_string; |
| 907 | |
Damien Miller | 7ea845e | 2010-02-12 09:21:02 +1100 | [diff] [blame] | 908 | case oPKCS11Provider: |
| 909 | charptr = &options->pkcs11_provider; |
Ben Lindstrom | f7db3bb | 2001-08-06 21:35:51 +0000 | [diff] [blame] | 910 | goto parse_string; |
Ben Lindstrom | ae996bf | 2001-08-06 21:27:53 +0000 | [diff] [blame] | 911 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 912 | case oProxyCommand: |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 913 | charptr = &options->proxy_command; |
| 914 | parse_command: |
Darren Tucker | a99c1b7 | 2003-06-28 12:40:12 +1000 | [diff] [blame] | 915 | if (s == NULL) |
| 916 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
Damien Miller | 61f08ac | 2003-02-24 11:56:27 +1100 | [diff] [blame] | 917 | len = strspn(s, WHITESPACE "="); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 918 | if (*activep && *charptr == NULL) |
Damien Miller | 61f08ac | 2003-02-24 11:56:27 +1100 | [diff] [blame] | 919 | *charptr = xstrdup(s + len); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 920 | return 0; |
| 921 | |
| 922 | case oPort: |
| 923 | intptr = &options->port; |
| 924 | parse_int: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 925 | arg = strdelim(&s); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 926 | if (!arg || *arg == '\0') |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 927 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 928 | if (arg[0] < '0' || arg[0] > '9') |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 929 | fatal("%.200s line %d: Bad number.", filename, linenum); |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 930 | |
| 931 | /* Octal, decimal, or hex format? */ |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 932 | value = strtol(arg, &endofnumber, 0); |
| 933 | if (arg == endofnumber) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 934 | fatal("%.200s line %d: Bad number.", filename, linenum); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 935 | if (*activep && *intptr == -1) |
| 936 | *intptr = value; |
| 937 | break; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 938 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 939 | case oConnectionAttempts: |
| 940 | intptr = &options->connection_attempts; |
| 941 | goto parse_int; |
Damien Miller | 5ce662a | 1999-11-11 17:57:39 +1100 | [diff] [blame] | 942 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 943 | case oCipher: |
| 944 | intptr = &options->cipher; |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 945 | arg = strdelim(&s); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 946 | if (!arg || *arg == '\0') |
Damien Miller | b1715dc | 2000-05-30 13:44:51 +1000 | [diff] [blame] | 947 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 948 | value = cipher_number(arg); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 949 | if (value == -1) |
| 950 | fatal("%.200s line %d: Bad cipher '%s'.", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 951 | filename, linenum, arg ? arg : "<NONE>"); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 952 | if (*activep && *intptr == -1) |
| 953 | *intptr = value; |
| 954 | break; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 955 | |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 956 | case oCiphers: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 957 | arg = strdelim(&s); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 958 | if (!arg || *arg == '\0') |
Damien Miller | b1715dc | 2000-05-30 13:44:51 +1000 | [diff] [blame] | 959 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 960 | if (!ciphers_valid(arg)) |
Damien Miller | 30c3d42 | 2000-05-09 11:02:59 +1000 | [diff] [blame] | 961 | fatal("%.200s line %d: Bad SSH2 cipher spec '%s'.", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 962 | filename, linenum, arg ? arg : "<NONE>"); |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 963 | if (*activep && options->ciphers == NULL) |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 964 | options->ciphers = xstrdup(arg); |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 965 | break; |
| 966 | |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 967 | case oMacs: |
| 968 | arg = strdelim(&s); |
| 969 | if (!arg || *arg == '\0') |
| 970 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
| 971 | if (!mac_valid(arg)) |
| 972 | fatal("%.200s line %d: Bad SSH2 Mac spec '%s'.", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 973 | filename, linenum, arg ? arg : "<NONE>"); |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 974 | if (*activep && options->macs == NULL) |
| 975 | options->macs = xstrdup(arg); |
| 976 | break; |
| 977 | |
Damien Miller | d5f62bf | 2010-09-24 22:11:14 +1000 | [diff] [blame] | 978 | case oKexAlgorithms: |
| 979 | arg = strdelim(&s); |
| 980 | if (!arg || *arg == '\0') |
| 981 | fatal("%.200s line %d: Missing argument.", |
| 982 | filename, linenum); |
| 983 | if (!kex_names_valid(arg)) |
| 984 | fatal("%.200s line %d: Bad SSH2 KexAlgorithms '%s'.", |
| 985 | filename, linenum, arg ? arg : "<NONE>"); |
| 986 | if (*activep && options->kex_algorithms == NULL) |
| 987 | options->kex_algorithms = xstrdup(arg); |
| 988 | break; |
| 989 | |
Ben Lindstrom | 982dbbc | 2001-04-17 18:11:36 +0000 | [diff] [blame] | 990 | case oHostKeyAlgorithms: |
| 991 | arg = strdelim(&s); |
| 992 | if (!arg || *arg == '\0') |
| 993 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
| 994 | if (!key_names_valid2(arg)) |
| 995 | fatal("%.200s line %d: Bad protocol 2 host key algorithms '%s'.", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 996 | filename, linenum, arg ? arg : "<NONE>"); |
Ben Lindstrom | 982dbbc | 2001-04-17 18:11:36 +0000 | [diff] [blame] | 997 | if (*activep && options->hostkeyalgorithms == NULL) |
| 998 | options->hostkeyalgorithms = xstrdup(arg); |
| 999 | break; |
| 1000 | |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 1001 | case oProtocol: |
| 1002 | intptr = &options->protocol; |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 1003 | arg = strdelim(&s); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 1004 | if (!arg || *arg == '\0') |
Damien Miller | b1715dc | 2000-05-30 13:44:51 +1000 | [diff] [blame] | 1005 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 1006 | value = proto_spec(arg); |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 1007 | if (value == SSH_PROTO_UNKNOWN) |
| 1008 | fatal("%.200s line %d: Bad protocol spec '%s'.", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 1009 | filename, linenum, arg ? arg : "<NONE>"); |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 1010 | if (*activep && *intptr == SSH_PROTO_UNKNOWN) |
| 1011 | *intptr = value; |
| 1012 | break; |
| 1013 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1014 | case oLogLevel: |
Darren Tucker | 1e44c5d | 2008-01-01 20:32:26 +1100 | [diff] [blame] | 1015 | log_level_ptr = &options->log_level; |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 1016 | arg = strdelim(&s); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 1017 | value = log_level_number(arg); |
Damien Miller | fcd9320 | 2002-02-05 12:26:34 +1100 | [diff] [blame] | 1018 | if (value == SYSLOG_LEVEL_NOT_SET) |
Ben Lindstrom | 6df8ef4 | 2001-03-05 07:47:23 +0000 | [diff] [blame] | 1019 | fatal("%.200s line %d: unsupported log level '%s'", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 1020 | filename, linenum, arg ? arg : "<NONE>"); |
Darren Tucker | 1e44c5d | 2008-01-01 20:32:26 +1100 | [diff] [blame] | 1021 | if (*activep && *log_level_ptr == SYSLOG_LEVEL_NOT_SET) |
| 1022 | *log_level_ptr = (LogLevel) value; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1023 | break; |
| 1024 | |
Ben Lindstrom | 62c25a4 | 2001-09-12 18:01:59 +0000 | [diff] [blame] | 1025 | case oLocalForward: |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1026 | case oRemoteForward: |
Damien Miller | a699d95 | 2008-11-03 19:27:34 +1100 | [diff] [blame] | 1027 | case oDynamicForward: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 1028 | arg = strdelim(&s); |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1029 | if (arg == NULL || *arg == '\0') |
Ben Lindstrom | 62c25a4 | 2001-09-12 18:01:59 +0000 | [diff] [blame] | 1030 | fatal("%.200s line %d: Missing port argument.", |
| 1031 | filename, linenum); |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1032 | |
Damien Miller | a699d95 | 2008-11-03 19:27:34 +1100 | [diff] [blame] | 1033 | if (opcode == oLocalForward || |
| 1034 | opcode == oRemoteForward) { |
| 1035 | arg2 = strdelim(&s); |
| 1036 | if (arg2 == NULL || *arg2 == '\0') |
| 1037 | fatal("%.200s line %d: Missing target argument.", |
| 1038 | filename, linenum); |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1039 | |
Damien Miller | a699d95 | 2008-11-03 19:27:34 +1100 | [diff] [blame] | 1040 | /* construct a string for parse_forward */ |
| 1041 | snprintf(fwdarg, sizeof(fwdarg), "%s:%s", arg, arg2); |
| 1042 | } else if (opcode == oDynamicForward) { |
| 1043 | strlcpy(fwdarg, arg, sizeof(fwdarg)); |
| 1044 | } |
| 1045 | |
| 1046 | if (parse_forward(&fwd, fwdarg, |
Damien Miller | 4bf648f | 2009-02-14 16:28:21 +1100 | [diff] [blame] | 1047 | opcode == oDynamicForward ? 1 : 0, |
| 1048 | opcode == oRemoteForward ? 1 : 0) == 0) |
Ben Lindstrom | 62c25a4 | 2001-09-12 18:01:59 +0000 | [diff] [blame] | 1049 | fatal("%.200s line %d: Bad forwarding specification.", |
| 1050 | filename, linenum); |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1051 | |
Ben Lindstrom | 62c25a4 | 2001-09-12 18:01:59 +0000 | [diff] [blame] | 1052 | if (*activep) { |
Damien Miller | a699d95 | 2008-11-03 19:27:34 +1100 | [diff] [blame] | 1053 | if (opcode == oLocalForward || |
| 1054 | opcode == oDynamicForward) |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1055 | add_local_forward(options, &fwd); |
Ben Lindstrom | 62c25a4 | 2001-09-12 18:01:59 +0000 | [diff] [blame] | 1056 | else if (opcode == oRemoteForward) |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1057 | add_remote_forward(options, &fwd); |
Ben Lindstrom | 62c25a4 | 2001-09-12 18:01:59 +0000 | [diff] [blame] | 1058 | } |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1059 | break; |
| 1060 | |
Ben Lindstrom | 2b7a0e9 | 2001-09-20 00:57:55 +0000 | [diff] [blame] | 1061 | case oClearAllForwardings: |
| 1062 | intptr = &options->clear_forwardings; |
| 1063 | goto parse_flag; |
| 1064 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1065 | case oHost: |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 1066 | if (cmdline) |
| 1067 | fatal("Host directive not supported as a command-line " |
| 1068 | "option"); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1069 | *activep = 0; |
Damien Miller | fe92421 | 2011-05-15 08:44:45 +1000 | [diff] [blame] | 1070 | arg2 = NULL; |
| 1071 | while ((arg = strdelim(&s)) != NULL && *arg != '\0') { |
| 1072 | negated = *arg == '!'; |
| 1073 | if (negated) |
| 1074 | arg++; |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 1075 | if (match_pattern(host, arg)) { |
Damien Miller | fe92421 | 2011-05-15 08:44:45 +1000 | [diff] [blame] | 1076 | if (negated) { |
| 1077 | debug("%.200s line %d: Skipping Host " |
| 1078 | "block because of negated match " |
| 1079 | "for %.100s", filename, linenum, |
| 1080 | arg); |
| 1081 | *activep = 0; |
| 1082 | break; |
| 1083 | } |
| 1084 | if (!*activep) |
| 1085 | arg2 = arg; /* logged below */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1086 | *activep = 1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1087 | } |
Damien Miller | fe92421 | 2011-05-15 08:44:45 +1000 | [diff] [blame] | 1088 | } |
| 1089 | if (*activep) |
| 1090 | debug("%.200s line %d: Applying options for %.100s", |
| 1091 | filename, linenum, arg2); |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 1092 | /* Avoid garbage check below, as strdelim is done. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1093 | return 0; |
| 1094 | |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 1095 | case oMatch: |
| 1096 | if (cmdline) |
| 1097 | fatal("Host directive not supported as a command-line " |
| 1098 | "option"); |
| 1099 | value = match_cfg_line(options, &s, pw, host, |
| 1100 | filename, linenum); |
| 1101 | if (value < 0) |
| 1102 | fatal("%.200s line %d: Bad Match condition", filename, |
| 1103 | linenum); |
| 1104 | *activep = value; |
| 1105 | break; |
| 1106 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1107 | case oEscapeChar: |
| 1108 | intptr = &options->escape_char; |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 1109 | arg = strdelim(&s); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 1110 | if (!arg || *arg == '\0') |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1111 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 1112 | if (arg[0] == '^' && arg[2] == 0 && |
Ben Lindstrom | 46c1622 | 2000-12-22 01:43:59 +0000 | [diff] [blame] | 1113 | (u_char) arg[1] >= 64 && (u_char) arg[1] < 128) |
| 1114 | value = (u_char) arg[1] & 31; |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 1115 | else if (strlen(arg) == 1) |
Ben Lindstrom | 46c1622 | 2000-12-22 01:43:59 +0000 | [diff] [blame] | 1116 | value = (u_char) arg[0]; |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 1117 | else if (strcmp(arg, "none") == 0) |
Ben Lindstrom | 2b1f71b | 2001-06-05 20:32:21 +0000 | [diff] [blame] | 1118 | value = SSH_ESCAPECHAR_NONE; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1119 | else { |
| 1120 | fatal("%.200s line %d: Bad escape character.", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 1121 | filename, linenum); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1122 | /* NOTREACHED */ |
| 1123 | value = 0; /* Avoid compiler warning. */ |
| 1124 | } |
| 1125 | if (*activep && *intptr == -1) |
| 1126 | *intptr = value; |
| 1127 | break; |
| 1128 | |
Damien Miller | 20a8f97 | 2003-05-18 20:50:30 +1000 | [diff] [blame] | 1129 | case oAddressFamily: |
Darren Tucker | 0a4f04b | 2003-07-03 20:37:47 +1000 | [diff] [blame] | 1130 | intptr = &options->address_family; |
Damien Miller | e9fc72e | 2013-10-15 12:14:12 +1100 | [diff] [blame^] | 1131 | multistate_ptr = multistate_addressfamily; |
| 1132 | goto parse_multistate; |
Damien Miller | 20a8f97 | 2003-05-18 20:50:30 +1000 | [diff] [blame] | 1133 | |
Ben Lindstrom | b6df73b | 2002-11-09 15:52:31 +0000 | [diff] [blame] | 1134 | case oEnableSSHKeysign: |
| 1135 | intptr = &options->enable_ssh_keysign; |
| 1136 | goto parse_flag; |
| 1137 | |
Damien Miller | bd394c3 | 2004-03-08 23:12:36 +1100 | [diff] [blame] | 1138 | case oIdentitiesOnly: |
| 1139 | intptr = &options->identities_only; |
| 1140 | goto parse_flag; |
| 1141 | |
Damien Miller | 509b010 | 2003-12-17 16:33:10 +1100 | [diff] [blame] | 1142 | case oServerAliveInterval: |
| 1143 | intptr = &options->server_alive_interval; |
| 1144 | goto parse_time; |
| 1145 | |
| 1146 | case oServerAliveCountMax: |
| 1147 | intptr = &options->server_alive_count_max; |
| 1148 | goto parse_int; |
| 1149 | |
Darren Tucker | 46bc075 | 2004-05-02 22:11:30 +1000 | [diff] [blame] | 1150 | case oSendEnv: |
| 1151 | while ((arg = strdelim(&s)) != NULL && *arg != '\0') { |
| 1152 | if (strchr(arg, '=') != NULL) |
| 1153 | fatal("%s line %d: Invalid environment name.", |
| 1154 | filename, linenum); |
Damien Miller | f8e7acc | 2005-03-05 11:22:50 +1100 | [diff] [blame] | 1155 | if (!*activep) |
| 1156 | continue; |
Darren Tucker | 46bc075 | 2004-05-02 22:11:30 +1000 | [diff] [blame] | 1157 | if (options->num_send_env >= MAX_SEND_ENV) |
| 1158 | fatal("%s line %d: too many send env.", |
| 1159 | filename, linenum); |
| 1160 | options->send_env[options->num_send_env++] = |
| 1161 | xstrdup(arg); |
| 1162 | } |
| 1163 | break; |
| 1164 | |
Damien Miller | 0e220db | 2004-06-15 10:34:08 +1000 | [diff] [blame] | 1165 | case oControlPath: |
| 1166 | charptr = &options->control_path; |
| 1167 | goto parse_string; |
| 1168 | |
| 1169 | case oControlMaster: |
| 1170 | intptr = &options->control_master; |
Damien Miller | e9fc72e | 2013-10-15 12:14:12 +1100 | [diff] [blame^] | 1171 | multistate_ptr = multistate_controlmaster; |
| 1172 | goto parse_multistate; |
Damien Miller | 0e220db | 2004-06-15 10:34:08 +1000 | [diff] [blame] | 1173 | |
Damien Miller | e11e1ea | 2010-08-03 16:04:46 +1000 | [diff] [blame] | 1174 | case oControlPersist: |
| 1175 | /* no/false/yes/true, or a time spec */ |
| 1176 | intptr = &options->control_persist; |
| 1177 | arg = strdelim(&s); |
| 1178 | if (!arg || *arg == '\0') |
| 1179 | fatal("%.200s line %d: Missing ControlPersist" |
| 1180 | " argument.", filename, linenum); |
| 1181 | value = 0; |
| 1182 | value2 = 0; /* timeout */ |
| 1183 | if (strcmp(arg, "no") == 0 || strcmp(arg, "false") == 0) |
| 1184 | value = 0; |
| 1185 | else if (strcmp(arg, "yes") == 0 || strcmp(arg, "true") == 0) |
| 1186 | value = 1; |
| 1187 | else if ((value2 = convtime(arg)) >= 0) |
| 1188 | value = 1; |
| 1189 | else |
| 1190 | fatal("%.200s line %d: Bad ControlPersist argument.", |
| 1191 | filename, linenum); |
| 1192 | if (*activep && *intptr == -1) { |
| 1193 | *intptr = value; |
| 1194 | options->control_persist_timeout = value2; |
| 1195 | } |
| 1196 | break; |
| 1197 | |
Damien Miller | e177615 | 2005-03-01 21:47:37 +1100 | [diff] [blame] | 1198 | case oHashKnownHosts: |
| 1199 | intptr = &options->hash_known_hosts; |
| 1200 | goto parse_flag; |
| 1201 | |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 1202 | case oTunnel: |
| 1203 | intptr = &options->tun_open; |
Damien Miller | e9fc72e | 2013-10-15 12:14:12 +1100 | [diff] [blame^] | 1204 | multistate_ptr = multistate_tunnel; |
| 1205 | goto parse_multistate; |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 1206 | |
| 1207 | case oTunnelDevice: |
| 1208 | arg = strdelim(&s); |
| 1209 | if (!arg || *arg == '\0') |
| 1210 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
| 1211 | value = a2tun(arg, &value2); |
Damien Miller | 7b58e80 | 2005-12-13 19:33:19 +1100 | [diff] [blame] | 1212 | if (value == SSH_TUNID_ERR) |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 1213 | fatal("%.200s line %d: Bad tun device.", filename, linenum); |
| 1214 | if (*activep) { |
| 1215 | options->tun_local = value; |
| 1216 | options->tun_remote = value2; |
| 1217 | } |
| 1218 | break; |
| 1219 | |
| 1220 | case oLocalCommand: |
| 1221 | charptr = &options->local_command; |
| 1222 | goto parse_command; |
| 1223 | |
| 1224 | case oPermitLocalCommand: |
| 1225 | intptr = &options->permit_local_command; |
| 1226 | goto parse_flag; |
| 1227 | |
Damien Miller | 1028824 | 2008-06-30 00:04:03 +1000 | [diff] [blame] | 1228 | case oVisualHostKey: |
| 1229 | intptr = &options->visual_host_key; |
| 1230 | goto parse_flag; |
| 1231 | |
Damien Miller | 0dac6fb | 2010-11-20 15:19:38 +1100 | [diff] [blame] | 1232 | case oIPQoS: |
| 1233 | arg = strdelim(&s); |
| 1234 | if ((value = parse_ipqos(arg)) == -1) |
| 1235 | fatal("%s line %d: Bad IPQoS value: %s", |
| 1236 | filename, linenum, arg); |
| 1237 | arg = strdelim(&s); |
| 1238 | if (arg == NULL) |
| 1239 | value2 = value; |
| 1240 | else if ((value2 = parse_ipqos(arg)) == -1) |
| 1241 | fatal("%s line %d: Bad IPQoS value: %s", |
| 1242 | filename, linenum, arg); |
| 1243 | if (*activep) { |
| 1244 | options->ip_qos_interactive = value; |
| 1245 | options->ip_qos_bulk = value2; |
| 1246 | } |
| 1247 | break; |
| 1248 | |
Darren Tucker | 71e4d54 | 2009-07-06 07:12:27 +1000 | [diff] [blame] | 1249 | case oUseRoaming: |
| 1250 | intptr = &options->use_roaming; |
| 1251 | goto parse_flag; |
| 1252 | |
Damien Miller | 21771e2 | 2011-05-15 08:45:50 +1000 | [diff] [blame] | 1253 | case oRequestTTY: |
Damien Miller | 21771e2 | 2011-05-15 08:45:50 +1000 | [diff] [blame] | 1254 | intptr = &options->request_tty; |
Damien Miller | e9fc72e | 2013-10-15 12:14:12 +1100 | [diff] [blame^] | 1255 | multistate_ptr = multistate_requesttty; |
| 1256 | goto parse_multistate; |
Damien Miller | 21771e2 | 2011-05-15 08:45:50 +1000 | [diff] [blame] | 1257 | |
Darren Tucker | 0763698 | 2013-05-16 20:30:03 +1000 | [diff] [blame] | 1258 | case oIgnoreUnknown: |
| 1259 | charptr = &options->ignored_unknown; |
| 1260 | goto parse_string; |
| 1261 | |
Damien Miller | 1262b66 | 2013-08-21 02:44:24 +1000 | [diff] [blame] | 1262 | case oProxyUseFdpass: |
| 1263 | intptr = &options->proxy_use_fdpass; |
| 1264 | goto parse_flag; |
| 1265 | |
Ben Lindstrom | 4daea86 | 2002-06-09 20:04:02 +0000 | [diff] [blame] | 1266 | case oDeprecated: |
Ben Lindstrom | 2e17b08 | 2002-06-09 20:13:27 +0000 | [diff] [blame] | 1267 | debug("%s line %d: Deprecated option \"%s\"", |
Ben Lindstrom | 4daea86 | 2002-06-09 20:04:02 +0000 | [diff] [blame] | 1268 | filename, linenum, keyword); |
Ben Lindstrom | 2e17b08 | 2002-06-09 20:13:27 +0000 | [diff] [blame] | 1269 | return 0; |
Ben Lindstrom | 4daea86 | 2002-06-09 20:04:02 +0000 | [diff] [blame] | 1270 | |
Damien Miller | f9b3feb | 2003-05-16 11:38:32 +1000 | [diff] [blame] | 1271 | case oUnsupported: |
| 1272 | error("%s line %d: Unsupported option \"%s\"", |
| 1273 | filename, linenum, keyword); |
| 1274 | return 0; |
| 1275 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1276 | default: |
| 1277 | fatal("process_config_line: Unimplemented opcode %d", opcode); |
| 1278 | } |
| 1279 | |
| 1280 | /* Check that there is no garbage at end of line. */ |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 1281 | if ((arg = strdelim(&s)) != NULL && *arg != '\0') { |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 1282 | fatal("%.200s line %d: garbage at end of line; \"%.200s\".", |
Damien Miller | 0dc1bef | 2005-07-17 17:22:45 +1000 | [diff] [blame] | 1283 | filename, linenum, arg); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 1284 | } |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1285 | return 0; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1286 | } |
| 1287 | |
| 1288 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 1289 | /* |
| 1290 | * Reads the config file and modifies the options accordingly. Options |
| 1291 | * should already be initialized before this call. This never returns if |
Ben Lindstrom | edc0cf2 | 2001-09-12 18:32:20 +0000 | [diff] [blame] | 1292 | * there is an error. If the file does not exist, this returns 0. |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 1293 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1294 | |
Ben Lindstrom | edc0cf2 | 2001-09-12 18:32:20 +0000 | [diff] [blame] | 1295 | int |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 1296 | read_config_file(const char *filename, struct passwd *pw, const char *host, |
| 1297 | Options *options, int flags) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1298 | { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1299 | FILE *f; |
| 1300 | char line[1024]; |
| 1301 | int active, linenum; |
| 1302 | int bad_options = 0; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1303 | |
Damien Miller | 57a4476 | 2004-04-20 20:11:57 +1000 | [diff] [blame] | 1304 | if ((f = fopen(filename, "r")) == NULL) |
Ben Lindstrom | edc0cf2 | 2001-09-12 18:32:20 +0000 | [diff] [blame] | 1305 | return 0; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1306 | |
Darren Tucker | aefa368 | 2013-04-05 11:18:35 +1100 | [diff] [blame] | 1307 | if (flags & SSHCONF_CHECKPERM) { |
Damien Miller | 57a4476 | 2004-04-20 20:11:57 +1000 | [diff] [blame] | 1308 | struct stat sb; |
Darren Tucker | fc95970 | 2004-07-17 16:12:08 +1000 | [diff] [blame] | 1309 | |
Damien Miller | 3379385 | 2004-06-15 10:27:55 +1000 | [diff] [blame] | 1310 | if (fstat(fileno(f), &sb) == -1) |
Damien Miller | 57a4476 | 2004-04-20 20:11:57 +1000 | [diff] [blame] | 1311 | fatal("fstat %s: %s", filename, strerror(errno)); |
Damien Miller | 57a4476 | 2004-04-20 20:11:57 +1000 | [diff] [blame] | 1312 | if (((sb.st_uid != 0 && sb.st_uid != getuid()) || |
Damien Miller | 3379385 | 2004-06-15 10:27:55 +1000 | [diff] [blame] | 1313 | (sb.st_mode & 022) != 0)) |
Damien Miller | 57a4476 | 2004-04-20 20:11:57 +1000 | [diff] [blame] | 1314 | fatal("Bad owner or permissions on %s", filename); |
Damien Miller | 57a4476 | 2004-04-20 20:11:57 +1000 | [diff] [blame] | 1315 | } |
| 1316 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1317 | debug("Reading configuration data %.200s", filename); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1318 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 1319 | /* |
| 1320 | * Mark that we are now processing the options. This flag is turned |
| 1321 | * on/off by Host specifications. |
| 1322 | */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1323 | active = 1; |
| 1324 | linenum = 0; |
| 1325 | while (fgets(line, sizeof(line), f)) { |
| 1326 | /* Update line number counter. */ |
| 1327 | linenum++; |
Damien Miller | 194fd90 | 2013-10-15 12:13:05 +1100 | [diff] [blame] | 1328 | if (process_config_line(options, pw, host, line, filename, |
| 1329 | linenum, &active, flags & SSHCONF_USERCONF) != 0) |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1330 | bad_options++; |
| 1331 | } |
| 1332 | fclose(f); |
| 1333 | if (bad_options > 0) |
Ben Lindstrom | 6df8ef4 | 2001-03-05 07:47:23 +0000 | [diff] [blame] | 1334 | fatal("%s: terminating, %d bad configuration options", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 1335 | filename, bad_options); |
Ben Lindstrom | edc0cf2 | 2001-09-12 18:32:20 +0000 | [diff] [blame] | 1336 | return 1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1337 | } |
| 1338 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 1339 | /* |
| 1340 | * Initializes options to special values that indicate that they have not yet |
| 1341 | * been set. Read_config_file will only set options with this value. Options |
| 1342 | * are processed in the following order: command line, user config file, |
| 1343 | * system config file. Last, fill_default_options is called. |
| 1344 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1345 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 1346 | void |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1347 | initialize_options(Options * options) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1348 | { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1349 | memset(options, 'X', sizeof(*options)); |
| 1350 | options->forward_agent = -1; |
| 1351 | options->forward_x11 = -1; |
Darren Tucker | 0a118da | 2003-10-15 15:54:32 +1000 | [diff] [blame] | 1352 | options->forward_x11_trusted = -1; |
Damien Miller | 1ab6a51 | 2010-06-26 10:02:24 +1000 | [diff] [blame] | 1353 | options->forward_x11_timeout = -1; |
Darren Tucker | e7d4b19 | 2006-07-12 22:17:10 +1000 | [diff] [blame] | 1354 | options->exit_on_forward_failure = -1; |
Damien Miller | d3a1857 | 2000-06-07 19:55:44 +1000 | [diff] [blame] | 1355 | options->xauth_location = NULL; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1356 | options->gateway_ports = -1; |
| 1357 | options->use_privileged_port = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1358 | options->rsa_authentication = -1; |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 1359 | options->pubkey_authentication = -1; |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 1360 | options->challenge_response_authentication = -1; |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 1361 | options->gss_authentication = -1; |
| 1362 | options->gss_deleg_creds = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1363 | options->password_authentication = -1; |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 1364 | options->kbd_interactive_authentication = -1; |
| 1365 | options->kbd_interactive_devices = NULL; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1366 | options->rhosts_rsa_authentication = -1; |
Ben Lindstrom | 5eabda3 | 2001-04-12 23:34:34 +0000 | [diff] [blame] | 1367 | options->hostbased_authentication = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1368 | options->batch_mode = -1; |
| 1369 | options->check_host_ip = -1; |
| 1370 | options->strict_host_key_checking = -1; |
| 1371 | options->compression = -1; |
Damien Miller | 12c150e | 2003-12-17 16:31:10 +1100 | [diff] [blame] | 1372 | options->tcp_keep_alive = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1373 | options->compression_level = -1; |
| 1374 | options->port = -1; |
Darren Tucker | 0a4f04b | 2003-07-03 20:37:47 +1000 | [diff] [blame] | 1375 | options->address_family = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1376 | options->connection_attempts = -1; |
Damien Miller | b78d5eb | 2003-05-16 11:39:04 +1000 | [diff] [blame] | 1377 | options->connection_timeout = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1378 | options->number_of_password_prompts = -1; |
| 1379 | options->cipher = -1; |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 1380 | options->ciphers = NULL; |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 1381 | options->macs = NULL; |
Damien Miller | d5f62bf | 2010-09-24 22:11:14 +1000 | [diff] [blame] | 1382 | options->kex_algorithms = NULL; |
Ben Lindstrom | 982dbbc | 2001-04-17 18:11:36 +0000 | [diff] [blame] | 1383 | options->hostkeyalgorithms = NULL; |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 1384 | options->protocol = SSH_PROTO_UNKNOWN; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1385 | options->num_identity_files = 0; |
| 1386 | options->hostname = NULL; |
Ben Lindstrom | 4dccfa5 | 2000-12-28 16:40:05 +0000 | [diff] [blame] | 1387 | options->host_key_alias = NULL; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1388 | options->proxy_command = NULL; |
| 1389 | options->user = NULL; |
| 1390 | options->escape_char = -1; |
Damien Miller | 295ee63 | 2011-05-29 21:42:31 +1000 | [diff] [blame] | 1391 | options->num_system_hostfiles = 0; |
| 1392 | options->num_user_hostfiles = 0; |
Damien Miller | 232cfb1 | 2010-06-26 09:50:30 +1000 | [diff] [blame] | 1393 | options->local_forwards = NULL; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1394 | options->num_local_forwards = 0; |
Damien Miller | 232cfb1 | 2010-06-26 09:50:30 +1000 | [diff] [blame] | 1395 | options->remote_forwards = NULL; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1396 | options->num_remote_forwards = 0; |
Ben Lindstrom | 2b7a0e9 | 2001-09-20 00:57:55 +0000 | [diff] [blame] | 1397 | options->clear_forwardings = -1; |
Damien Miller | fcd9320 | 2002-02-05 12:26:34 +1100 | [diff] [blame] | 1398 | options->log_level = SYSLOG_LEVEL_NOT_SET; |
Ben Lindstrom | b9be60a | 2001-03-11 01:49:19 +0000 | [diff] [blame] | 1399 | options->preferred_authentications = NULL; |
Ben Lindstrom | e0f8804 | 2001-04-30 13:06:24 +0000 | [diff] [blame] | 1400 | options->bind_address = NULL; |
Damien Miller | 7ea845e | 2010-02-12 09:21:02 +1100 | [diff] [blame] | 1401 | options->pkcs11_provider = NULL; |
Ben Lindstrom | b6df73b | 2002-11-09 15:52:31 +0000 | [diff] [blame] | 1402 | options->enable_ssh_keysign = - 1; |
Ben Lindstrom | 3cecc9a | 2001-10-03 17:39:38 +0000 | [diff] [blame] | 1403 | options->no_host_authentication_for_localhost = - 1; |
Damien Miller | bd394c3 | 2004-03-08 23:12:36 +1100 | [diff] [blame] | 1404 | options->identities_only = - 1; |
Damien Miller | a5539d2 | 2003-04-09 20:50:06 +1000 | [diff] [blame] | 1405 | options->rekey_limit = - 1; |
Darren Tucker | c53c2af | 2013-05-16 20:28:16 +1000 | [diff] [blame] | 1406 | options->rekey_interval = -1; |
Damien Miller | 37876e9 | 2003-05-15 10:19:46 +1000 | [diff] [blame] | 1407 | options->verify_host_key_dns = -1; |
Damien Miller | 509b010 | 2003-12-17 16:33:10 +1100 | [diff] [blame] | 1408 | options->server_alive_interval = -1; |
| 1409 | options->server_alive_count_max = -1; |
Darren Tucker | 46bc075 | 2004-05-02 22:11:30 +1000 | [diff] [blame] | 1410 | options->num_send_env = 0; |
Damien Miller | 0e220db | 2004-06-15 10:34:08 +1000 | [diff] [blame] | 1411 | options->control_path = NULL; |
| 1412 | options->control_master = -1; |
Damien Miller | e11e1ea | 2010-08-03 16:04:46 +1000 | [diff] [blame] | 1413 | options->control_persist = -1; |
| 1414 | options->control_persist_timeout = 0; |
Damien Miller | e177615 | 2005-03-01 21:47:37 +1100 | [diff] [blame] | 1415 | options->hash_known_hosts = -1; |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 1416 | options->tun_open = -1; |
| 1417 | options->tun_local = -1; |
| 1418 | options->tun_remote = -1; |
| 1419 | options->local_command = NULL; |
| 1420 | options->permit_local_command = -1; |
Darren Tucker | 71e4d54 | 2009-07-06 07:12:27 +1000 | [diff] [blame] | 1421 | options->use_roaming = -1; |
Damien Miller | 1028824 | 2008-06-30 00:04:03 +1000 | [diff] [blame] | 1422 | options->visual_host_key = -1; |
Damien Miller | 01ed227 | 2008-11-05 16:20:46 +1100 | [diff] [blame] | 1423 | options->zero_knowledge_password_authentication = -1; |
Damien Miller | 0dac6fb | 2010-11-20 15:19:38 +1100 | [diff] [blame] | 1424 | options->ip_qos_interactive = -1; |
| 1425 | options->ip_qos_bulk = -1; |
Damien Miller | 21771e2 | 2011-05-15 08:45:50 +1000 | [diff] [blame] | 1426 | options->request_tty = -1; |
Damien Miller | 1262b66 | 2013-08-21 02:44:24 +1000 | [diff] [blame] | 1427 | options->proxy_use_fdpass = -1; |
Darren Tucker | 0763698 | 2013-05-16 20:30:03 +1000 | [diff] [blame] | 1428 | options->ignored_unknown = NULL; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1429 | } |
| 1430 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 1431 | /* |
| 1432 | * Called after processing other sources of option data, this fills those |
| 1433 | * options for which no value has been specified with their default values. |
| 1434 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1435 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 1436 | void |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1437 | fill_default_options(Options * options) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1438 | { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1439 | if (options->forward_agent == -1) |
Damien Miller | b1715dc | 2000-05-30 13:44:51 +1000 | [diff] [blame] | 1440 | options->forward_agent = 0; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1441 | if (options->forward_x11 == -1) |
Damien Miller | 98c7ad6 | 2000-03-09 21:27:49 +1100 | [diff] [blame] | 1442 | options->forward_x11 = 0; |
Darren Tucker | 0a118da | 2003-10-15 15:54:32 +1000 | [diff] [blame] | 1443 | if (options->forward_x11_trusted == -1) |
| 1444 | options->forward_x11_trusted = 0; |
Damien Miller | 1ab6a51 | 2010-06-26 10:02:24 +1000 | [diff] [blame] | 1445 | if (options->forward_x11_timeout == -1) |
| 1446 | options->forward_x11_timeout = 1200; |
Darren Tucker | e7d4b19 | 2006-07-12 22:17:10 +1000 | [diff] [blame] | 1447 | if (options->exit_on_forward_failure == -1) |
| 1448 | options->exit_on_forward_failure = 0; |
Damien Miller | d3a1857 | 2000-06-07 19:55:44 +1000 | [diff] [blame] | 1449 | if (options->xauth_location == NULL) |
Ben Lindstrom | 1bf11f6 | 2001-06-09 01:48:01 +0000 | [diff] [blame] | 1450 | options->xauth_location = _PATH_XAUTH; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1451 | if (options->gateway_ports == -1) |
| 1452 | options->gateway_ports = 0; |
| 1453 | if (options->use_privileged_port == -1) |
Ben Lindstrom | cebc858 | 2001-03-08 03:39:10 +0000 | [diff] [blame] | 1454 | options->use_privileged_port = 0; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1455 | if (options->rsa_authentication == -1) |
| 1456 | options->rsa_authentication = 1; |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 1457 | if (options->pubkey_authentication == -1) |
| 1458 | options->pubkey_authentication = 1; |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 1459 | if (options->challenge_response_authentication == -1) |
Ben Lindstrom | 0076d75 | 2001-08-06 20:53:26 +0000 | [diff] [blame] | 1460 | options->challenge_response_authentication = 1; |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 1461 | if (options->gss_authentication == -1) |
Darren Tucker | a044f47 | 2003-10-15 15:52:03 +1000 | [diff] [blame] | 1462 | options->gss_authentication = 0; |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 1463 | if (options->gss_deleg_creds == -1) |
| 1464 | options->gss_deleg_creds = 0; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1465 | if (options->password_authentication == -1) |
| 1466 | options->password_authentication = 1; |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 1467 | if (options->kbd_interactive_authentication == -1) |
Ben Lindstrom | 95fb2dd | 2001-01-23 03:12:10 +0000 | [diff] [blame] | 1468 | options->kbd_interactive_authentication = 1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1469 | if (options->rhosts_rsa_authentication == -1) |
Ben Lindstrom | 2bf8276 | 2002-06-11 15:53:05 +0000 | [diff] [blame] | 1470 | options->rhosts_rsa_authentication = 0; |
Ben Lindstrom | 5eabda3 | 2001-04-12 23:34:34 +0000 | [diff] [blame] | 1471 | if (options->hostbased_authentication == -1) |
| 1472 | options->hostbased_authentication = 0; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1473 | if (options->batch_mode == -1) |
| 1474 | options->batch_mode = 0; |
| 1475 | if (options->check_host_ip == -1) |
| 1476 | options->check_host_ip = 1; |
| 1477 | if (options->strict_host_key_checking == -1) |
| 1478 | options->strict_host_key_checking = 2; /* 2 is default */ |
| 1479 | if (options->compression == -1) |
| 1480 | options->compression = 0; |
Damien Miller | 12c150e | 2003-12-17 16:31:10 +1100 | [diff] [blame] | 1481 | if (options->tcp_keep_alive == -1) |
| 1482 | options->tcp_keep_alive = 1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1483 | if (options->compression_level == -1) |
| 1484 | options->compression_level = 6; |
| 1485 | if (options->port == -1) |
| 1486 | options->port = 0; /* Filled in ssh_connect. */ |
Darren Tucker | 0a4f04b | 2003-07-03 20:37:47 +1000 | [diff] [blame] | 1487 | if (options->address_family == -1) |
| 1488 | options->address_family = AF_UNSPEC; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1489 | if (options->connection_attempts == -1) |
Ben Lindstrom | f9cedb9 | 2001-08-06 21:07:11 +0000 | [diff] [blame] | 1490 | options->connection_attempts = 1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1491 | if (options->number_of_password_prompts == -1) |
| 1492 | options->number_of_password_prompts = 3; |
| 1493 | /* Selected in ssh_login(). */ |
| 1494 | if (options->cipher == -1) |
| 1495 | options->cipher = SSH_CIPHER_NOT_SET; |
Damien Miller | 30c3d42 | 2000-05-09 11:02:59 +1000 | [diff] [blame] | 1496 | /* options->ciphers, default set in myproposals.h */ |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 1497 | /* options->macs, default set in myproposals.h */ |
Damien Miller | d5f62bf | 2010-09-24 22:11:14 +1000 | [diff] [blame] | 1498 | /* options->kex_algorithms, default set in myproposals.h */ |
Ben Lindstrom | 982dbbc | 2001-04-17 18:11:36 +0000 | [diff] [blame] | 1499 | /* options->hostkeyalgorithms, default set in myproposals.h */ |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 1500 | if (options->protocol == SSH_PROTO_UNKNOWN) |
Darren Tucker | bad5076 | 2009-10-11 21:51:08 +1100 | [diff] [blame] | 1501 | options->protocol = SSH_PROTO_2; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1502 | if (options->num_identity_files == 0) { |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 1503 | if (options->protocol & SSH_PROTO_1) { |
Darren Tucker | 1910478 | 2013-04-05 11:13:08 +1100 | [diff] [blame] | 1504 | add_identity_file(options, "~/", |
| 1505 | _PATH_SSH_CLIENT_IDENTITY, 0); |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 1506 | } |
| 1507 | if (options->protocol & SSH_PROTO_2) { |
Darren Tucker | 1910478 | 2013-04-05 11:13:08 +1100 | [diff] [blame] | 1508 | add_identity_file(options, "~/", |
| 1509 | _PATH_SSH_CLIENT_ID_RSA, 0); |
| 1510 | add_identity_file(options, "~/", |
| 1511 | _PATH_SSH_CLIENT_ID_DSA, 0); |
Damien Miller | 6af914a | 2010-09-10 11:39:26 +1000 | [diff] [blame] | 1512 | #ifdef OPENSSL_HAS_ECC |
Darren Tucker | 1910478 | 2013-04-05 11:13:08 +1100 | [diff] [blame] | 1513 | add_identity_file(options, "~/", |
| 1514 | _PATH_SSH_CLIENT_ID_ECDSA, 0); |
Damien Miller | 6af914a | 2010-09-10 11:39:26 +1000 | [diff] [blame] | 1515 | #endif |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 1516 | } |
Damien Miller | eba71ba | 2000-04-29 23:57:08 +1000 | [diff] [blame] | 1517 | } |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1518 | if (options->escape_char == -1) |
| 1519 | options->escape_char = '~'; |
Damien Miller | 295ee63 | 2011-05-29 21:42:31 +1000 | [diff] [blame] | 1520 | if (options->num_system_hostfiles == 0) { |
| 1521 | options->system_hostfiles[options->num_system_hostfiles++] = |
| 1522 | xstrdup(_PATH_SSH_SYSTEM_HOSTFILE); |
| 1523 | options->system_hostfiles[options->num_system_hostfiles++] = |
| 1524 | xstrdup(_PATH_SSH_SYSTEM_HOSTFILE2); |
| 1525 | } |
| 1526 | if (options->num_user_hostfiles == 0) { |
| 1527 | options->user_hostfiles[options->num_user_hostfiles++] = |
| 1528 | xstrdup(_PATH_SSH_USER_HOSTFILE); |
| 1529 | options->user_hostfiles[options->num_user_hostfiles++] = |
| 1530 | xstrdup(_PATH_SSH_USER_HOSTFILE2); |
| 1531 | } |
Damien Miller | fcd9320 | 2002-02-05 12:26:34 +1100 | [diff] [blame] | 1532 | if (options->log_level == SYSLOG_LEVEL_NOT_SET) |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 1533 | options->log_level = SYSLOG_LEVEL_INFO; |
Ben Lindstrom | 2b7a0e9 | 2001-09-20 00:57:55 +0000 | [diff] [blame] | 1534 | if (options->clear_forwardings == 1) |
| 1535 | clear_forwardings(options); |
Ben Lindstrom | 3cecc9a | 2001-10-03 17:39:38 +0000 | [diff] [blame] | 1536 | if (options->no_host_authentication_for_localhost == - 1) |
| 1537 | options->no_host_authentication_for_localhost = 0; |
Damien Miller | bd394c3 | 2004-03-08 23:12:36 +1100 | [diff] [blame] | 1538 | if (options->identities_only == -1) |
| 1539 | options->identities_only = 0; |
Ben Lindstrom | b6df73b | 2002-11-09 15:52:31 +0000 | [diff] [blame] | 1540 | if (options->enable_ssh_keysign == -1) |
| 1541 | options->enable_ssh_keysign = 0; |
Damien Miller | a5539d2 | 2003-04-09 20:50:06 +1000 | [diff] [blame] | 1542 | if (options->rekey_limit == -1) |
| 1543 | options->rekey_limit = 0; |
Darren Tucker | c53c2af | 2013-05-16 20:28:16 +1000 | [diff] [blame] | 1544 | if (options->rekey_interval == -1) |
| 1545 | options->rekey_interval = 0; |
Damien Miller | 37876e9 | 2003-05-15 10:19:46 +1000 | [diff] [blame] | 1546 | if (options->verify_host_key_dns == -1) |
| 1547 | options->verify_host_key_dns = 0; |
Damien Miller | 509b010 | 2003-12-17 16:33:10 +1100 | [diff] [blame] | 1548 | if (options->server_alive_interval == -1) |
| 1549 | options->server_alive_interval = 0; |
| 1550 | if (options->server_alive_count_max == -1) |
| 1551 | options->server_alive_count_max = 3; |
Damien Miller | 0e220db | 2004-06-15 10:34:08 +1000 | [diff] [blame] | 1552 | if (options->control_master == -1) |
| 1553 | options->control_master = 0; |
Damien Miller | e11e1ea | 2010-08-03 16:04:46 +1000 | [diff] [blame] | 1554 | if (options->control_persist == -1) { |
| 1555 | options->control_persist = 0; |
| 1556 | options->control_persist_timeout = 0; |
| 1557 | } |
Damien Miller | e177615 | 2005-03-01 21:47:37 +1100 | [diff] [blame] | 1558 | if (options->hash_known_hosts == -1) |
| 1559 | options->hash_known_hosts = 0; |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 1560 | if (options->tun_open == -1) |
Damien Miller | 7b58e80 | 2005-12-13 19:33:19 +1100 | [diff] [blame] | 1561 | options->tun_open = SSH_TUNMODE_NO; |
| 1562 | if (options->tun_local == -1) |
| 1563 | options->tun_local = SSH_TUNID_ANY; |
| 1564 | if (options->tun_remote == -1) |
| 1565 | options->tun_remote = SSH_TUNID_ANY; |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 1566 | if (options->permit_local_command == -1) |
| 1567 | options->permit_local_command = 0; |
Darren Tucker | 71e4d54 | 2009-07-06 07:12:27 +1000 | [diff] [blame] | 1568 | if (options->use_roaming == -1) |
| 1569 | options->use_roaming = 1; |
Damien Miller | 1028824 | 2008-06-30 00:04:03 +1000 | [diff] [blame] | 1570 | if (options->visual_host_key == -1) |
| 1571 | options->visual_host_key = 0; |
Damien Miller | 01ed227 | 2008-11-05 16:20:46 +1100 | [diff] [blame] | 1572 | if (options->zero_knowledge_password_authentication == -1) |
| 1573 | options->zero_knowledge_password_authentication = 0; |
Damien Miller | 0dac6fb | 2010-11-20 15:19:38 +1100 | [diff] [blame] | 1574 | if (options->ip_qos_interactive == -1) |
| 1575 | options->ip_qos_interactive = IPTOS_LOWDELAY; |
| 1576 | if (options->ip_qos_bulk == -1) |
| 1577 | options->ip_qos_bulk = IPTOS_THROUGHPUT; |
Damien Miller | 21771e2 | 2011-05-15 08:45:50 +1000 | [diff] [blame] | 1578 | if (options->request_tty == -1) |
| 1579 | options->request_tty = REQUEST_TTY_AUTO; |
Damien Miller | 1262b66 | 2013-08-21 02:44:24 +1000 | [diff] [blame] | 1580 | if (options->proxy_use_fdpass == -1) |
| 1581 | options->proxy_use_fdpass = 0; |
Damien Miller | e9fc72e | 2013-10-15 12:14:12 +1100 | [diff] [blame^] | 1582 | #define CLEAR_ON_NONE(v) \ |
| 1583 | do { \ |
| 1584 | if (v != NULL && strcasecmp(v, "none") == 0) { \ |
| 1585 | free(v); \ |
| 1586 | v = NULL; \ |
| 1587 | } \ |
| 1588 | } while(0) |
| 1589 | CLEAR_ON_NONE(options->local_command); |
| 1590 | CLEAR_ON_NONE(options->proxy_command); |
| 1591 | CLEAR_ON_NONE(options->control_path); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1592 | /* options->user will be set in the main program if appropriate */ |
| 1593 | /* options->hostname will be set in the main program if appropriate */ |
Ben Lindstrom | 4dccfa5 | 2000-12-28 16:40:05 +0000 | [diff] [blame] | 1594 | /* options->host_key_alias should not be set by default */ |
Ben Lindstrom | b9be60a | 2001-03-11 01:49:19 +0000 | [diff] [blame] | 1595 | /* options->preferred_authentications will be set in ssh */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1596 | } |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1597 | |
| 1598 | /* |
| 1599 | * parse_forward |
| 1600 | * parses a string containing a port forwarding specification of the form: |
Damien Miller | a699d95 | 2008-11-03 19:27:34 +1100 | [diff] [blame] | 1601 | * dynamicfwd == 0 |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1602 | * [listenhost:]listenport:connecthost:connectport |
Damien Miller | a699d95 | 2008-11-03 19:27:34 +1100 | [diff] [blame] | 1603 | * dynamicfwd == 1 |
| 1604 | * [listenhost:]listenport |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1605 | * returns number of arguments parsed or zero on error |
| 1606 | */ |
| 1607 | int |
Damien Miller | 4bf648f | 2009-02-14 16:28:21 +1100 | [diff] [blame] | 1608 | parse_forward(Forward *fwd, const char *fwdspec, int dynamicfwd, int remotefwd) |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1609 | { |
| 1610 | int i; |
| 1611 | char *p, *cp, *fwdarg[4]; |
| 1612 | |
| 1613 | memset(fwd, '\0', sizeof(*fwd)); |
| 1614 | |
| 1615 | cp = p = xstrdup(fwdspec); |
| 1616 | |
| 1617 | /* skip leading spaces */ |
Darren Tucker | 03b1cdb | 2007-03-21 20:46:03 +1100 | [diff] [blame] | 1618 | while (isspace(*cp)) |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1619 | cp++; |
| 1620 | |
| 1621 | for (i = 0; i < 4; ++i) |
| 1622 | if ((fwdarg[i] = hpdelim(&cp)) == NULL) |
| 1623 | break; |
| 1624 | |
Damien Miller | f4b3953 | 2008-11-03 19:28:21 +1100 | [diff] [blame] | 1625 | /* Check for trailing garbage */ |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1626 | if (cp != NULL) |
| 1627 | i = 0; /* failure */ |
| 1628 | |
| 1629 | switch (i) { |
Damien Miller | a699d95 | 2008-11-03 19:27:34 +1100 | [diff] [blame] | 1630 | case 1: |
| 1631 | fwd->listen_host = NULL; |
| 1632 | fwd->listen_port = a2port(fwdarg[0]); |
| 1633 | fwd->connect_host = xstrdup("socks"); |
| 1634 | break; |
| 1635 | |
| 1636 | case 2: |
| 1637 | fwd->listen_host = xstrdup(cleanhostname(fwdarg[0])); |
| 1638 | fwd->listen_port = a2port(fwdarg[1]); |
| 1639 | fwd->connect_host = xstrdup("socks"); |
| 1640 | break; |
| 1641 | |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1642 | case 3: |
| 1643 | fwd->listen_host = NULL; |
| 1644 | fwd->listen_port = a2port(fwdarg[0]); |
| 1645 | fwd->connect_host = xstrdup(cleanhostname(fwdarg[1])); |
| 1646 | fwd->connect_port = a2port(fwdarg[2]); |
| 1647 | break; |
| 1648 | |
| 1649 | case 4: |
| 1650 | fwd->listen_host = xstrdup(cleanhostname(fwdarg[0])); |
| 1651 | fwd->listen_port = a2port(fwdarg[1]); |
| 1652 | fwd->connect_host = xstrdup(cleanhostname(fwdarg[2])); |
| 1653 | fwd->connect_port = a2port(fwdarg[3]); |
| 1654 | break; |
| 1655 | default: |
| 1656 | i = 0; /* failure */ |
| 1657 | } |
| 1658 | |
Darren Tucker | a627d42 | 2013-06-02 07:31:17 +1000 | [diff] [blame] | 1659 | free(p); |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1660 | |
Damien Miller | a699d95 | 2008-11-03 19:27:34 +1100 | [diff] [blame] | 1661 | if (dynamicfwd) { |
| 1662 | if (!(i == 1 || i == 2)) |
| 1663 | goto fail_free; |
| 1664 | } else { |
| 1665 | if (!(i == 3 || i == 4)) |
| 1666 | goto fail_free; |
Damien Miller | 3dc71ad | 2009-01-28 16:31:22 +1100 | [diff] [blame] | 1667 | if (fwd->connect_port <= 0) |
Damien Miller | a699d95 | 2008-11-03 19:27:34 +1100 | [diff] [blame] | 1668 | goto fail_free; |
| 1669 | } |
| 1670 | |
Damien Miller | 4bf648f | 2009-02-14 16:28:21 +1100 | [diff] [blame] | 1671 | if (fwd->listen_port < 0 || (!remotefwd && fwd->listen_port == 0)) |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1672 | goto fail_free; |
| 1673 | |
| 1674 | if (fwd->connect_host != NULL && |
| 1675 | strlen(fwd->connect_host) >= NI_MAXHOST) |
| 1676 | goto fail_free; |
Damien Miller | 4bf648f | 2009-02-14 16:28:21 +1100 | [diff] [blame] | 1677 | if (fwd->listen_host != NULL && |
| 1678 | strlen(fwd->listen_host) >= NI_MAXHOST) |
| 1679 | goto fail_free; |
| 1680 | |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1681 | |
| 1682 | return (i); |
| 1683 | |
| 1684 | fail_free: |
Darren Tucker | a627d42 | 2013-06-02 07:31:17 +1000 | [diff] [blame] | 1685 | free(fwd->connect_host); |
| 1686 | fwd->connect_host = NULL; |
| 1687 | free(fwd->listen_host); |
| 1688 | fwd->listen_host = NULL; |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 1689 | return (0); |
| 1690 | } |