blob: 8094d34ca4b18907ecfabf5b18ca470b34404660 [file] [log] [blame]
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001/*
Damien Miller95def091999-11-25 00:26:21 +11002 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
3 * All rights reserved
Damien Miller4af51302000-04-16 11:18:38 +10004 *
Damien Millere4340be2000-09-16 13:29:08 +11005 * As far as I am concerned, the code I have written for this software
6 * can be used freely for any purpose. Any derived versions of this
7 * software must be clearly marked as such, and if the derived work is
8 * incompatible with the protocol description in the RFC file, it must be
9 * called by a name other than "ssh" or "Secure Shell".
Damien Miller95def091999-11-25 00:26:21 +110010 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +100011
12#include "includes.h"
Ben Lindstrom3704c262001-04-02 18:20:03 +000013RCSID("$OpenBSD: servconf.c,v 1.73 2001/04/02 14:20:23 stevesk Exp $");
Ben Lindstrom226cfa02001-01-22 05:34:40 +000014
15#ifdef KRB4
16#include <krb.h>
17#endif
18#ifdef AFS
19#include <kafs.h>
20#endif
Damien Millerd4a8b7e1999-10-27 13:42:43 +100021
22#include "ssh.h"
Ben Lindstrom226cfa02001-01-22 05:34:40 +000023#include "log.h"
Damien Millerd4a8b7e1999-10-27 13:42:43 +100024#include "servconf.h"
25#include "xmalloc.h"
Damien Miller78928792000-04-12 20:17:38 +100026#include "compat.h"
Ben Lindstrom226cfa02001-01-22 05:34:40 +000027#include "pathnames.h"
28#include "tildexpand.h"
29#include "misc.h"
30#include "cipher.h"
Ben Lindstrom06b33aa2001-02-15 03:01:59 +000031#include "kex.h"
32#include "mac.h"
Ben Lindstrom226cfa02001-01-22 05:34:40 +000033
Damien Miller34132e52000-01-14 15:45:46 +110034/* add listen address */
35void add_listen_addr(ServerOptions *options, char *addr);
36
Ben Lindstrom226cfa02001-01-22 05:34:40 +000037/* AF_UNSPEC or AF_INET or AF_INET6 */
38extern int IPv4or6;
39
Damien Millerd4a8b7e1999-10-27 13:42:43 +100040/* Initializes the server options to their default values. */
41
Damien Miller4af51302000-04-16 11:18:38 +100042void
Damien Miller95def091999-11-25 00:26:21 +110043initialize_server_options(ServerOptions *options)
Damien Millerd4a8b7e1999-10-27 13:42:43 +100044{
Damien Miller95def091999-11-25 00:26:21 +110045 memset(options, 0, sizeof(*options));
Damien Miller34132e52000-01-14 15:45:46 +110046 options->num_ports = 0;
47 options->ports_from_cmdline = 0;
48 options->listen_addrs = NULL;
Damien Miller0bc1bd82000-11-13 22:57:25 +110049 options->num_host_key_files = 0;
Damien Miller6f83b8e2000-05-02 09:23:45 +100050 options->pid_file = NULL;
Damien Miller95def091999-11-25 00:26:21 +110051 options->server_key_bits = -1;
52 options->login_grace_time = -1;
53 options->key_regeneration_time = -1;
Ben Lindstromd8a90212001-02-15 03:08:27 +000054 options->permit_root_login = PERMIT_NOT_SET;
Damien Miller95def091999-11-25 00:26:21 +110055 options->ignore_rhosts = -1;
56 options->ignore_user_known_hosts = -1;
57 options->print_motd = -1;
Ben Lindstrom7bfff362001-03-26 05:45:53 +000058 options->print_lastlog = -1;
Damien Miller95def091999-11-25 00:26:21 +110059 options->check_mail = -1;
60 options->x11_forwarding = -1;
61 options->x11_display_offset = -1;
Damien Millerd3a18572000-06-07 19:55:44 +100062 options->xauth_location = NULL;
Damien Miller95def091999-11-25 00:26:21 +110063 options->strict_modes = -1;
64 options->keepalives = -1;
65 options->log_facility = (SyslogFacility) - 1;
66 options->log_level = (LogLevel) - 1;
67 options->rhosts_authentication = -1;
68 options->rhosts_rsa_authentication = -1;
69 options->rsa_authentication = -1;
Damien Miller0bc1bd82000-11-13 22:57:25 +110070 options->pubkey_authentication = -1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +100071#ifdef KRB4
Damien Miller95def091999-11-25 00:26:21 +110072 options->kerberos_authentication = -1;
73 options->kerberos_or_local_passwd = -1;
74 options->kerberos_ticket_cleanup = -1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +100075#endif
76#ifdef AFS
Damien Miller95def091999-11-25 00:26:21 +110077 options->kerberos_tgt_passing = -1;
78 options->afs_token_passing = -1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +100079#endif
Damien Miller95def091999-11-25 00:26:21 +110080 options->password_authentication = -1;
Damien Miller874d77b2000-10-14 16:23:11 +110081 options->kbd_interactive_authentication = -1;
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +000082 options->challenge_reponse_authentication = -1;
Damien Miller95def091999-11-25 00:26:21 +110083 options->permit_empty_passwd = -1;
84 options->use_login = -1;
Damien Miller50a41ed2000-10-16 12:14:42 +110085 options->allow_tcp_forwarding = -1;
Damien Miller95def091999-11-25 00:26:21 +110086 options->num_allow_users = 0;
87 options->num_deny_users = 0;
88 options->num_allow_groups = 0;
89 options->num_deny_groups = 0;
Damien Miller78928792000-04-12 20:17:38 +100090 options->ciphers = NULL;
Ben Lindstrom06b33aa2001-02-15 03:01:59 +000091 options->macs = NULL;
Damien Miller78928792000-04-12 20:17:38 +100092 options->protocol = SSH_PROTO_UNKNOWN;
Damien Millere247cc42000-05-07 12:03:14 +100093 options->gateway_ports = -1;
Damien Millerf6d9e222000-06-18 14:50:44 +100094 options->num_subsystems = 0;
Damien Miller942da032000-08-18 13:59:06 +100095 options->max_startups_begin = -1;
96 options->max_startups_rate = -1;
Damien Miller37023962000-07-11 17:31:38 +100097 options->max_startups = -1;
Ben Lindstrom48bd7c12001-01-09 00:35:42 +000098 options->banner = NULL;
Damien Miller33804262001-02-04 23:20:18 +110099 options->reverse_mapping_check = -1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000100}
101
Damien Miller4af51302000-04-16 11:18:38 +1000102void
Damien Miller95def091999-11-25 00:26:21 +1100103fill_default_server_options(ServerOptions *options)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000104{
Damien Miller0bc1bd82000-11-13 22:57:25 +1100105 if (options->protocol == SSH_PROTO_UNKNOWN)
106 options->protocol = SSH_PROTO_1|SSH_PROTO_2;
107 if (options->num_host_key_files == 0) {
108 /* fill default hostkeys for protocols */
109 if (options->protocol & SSH_PROTO_1)
Ben Lindstrom226cfa02001-01-22 05:34:40 +0000110 options->host_key_files[options->num_host_key_files++] = _PATH_HOST_KEY_FILE;
Damien Miller0bc1bd82000-11-13 22:57:25 +1100111 if (options->protocol & SSH_PROTO_2)
Ben Lindstrom226cfa02001-01-22 05:34:40 +0000112 options->host_key_files[options->num_host_key_files++] = _PATH_HOST_DSA_KEY_FILE;
Damien Miller0bc1bd82000-11-13 22:57:25 +1100113 }
Damien Miller34132e52000-01-14 15:45:46 +1100114 if (options->num_ports == 0)
115 options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
116 if (options->listen_addrs == NULL)
117 add_listen_addr(options, NULL);
Damien Miller6f83b8e2000-05-02 09:23:45 +1000118 if (options->pid_file == NULL)
Ben Lindstrom226cfa02001-01-22 05:34:40 +0000119 options->pid_file = _PATH_SSH_DAEMON_PID_FILE;
Damien Miller95def091999-11-25 00:26:21 +1100120 if (options->server_key_bits == -1)
121 options->server_key_bits = 768;
122 if (options->login_grace_time == -1)
123 options->login_grace_time = 600;
124 if (options->key_regeneration_time == -1)
125 options->key_regeneration_time = 3600;
Ben Lindstromd8a90212001-02-15 03:08:27 +0000126 if (options->permit_root_login == PERMIT_NOT_SET)
127 options->permit_root_login = PERMIT_YES;
Damien Miller95def091999-11-25 00:26:21 +1100128 if (options->ignore_rhosts == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100129 options->ignore_rhosts = 1;
Damien Miller95def091999-11-25 00:26:21 +1100130 if (options->ignore_user_known_hosts == -1)
131 options->ignore_user_known_hosts = 0;
132 if (options->check_mail == -1)
133 options->check_mail = 0;
134 if (options->print_motd == -1)
135 options->print_motd = 1;
Ben Lindstrom7bfff362001-03-26 05:45:53 +0000136 if (options->print_lastlog == -1)
137 options->print_lastlog = 1;
Damien Miller95def091999-11-25 00:26:21 +1100138 if (options->x11_forwarding == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100139 options->x11_forwarding = 0;
Damien Miller95def091999-11-25 00:26:21 +1100140 if (options->x11_display_offset == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100141 options->x11_display_offset = 10;
Damien Millerd3a18572000-06-07 19:55:44 +1000142#ifdef XAUTH_PATH
143 if (options->xauth_location == NULL)
144 options->xauth_location = XAUTH_PATH;
145#endif /* XAUTH_PATH */
Damien Miller95def091999-11-25 00:26:21 +1100146 if (options->strict_modes == -1)
147 options->strict_modes = 1;
148 if (options->keepalives == -1)
149 options->keepalives = 1;
150 if (options->log_facility == (SyslogFacility) (-1))
151 options->log_facility = SYSLOG_FACILITY_AUTH;
152 if (options->log_level == (LogLevel) (-1))
Ben Lindstromdb65e8f2001-01-19 04:26:52 +0000153 options->log_level = SYSLOG_LEVEL_INFO;
Damien Miller95def091999-11-25 00:26:21 +1100154 if (options->rhosts_authentication == -1)
155 options->rhosts_authentication = 0;
156 if (options->rhosts_rsa_authentication == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100157 options->rhosts_rsa_authentication = 0;
Damien Miller95def091999-11-25 00:26:21 +1100158 if (options->rsa_authentication == -1)
159 options->rsa_authentication = 1;
Damien Miller0bc1bd82000-11-13 22:57:25 +1100160 if (options->pubkey_authentication == -1)
161 options->pubkey_authentication = 1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000162#ifdef KRB4
Damien Miller95def091999-11-25 00:26:21 +1100163 if (options->kerberos_authentication == -1)
164 options->kerberos_authentication = (access(KEYFILE, R_OK) == 0);
165 if (options->kerberos_or_local_passwd == -1)
166 options->kerberos_or_local_passwd = 1;
167 if (options->kerberos_ticket_cleanup == -1)
168 options->kerberos_ticket_cleanup = 1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000169#endif /* KRB4 */
170#ifdef AFS
Damien Miller95def091999-11-25 00:26:21 +1100171 if (options->kerberos_tgt_passing == -1)
172 options->kerberos_tgt_passing = 0;
173 if (options->afs_token_passing == -1)
174 options->afs_token_passing = k_hasafs();
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000175#endif /* AFS */
Damien Miller95def091999-11-25 00:26:21 +1100176 if (options->password_authentication == -1)
177 options->password_authentication = 1;
Damien Miller874d77b2000-10-14 16:23:11 +1100178 if (options->kbd_interactive_authentication == -1)
179 options->kbd_interactive_authentication = 0;
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +0000180 if (options->challenge_reponse_authentication == -1)
181 options->challenge_reponse_authentication = 1;
Damien Miller95def091999-11-25 00:26:21 +1100182 if (options->permit_empty_passwd == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100183 options->permit_empty_passwd = 0;
Damien Miller95def091999-11-25 00:26:21 +1100184 if (options->use_login == -1)
185 options->use_login = 0;
Damien Miller50a41ed2000-10-16 12:14:42 +1100186 if (options->allow_tcp_forwarding == -1)
187 options->allow_tcp_forwarding = 1;
Damien Millere247cc42000-05-07 12:03:14 +1000188 if (options->gateway_ports == -1)
189 options->gateway_ports = 0;
Damien Miller37023962000-07-11 17:31:38 +1000190 if (options->max_startups == -1)
191 options->max_startups = 10;
Damien Miller942da032000-08-18 13:59:06 +1000192 if (options->max_startups_rate == -1)
193 options->max_startups_rate = 100; /* 100% */
194 if (options->max_startups_begin == -1)
195 options->max_startups_begin = options->max_startups;
Damien Miller33804262001-02-04 23:20:18 +1100196 if (options->reverse_mapping_check == -1)
197 options->reverse_mapping_check = 0;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000198}
199
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000200/* Keyword tokens. */
Damien Miller95def091999-11-25 00:26:21 +1100201typedef enum {
202 sBadOption, /* == unknown option */
203 sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime, sKeyRegenerationTime,
204 sPermitRootLogin, sLogFacility, sLogLevel,
205 sRhostsAuthentication, sRhostsRSAAuthentication, sRSAAuthentication,
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000206#ifdef KRB4
Damien Miller95def091999-11-25 00:26:21 +1100207 sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup,
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000208#endif
209#ifdef AFS
Damien Miller95def091999-11-25 00:26:21 +1100210 sKerberosTgtPassing, sAFSTokenPassing,
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000211#endif
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +0000212 sChallengeResponseAuthentication,
Damien Miller874d77b2000-10-14 16:23:11 +1100213 sPasswordAuthentication, sKbdInteractiveAuthentication, sListenAddress,
Ben Lindstrom7bfff362001-03-26 05:45:53 +0000214 sPrintMotd, sPrintLastLog, sIgnoreRhosts,
215 sX11Forwarding, sX11DisplayOffset,
Ben Lindstromd9cae222001-03-05 07:42:03 +0000216 sStrictModes, sEmptyPasswd, sKeepAlives, sCheckMail,
Damien Miller50a41ed2000-10-16 12:14:42 +1100217 sUseLogin, sAllowTcpForwarding,
218 sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000219 sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile,
Damien Miller0bc1bd82000-11-13 22:57:25 +1100220 sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, sMaxStartups,
Damien Miller33804262001-02-04 23:20:18 +1100221 sBanner, sReverseMappingCheck
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000222} ServerOpCodes;
223
224/* Textual representation of the tokens. */
Damien Miller95def091999-11-25 00:26:21 +1100225static struct {
226 const char *name;
227 ServerOpCodes opcode;
228} keywords[] = {
229 { "port", sPort },
230 { "hostkey", sHostKeyFile },
Damien Miller0bc1bd82000-11-13 22:57:25 +1100231 { "hostdsakey", sHostKeyFile }, /* alias */
Kevin Stevesef4eea92001-02-05 12:42:17 +0000232 { "pidfile", sPidFile },
Damien Miller95def091999-11-25 00:26:21 +1100233 { "serverkeybits", sServerKeyBits },
234 { "logingracetime", sLoginGraceTime },
235 { "keyregenerationinterval", sKeyRegenerationTime },
236 { "permitrootlogin", sPermitRootLogin },
237 { "syslogfacility", sLogFacility },
238 { "loglevel", sLogLevel },
239 { "rhostsauthentication", sRhostsAuthentication },
240 { "rhostsrsaauthentication", sRhostsRSAAuthentication },
241 { "rsaauthentication", sRSAAuthentication },
Damien Miller0bc1bd82000-11-13 22:57:25 +1100242 { "pubkeyauthentication", sPubkeyAuthentication },
243 { "dsaauthentication", sPubkeyAuthentication }, /* alias */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000244#ifdef KRB4
Damien Miller95def091999-11-25 00:26:21 +1100245 { "kerberosauthentication", sKerberosAuthentication },
246 { "kerberosorlocalpasswd", sKerberosOrLocalPasswd },
247 { "kerberosticketcleanup", sKerberosTicketCleanup },
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000248#endif
249#ifdef AFS
Damien Miller95def091999-11-25 00:26:21 +1100250 { "kerberostgtpassing", sKerberosTgtPassing },
251 { "afstokenpassing", sAFSTokenPassing },
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000252#endif
Damien Miller95def091999-11-25 00:26:21 +1100253 { "passwordauthentication", sPasswordAuthentication },
Damien Miller874d77b2000-10-14 16:23:11 +1100254 { "kbdinteractiveauthentication", sKbdInteractiveAuthentication },
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +0000255 { "challengeresponseauthentication", sChallengeResponseAuthentication },
256 { "skeyauthentication", sChallengeResponseAuthentication }, /* alias */
Damien Miller95def091999-11-25 00:26:21 +1100257 { "checkmail", sCheckMail },
258 { "listenaddress", sListenAddress },
259 { "printmotd", sPrintMotd },
Ben Lindstrom7bfff362001-03-26 05:45:53 +0000260 { "printlastlog", sPrintLastLog },
Damien Miller95def091999-11-25 00:26:21 +1100261 { "ignorerhosts", sIgnoreRhosts },
262 { "ignoreuserknownhosts", sIgnoreUserKnownHosts },
263 { "x11forwarding", sX11Forwarding },
264 { "x11displayoffset", sX11DisplayOffset },
Damien Millerd3a18572000-06-07 19:55:44 +1000265 { "xauthlocation", sXAuthLocation },
Damien Miller95def091999-11-25 00:26:21 +1100266 { "strictmodes", sStrictModes },
267 { "permitemptypasswords", sEmptyPasswd },
268 { "uselogin", sUseLogin },
Damien Miller95def091999-11-25 00:26:21 +1100269 { "keepalive", sKeepAlives },
Damien Miller50a41ed2000-10-16 12:14:42 +1100270 { "allowtcpforwarding", sAllowTcpForwarding },
Damien Miller95def091999-11-25 00:26:21 +1100271 { "allowusers", sAllowUsers },
272 { "denyusers", sDenyUsers },
273 { "allowgroups", sAllowGroups },
274 { "denygroups", sDenyGroups },
Damien Miller78928792000-04-12 20:17:38 +1000275 { "ciphers", sCiphers },
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000276 { "macs", sMacs },
Damien Miller78928792000-04-12 20:17:38 +1000277 { "protocol", sProtocol },
Damien Millere247cc42000-05-07 12:03:14 +1000278 { "gatewayports", sGatewayPorts },
Damien Millerf6d9e222000-06-18 14:50:44 +1000279 { "subsystem", sSubsystem },
Damien Miller37023962000-07-11 17:31:38 +1000280 { "maxstartups", sMaxStartups },
Ben Lindstrom48bd7c12001-01-09 00:35:42 +0000281 { "banner", sBanner },
Damien Miller33804262001-02-04 23:20:18 +1100282 { "reversemappingcheck", sReverseMappingCheck },
Damien Miller95def091999-11-25 00:26:21 +1100283 { NULL, 0 }
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000284};
285
Damien Miller5428f641999-11-25 11:54:57 +1100286/*
Ben Lindstrom3704c262001-04-02 18:20:03 +0000287 * Returns the number of the token pointed to by cp or sBadOption.
Damien Miller5428f641999-11-25 11:54:57 +1100288 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000289
Damien Miller4af51302000-04-16 11:18:38 +1000290static ServerOpCodes
Damien Miller95def091999-11-25 00:26:21 +1100291parse_token(const char *cp, const char *filename,
292 int linenum)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000293{
Ben Lindstrom46c16222000-12-22 01:43:59 +0000294 u_int i;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000295
Damien Miller95def091999-11-25 00:26:21 +1100296 for (i = 0; keywords[i].name; i++)
Damien Miller5428f641999-11-25 11:54:57 +1100297 if (strcasecmp(cp, keywords[i].name) == 0)
Damien Miller95def091999-11-25 00:26:21 +1100298 return keywords[i].opcode;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000299
Damien Miller95def091999-11-25 00:26:21 +1100300 fprintf(stderr, "%s: line %d: Bad configuration option: %s\n",
301 filename, linenum, cp);
302 return sBadOption;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000303}
304
Damien Miller34132e52000-01-14 15:45:46 +1100305/*
306 * add listen address
307 */
Damien Miller4af51302000-04-16 11:18:38 +1000308void
Damien Miller34132e52000-01-14 15:45:46 +1100309add_listen_addr(ServerOptions *options, char *addr)
310{
Damien Miller34132e52000-01-14 15:45:46 +1100311 struct addrinfo hints, *ai, *aitop;
312 char strport[NI_MAXSERV];
313 int gaierr;
314 int i;
315
316 if (options->num_ports == 0)
317 options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
318 for (i = 0; i < options->num_ports; i++) {
319 memset(&hints, 0, sizeof(hints));
320 hints.ai_family = IPv4or6;
321 hints.ai_socktype = SOCK_STREAM;
322 hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0;
323 snprintf(strport, sizeof strport, "%d", options->ports[i]);
324 if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000325 fatal("bad addr or host: %s (%s)",
Damien Miller34132e52000-01-14 15:45:46 +1100326 addr ? addr : "<NULL>",
327 gai_strerror(gaierr));
328 for (ai = aitop; ai->ai_next; ai = ai->ai_next)
329 ;
330 ai->ai_next = options->listen_addrs;
331 options->listen_addrs = aitop;
332 }
333}
334
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000335/* Reads the server configuration file. */
336
Damien Miller4af51302000-04-16 11:18:38 +1000337void
Damien Miller95def091999-11-25 00:26:21 +1100338read_server_config(ServerOptions *options, const char *filename)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000339{
Damien Miller95def091999-11-25 00:26:21 +1100340 FILE *f;
341 char line[1024];
Damien Miller37023962000-07-11 17:31:38 +1000342 char *cp, **charptr, *arg;
Damien Miller95def091999-11-25 00:26:21 +1100343 int linenum, *intptr, value;
344 int bad_options = 0;
345 ServerOpCodes opcode;
Damien Millerf6d9e222000-06-18 14:50:44 +1000346 int i;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000347
Damien Miller95def091999-11-25 00:26:21 +1100348 f = fopen(filename, "r");
349 if (!f) {
350 perror(filename);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000351 exit(1);
Damien Miller95def091999-11-25 00:26:21 +1100352 }
353 linenum = 0;
354 while (fgets(line, sizeof(line), f)) {
355 linenum++;
Damien Millerbe484b52000-07-15 14:14:16 +1000356 cp = line;
357 arg = strdelim(&cp);
358 /* Ignore leading whitespace */
359 if (*arg == '\0')
360 arg = strdelim(&cp);
Ben Lindstrom226cfa02001-01-22 05:34:40 +0000361 if (!arg || !*arg || *arg == '#')
Damien Miller95def091999-11-25 00:26:21 +1100362 continue;
Damien Miller0bc1bd82000-11-13 22:57:25 +1100363 intptr = NULL;
364 charptr = NULL;
Damien Miller37023962000-07-11 17:31:38 +1000365 opcode = parse_token(arg, filename, linenum);
Damien Miller95def091999-11-25 00:26:21 +1100366 switch (opcode) {
367 case sBadOption:
368 bad_options++;
369 continue;
370 case sPort:
Damien Miller34132e52000-01-14 15:45:46 +1100371 /* ignore ports from configfile if cmdline specifies ports */
372 if (options->ports_from_cmdline)
373 continue;
374 if (options->listen_addrs != NULL)
375 fatal("%s line %d: ports must be specified before "
376 "ListenAdress.\n", filename, linenum);
377 if (options->num_ports >= MAX_PORTS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000378 fatal("%s line %d: too many ports.",
Damien Miller4af51302000-04-16 11:18:38 +1000379 filename, linenum);
Damien Millerbe484b52000-07-15 14:14:16 +1000380 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000381 if (!arg || *arg == '\0')
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000382 fatal("%s line %d: missing port number.",
Damien Miller34132e52000-01-14 15:45:46 +1100383 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000384 options->ports[options->num_ports++] = atoi(arg);
Damien Miller34132e52000-01-14 15:45:46 +1100385 break;
386
387 case sServerKeyBits:
388 intptr = &options->server_key_bits;
Damien Miller95def091999-11-25 00:26:21 +1100389parse_int:
Damien Millerbe484b52000-07-15 14:14:16 +1000390 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000391 if (!arg || *arg == '\0') {
Damien Miller95def091999-11-25 00:26:21 +1100392 fprintf(stderr, "%s line %d: missing integer value.\n",
393 filename, linenum);
394 exit(1);
395 }
Damien Miller37023962000-07-11 17:31:38 +1000396 value = atoi(arg);
Damien Miller95def091999-11-25 00:26:21 +1100397 if (*intptr == -1)
398 *intptr = value;
399 break;
Damien Miller32265091999-11-12 11:33:04 +1100400
Damien Miller95def091999-11-25 00:26:21 +1100401 case sLoginGraceTime:
402 intptr = &options->login_grace_time;
403 goto parse_int;
404
405 case sKeyRegenerationTime:
406 intptr = &options->key_regeneration_time;
407 goto parse_int;
408
409 case sListenAddress:
Damien Millerbe484b52000-07-15 14:14:16 +1000410 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000411 if (!arg || *arg == '\0')
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000412 fatal("%s line %d: missing inet addr.",
Damien Miller34132e52000-01-14 15:45:46 +1100413 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000414 add_listen_addr(options, arg);
Damien Miller95def091999-11-25 00:26:21 +1100415 break;
416
417 case sHostKeyFile:
Damien Miller0bc1bd82000-11-13 22:57:25 +1100418 intptr = &options->num_host_key_files;
419 if (*intptr >= MAX_HOSTKEYS) {
Ben Lindstrom33a3cc32001-03-05 05:07:52 +0000420 fprintf(stderr,
421 "%s line %d: too many host keys specified (max %d).\n",
Damien Miller0bc1bd82000-11-13 22:57:25 +1100422 filename, linenum, MAX_HOSTKEYS);
423 exit(1);
424 }
425 charptr = &options->host_key_files[*intptr];
Damien Millerd3a18572000-06-07 19:55:44 +1000426parse_filename:
Damien Millerbe484b52000-07-15 14:14:16 +1000427 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000428 if (!arg || *arg == '\0') {
Damien Miller95def091999-11-25 00:26:21 +1100429 fprintf(stderr, "%s line %d: missing file name.\n",
Damien Miller6f83b8e2000-05-02 09:23:45 +1000430 filename, linenum);
431 exit(1);
432 }
Damien Miller0bc1bd82000-11-13 22:57:25 +1100433 if (*charptr == NULL) {
Damien Miller37023962000-07-11 17:31:38 +1000434 *charptr = tilde_expand_filename(arg, getuid());
Damien Miller0bc1bd82000-11-13 22:57:25 +1100435 /* increase optional counter */
436 if (intptr != NULL)
437 *intptr = *intptr + 1;
438 }
Damien Miller6f83b8e2000-05-02 09:23:45 +1000439 break;
440
441 case sPidFile:
442 charptr = &options->pid_file;
Damien Millerd3a18572000-06-07 19:55:44 +1000443 goto parse_filename;
Damien Miller95def091999-11-25 00:26:21 +1100444
Damien Miller95def091999-11-25 00:26:21 +1100445 case sPermitRootLogin:
446 intptr = &options->permit_root_login;
Damien Millerbe484b52000-07-15 14:14:16 +1000447 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000448 if (!arg || *arg == '\0') {
Ben Lindstrom35f1f4e2001-03-06 01:02:41 +0000449 fprintf(stderr, "%s line %d: missing yes/"
450 "without-password/forced-commands-only/no "
451 "argument.\n", filename, linenum);
Damien Miller95def091999-11-25 00:26:21 +1100452 exit(1);
453 }
Damien Miller37023962000-07-11 17:31:38 +1000454 if (strcmp(arg, "without-password") == 0)
Ben Lindstromd8a90212001-02-15 03:08:27 +0000455 value = PERMIT_NO_PASSWD;
456 else if (strcmp(arg, "forced-commands-only") == 0)
457 value = PERMIT_FORCED_ONLY;
Damien Miller37023962000-07-11 17:31:38 +1000458 else if (strcmp(arg, "yes") == 0)
Ben Lindstromd8a90212001-02-15 03:08:27 +0000459 value = PERMIT_YES;
Damien Miller37023962000-07-11 17:31:38 +1000460 else if (strcmp(arg, "no") == 0)
Ben Lindstromd8a90212001-02-15 03:08:27 +0000461 value = PERMIT_NO;
Damien Miller95def091999-11-25 00:26:21 +1100462 else {
Ben Lindstromd8a90212001-02-15 03:08:27 +0000463 fprintf(stderr, "%s line %d: Bad yes/"
464 "without-password/forced-commands-only/no "
465 "argument: %s\n", filename, linenum, arg);
Damien Miller95def091999-11-25 00:26:21 +1100466 exit(1);
467 }
468 if (*intptr == -1)
469 *intptr = value;
470 break;
471
472 case sIgnoreRhosts:
473 intptr = &options->ignore_rhosts;
474parse_flag:
Damien Millerbe484b52000-07-15 14:14:16 +1000475 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000476 if (!arg || *arg == '\0') {
Damien Miller95def091999-11-25 00:26:21 +1100477 fprintf(stderr, "%s line %d: missing yes/no argument.\n",
478 filename, linenum);
479 exit(1);
480 }
Damien Miller37023962000-07-11 17:31:38 +1000481 if (strcmp(arg, "yes") == 0)
Damien Miller95def091999-11-25 00:26:21 +1100482 value = 1;
Damien Miller37023962000-07-11 17:31:38 +1000483 else if (strcmp(arg, "no") == 0)
Damien Miller95def091999-11-25 00:26:21 +1100484 value = 0;
485 else {
486 fprintf(stderr, "%s line %d: Bad yes/no argument: %s\n",
Damien Miller37023962000-07-11 17:31:38 +1000487 filename, linenum, arg);
Damien Miller95def091999-11-25 00:26:21 +1100488 exit(1);
489 }
490 if (*intptr == -1)
491 *intptr = value;
492 break;
493
494 case sIgnoreUserKnownHosts:
495 intptr = &options->ignore_user_known_hosts;
Damien Miller98c7ad62000-03-09 21:27:49 +1100496 goto parse_flag;
Damien Miller95def091999-11-25 00:26:21 +1100497
498 case sRhostsAuthentication:
499 intptr = &options->rhosts_authentication;
500 goto parse_flag;
501
502 case sRhostsRSAAuthentication:
503 intptr = &options->rhosts_rsa_authentication;
504 goto parse_flag;
505
506 case sRSAAuthentication:
507 intptr = &options->rsa_authentication;
508 goto parse_flag;
509
Damien Miller0bc1bd82000-11-13 22:57:25 +1100510 case sPubkeyAuthentication:
511 intptr = &options->pubkey_authentication;
Damien Millere247cc42000-05-07 12:03:14 +1000512 goto parse_flag;
513
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000514#ifdef KRB4
Damien Miller95def091999-11-25 00:26:21 +1100515 case sKerberosAuthentication:
516 intptr = &options->kerberos_authentication;
517 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000518
Damien Miller95def091999-11-25 00:26:21 +1100519 case sKerberosOrLocalPasswd:
520 intptr = &options->kerberos_or_local_passwd;
521 goto parse_flag;
522
523 case sKerberosTicketCleanup:
524 intptr = &options->kerberos_ticket_cleanup;
525 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000526#endif
Damien Miller95def091999-11-25 00:26:21 +1100527
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000528#ifdef AFS
Damien Miller95def091999-11-25 00:26:21 +1100529 case sKerberosTgtPassing:
530 intptr = &options->kerberos_tgt_passing;
531 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000532
Damien Miller95def091999-11-25 00:26:21 +1100533 case sAFSTokenPassing:
534 intptr = &options->afs_token_passing;
535 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000536#endif
537
Damien Miller95def091999-11-25 00:26:21 +1100538 case sPasswordAuthentication:
539 intptr = &options->password_authentication;
540 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000541
Damien Miller874d77b2000-10-14 16:23:11 +1100542 case sKbdInteractiveAuthentication:
543 intptr = &options->kbd_interactive_authentication;
544 goto parse_flag;
545
Damien Miller95def091999-11-25 00:26:21 +1100546 case sCheckMail:
547 intptr = &options->check_mail;
548 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000549
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +0000550 case sChallengeResponseAuthentication:
551 intptr = &options->challenge_reponse_authentication;
Damien Miller95def091999-11-25 00:26:21 +1100552 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000553
Damien Miller95def091999-11-25 00:26:21 +1100554 case sPrintMotd:
555 intptr = &options->print_motd;
556 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000557
Ben Lindstrom7bfff362001-03-26 05:45:53 +0000558 case sPrintLastLog:
559 intptr = &options->print_lastlog;
560 goto parse_flag;
561
Damien Miller95def091999-11-25 00:26:21 +1100562 case sX11Forwarding:
563 intptr = &options->x11_forwarding;
564 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000565
Damien Miller95def091999-11-25 00:26:21 +1100566 case sX11DisplayOffset:
567 intptr = &options->x11_display_offset;
568 goto parse_int;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000569
Damien Millerd3a18572000-06-07 19:55:44 +1000570 case sXAuthLocation:
571 charptr = &options->xauth_location;
572 goto parse_filename;
Kevin Stevesef4eea92001-02-05 12:42:17 +0000573
Damien Miller95def091999-11-25 00:26:21 +1100574 case sStrictModes:
575 intptr = &options->strict_modes;
576 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000577
Damien Miller95def091999-11-25 00:26:21 +1100578 case sKeepAlives:
579 intptr = &options->keepalives;
580 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000581
Damien Miller95def091999-11-25 00:26:21 +1100582 case sEmptyPasswd:
583 intptr = &options->permit_empty_passwd;
584 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000585
Damien Miller95def091999-11-25 00:26:21 +1100586 case sUseLogin:
587 intptr = &options->use_login;
588 goto parse_flag;
Damien Miller5ce662a1999-11-11 17:57:39 +1100589
Damien Millere247cc42000-05-07 12:03:14 +1000590 case sGatewayPorts:
591 intptr = &options->gateway_ports;
592 goto parse_flag;
593
Damien Miller33804262001-02-04 23:20:18 +1100594 case sReverseMappingCheck:
595 intptr = &options->reverse_mapping_check;
596 goto parse_flag;
597
Damien Miller95def091999-11-25 00:26:21 +1100598 case sLogFacility:
599 intptr = (int *) &options->log_facility;
Damien Millerbe484b52000-07-15 14:14:16 +1000600 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000601 value = log_facility_number(arg);
Damien Miller95def091999-11-25 00:26:21 +1100602 if (value == (SyslogFacility) - 1)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000603 fatal("%.200s line %d: unsupported log facility '%s'",
Damien Miller37023962000-07-11 17:31:38 +1000604 filename, linenum, arg ? arg : "<NONE>");
Damien Miller95def091999-11-25 00:26:21 +1100605 if (*intptr == -1)
606 *intptr = (SyslogFacility) value;
607 break;
608
609 case sLogLevel:
610 intptr = (int *) &options->log_level;
Damien Millerbe484b52000-07-15 14:14:16 +1000611 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000612 value = log_level_number(arg);
Damien Miller95def091999-11-25 00:26:21 +1100613 if (value == (LogLevel) - 1)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000614 fatal("%.200s line %d: unsupported log level '%s'",
Damien Miller37023962000-07-11 17:31:38 +1000615 filename, linenum, arg ? arg : "<NONE>");
Damien Miller95def091999-11-25 00:26:21 +1100616 if (*intptr == -1)
617 *intptr = (LogLevel) value;
618 break;
619
Damien Miller50a41ed2000-10-16 12:14:42 +1100620 case sAllowTcpForwarding:
621 intptr = &options->allow_tcp_forwarding;
622 goto parse_flag;
623
Damien Miller95def091999-11-25 00:26:21 +1100624 case sAllowUsers:
Damien Millerbe484b52000-07-15 14:14:16 +1000625 while ((arg = strdelim(&cp)) && *arg != '\0') {
Damien Miller78928792000-04-12 20:17:38 +1000626 if (options->num_allow_users >= MAX_ALLOW_USERS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000627 fatal("%s line %d: too many allow users.",
Damien Miller78928792000-04-12 20:17:38 +1000628 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000629 options->allow_users[options->num_allow_users++] = xstrdup(arg);
Damien Miller95def091999-11-25 00:26:21 +1100630 }
631 break;
632
633 case sDenyUsers:
Damien Millerbe484b52000-07-15 14:14:16 +1000634 while ((arg = strdelim(&cp)) && *arg != '\0') {
Damien Miller78928792000-04-12 20:17:38 +1000635 if (options->num_deny_users >= MAX_DENY_USERS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000636 fatal( "%s line %d: too many deny users.",
Damien Miller78928792000-04-12 20:17:38 +1000637 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000638 options->deny_users[options->num_deny_users++] = xstrdup(arg);
Damien Miller95def091999-11-25 00:26:21 +1100639 }
640 break;
641
642 case sAllowGroups:
Damien Millerbe484b52000-07-15 14:14:16 +1000643 while ((arg = strdelim(&cp)) && *arg != '\0') {
Damien Miller78928792000-04-12 20:17:38 +1000644 if (options->num_allow_groups >= MAX_ALLOW_GROUPS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000645 fatal("%s line %d: too many allow groups.",
Damien Miller78928792000-04-12 20:17:38 +1000646 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000647 options->allow_groups[options->num_allow_groups++] = xstrdup(arg);
Damien Miller95def091999-11-25 00:26:21 +1100648 }
649 break;
650
651 case sDenyGroups:
Damien Millerbe484b52000-07-15 14:14:16 +1000652 while ((arg = strdelim(&cp)) && *arg != '\0') {
Damien Miller78928792000-04-12 20:17:38 +1000653 if (options->num_deny_groups >= MAX_DENY_GROUPS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000654 fatal("%s line %d: too many deny groups.",
Damien Miller78928792000-04-12 20:17:38 +1000655 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000656 options->deny_groups[options->num_deny_groups++] = xstrdup(arg);
Damien Miller95def091999-11-25 00:26:21 +1100657 }
658 break;
659
Damien Miller78928792000-04-12 20:17:38 +1000660 case sCiphers:
Damien Millerbe484b52000-07-15 14:14:16 +1000661 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000662 if (!arg || *arg == '\0')
Damien Millerb1715dc2000-05-30 13:44:51 +1000663 fatal("%s line %d: Missing argument.", filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000664 if (!ciphers_valid(arg))
Damien Miller30c3d422000-05-09 11:02:59 +1000665 fatal("%s line %d: Bad SSH2 cipher spec '%s'.",
Damien Miller37023962000-07-11 17:31:38 +1000666 filename, linenum, arg ? arg : "<NONE>");
Damien Miller78928792000-04-12 20:17:38 +1000667 if (options->ciphers == NULL)
Damien Miller37023962000-07-11 17:31:38 +1000668 options->ciphers = xstrdup(arg);
Damien Miller78928792000-04-12 20:17:38 +1000669 break;
670
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000671 case sMacs:
672 arg = strdelim(&cp);
673 if (!arg || *arg == '\0')
674 fatal("%s line %d: Missing argument.", filename, linenum);
675 if (!mac_valid(arg))
676 fatal("%s line %d: Bad SSH2 mac spec '%s'.",
677 filename, linenum, arg ? arg : "<NONE>");
678 if (options->macs == NULL)
679 options->macs = xstrdup(arg);
680 break;
681
Damien Miller78928792000-04-12 20:17:38 +1000682 case sProtocol:
683 intptr = &options->protocol;
Damien Millerbe484b52000-07-15 14:14:16 +1000684 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000685 if (!arg || *arg == '\0')
Damien Millerb1715dc2000-05-30 13:44:51 +1000686 fatal("%s line %d: Missing argument.", filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000687 value = proto_spec(arg);
Damien Miller78928792000-04-12 20:17:38 +1000688 if (value == SSH_PROTO_UNKNOWN)
689 fatal("%s line %d: Bad protocol spec '%s'.",
Damien Miller37023962000-07-11 17:31:38 +1000690 filename, linenum, arg ? arg : "<NONE>");
Damien Miller78928792000-04-12 20:17:38 +1000691 if (*intptr == SSH_PROTO_UNKNOWN)
692 *intptr = value;
693 break;
694
Damien Millerf6d9e222000-06-18 14:50:44 +1000695 case sSubsystem:
696 if(options->num_subsystems >= MAX_SUBSYSTEMS) {
697 fatal("%s line %d: too many subsystems defined.",
698 filename, linenum);
699 }
Damien Millerbe484b52000-07-15 14:14:16 +1000700 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000701 if (!arg || *arg == '\0')
Damien Millerf6d9e222000-06-18 14:50:44 +1000702 fatal("%s line %d: Missing subsystem name.",
703 filename, linenum);
704 for (i = 0; i < options->num_subsystems; i++)
Damien Miller37023962000-07-11 17:31:38 +1000705 if(strcmp(arg, options->subsystem_name[i]) == 0)
Damien Millerf6d9e222000-06-18 14:50:44 +1000706 fatal("%s line %d: Subsystem '%s' already defined.",
Damien Miller37023962000-07-11 17:31:38 +1000707 filename, linenum, arg);
708 options->subsystem_name[options->num_subsystems] = xstrdup(arg);
Damien Millerbe484b52000-07-15 14:14:16 +1000709 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000710 if (!arg || *arg == '\0')
Damien Millerf6d9e222000-06-18 14:50:44 +1000711 fatal("%s line %d: Missing subsystem command.",
712 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000713 options->subsystem_command[options->num_subsystems] = xstrdup(arg);
Damien Millerf6d9e222000-06-18 14:50:44 +1000714 options->num_subsystems++;
715 break;
716
Damien Miller37023962000-07-11 17:31:38 +1000717 case sMaxStartups:
Damien Miller942da032000-08-18 13:59:06 +1000718 arg = strdelim(&cp);
719 if (!arg || *arg == '\0')
720 fatal("%s line %d: Missing MaxStartups spec.",
721 filename, linenum);
722 if (sscanf(arg, "%d:%d:%d",
723 &options->max_startups_begin,
724 &options->max_startups_rate,
725 &options->max_startups) == 3) {
726 if (options->max_startups_begin >
727 options->max_startups ||
728 options->max_startups_rate > 100 ||
729 options->max_startups_rate < 1)
730 fatal("%s line %d: Illegal MaxStartups spec.",
731 filename, linenum);
732 break;
733 }
Damien Miller37023962000-07-11 17:31:38 +1000734 intptr = &options->max_startups;
735 goto parse_int;
736
Ben Lindstrom48bd7c12001-01-09 00:35:42 +0000737 case sBanner:
738 charptr = &options->banner;
739 goto parse_filename;
Kevin Stevesef4eea92001-02-05 12:42:17 +0000740
Damien Miller95def091999-11-25 00:26:21 +1100741 default:
742 fprintf(stderr, "%s line %d: Missing handler for opcode %s (%d)\n",
Damien Miller37023962000-07-11 17:31:38 +1000743 filename, linenum, arg, opcode);
Damien Miller95def091999-11-25 00:26:21 +1100744 exit(1);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000745 }
Damien Millerbe484b52000-07-15 14:14:16 +1000746 if ((arg = strdelim(&cp)) != NULL && *arg != '\0') {
Kevin Stevesef4eea92001-02-05 12:42:17 +0000747 fprintf(stderr,
Damien Miller37023962000-07-11 17:31:38 +1000748 "%s line %d: garbage at end of line; \"%.200s\".\n",
749 filename, linenum, arg);
Damien Miller95def091999-11-25 00:26:21 +1100750 exit(1);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000751 }
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000752 }
Damien Miller95def091999-11-25 00:26:21 +1100753 fclose(f);
754 if (bad_options > 0) {
755 fprintf(stderr, "%s: terminating, %d bad configuration options\n",
756 filename, bad_options);
757 exit(1);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000758 }
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000759}