blob: 075eed400e856bcfb2ea4b0e15fc8d282dce5e73 [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 Lindstrom35f1f4e2001-03-06 01:02:41 +000013RCSID("$OpenBSD: servconf.c,v 1.71 2001/03/05 15:44:51 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;
58 options->check_mail = -1;
59 options->x11_forwarding = -1;
60 options->x11_display_offset = -1;
Damien Millerd3a18572000-06-07 19:55:44 +100061 options->xauth_location = NULL;
Damien Miller95def091999-11-25 00:26:21 +110062 options->strict_modes = -1;
63 options->keepalives = -1;
64 options->log_facility = (SyslogFacility) - 1;
65 options->log_level = (LogLevel) - 1;
66 options->rhosts_authentication = -1;
67 options->rhosts_rsa_authentication = -1;
68 options->rsa_authentication = -1;
Damien Miller0bc1bd82000-11-13 22:57:25 +110069 options->pubkey_authentication = -1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +100070#ifdef KRB4
Damien Miller95def091999-11-25 00:26:21 +110071 options->kerberos_authentication = -1;
72 options->kerberos_or_local_passwd = -1;
73 options->kerberos_ticket_cleanup = -1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +100074#endif
75#ifdef AFS
Damien Miller95def091999-11-25 00:26:21 +110076 options->kerberos_tgt_passing = -1;
77 options->afs_token_passing = -1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +100078#endif
Damien Miller95def091999-11-25 00:26:21 +110079 options->password_authentication = -1;
Damien Miller874d77b2000-10-14 16:23:11 +110080 options->kbd_interactive_authentication = -1;
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +000081 options->challenge_reponse_authentication = -1;
Damien Miller95def091999-11-25 00:26:21 +110082 options->permit_empty_passwd = -1;
83 options->use_login = -1;
Damien Miller50a41ed2000-10-16 12:14:42 +110084 options->allow_tcp_forwarding = -1;
Damien Miller95def091999-11-25 00:26:21 +110085 options->num_allow_users = 0;
86 options->num_deny_users = 0;
87 options->num_allow_groups = 0;
88 options->num_deny_groups = 0;
Damien Miller78928792000-04-12 20:17:38 +100089 options->ciphers = NULL;
Ben Lindstrom06b33aa2001-02-15 03:01:59 +000090 options->macs = NULL;
Damien Miller78928792000-04-12 20:17:38 +100091 options->protocol = SSH_PROTO_UNKNOWN;
Damien Millere247cc42000-05-07 12:03:14 +100092 options->gateway_ports = -1;
Damien Millerf6d9e222000-06-18 14:50:44 +100093 options->num_subsystems = 0;
Damien Miller942da032000-08-18 13:59:06 +100094 options->max_startups_begin = -1;
95 options->max_startups_rate = -1;
Damien Miller37023962000-07-11 17:31:38 +100096 options->max_startups = -1;
Ben Lindstrom48bd7c12001-01-09 00:35:42 +000097 options->banner = NULL;
Damien Miller33804262001-02-04 23:20:18 +110098 options->reverse_mapping_check = -1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +100099}
100
Damien Miller4af51302000-04-16 11:18:38 +1000101void
Damien Miller95def091999-11-25 00:26:21 +1100102fill_default_server_options(ServerOptions *options)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000103{
Damien Miller0bc1bd82000-11-13 22:57:25 +1100104 if (options->protocol == SSH_PROTO_UNKNOWN)
105 options->protocol = SSH_PROTO_1|SSH_PROTO_2;
106 if (options->num_host_key_files == 0) {
107 /* fill default hostkeys for protocols */
108 if (options->protocol & SSH_PROTO_1)
Ben Lindstrom226cfa02001-01-22 05:34:40 +0000109 options->host_key_files[options->num_host_key_files++] = _PATH_HOST_KEY_FILE;
Damien Miller0bc1bd82000-11-13 22:57:25 +1100110 if (options->protocol & SSH_PROTO_2)
Ben Lindstrom226cfa02001-01-22 05:34:40 +0000111 options->host_key_files[options->num_host_key_files++] = _PATH_HOST_DSA_KEY_FILE;
Damien Miller0bc1bd82000-11-13 22:57:25 +1100112 }
Damien Miller34132e52000-01-14 15:45:46 +1100113 if (options->num_ports == 0)
114 options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
115 if (options->listen_addrs == NULL)
116 add_listen_addr(options, NULL);
Damien Miller6f83b8e2000-05-02 09:23:45 +1000117 if (options->pid_file == NULL)
Ben Lindstrom226cfa02001-01-22 05:34:40 +0000118 options->pid_file = _PATH_SSH_DAEMON_PID_FILE;
Damien Miller95def091999-11-25 00:26:21 +1100119 if (options->server_key_bits == -1)
120 options->server_key_bits = 768;
121 if (options->login_grace_time == -1)
122 options->login_grace_time = 600;
123 if (options->key_regeneration_time == -1)
124 options->key_regeneration_time = 3600;
Ben Lindstromd8a90212001-02-15 03:08:27 +0000125 if (options->permit_root_login == PERMIT_NOT_SET)
126 options->permit_root_login = PERMIT_YES;
Damien Miller95def091999-11-25 00:26:21 +1100127 if (options->ignore_rhosts == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100128 options->ignore_rhosts = 1;
Damien Miller95def091999-11-25 00:26:21 +1100129 if (options->ignore_user_known_hosts == -1)
130 options->ignore_user_known_hosts = 0;
131 if (options->check_mail == -1)
132 options->check_mail = 0;
133 if (options->print_motd == -1)
134 options->print_motd = 1;
135 if (options->x11_forwarding == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100136 options->x11_forwarding = 0;
Damien Miller95def091999-11-25 00:26:21 +1100137 if (options->x11_display_offset == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100138 options->x11_display_offset = 10;
Damien Millerd3a18572000-06-07 19:55:44 +1000139#ifdef XAUTH_PATH
140 if (options->xauth_location == NULL)
141 options->xauth_location = XAUTH_PATH;
142#endif /* XAUTH_PATH */
Damien Miller95def091999-11-25 00:26:21 +1100143 if (options->strict_modes == -1)
144 options->strict_modes = 1;
145 if (options->keepalives == -1)
146 options->keepalives = 1;
147 if (options->log_facility == (SyslogFacility) (-1))
148 options->log_facility = SYSLOG_FACILITY_AUTH;
149 if (options->log_level == (LogLevel) (-1))
Ben Lindstromdb65e8f2001-01-19 04:26:52 +0000150 options->log_level = SYSLOG_LEVEL_INFO;
Damien Miller95def091999-11-25 00:26:21 +1100151 if (options->rhosts_authentication == -1)
152 options->rhosts_authentication = 0;
153 if (options->rhosts_rsa_authentication == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100154 options->rhosts_rsa_authentication = 0;
Damien Miller95def091999-11-25 00:26:21 +1100155 if (options->rsa_authentication == -1)
156 options->rsa_authentication = 1;
Damien Miller0bc1bd82000-11-13 22:57:25 +1100157 if (options->pubkey_authentication == -1)
158 options->pubkey_authentication = 1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000159#ifdef KRB4
Damien Miller95def091999-11-25 00:26:21 +1100160 if (options->kerberos_authentication == -1)
161 options->kerberos_authentication = (access(KEYFILE, R_OK) == 0);
162 if (options->kerberos_or_local_passwd == -1)
163 options->kerberos_or_local_passwd = 1;
164 if (options->kerberos_ticket_cleanup == -1)
165 options->kerberos_ticket_cleanup = 1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000166#endif /* KRB4 */
167#ifdef AFS
Damien Miller95def091999-11-25 00:26:21 +1100168 if (options->kerberos_tgt_passing == -1)
169 options->kerberos_tgt_passing = 0;
170 if (options->afs_token_passing == -1)
171 options->afs_token_passing = k_hasafs();
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000172#endif /* AFS */
Damien Miller95def091999-11-25 00:26:21 +1100173 if (options->password_authentication == -1)
174 options->password_authentication = 1;
Damien Miller874d77b2000-10-14 16:23:11 +1100175 if (options->kbd_interactive_authentication == -1)
176 options->kbd_interactive_authentication = 0;
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +0000177 if (options->challenge_reponse_authentication == -1)
178 options->challenge_reponse_authentication = 1;
Damien Miller95def091999-11-25 00:26:21 +1100179 if (options->permit_empty_passwd == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100180 options->permit_empty_passwd = 0;
Damien Miller95def091999-11-25 00:26:21 +1100181 if (options->use_login == -1)
182 options->use_login = 0;
Damien Miller50a41ed2000-10-16 12:14:42 +1100183 if (options->allow_tcp_forwarding == -1)
184 options->allow_tcp_forwarding = 1;
Damien Millere247cc42000-05-07 12:03:14 +1000185 if (options->gateway_ports == -1)
186 options->gateway_ports = 0;
Damien Miller37023962000-07-11 17:31:38 +1000187 if (options->max_startups == -1)
188 options->max_startups = 10;
Damien Miller942da032000-08-18 13:59:06 +1000189 if (options->max_startups_rate == -1)
190 options->max_startups_rate = 100; /* 100% */
191 if (options->max_startups_begin == -1)
192 options->max_startups_begin = options->max_startups;
Damien Miller33804262001-02-04 23:20:18 +1100193 if (options->reverse_mapping_check == -1)
194 options->reverse_mapping_check = 0;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000195}
196
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000197/* Keyword tokens. */
Damien Miller95def091999-11-25 00:26:21 +1100198typedef enum {
199 sBadOption, /* == unknown option */
200 sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime, sKeyRegenerationTime,
201 sPermitRootLogin, sLogFacility, sLogLevel,
202 sRhostsAuthentication, sRhostsRSAAuthentication, sRSAAuthentication,
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000203#ifdef KRB4
Damien Miller95def091999-11-25 00:26:21 +1100204 sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup,
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000205#endif
206#ifdef AFS
Damien Miller95def091999-11-25 00:26:21 +1100207 sKerberosTgtPassing, sAFSTokenPassing,
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000208#endif
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +0000209 sChallengeResponseAuthentication,
Damien Miller874d77b2000-10-14 16:23:11 +1100210 sPasswordAuthentication, sKbdInteractiveAuthentication, sListenAddress,
Damien Miller95def091999-11-25 00:26:21 +1100211 sPrintMotd, sIgnoreRhosts, sX11Forwarding, sX11DisplayOffset,
Ben Lindstromd9cae222001-03-05 07:42:03 +0000212 sStrictModes, sEmptyPasswd, sKeepAlives, sCheckMail,
Damien Miller50a41ed2000-10-16 12:14:42 +1100213 sUseLogin, sAllowTcpForwarding,
214 sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000215 sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile,
Damien Miller0bc1bd82000-11-13 22:57:25 +1100216 sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, sMaxStartups,
Damien Miller33804262001-02-04 23:20:18 +1100217 sBanner, sReverseMappingCheck
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000218} ServerOpCodes;
219
220/* Textual representation of the tokens. */
Damien Miller95def091999-11-25 00:26:21 +1100221static struct {
222 const char *name;
223 ServerOpCodes opcode;
224} keywords[] = {
225 { "port", sPort },
226 { "hostkey", sHostKeyFile },
Damien Miller0bc1bd82000-11-13 22:57:25 +1100227 { "hostdsakey", sHostKeyFile }, /* alias */
Kevin Stevesef4eea92001-02-05 12:42:17 +0000228 { "pidfile", sPidFile },
Damien Miller95def091999-11-25 00:26:21 +1100229 { "serverkeybits", sServerKeyBits },
230 { "logingracetime", sLoginGraceTime },
231 { "keyregenerationinterval", sKeyRegenerationTime },
232 { "permitrootlogin", sPermitRootLogin },
233 { "syslogfacility", sLogFacility },
234 { "loglevel", sLogLevel },
235 { "rhostsauthentication", sRhostsAuthentication },
236 { "rhostsrsaauthentication", sRhostsRSAAuthentication },
237 { "rsaauthentication", sRSAAuthentication },
Damien Miller0bc1bd82000-11-13 22:57:25 +1100238 { "pubkeyauthentication", sPubkeyAuthentication },
239 { "dsaauthentication", sPubkeyAuthentication }, /* alias */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000240#ifdef KRB4
Damien Miller95def091999-11-25 00:26:21 +1100241 { "kerberosauthentication", sKerberosAuthentication },
242 { "kerberosorlocalpasswd", sKerberosOrLocalPasswd },
243 { "kerberosticketcleanup", sKerberosTicketCleanup },
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000244#endif
245#ifdef AFS
Damien Miller95def091999-11-25 00:26:21 +1100246 { "kerberostgtpassing", sKerberosTgtPassing },
247 { "afstokenpassing", sAFSTokenPassing },
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000248#endif
Damien Miller95def091999-11-25 00:26:21 +1100249 { "passwordauthentication", sPasswordAuthentication },
Damien Miller874d77b2000-10-14 16:23:11 +1100250 { "kbdinteractiveauthentication", sKbdInteractiveAuthentication },
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +0000251 { "challengeresponseauthentication", sChallengeResponseAuthentication },
252 { "skeyauthentication", sChallengeResponseAuthentication }, /* alias */
Damien Miller95def091999-11-25 00:26:21 +1100253 { "checkmail", sCheckMail },
254 { "listenaddress", sListenAddress },
255 { "printmotd", sPrintMotd },
256 { "ignorerhosts", sIgnoreRhosts },
257 { "ignoreuserknownhosts", sIgnoreUserKnownHosts },
258 { "x11forwarding", sX11Forwarding },
259 { "x11displayoffset", sX11DisplayOffset },
Damien Millerd3a18572000-06-07 19:55:44 +1000260 { "xauthlocation", sXAuthLocation },
Damien Miller95def091999-11-25 00:26:21 +1100261 { "strictmodes", sStrictModes },
262 { "permitemptypasswords", sEmptyPasswd },
263 { "uselogin", sUseLogin },
Damien Miller95def091999-11-25 00:26:21 +1100264 { "keepalive", sKeepAlives },
Damien Miller50a41ed2000-10-16 12:14:42 +1100265 { "allowtcpforwarding", sAllowTcpForwarding },
Damien Miller95def091999-11-25 00:26:21 +1100266 { "allowusers", sAllowUsers },
267 { "denyusers", sDenyUsers },
268 { "allowgroups", sAllowGroups },
269 { "denygroups", sDenyGroups },
Damien Miller78928792000-04-12 20:17:38 +1000270 { "ciphers", sCiphers },
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000271 { "macs", sMacs },
Damien Miller78928792000-04-12 20:17:38 +1000272 { "protocol", sProtocol },
Damien Millere247cc42000-05-07 12:03:14 +1000273 { "gatewayports", sGatewayPorts },
Damien Millerf6d9e222000-06-18 14:50:44 +1000274 { "subsystem", sSubsystem },
Damien Miller37023962000-07-11 17:31:38 +1000275 { "maxstartups", sMaxStartups },
Ben Lindstrom48bd7c12001-01-09 00:35:42 +0000276 { "banner", sBanner },
Damien Miller33804262001-02-04 23:20:18 +1100277 { "reversemappingcheck", sReverseMappingCheck },
Damien Miller95def091999-11-25 00:26:21 +1100278 { NULL, 0 }
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000279};
280
Damien Miller5428f641999-11-25 11:54:57 +1100281/*
282 * Returns the number of the token pointed to by cp of length len. Never
283 * returns if the token is not known.
284 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000285
Damien Miller4af51302000-04-16 11:18:38 +1000286static ServerOpCodes
Damien Miller95def091999-11-25 00:26:21 +1100287parse_token(const char *cp, const char *filename,
288 int linenum)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000289{
Ben Lindstrom46c16222000-12-22 01:43:59 +0000290 u_int i;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000291
Damien Miller95def091999-11-25 00:26:21 +1100292 for (i = 0; keywords[i].name; i++)
Damien Miller5428f641999-11-25 11:54:57 +1100293 if (strcasecmp(cp, keywords[i].name) == 0)
Damien Miller95def091999-11-25 00:26:21 +1100294 return keywords[i].opcode;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000295
Damien Miller95def091999-11-25 00:26:21 +1100296 fprintf(stderr, "%s: line %d: Bad configuration option: %s\n",
297 filename, linenum, cp);
298 return sBadOption;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000299}
300
Damien Miller34132e52000-01-14 15:45:46 +1100301/*
302 * add listen address
303 */
Damien Miller4af51302000-04-16 11:18:38 +1000304void
Damien Miller34132e52000-01-14 15:45:46 +1100305add_listen_addr(ServerOptions *options, char *addr)
306{
Damien Miller34132e52000-01-14 15:45:46 +1100307 struct addrinfo hints, *ai, *aitop;
308 char strport[NI_MAXSERV];
309 int gaierr;
310 int i;
311
312 if (options->num_ports == 0)
313 options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
314 for (i = 0; i < options->num_ports; i++) {
315 memset(&hints, 0, sizeof(hints));
316 hints.ai_family = IPv4or6;
317 hints.ai_socktype = SOCK_STREAM;
318 hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0;
319 snprintf(strport, sizeof strport, "%d", options->ports[i]);
320 if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000321 fatal("bad addr or host: %s (%s)",
Damien Miller34132e52000-01-14 15:45:46 +1100322 addr ? addr : "<NULL>",
323 gai_strerror(gaierr));
324 for (ai = aitop; ai->ai_next; ai = ai->ai_next)
325 ;
326 ai->ai_next = options->listen_addrs;
327 options->listen_addrs = aitop;
328 }
329}
330
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000331/* Reads the server configuration file. */
332
Damien Miller4af51302000-04-16 11:18:38 +1000333void
Damien Miller95def091999-11-25 00:26:21 +1100334read_server_config(ServerOptions *options, const char *filename)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000335{
Damien Miller95def091999-11-25 00:26:21 +1100336 FILE *f;
337 char line[1024];
Damien Miller37023962000-07-11 17:31:38 +1000338 char *cp, **charptr, *arg;
Damien Miller95def091999-11-25 00:26:21 +1100339 int linenum, *intptr, value;
340 int bad_options = 0;
341 ServerOpCodes opcode;
Damien Millerf6d9e222000-06-18 14:50:44 +1000342 int i;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000343
Damien Miller95def091999-11-25 00:26:21 +1100344 f = fopen(filename, "r");
345 if (!f) {
346 perror(filename);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000347 exit(1);
Damien Miller95def091999-11-25 00:26:21 +1100348 }
349 linenum = 0;
350 while (fgets(line, sizeof(line), f)) {
351 linenum++;
Damien Millerbe484b52000-07-15 14:14:16 +1000352 cp = line;
353 arg = strdelim(&cp);
354 /* Ignore leading whitespace */
355 if (*arg == '\0')
356 arg = strdelim(&cp);
Ben Lindstrom226cfa02001-01-22 05:34:40 +0000357 if (!arg || !*arg || *arg == '#')
Damien Miller95def091999-11-25 00:26:21 +1100358 continue;
Damien Miller0bc1bd82000-11-13 22:57:25 +1100359 intptr = NULL;
360 charptr = NULL;
Damien Miller37023962000-07-11 17:31:38 +1000361 opcode = parse_token(arg, filename, linenum);
Damien Miller95def091999-11-25 00:26:21 +1100362 switch (opcode) {
363 case sBadOption:
364 bad_options++;
365 continue;
366 case sPort:
Damien Miller34132e52000-01-14 15:45:46 +1100367 /* ignore ports from configfile if cmdline specifies ports */
368 if (options->ports_from_cmdline)
369 continue;
370 if (options->listen_addrs != NULL)
371 fatal("%s line %d: ports must be specified before "
372 "ListenAdress.\n", filename, linenum);
373 if (options->num_ports >= MAX_PORTS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000374 fatal("%s line %d: too many ports.",
Damien Miller4af51302000-04-16 11:18:38 +1000375 filename, linenum);
Damien Millerbe484b52000-07-15 14:14:16 +1000376 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000377 if (!arg || *arg == '\0')
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000378 fatal("%s line %d: missing port number.",
Damien Miller34132e52000-01-14 15:45:46 +1100379 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000380 options->ports[options->num_ports++] = atoi(arg);
Damien Miller34132e52000-01-14 15:45:46 +1100381 break;
382
383 case sServerKeyBits:
384 intptr = &options->server_key_bits;
Damien Miller95def091999-11-25 00:26:21 +1100385parse_int:
Damien Millerbe484b52000-07-15 14:14:16 +1000386 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000387 if (!arg || *arg == '\0') {
Damien Miller95def091999-11-25 00:26:21 +1100388 fprintf(stderr, "%s line %d: missing integer value.\n",
389 filename, linenum);
390 exit(1);
391 }
Damien Miller37023962000-07-11 17:31:38 +1000392 value = atoi(arg);
Damien Miller95def091999-11-25 00:26:21 +1100393 if (*intptr == -1)
394 *intptr = value;
395 break;
Damien Miller32265091999-11-12 11:33:04 +1100396
Damien Miller95def091999-11-25 00:26:21 +1100397 case sLoginGraceTime:
398 intptr = &options->login_grace_time;
399 goto parse_int;
400
401 case sKeyRegenerationTime:
402 intptr = &options->key_regeneration_time;
403 goto parse_int;
404
405 case sListenAddress:
Damien Millerbe484b52000-07-15 14:14:16 +1000406 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000407 if (!arg || *arg == '\0')
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000408 fatal("%s line %d: missing inet addr.",
Damien Miller34132e52000-01-14 15:45:46 +1100409 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000410 add_listen_addr(options, arg);
Damien Miller95def091999-11-25 00:26:21 +1100411 break;
412
413 case sHostKeyFile:
Damien Miller0bc1bd82000-11-13 22:57:25 +1100414 intptr = &options->num_host_key_files;
415 if (*intptr >= MAX_HOSTKEYS) {
Ben Lindstrom33a3cc32001-03-05 05:07:52 +0000416 fprintf(stderr,
417 "%s line %d: too many host keys specified (max %d).\n",
Damien Miller0bc1bd82000-11-13 22:57:25 +1100418 filename, linenum, MAX_HOSTKEYS);
419 exit(1);
420 }
421 charptr = &options->host_key_files[*intptr];
Damien Millerd3a18572000-06-07 19:55:44 +1000422parse_filename:
Damien Millerbe484b52000-07-15 14:14:16 +1000423 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000424 if (!arg || *arg == '\0') {
Damien Miller95def091999-11-25 00:26:21 +1100425 fprintf(stderr, "%s line %d: missing file name.\n",
Damien Miller6f83b8e2000-05-02 09:23:45 +1000426 filename, linenum);
427 exit(1);
428 }
Damien Miller0bc1bd82000-11-13 22:57:25 +1100429 if (*charptr == NULL) {
Damien Miller37023962000-07-11 17:31:38 +1000430 *charptr = tilde_expand_filename(arg, getuid());
Damien Miller0bc1bd82000-11-13 22:57:25 +1100431 /* increase optional counter */
432 if (intptr != NULL)
433 *intptr = *intptr + 1;
434 }
Damien Miller6f83b8e2000-05-02 09:23:45 +1000435 break;
436
437 case sPidFile:
438 charptr = &options->pid_file;
Damien Millerd3a18572000-06-07 19:55:44 +1000439 goto parse_filename;
Damien Miller95def091999-11-25 00:26:21 +1100440
Damien Miller95def091999-11-25 00:26:21 +1100441 case sPermitRootLogin:
442 intptr = &options->permit_root_login;
Damien Millerbe484b52000-07-15 14:14:16 +1000443 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000444 if (!arg || *arg == '\0') {
Ben Lindstrom35f1f4e2001-03-06 01:02:41 +0000445 fprintf(stderr, "%s line %d: missing yes/"
446 "without-password/forced-commands-only/no "
447 "argument.\n", filename, linenum);
Damien Miller95def091999-11-25 00:26:21 +1100448 exit(1);
449 }
Damien Miller37023962000-07-11 17:31:38 +1000450 if (strcmp(arg, "without-password") == 0)
Ben Lindstromd8a90212001-02-15 03:08:27 +0000451 value = PERMIT_NO_PASSWD;
452 else if (strcmp(arg, "forced-commands-only") == 0)
453 value = PERMIT_FORCED_ONLY;
Damien Miller37023962000-07-11 17:31:38 +1000454 else if (strcmp(arg, "yes") == 0)
Ben Lindstromd8a90212001-02-15 03:08:27 +0000455 value = PERMIT_YES;
Damien Miller37023962000-07-11 17:31:38 +1000456 else if (strcmp(arg, "no") == 0)
Ben Lindstromd8a90212001-02-15 03:08:27 +0000457 value = PERMIT_NO;
Damien Miller95def091999-11-25 00:26:21 +1100458 else {
Ben Lindstromd8a90212001-02-15 03:08:27 +0000459 fprintf(stderr, "%s line %d: Bad yes/"
460 "without-password/forced-commands-only/no "
461 "argument: %s\n", filename, linenum, arg);
Damien Miller95def091999-11-25 00:26:21 +1100462 exit(1);
463 }
464 if (*intptr == -1)
465 *intptr = value;
466 break;
467
468 case sIgnoreRhosts:
469 intptr = &options->ignore_rhosts;
470parse_flag:
Damien Millerbe484b52000-07-15 14:14:16 +1000471 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000472 if (!arg || *arg == '\0') {
Damien Miller95def091999-11-25 00:26:21 +1100473 fprintf(stderr, "%s line %d: missing yes/no argument.\n",
474 filename, linenum);
475 exit(1);
476 }
Damien Miller37023962000-07-11 17:31:38 +1000477 if (strcmp(arg, "yes") == 0)
Damien Miller95def091999-11-25 00:26:21 +1100478 value = 1;
Damien Miller37023962000-07-11 17:31:38 +1000479 else if (strcmp(arg, "no") == 0)
Damien Miller95def091999-11-25 00:26:21 +1100480 value = 0;
481 else {
482 fprintf(stderr, "%s line %d: Bad yes/no argument: %s\n",
Damien Miller37023962000-07-11 17:31:38 +1000483 filename, linenum, arg);
Damien Miller95def091999-11-25 00:26:21 +1100484 exit(1);
485 }
486 if (*intptr == -1)
487 *intptr = value;
488 break;
489
490 case sIgnoreUserKnownHosts:
491 intptr = &options->ignore_user_known_hosts;
Damien Miller98c7ad62000-03-09 21:27:49 +1100492 goto parse_flag;
Damien Miller95def091999-11-25 00:26:21 +1100493
494 case sRhostsAuthentication:
495 intptr = &options->rhosts_authentication;
496 goto parse_flag;
497
498 case sRhostsRSAAuthentication:
499 intptr = &options->rhosts_rsa_authentication;
500 goto parse_flag;
501
502 case sRSAAuthentication:
503 intptr = &options->rsa_authentication;
504 goto parse_flag;
505
Damien Miller0bc1bd82000-11-13 22:57:25 +1100506 case sPubkeyAuthentication:
507 intptr = &options->pubkey_authentication;
Damien Millere247cc42000-05-07 12:03:14 +1000508 goto parse_flag;
509
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000510#ifdef KRB4
Damien Miller95def091999-11-25 00:26:21 +1100511 case sKerberosAuthentication:
512 intptr = &options->kerberos_authentication;
513 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000514
Damien Miller95def091999-11-25 00:26:21 +1100515 case sKerberosOrLocalPasswd:
516 intptr = &options->kerberos_or_local_passwd;
517 goto parse_flag;
518
519 case sKerberosTicketCleanup:
520 intptr = &options->kerberos_ticket_cleanup;
521 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000522#endif
Damien Miller95def091999-11-25 00:26:21 +1100523
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000524#ifdef AFS
Damien Miller95def091999-11-25 00:26:21 +1100525 case sKerberosTgtPassing:
526 intptr = &options->kerberos_tgt_passing;
527 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000528
Damien Miller95def091999-11-25 00:26:21 +1100529 case sAFSTokenPassing:
530 intptr = &options->afs_token_passing;
531 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000532#endif
533
Damien Miller95def091999-11-25 00:26:21 +1100534 case sPasswordAuthentication:
535 intptr = &options->password_authentication;
536 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000537
Damien Miller874d77b2000-10-14 16:23:11 +1100538 case sKbdInteractiveAuthentication:
539 intptr = &options->kbd_interactive_authentication;
540 goto parse_flag;
541
Damien Miller95def091999-11-25 00:26:21 +1100542 case sCheckMail:
543 intptr = &options->check_mail;
544 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000545
Ben Lindstrom95fb2dd2001-01-23 03:12:10 +0000546 case sChallengeResponseAuthentication:
547 intptr = &options->challenge_reponse_authentication;
Damien Miller95def091999-11-25 00:26:21 +1100548 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000549
Damien Miller95def091999-11-25 00:26:21 +1100550 case sPrintMotd:
551 intptr = &options->print_motd;
552 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000553
Damien Miller95def091999-11-25 00:26:21 +1100554 case sX11Forwarding:
555 intptr = &options->x11_forwarding;
556 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000557
Damien Miller95def091999-11-25 00:26:21 +1100558 case sX11DisplayOffset:
559 intptr = &options->x11_display_offset;
560 goto parse_int;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000561
Damien Millerd3a18572000-06-07 19:55:44 +1000562 case sXAuthLocation:
563 charptr = &options->xauth_location;
564 goto parse_filename;
Kevin Stevesef4eea92001-02-05 12:42:17 +0000565
Damien Miller95def091999-11-25 00:26:21 +1100566 case sStrictModes:
567 intptr = &options->strict_modes;
568 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000569
Damien Miller95def091999-11-25 00:26:21 +1100570 case sKeepAlives:
571 intptr = &options->keepalives;
572 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000573
Damien Miller95def091999-11-25 00:26:21 +1100574 case sEmptyPasswd:
575 intptr = &options->permit_empty_passwd;
576 goto parse_flag;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000577
Damien Miller95def091999-11-25 00:26:21 +1100578 case sUseLogin:
579 intptr = &options->use_login;
580 goto parse_flag;
Damien Miller5ce662a1999-11-11 17:57:39 +1100581
Damien Millere247cc42000-05-07 12:03:14 +1000582 case sGatewayPorts:
583 intptr = &options->gateway_ports;
584 goto parse_flag;
585
Damien Miller33804262001-02-04 23:20:18 +1100586 case sReverseMappingCheck:
587 intptr = &options->reverse_mapping_check;
588 goto parse_flag;
589
Damien Miller95def091999-11-25 00:26:21 +1100590 case sLogFacility:
591 intptr = (int *) &options->log_facility;
Damien Millerbe484b52000-07-15 14:14:16 +1000592 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000593 value = log_facility_number(arg);
Damien Miller95def091999-11-25 00:26:21 +1100594 if (value == (SyslogFacility) - 1)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000595 fatal("%.200s line %d: unsupported log facility '%s'",
Damien Miller37023962000-07-11 17:31:38 +1000596 filename, linenum, arg ? arg : "<NONE>");
Damien Miller95def091999-11-25 00:26:21 +1100597 if (*intptr == -1)
598 *intptr = (SyslogFacility) value;
599 break;
600
601 case sLogLevel:
602 intptr = (int *) &options->log_level;
Damien Millerbe484b52000-07-15 14:14:16 +1000603 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000604 value = log_level_number(arg);
Damien Miller95def091999-11-25 00:26:21 +1100605 if (value == (LogLevel) - 1)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000606 fatal("%.200s line %d: unsupported log level '%s'",
Damien Miller37023962000-07-11 17:31:38 +1000607 filename, linenum, arg ? arg : "<NONE>");
Damien Miller95def091999-11-25 00:26:21 +1100608 if (*intptr == -1)
609 *intptr = (LogLevel) value;
610 break;
611
Damien Miller50a41ed2000-10-16 12:14:42 +1100612 case sAllowTcpForwarding:
613 intptr = &options->allow_tcp_forwarding;
614 goto parse_flag;
615
Damien Miller95def091999-11-25 00:26:21 +1100616 case sAllowUsers:
Damien Millerbe484b52000-07-15 14:14:16 +1000617 while ((arg = strdelim(&cp)) && *arg != '\0') {
Damien Miller78928792000-04-12 20:17:38 +1000618 if (options->num_allow_users >= MAX_ALLOW_USERS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000619 fatal("%s line %d: too many allow users.",
Damien Miller78928792000-04-12 20:17:38 +1000620 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000621 options->allow_users[options->num_allow_users++] = xstrdup(arg);
Damien Miller95def091999-11-25 00:26:21 +1100622 }
623 break;
624
625 case sDenyUsers:
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_deny_users >= MAX_DENY_USERS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000628 fatal( "%s line %d: too many deny users.",
Damien Miller78928792000-04-12 20:17:38 +1000629 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000630 options->deny_users[options->num_deny_users++] = xstrdup(arg);
Damien Miller95def091999-11-25 00:26:21 +1100631 }
632 break;
633
634 case sAllowGroups:
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_allow_groups >= MAX_ALLOW_GROUPS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000637 fatal("%s line %d: too many allow groups.",
Damien Miller78928792000-04-12 20:17:38 +1000638 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000639 options->allow_groups[options->num_allow_groups++] = xstrdup(arg);
Damien Miller95def091999-11-25 00:26:21 +1100640 }
641 break;
642
643 case sDenyGroups:
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_deny_groups >= MAX_DENY_GROUPS)
Ben Lindstrom6df8ef42001-03-05 07:47:23 +0000646 fatal("%s line %d: too many deny groups.",
Damien Miller78928792000-04-12 20:17:38 +1000647 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000648 options->deny_groups[options->num_deny_groups++] = xstrdup(arg);
Damien Miller95def091999-11-25 00:26:21 +1100649 }
650 break;
651
Damien Miller78928792000-04-12 20:17:38 +1000652 case sCiphers:
Damien Millerbe484b52000-07-15 14:14:16 +1000653 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000654 if (!arg || *arg == '\0')
Damien Millerb1715dc2000-05-30 13:44:51 +1000655 fatal("%s line %d: Missing argument.", filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000656 if (!ciphers_valid(arg))
Damien Miller30c3d422000-05-09 11:02:59 +1000657 fatal("%s line %d: Bad SSH2 cipher spec '%s'.",
Damien Miller37023962000-07-11 17:31:38 +1000658 filename, linenum, arg ? arg : "<NONE>");
Damien Miller78928792000-04-12 20:17:38 +1000659 if (options->ciphers == NULL)
Damien Miller37023962000-07-11 17:31:38 +1000660 options->ciphers = xstrdup(arg);
Damien Miller78928792000-04-12 20:17:38 +1000661 break;
662
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000663 case sMacs:
664 arg = strdelim(&cp);
665 if (!arg || *arg == '\0')
666 fatal("%s line %d: Missing argument.", filename, linenum);
667 if (!mac_valid(arg))
668 fatal("%s line %d: Bad SSH2 mac spec '%s'.",
669 filename, linenum, arg ? arg : "<NONE>");
670 if (options->macs == NULL)
671 options->macs = xstrdup(arg);
672 break;
673
Damien Miller78928792000-04-12 20:17:38 +1000674 case sProtocol:
675 intptr = &options->protocol;
Damien Millerbe484b52000-07-15 14:14:16 +1000676 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000677 if (!arg || *arg == '\0')
Damien Millerb1715dc2000-05-30 13:44:51 +1000678 fatal("%s line %d: Missing argument.", filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000679 value = proto_spec(arg);
Damien Miller78928792000-04-12 20:17:38 +1000680 if (value == SSH_PROTO_UNKNOWN)
681 fatal("%s line %d: Bad protocol spec '%s'.",
Damien Miller37023962000-07-11 17:31:38 +1000682 filename, linenum, arg ? arg : "<NONE>");
Damien Miller78928792000-04-12 20:17:38 +1000683 if (*intptr == SSH_PROTO_UNKNOWN)
684 *intptr = value;
685 break;
686
Damien Millerf6d9e222000-06-18 14:50:44 +1000687 case sSubsystem:
688 if(options->num_subsystems >= MAX_SUBSYSTEMS) {
689 fatal("%s line %d: too many subsystems defined.",
690 filename, linenum);
691 }
Damien Millerbe484b52000-07-15 14:14:16 +1000692 arg = strdelim(&cp);
Damien Miller37023962000-07-11 17:31:38 +1000693 if (!arg || *arg == '\0')
Damien Millerf6d9e222000-06-18 14:50:44 +1000694 fatal("%s line %d: Missing subsystem name.",
695 filename, linenum);
696 for (i = 0; i < options->num_subsystems; i++)
Damien Miller37023962000-07-11 17:31:38 +1000697 if(strcmp(arg, options->subsystem_name[i]) == 0)
Damien Millerf6d9e222000-06-18 14:50:44 +1000698 fatal("%s line %d: Subsystem '%s' already defined.",
Damien Miller37023962000-07-11 17:31:38 +1000699 filename, linenum, arg);
700 options->subsystem_name[options->num_subsystems] = xstrdup(arg);
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 command.",
704 filename, linenum);
Damien Miller37023962000-07-11 17:31:38 +1000705 options->subsystem_command[options->num_subsystems] = xstrdup(arg);
Damien Millerf6d9e222000-06-18 14:50:44 +1000706 options->num_subsystems++;
707 break;
708
Damien Miller37023962000-07-11 17:31:38 +1000709 case sMaxStartups:
Damien Miller942da032000-08-18 13:59:06 +1000710 arg = strdelim(&cp);
711 if (!arg || *arg == '\0')
712 fatal("%s line %d: Missing MaxStartups spec.",
713 filename, linenum);
714 if (sscanf(arg, "%d:%d:%d",
715 &options->max_startups_begin,
716 &options->max_startups_rate,
717 &options->max_startups) == 3) {
718 if (options->max_startups_begin >
719 options->max_startups ||
720 options->max_startups_rate > 100 ||
721 options->max_startups_rate < 1)
722 fatal("%s line %d: Illegal MaxStartups spec.",
723 filename, linenum);
724 break;
725 }
Damien Miller37023962000-07-11 17:31:38 +1000726 intptr = &options->max_startups;
727 goto parse_int;
728
Ben Lindstrom48bd7c12001-01-09 00:35:42 +0000729 case sBanner:
730 charptr = &options->banner;
731 goto parse_filename;
Kevin Stevesef4eea92001-02-05 12:42:17 +0000732
Damien Miller95def091999-11-25 00:26:21 +1100733 default:
734 fprintf(stderr, "%s line %d: Missing handler for opcode %s (%d)\n",
Damien Miller37023962000-07-11 17:31:38 +1000735 filename, linenum, arg, opcode);
Damien Miller95def091999-11-25 00:26:21 +1100736 exit(1);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000737 }
Damien Millerbe484b52000-07-15 14:14:16 +1000738 if ((arg = strdelim(&cp)) != NULL && *arg != '\0') {
Kevin Stevesef4eea92001-02-05 12:42:17 +0000739 fprintf(stderr,
Damien Miller37023962000-07-11 17:31:38 +1000740 "%s line %d: garbage at end of line; \"%.200s\".\n",
741 filename, linenum, arg);
Damien Miller95def091999-11-25 00:26:21 +1100742 exit(1);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000743 }
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000744 }
Damien Miller95def091999-11-25 00:26:21 +1100745 fclose(f);
746 if (bad_options > 0) {
747 fprintf(stderr, "%s: terminating, %d bad configuration options\n",
748 filename, bad_options);
749 exit(1);
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000750 }
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000751}