blob: 681878615a905bcc0bcc833617bfc785bdf54bd6 [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 Lindstrom7bfff362001-03-26 05:45:53 +000013RCSID("$OpenBSD: servconf.c,v 1.72 2001/03/25 13:16:10 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/*
287 * Returns the number of the token pointed to by cp of length len. Never
288 * returns if the token is not known.
289 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000290
Damien Miller4af51302000-04-16 11:18:38 +1000291static ServerOpCodes
Damien Miller95def091999-11-25 00:26:21 +1100292parse_token(const char *cp, const char *filename,
293 int linenum)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000294{
Ben Lindstrom46c16222000-12-22 01:43:59 +0000295 u_int i;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000296
Damien Miller95def091999-11-25 00:26:21 +1100297 for (i = 0; keywords[i].name; i++)
Damien Miller5428f641999-11-25 11:54:57 +1100298 if (strcasecmp(cp, keywords[i].name) == 0)
Damien Miller95def091999-11-25 00:26:21 +1100299 return keywords[i].opcode;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000300
Damien Miller95def091999-11-25 00:26:21 +1100301 fprintf(stderr, "%s: line %d: Bad configuration option: %s\n",
302 filename, linenum, cp);
303 return sBadOption;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000304}
305
Damien Miller34132e52000-01-14 15:45:46 +1100306/*
307 * add listen address
308 */
Damien Miller4af51302000-04-16 11:18:38 +1000309void
Damien Miller34132e52000-01-14 15:45:46 +1100310add_listen_addr(ServerOptions *options, char *addr)
311{
Damien Miller34132e52000-01-14 15:45:46 +1100312 struct addrinfo hints, *ai, *aitop;
313 char strport[NI_MAXSERV];
314 int gaierr;
315 int i;
316
317 if (options->num_ports == 0)
318 options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
319 for (i = 0; i < options->num_ports; i++) {
320 memset(&hints, 0, sizeof(hints));
321 hints.ai_family = IPv4or6;
322 hints.ai_socktype = SOCK_STREAM;
323 hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0;
324 snprintf(strport, sizeof strport, "%d", options->ports[i]);
325 if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000326 fatal("bad addr or host: %s (%s)",
Damien Miller34132e52000-01-14 15:45:46 +1100327 addr ? addr : "<NULL>",
328 gai_strerror(gaierr));
329 for (ai = aitop; ai->ai_next; ai = ai->ai_next)
330 ;
331 ai->ai_next = options->listen_addrs;
332 options->listen_addrs = aitop;
333 }
334}
335
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000336/* Reads the server configuration file. */
337
Damien Miller4af51302000-04-16 11:18:38 +1000338void
Damien Miller95def091999-11-25 00:26:21 +1100339read_server_config(ServerOptions *options, const char *filename)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000340{
Damien Miller95def091999-11-25 00:26:21 +1100341 FILE *f;
342 char line[1024];
Damien Miller37023962000-07-11 17:31:38 +1000343 char *cp, **charptr, *arg;
Damien Miller95def091999-11-25 00:26:21 +1100344 int linenum, *intptr, value;
345 int bad_options = 0;
346 ServerOpCodes opcode;
Damien Millerf6d9e222000-06-18 14:50:44 +1000347 int i;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000348
Damien Miller95def091999-11-25 00:26:21 +1100349 f = fopen(filename, "r");
350 if (!f) {
351 perror(filename);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000352 exit(1);
Damien Miller95def091999-11-25 00:26:21 +1100353 }
354 linenum = 0;
355 while (fgets(line, sizeof(line), f)) {
356 linenum++;
Damien Millerbe484b52000-07-15 14:14:16 +1000357 cp = line;
358 arg = strdelim(&cp);
359 /* Ignore leading whitespace */
360 if (*arg == '\0')
361 arg = strdelim(&cp);
Ben Lindstrom226cfa02001-01-22 05:34:40 +0000362 if (!arg || !*arg || *arg == '#')
Damien Miller95def091999-11-25 00:26:21 +1100363 continue;
Damien Miller0bc1bd82000-11-13 22:57:25 +1100364 intptr = NULL;
365 charptr = NULL;
Damien Miller37023962000-07-11 17:31:38 +1000366 opcode = parse_token(arg, filename, linenum);
Damien Miller95def091999-11-25 00:26:21 +1100367 switch (opcode) {
368 case sBadOption:
369 bad_options++;
370 continue;
371 case sPort:
Damien Miller34132e52000-01-14 15:45:46 +1100372 /* ignore ports from configfile if cmdline specifies ports */
373 if (options->ports_from_cmdline)
374 continue;
375 if (options->listen_addrs != NULL)
376 fatal("%s line %d: ports must be specified before "
377 "ListenAdress.\n", filename, linenum);
378 if (options->num_ports >= MAX_PORTS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000379 fatal("%s line %d: too many ports.",
Damien Miller4af51302000-04-16 11:18:38 +1000380 filename, linenum);
Damien Millerbe484b52000-07-15 14:14:16 +1000381 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000382 if (!arg || *arg == '\0')
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000383 fatal("%s line %d: missing port number.",
Damien Miller34132e52000-01-14 15:45:46 +1100384 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000385 options->ports[options->num_ports++] = atoi(arg);
Damien Miller34132e52000-01-14 15:45:46 +1100386 break;
387
388 case sServerKeyBits:
389 intptr = &options->server_key_bits;
Damien Miller95def091999-11-25 00:26:21 +1100390parse_int:
Damien Millerbe484b52000-07-15 14:14:16 +1000391 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000392 if (!arg || *arg == '\0') {
Damien Miller95def091999-11-25 00:26:21 +1100393 fprintf(stderr, "%s line %d: missing integer value.\n",
394 filename, linenum);
395 exit(1);
396 }
Damien Miller37023962000-07-11 17:31:38 +1000397 value = atoi(arg);
Damien Miller95def091999-11-25 00:26:21 +1100398 if (*intptr == -1)
399 *intptr = value;
400 break;
Damien Miller32265091999-11-12 11:33:04 +1100401
Damien Miller95def091999-11-25 00:26:21 +1100402 case sLoginGraceTime:
403 intptr = &options->login_grace_time;
404 goto parse_int;
405
406 case sKeyRegenerationTime:
407 intptr = &options->key_regeneration_time;
408 goto parse_int;
409
410 case sListenAddress:
Damien Millerbe484b52000-07-15 14:14:16 +1000411 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000412 if (!arg || *arg == '\0')
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000413 fatal("%s line %d: missing inet addr.",
Damien Miller34132e52000-01-14 15:45:46 +1100414 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000415 add_listen_addr(options, arg);
Damien Miller95def091999-11-25 00:26:21 +1100416 break;
417
418 case sHostKeyFile:
Damien Miller0bc1bd82000-11-13 22:57:25 +1100419 intptr = &options->num_host_key_files;
420 if (*intptr >= MAX_HOSTKEYS) {
Ben Lindstrom33a3cc32001-03-05 05:07:52 +0000421 fprintf(stderr,
422 "%s line %d: too many host keys specified (max %d).\n",
Damien Miller0bc1bd82000-11-13 22:57:25 +1100423 filename, linenum, MAX_HOSTKEYS);
424 exit(1);
425 }
426 charptr = &options->host_key_files[*intptr];
Damien Millerd3a18572000-06-07 19:55:44 +1000427parse_filename:
Damien Millerbe484b52000-07-15 14:14:16 +1000428 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000429 if (!arg || *arg == '\0') {
Damien Miller95def091999-11-25 00:26:21 +1100430 fprintf(stderr, "%s line %d: missing file name.\n",
Damien Miller6f83b8e2000-05-02 09:23:45 +1000431 filename, linenum);
432 exit(1);
433 }
Damien Miller0bc1bd82000-11-13 22:57:25 +1100434 if (*charptr == NULL) {
Damien Miller37023962000-07-11 17:31:38 +1000435 *charptr = tilde_expand_filename(arg, getuid());
Damien Miller0bc1bd82000-11-13 22:57:25 +1100436 /* increase optional counter */
437 if (intptr != NULL)
438 *intptr = *intptr + 1;
439 }
Damien Miller6f83b8e2000-05-02 09:23:45 +1000440 break;
441
442 case sPidFile:
443 charptr = &options->pid_file;
Damien Millerd3a18572000-06-07 19:55:44 +1000444 goto parse_filename;
Damien Miller95def091999-11-25 00:26:21 +1100445
Damien Miller95def091999-11-25 00:26:21 +1100446 case sPermitRootLogin:
447 intptr = &options->permit_root_login;
Damien Millerbe484b52000-07-15 14:14:16 +1000448 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000449 if (!arg || *arg == '\0') {
Ben Lindstrom35f1f4e2001-03-06 01:02:41 +0000450 fprintf(stderr, "%s line %d: missing yes/"
451 "without-password/forced-commands-only/no "
452 "argument.\n", filename, linenum);
Damien Miller95def091999-11-25 00:26:21 +1100453 exit(1);
454 }
Damien Miller37023962000-07-11 17:31:38 +1000455 if (strcmp(arg, "without-password") == 0)
Ben Lindstromd8a90212001-02-15 03:08:27 +0000456 value = PERMIT_NO_PASSWD;
457 else if (strcmp(arg, "forced-commands-only") == 0)
458 value = PERMIT_FORCED_ONLY;
Damien Miller37023962000-07-11 17:31:38 +1000459 else if (strcmp(arg, "yes") == 0)
Ben Lindstromd8a90212001-02-15 03:08:27 +0000460 value = PERMIT_YES;
Damien Miller37023962000-07-11 17:31:38 +1000461 else if (strcmp(arg, "no") == 0)
Ben Lindstromd8a90212001-02-15 03:08:27 +0000462 value = PERMIT_NO;
Damien Miller95def091999-11-25 00:26:21 +1100463 else {
Ben Lindstromd8a90212001-02-15 03:08:27 +0000464 fprintf(stderr, "%s line %d: Bad yes/"
465 "without-password/forced-commands-only/no "
466 "argument: %s\n", filename, linenum, arg);
Damien Miller95def091999-11-25 00:26:21 +1100467 exit(1);
468 }
469 if (*intptr == -1)
470 *intptr = value;
471 break;
472
473 case sIgnoreRhosts:
474 intptr = &options->ignore_rhosts;
475parse_flag:
Damien Millerbe484b52000-07-15 14:14:16 +1000476 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000477 if (!arg || *arg == '\0') {
Damien Miller95def091999-11-25 00:26:21 +1100478 fprintf(stderr, "%s line %d: missing yes/no argument.\n",
479 filename, linenum);
480 exit(1);
481 }
Damien Miller37023962000-07-11 17:31:38 +1000482 if (strcmp(arg, "yes") == 0)
Damien Miller95def091999-11-25 00:26:21 +1100483 value = 1;
Damien Miller37023962000-07-11 17:31:38 +1000484 else if (strcmp(arg, "no") == 0)
Damien Miller95def091999-11-25 00:26:21 +1100485 value = 0;
486 else {
487 fprintf(stderr, "%s line %d: Bad yes/no argument: %s\n",
Damien Miller37023962000-07-11 17:31:38 +1000488 filename, linenum, arg);
Damien Miller95def091999-11-25 00:26:21 +1100489 exit(1);
490 }
491 if (*intptr == -1)
492 *intptr = value;
493 break;
494
495 case sIgnoreUserKnownHosts:
496 intptr = &options->ignore_user_known_hosts;
Damien Miller98c7ad62000-03-09 21:27:49 +1100497 goto parse_flag;
Damien Miller95def091999-11-25 00:26:21 +1100498
499 case sRhostsAuthentication:
500 intptr = &options->rhosts_authentication;
501 goto parse_flag;
502
503 case sRhostsRSAAuthentication:
504 intptr = &options->rhosts_rsa_authentication;
505 goto parse_flag;
506
507 case sRSAAuthentication:
508 intptr = &options->rsa_authentication;
509 goto parse_flag;
510
Damien Miller0bc1bd82000-11-13 22:57:25 +1100511 case sPubkeyAuthentication:
512 intptr = &options->pubkey_authentication;
Damien Millere247cc42000-05-07 12:03:14 +1000513 goto parse_flag;
514
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000515#ifdef KRB4
Damien Miller95def091999-11-25 00:26:21 +1100516 case sKerberosAuthentication:
517 intptr = &options->kerberos_authentication;
518 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000519
Damien Miller95def091999-11-25 00:26:21 +1100520 case sKerberosOrLocalPasswd:
521 intptr = &options->kerberos_or_local_passwd;
522 goto parse_flag;
523
524 case sKerberosTicketCleanup:
525 intptr = &options->kerberos_ticket_cleanup;
526 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000527#endif
Damien Miller95def091999-11-25 00:26:21 +1100528
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000529#ifdef AFS
Damien Miller95def091999-11-25 00:26:21 +1100530 case sKerberosTgtPassing:
531 intptr = &options->kerberos_tgt_passing;
532 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000533
Damien Miller95def091999-11-25 00:26:21 +1100534 case sAFSTokenPassing:
535 intptr = &options->afs_token_passing;
536 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000537#endif
538
Damien Miller95def091999-11-25 00:26:21 +1100539 case sPasswordAuthentication:
540 intptr = &options->password_authentication;
541 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000542
Damien Miller874d77b2000-10-14 16:23:11 +1100543 case sKbdInteractiveAuthentication:
544 intptr = &options->kbd_interactive_authentication;
545 goto parse_flag;
546
Damien Miller95def091999-11-25 00:26:21 +1100547 case sCheckMail:
548 intptr = &options->check_mail;
549 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000550
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +0000551 case sChallengeResponseAuthentication:
552 intptr = &options->challenge_reponse_authentication;
Damien Miller95def091999-11-25 00:26:21 +1100553 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000554
Damien Miller95def091999-11-25 00:26:21 +1100555 case sPrintMotd:
556 intptr = &options->print_motd;
557 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000558
Ben Lindstrom7bfff362001-03-26 05:45:53 +0000559 case sPrintLastLog:
560 intptr = &options->print_lastlog;
561 goto parse_flag;
562
Damien Miller95def091999-11-25 00:26:21 +1100563 case sX11Forwarding:
564 intptr = &options->x11_forwarding;
565 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000566
Damien Miller95def091999-11-25 00:26:21 +1100567 case sX11DisplayOffset:
568 intptr = &options->x11_display_offset;
569 goto parse_int;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000570
Damien Millerd3a18572000-06-07 19:55:44 +1000571 case sXAuthLocation:
572 charptr = &options->xauth_location;
573 goto parse_filename;
Kevin Stevesef4eea92001-02-05 12:42:17 +0000574
Damien Miller95def091999-11-25 00:26:21 +1100575 case sStrictModes:
576 intptr = &options->strict_modes;
577 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000578
Damien Miller95def091999-11-25 00:26:21 +1100579 case sKeepAlives:
580 intptr = &options->keepalives;
581 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000582
Damien Miller95def091999-11-25 00:26:21 +1100583 case sEmptyPasswd:
584 intptr = &options->permit_empty_passwd;
585 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000586
Damien Miller95def091999-11-25 00:26:21 +1100587 case sUseLogin:
588 intptr = &options->use_login;
589 goto parse_flag;
Damien Miller5ce662a1999-11-11 17:57:39 +1100590
Damien Millere247cc42000-05-07 12:03:14 +1000591 case sGatewayPorts:
592 intptr = &options->gateway_ports;
593 goto parse_flag;
594
Damien Miller33804262001-02-04 23:20:18 +1100595 case sReverseMappingCheck:
596 intptr = &options->reverse_mapping_check;
597 goto parse_flag;
598
Damien Miller95def091999-11-25 00:26:21 +1100599 case sLogFacility:
600 intptr = (int *) &options->log_facility;
Damien Millerbe484b52000-07-15 14:14:16 +1000601 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000602 value = log_facility_number(arg);
Damien Miller95def091999-11-25 00:26:21 +1100603 if (value == (SyslogFacility) - 1)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000604 fatal("%.200s line %d: unsupported log facility '%s'",
Damien Miller37023962000-07-11 17:31:38 +1000605 filename, linenum, arg ? arg : "<NONE>");
Damien Miller95def091999-11-25 00:26:21 +1100606 if (*intptr == -1)
607 *intptr = (SyslogFacility) value;
608 break;
609
610 case sLogLevel:
611 intptr = (int *) &options->log_level;
Damien Millerbe484b52000-07-15 14:14:16 +1000612 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000613 value = log_level_number(arg);
Damien Miller95def091999-11-25 00:26:21 +1100614 if (value == (LogLevel) - 1)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000615 fatal("%.200s line %d: unsupported log level '%s'",
Damien Miller37023962000-07-11 17:31:38 +1000616 filename, linenum, arg ? arg : "<NONE>");
Damien Miller95def091999-11-25 00:26:21 +1100617 if (*intptr == -1)
618 *intptr = (LogLevel) value;
619 break;
620
Damien Miller50a41ed2000-10-16 12:14:42 +1100621 case sAllowTcpForwarding:
622 intptr = &options->allow_tcp_forwarding;
623 goto parse_flag;
624
Damien Miller95def091999-11-25 00:26:21 +1100625 case sAllowUsers:
Damien Millerbe484b52000-07-15 14:14:16 +1000626 while ((arg = strdelim(&cp)) && *arg != '\0') {
Damien Miller78928792000-04-12 20:17:38 +1000627 if (options->num_allow_users >= MAX_ALLOW_USERS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000628 fatal("%s line %d: too many allow users.",
Damien Miller78928792000-04-12 20:17:38 +1000629 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000630 options->allow_users[options->num_allow_users++] = xstrdup(arg);
Damien Miller95def091999-11-25 00:26:21 +1100631 }
632 break;
633
634 case sDenyUsers:
Damien Millerbe484b52000-07-15 14:14:16 +1000635 while ((arg = strdelim(&cp)) && *arg != '\0') {
Damien Miller78928792000-04-12 20:17:38 +1000636 if (options->num_deny_users >= MAX_DENY_USERS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000637 fatal( "%s line %d: too many deny users.",
Damien Miller78928792000-04-12 20:17:38 +1000638 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000639 options->deny_users[options->num_deny_users++] = xstrdup(arg);
Damien Miller95def091999-11-25 00:26:21 +1100640 }
641 break;
642
643 case sAllowGroups:
Damien Millerbe484b52000-07-15 14:14:16 +1000644 while ((arg = strdelim(&cp)) && *arg != '\0') {
Damien Miller78928792000-04-12 20:17:38 +1000645 if (options->num_allow_groups >= MAX_ALLOW_GROUPS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000646 fatal("%s line %d: too many allow groups.",
Damien Miller78928792000-04-12 20:17:38 +1000647 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000648 options->allow_groups[options->num_allow_groups++] = xstrdup(arg);
Damien Miller95def091999-11-25 00:26:21 +1100649 }
650 break;
651
652 case sDenyGroups:
Damien Millerbe484b52000-07-15 14:14:16 +1000653 while ((arg = strdelim(&cp)) && *arg != '\0') {
Damien Miller78928792000-04-12 20:17:38 +1000654 if (options->num_deny_groups >= MAX_DENY_GROUPS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000655 fatal("%s line %d: too many deny groups.",
Damien Miller78928792000-04-12 20:17:38 +1000656 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000657 options->deny_groups[options->num_deny_groups++] = xstrdup(arg);
Damien Miller95def091999-11-25 00:26:21 +1100658 }
659 break;
660
Damien Miller78928792000-04-12 20:17:38 +1000661 case sCiphers:
Damien Millerbe484b52000-07-15 14:14:16 +1000662 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000663 if (!arg || *arg == '\0')
Damien Millerb1715dc2000-05-30 13:44:51 +1000664 fatal("%s line %d: Missing argument.", filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000665 if (!ciphers_valid(arg))
Damien Miller30c3d422000-05-09 11:02:59 +1000666 fatal("%s line %d: Bad SSH2 cipher spec '%s'.",
Damien Miller37023962000-07-11 17:31:38 +1000667 filename, linenum, arg ? arg : "<NONE>");
Damien Miller78928792000-04-12 20:17:38 +1000668 if (options->ciphers == NULL)
Damien Miller37023962000-07-11 17:31:38 +1000669 options->ciphers = xstrdup(arg);
Damien Miller78928792000-04-12 20:17:38 +1000670 break;
671
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000672 case sMacs:
673 arg = strdelim(&cp);
674 if (!arg || *arg == '\0')
675 fatal("%s line %d: Missing argument.", filename, linenum);
676 if (!mac_valid(arg))
677 fatal("%s line %d: Bad SSH2 mac spec '%s'.",
678 filename, linenum, arg ? arg : "<NONE>");
679 if (options->macs == NULL)
680 options->macs = xstrdup(arg);
681 break;
682
Damien Miller78928792000-04-12 20:17:38 +1000683 case sProtocol:
684 intptr = &options->protocol;
Damien Millerbe484b52000-07-15 14:14:16 +1000685 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000686 if (!arg || *arg == '\0')
Damien Millerb1715dc2000-05-30 13:44:51 +1000687 fatal("%s line %d: Missing argument.", filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000688 value = proto_spec(arg);
Damien Miller78928792000-04-12 20:17:38 +1000689 if (value == SSH_PROTO_UNKNOWN)
690 fatal("%s line %d: Bad protocol spec '%s'.",
Damien Miller37023962000-07-11 17:31:38 +1000691 filename, linenum, arg ? arg : "<NONE>");
Damien Miller78928792000-04-12 20:17:38 +1000692 if (*intptr == SSH_PROTO_UNKNOWN)
693 *intptr = value;
694 break;
695
Damien Millerf6d9e222000-06-18 14:50:44 +1000696 case sSubsystem:
697 if(options->num_subsystems >= MAX_SUBSYSTEMS) {
698 fatal("%s line %d: too many subsystems defined.",
699 filename, linenum);
700 }
Damien Millerbe484b52000-07-15 14:14:16 +1000701 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000702 if (!arg || *arg == '\0')
Damien Millerf6d9e222000-06-18 14:50:44 +1000703 fatal("%s line %d: Missing subsystem name.",
704 filename, linenum);
705 for (i = 0; i < options->num_subsystems; i++)
Damien Miller37023962000-07-11 17:31:38 +1000706 if(strcmp(arg, options->subsystem_name[i]) == 0)
Damien Millerf6d9e222000-06-18 14:50:44 +1000707 fatal("%s line %d: Subsystem '%s' already defined.",
Damien Miller37023962000-07-11 17:31:38 +1000708 filename, linenum, arg);
709 options->subsystem_name[options->num_subsystems] = xstrdup(arg);
Damien Millerbe484b52000-07-15 14:14:16 +1000710 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000711 if (!arg || *arg == '\0')
Damien Millerf6d9e222000-06-18 14:50:44 +1000712 fatal("%s line %d: Missing subsystem command.",
713 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000714 options->subsystem_command[options->num_subsystems] = xstrdup(arg);
Damien Millerf6d9e222000-06-18 14:50:44 +1000715 options->num_subsystems++;
716 break;
717
Damien Miller37023962000-07-11 17:31:38 +1000718 case sMaxStartups:
Damien Miller942da032000-08-18 13:59:06 +1000719 arg = strdelim(&cp);
720 if (!arg || *arg == '\0')
721 fatal("%s line %d: Missing MaxStartups spec.",
722 filename, linenum);
723 if (sscanf(arg, "%d:%d:%d",
724 &options->max_startups_begin,
725 &options->max_startups_rate,
726 &options->max_startups) == 3) {
727 if (options->max_startups_begin >
728 options->max_startups ||
729 options->max_startups_rate > 100 ||
730 options->max_startups_rate < 1)
731 fatal("%s line %d: Illegal MaxStartups spec.",
732 filename, linenum);
733 break;
734 }
Damien Miller37023962000-07-11 17:31:38 +1000735 intptr = &options->max_startups;
736 goto parse_int;
737
Ben Lindstrom48bd7c12001-01-09 00:35:42 +0000738 case sBanner:
739 charptr = &options->banner;
740 goto parse_filename;
Kevin Stevesef4eea92001-02-05 12:42:17 +0000741
Damien Miller95def091999-11-25 00:26:21 +1100742 default:
743 fprintf(stderr, "%s line %d: Missing handler for opcode %s (%d)\n",
Damien Miller37023962000-07-11 17:31:38 +1000744 filename, linenum, arg, opcode);
Damien Miller95def091999-11-25 00:26:21 +1100745 exit(1);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000746 }
Damien Millerbe484b52000-07-15 14:14:16 +1000747 if ((arg = strdelim(&cp)) != NULL && *arg != '\0') {
Kevin Stevesef4eea92001-02-05 12:42:17 +0000748 fprintf(stderr,
Damien Miller37023962000-07-11 17:31:38 +1000749 "%s line %d: garbage at end of line; \"%.200s\".\n",
750 filename, linenum, arg);
Damien Miller95def091999-11-25 00:26:21 +1100751 exit(1);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000752 }
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000753 }
Damien Miller95def091999-11-25 00:26:21 +1100754 fclose(f);
755 if (bad_options > 0) {
756 fprintf(stderr, "%s: terminating, %d bad configuration options\n",
757 filename, bad_options);
758 exit(1);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000759 }
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000760}