Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1 | /* |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 2 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
| 3 | * All rights reserved |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 4 | * |
Damien Miller | e4340be | 2000-09-16 13:29:08 +1100 | [diff] [blame] | 5 | * 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 Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 10 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 11 | |
| 12 | #include "includes.h" |
Ben Lindstrom | 5eabda3 | 2001-04-12 23:34:34 +0000 | [diff] [blame] | 13 | RCSID("$OpenBSD: servconf.c,v 1.75 2001/04/12 19:15:25 markus Exp $"); |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 14 | |
| 15 | #ifdef KRB4 |
| 16 | #include <krb.h> |
| 17 | #endif |
| 18 | #ifdef AFS |
| 19 | #include <kafs.h> |
| 20 | #endif |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 21 | |
| 22 | #include "ssh.h" |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 23 | #include "log.h" |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 24 | #include "servconf.h" |
| 25 | #include "xmalloc.h" |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 26 | #include "compat.h" |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 27 | #include "pathnames.h" |
| 28 | #include "tildexpand.h" |
| 29 | #include "misc.h" |
| 30 | #include "cipher.h" |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 31 | #include "kex.h" |
| 32 | #include "mac.h" |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 33 | |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 34 | /* add listen address */ |
Ben Lindstrom | c510af4 | 2001-04-07 17:25:48 +0000 | [diff] [blame] | 35 | void add_listen_addr(ServerOptions *options, char *addr, char *port); |
| 36 | void add_one_listen_addr(ServerOptions *options, char *addr, u_short port); |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 37 | |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 38 | /* AF_UNSPEC or AF_INET or AF_INET6 */ |
| 39 | extern int IPv4or6; |
| 40 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 41 | /* Initializes the server options to their default values. */ |
| 42 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 43 | void |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 44 | initialize_server_options(ServerOptions *options) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 45 | { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 46 | memset(options, 0, sizeof(*options)); |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 47 | options->num_ports = 0; |
| 48 | options->ports_from_cmdline = 0; |
| 49 | options->listen_addrs = NULL; |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 50 | options->num_host_key_files = 0; |
Damien Miller | 6f83b8e | 2000-05-02 09:23:45 +1000 | [diff] [blame] | 51 | options->pid_file = NULL; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 52 | options->server_key_bits = -1; |
| 53 | options->login_grace_time = -1; |
| 54 | options->key_regeneration_time = -1; |
Ben Lindstrom | d8a9021 | 2001-02-15 03:08:27 +0000 | [diff] [blame] | 55 | options->permit_root_login = PERMIT_NOT_SET; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 56 | options->ignore_rhosts = -1; |
| 57 | options->ignore_user_known_hosts = -1; |
| 58 | options->print_motd = -1; |
Ben Lindstrom | 7bfff36 | 2001-03-26 05:45:53 +0000 | [diff] [blame] | 59 | options->print_lastlog = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 60 | options->check_mail = -1; |
| 61 | options->x11_forwarding = -1; |
| 62 | options->x11_display_offset = -1; |
Damien Miller | d3a1857 | 2000-06-07 19:55:44 +1000 | [diff] [blame] | 63 | options->xauth_location = NULL; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 64 | options->strict_modes = -1; |
| 65 | options->keepalives = -1; |
| 66 | options->log_facility = (SyslogFacility) - 1; |
| 67 | options->log_level = (LogLevel) - 1; |
| 68 | options->rhosts_authentication = -1; |
| 69 | options->rhosts_rsa_authentication = -1; |
Ben Lindstrom | 5eabda3 | 2001-04-12 23:34:34 +0000 | [diff] [blame] | 70 | options->hostbased_authentication = -1; |
| 71 | options->hostbased_uses_name_from_packet_only = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 72 | options->rsa_authentication = -1; |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 73 | options->pubkey_authentication = -1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 74 | #ifdef KRB4 |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 75 | options->kerberos_authentication = -1; |
| 76 | options->kerberos_or_local_passwd = -1; |
| 77 | options->kerberos_ticket_cleanup = -1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 78 | #endif |
| 79 | #ifdef AFS |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 80 | options->kerberos_tgt_passing = -1; |
| 81 | options->afs_token_passing = -1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 82 | #endif |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 83 | options->password_authentication = -1; |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 84 | options->kbd_interactive_authentication = -1; |
Ben Lindstrom | 95fb2dd | 2001-01-23 03:12:10 +0000 | [diff] [blame] | 85 | options->challenge_reponse_authentication = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 86 | options->permit_empty_passwd = -1; |
| 87 | options->use_login = -1; |
Damien Miller | 50a41ed | 2000-10-16 12:14:42 +1100 | [diff] [blame] | 88 | options->allow_tcp_forwarding = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 89 | options->num_allow_users = 0; |
| 90 | options->num_deny_users = 0; |
| 91 | options->num_allow_groups = 0; |
| 92 | options->num_deny_groups = 0; |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 93 | options->ciphers = NULL; |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 94 | options->macs = NULL; |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 95 | options->protocol = SSH_PROTO_UNKNOWN; |
Damien Miller | e247cc4 | 2000-05-07 12:03:14 +1000 | [diff] [blame] | 96 | options->gateway_ports = -1; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 97 | options->num_subsystems = 0; |
Damien Miller | 942da03 | 2000-08-18 13:59:06 +1000 | [diff] [blame] | 98 | options->max_startups_begin = -1; |
| 99 | options->max_startups_rate = -1; |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 100 | options->max_startups = -1; |
Ben Lindstrom | 48bd7c1 | 2001-01-09 00:35:42 +0000 | [diff] [blame] | 101 | options->banner = NULL; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 102 | options->reverse_mapping_check = -1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 103 | } |
| 104 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 105 | void |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 106 | fill_default_server_options(ServerOptions *options) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 107 | { |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 108 | if (options->protocol == SSH_PROTO_UNKNOWN) |
| 109 | options->protocol = SSH_PROTO_1|SSH_PROTO_2; |
| 110 | if (options->num_host_key_files == 0) { |
| 111 | /* fill default hostkeys for protocols */ |
| 112 | if (options->protocol & SSH_PROTO_1) |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 113 | options->host_key_files[options->num_host_key_files++] = _PATH_HOST_KEY_FILE; |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 114 | if (options->protocol & SSH_PROTO_2) |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 115 | options->host_key_files[options->num_host_key_files++] = _PATH_HOST_DSA_KEY_FILE; |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 116 | } |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 117 | if (options->num_ports == 0) |
| 118 | options->ports[options->num_ports++] = SSH_DEFAULT_PORT; |
| 119 | if (options->listen_addrs == NULL) |
Ben Lindstrom | c510af4 | 2001-04-07 17:25:48 +0000 | [diff] [blame] | 120 | add_listen_addr(options, NULL, NULL); |
Damien Miller | 6f83b8e | 2000-05-02 09:23:45 +1000 | [diff] [blame] | 121 | if (options->pid_file == NULL) |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 122 | options->pid_file = _PATH_SSH_DAEMON_PID_FILE; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 123 | if (options->server_key_bits == -1) |
| 124 | options->server_key_bits = 768; |
| 125 | if (options->login_grace_time == -1) |
| 126 | options->login_grace_time = 600; |
| 127 | if (options->key_regeneration_time == -1) |
| 128 | options->key_regeneration_time = 3600; |
Ben Lindstrom | d8a9021 | 2001-02-15 03:08:27 +0000 | [diff] [blame] | 129 | if (options->permit_root_login == PERMIT_NOT_SET) |
| 130 | options->permit_root_login = PERMIT_YES; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 131 | if (options->ignore_rhosts == -1) |
Damien Miller | 98c7ad6 | 2000-03-09 21:27:49 +1100 | [diff] [blame] | 132 | options->ignore_rhosts = 1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 133 | if (options->ignore_user_known_hosts == -1) |
| 134 | options->ignore_user_known_hosts = 0; |
| 135 | if (options->check_mail == -1) |
| 136 | options->check_mail = 0; |
| 137 | if (options->print_motd == -1) |
| 138 | options->print_motd = 1; |
Ben Lindstrom | 7bfff36 | 2001-03-26 05:45:53 +0000 | [diff] [blame] | 139 | if (options->print_lastlog == -1) |
| 140 | options->print_lastlog = 1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 141 | if (options->x11_forwarding == -1) |
Damien Miller | 98c7ad6 | 2000-03-09 21:27:49 +1100 | [diff] [blame] | 142 | options->x11_forwarding = 0; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 143 | if (options->x11_display_offset == -1) |
Damien Miller | 98c7ad6 | 2000-03-09 21:27:49 +1100 | [diff] [blame] | 144 | options->x11_display_offset = 10; |
Damien Miller | d3a1857 | 2000-06-07 19:55:44 +1000 | [diff] [blame] | 145 | #ifdef XAUTH_PATH |
| 146 | if (options->xauth_location == NULL) |
| 147 | options->xauth_location = XAUTH_PATH; |
| 148 | #endif /* XAUTH_PATH */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 149 | if (options->strict_modes == -1) |
| 150 | options->strict_modes = 1; |
| 151 | if (options->keepalives == -1) |
| 152 | options->keepalives = 1; |
| 153 | if (options->log_facility == (SyslogFacility) (-1)) |
| 154 | options->log_facility = SYSLOG_FACILITY_AUTH; |
| 155 | if (options->log_level == (LogLevel) (-1)) |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 156 | options->log_level = SYSLOG_LEVEL_INFO; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 157 | if (options->rhosts_authentication == -1) |
| 158 | options->rhosts_authentication = 0; |
| 159 | if (options->rhosts_rsa_authentication == -1) |
Damien Miller | 98c7ad6 | 2000-03-09 21:27:49 +1100 | [diff] [blame] | 160 | options->rhosts_rsa_authentication = 0; |
Ben Lindstrom | 5eabda3 | 2001-04-12 23:34:34 +0000 | [diff] [blame] | 161 | if (options->hostbased_authentication == -1) |
| 162 | options->hostbased_authentication = 0; |
| 163 | if (options->hostbased_uses_name_from_packet_only == -1) |
| 164 | options->hostbased_uses_name_from_packet_only = 0; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 165 | if (options->rsa_authentication == -1) |
| 166 | options->rsa_authentication = 1; |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 167 | if (options->pubkey_authentication == -1) |
| 168 | options->pubkey_authentication = 1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 169 | #ifdef KRB4 |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 170 | if (options->kerberos_authentication == -1) |
| 171 | options->kerberos_authentication = (access(KEYFILE, R_OK) == 0); |
| 172 | if (options->kerberos_or_local_passwd == -1) |
| 173 | options->kerberos_or_local_passwd = 1; |
| 174 | if (options->kerberos_ticket_cleanup == -1) |
| 175 | options->kerberos_ticket_cleanup = 1; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 176 | #endif /* KRB4 */ |
| 177 | #ifdef AFS |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 178 | if (options->kerberos_tgt_passing == -1) |
| 179 | options->kerberos_tgt_passing = 0; |
| 180 | if (options->afs_token_passing == -1) |
| 181 | options->afs_token_passing = k_hasafs(); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 182 | #endif /* AFS */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 183 | if (options->password_authentication == -1) |
| 184 | options->password_authentication = 1; |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 185 | if (options->kbd_interactive_authentication == -1) |
| 186 | options->kbd_interactive_authentication = 0; |
Ben Lindstrom | 95fb2dd | 2001-01-23 03:12:10 +0000 | [diff] [blame] | 187 | if (options->challenge_reponse_authentication == -1) |
| 188 | options->challenge_reponse_authentication = 1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 189 | if (options->permit_empty_passwd == -1) |
Damien Miller | 98c7ad6 | 2000-03-09 21:27:49 +1100 | [diff] [blame] | 190 | options->permit_empty_passwd = 0; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 191 | if (options->use_login == -1) |
| 192 | options->use_login = 0; |
Damien Miller | 50a41ed | 2000-10-16 12:14:42 +1100 | [diff] [blame] | 193 | if (options->allow_tcp_forwarding == -1) |
| 194 | options->allow_tcp_forwarding = 1; |
Damien Miller | e247cc4 | 2000-05-07 12:03:14 +1000 | [diff] [blame] | 195 | if (options->gateway_ports == -1) |
| 196 | options->gateway_ports = 0; |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 197 | if (options->max_startups == -1) |
| 198 | options->max_startups = 10; |
Damien Miller | 942da03 | 2000-08-18 13:59:06 +1000 | [diff] [blame] | 199 | if (options->max_startups_rate == -1) |
| 200 | options->max_startups_rate = 100; /* 100% */ |
| 201 | if (options->max_startups_begin == -1) |
| 202 | options->max_startups_begin = options->max_startups; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 203 | if (options->reverse_mapping_check == -1) |
| 204 | options->reverse_mapping_check = 0; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 205 | } |
| 206 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 207 | /* Keyword tokens. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 208 | typedef enum { |
| 209 | sBadOption, /* == unknown option */ |
| 210 | sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime, sKeyRegenerationTime, |
| 211 | sPermitRootLogin, sLogFacility, sLogLevel, |
| 212 | sRhostsAuthentication, sRhostsRSAAuthentication, sRSAAuthentication, |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 213 | #ifdef KRB4 |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 214 | sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup, |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 215 | #endif |
| 216 | #ifdef AFS |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 217 | sKerberosTgtPassing, sAFSTokenPassing, |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 218 | #endif |
Ben Lindstrom | 95fb2dd | 2001-01-23 03:12:10 +0000 | [diff] [blame] | 219 | sChallengeResponseAuthentication, |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 220 | sPasswordAuthentication, sKbdInteractiveAuthentication, sListenAddress, |
Ben Lindstrom | 7bfff36 | 2001-03-26 05:45:53 +0000 | [diff] [blame] | 221 | sPrintMotd, sPrintLastLog, sIgnoreRhosts, |
| 222 | sX11Forwarding, sX11DisplayOffset, |
Ben Lindstrom | d9cae22 | 2001-03-05 07:42:03 +0000 | [diff] [blame] | 223 | sStrictModes, sEmptyPasswd, sKeepAlives, sCheckMail, |
Damien Miller | 50a41ed | 2000-10-16 12:14:42 +1100 | [diff] [blame] | 224 | sUseLogin, sAllowTcpForwarding, |
| 225 | sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups, |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 226 | sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile, |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 227 | sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, sMaxStartups, |
Ben Lindstrom | 5eabda3 | 2001-04-12 23:34:34 +0000 | [diff] [blame] | 228 | sBanner, sReverseMappingCheck, sHostbasedAuthentication, |
| 229 | sHostbasedUsesNameFromPacketOnly |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 230 | } ServerOpCodes; |
| 231 | |
| 232 | /* Textual representation of the tokens. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 233 | static struct { |
| 234 | const char *name; |
| 235 | ServerOpCodes opcode; |
| 236 | } keywords[] = { |
| 237 | { "port", sPort }, |
| 238 | { "hostkey", sHostKeyFile }, |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 239 | { "hostdsakey", sHostKeyFile }, /* alias */ |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 240 | { "pidfile", sPidFile }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 241 | { "serverkeybits", sServerKeyBits }, |
| 242 | { "logingracetime", sLoginGraceTime }, |
| 243 | { "keyregenerationinterval", sKeyRegenerationTime }, |
| 244 | { "permitrootlogin", sPermitRootLogin }, |
| 245 | { "syslogfacility", sLogFacility }, |
| 246 | { "loglevel", sLogLevel }, |
| 247 | { "rhostsauthentication", sRhostsAuthentication }, |
| 248 | { "rhostsrsaauthentication", sRhostsRSAAuthentication }, |
Ben Lindstrom | 5eabda3 | 2001-04-12 23:34:34 +0000 | [diff] [blame] | 249 | { "hostbasedauthentication", sHostbasedAuthentication }, |
| 250 | { "hostbasedusesnamefrompacketonly", sHostbasedUsesNameFromPacketOnly }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 251 | { "rsaauthentication", sRSAAuthentication }, |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 252 | { "pubkeyauthentication", sPubkeyAuthentication }, |
| 253 | { "dsaauthentication", sPubkeyAuthentication }, /* alias */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 254 | #ifdef KRB4 |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 255 | { "kerberosauthentication", sKerberosAuthentication }, |
| 256 | { "kerberosorlocalpasswd", sKerberosOrLocalPasswd }, |
| 257 | { "kerberosticketcleanup", sKerberosTicketCleanup }, |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 258 | #endif |
| 259 | #ifdef AFS |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 260 | { "kerberostgtpassing", sKerberosTgtPassing }, |
| 261 | { "afstokenpassing", sAFSTokenPassing }, |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 262 | #endif |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 263 | { "passwordauthentication", sPasswordAuthentication }, |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 264 | { "kbdinteractiveauthentication", sKbdInteractiveAuthentication }, |
Ben Lindstrom | 95fb2dd | 2001-01-23 03:12:10 +0000 | [diff] [blame] | 265 | { "challengeresponseauthentication", sChallengeResponseAuthentication }, |
| 266 | { "skeyauthentication", sChallengeResponseAuthentication }, /* alias */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 267 | { "checkmail", sCheckMail }, |
| 268 | { "listenaddress", sListenAddress }, |
| 269 | { "printmotd", sPrintMotd }, |
Ben Lindstrom | 7bfff36 | 2001-03-26 05:45:53 +0000 | [diff] [blame] | 270 | { "printlastlog", sPrintLastLog }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 271 | { "ignorerhosts", sIgnoreRhosts }, |
| 272 | { "ignoreuserknownhosts", sIgnoreUserKnownHosts }, |
| 273 | { "x11forwarding", sX11Forwarding }, |
| 274 | { "x11displayoffset", sX11DisplayOffset }, |
Damien Miller | d3a1857 | 2000-06-07 19:55:44 +1000 | [diff] [blame] | 275 | { "xauthlocation", sXAuthLocation }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 276 | { "strictmodes", sStrictModes }, |
| 277 | { "permitemptypasswords", sEmptyPasswd }, |
| 278 | { "uselogin", sUseLogin }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 279 | { "keepalive", sKeepAlives }, |
Damien Miller | 50a41ed | 2000-10-16 12:14:42 +1100 | [diff] [blame] | 280 | { "allowtcpforwarding", sAllowTcpForwarding }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 281 | { "allowusers", sAllowUsers }, |
| 282 | { "denyusers", sDenyUsers }, |
| 283 | { "allowgroups", sAllowGroups }, |
| 284 | { "denygroups", sDenyGroups }, |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 285 | { "ciphers", sCiphers }, |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 286 | { "macs", sMacs }, |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 287 | { "protocol", sProtocol }, |
Damien Miller | e247cc4 | 2000-05-07 12:03:14 +1000 | [diff] [blame] | 288 | { "gatewayports", sGatewayPorts }, |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 289 | { "subsystem", sSubsystem }, |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 290 | { "maxstartups", sMaxStartups }, |
Ben Lindstrom | 48bd7c1 | 2001-01-09 00:35:42 +0000 | [diff] [blame] | 291 | { "banner", sBanner }, |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 292 | { "reversemappingcheck", sReverseMappingCheck }, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 293 | { NULL, 0 } |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 294 | }; |
| 295 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 296 | /* |
Ben Lindstrom | 3704c26 | 2001-04-02 18:20:03 +0000 | [diff] [blame] | 297 | * Returns the number of the token pointed to by cp or sBadOption. |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 298 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 299 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 300 | static ServerOpCodes |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 301 | parse_token(const char *cp, const char *filename, |
| 302 | int linenum) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 303 | { |
Ben Lindstrom | 46c1622 | 2000-12-22 01:43:59 +0000 | [diff] [blame] | 304 | u_int i; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 305 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 306 | for (i = 0; keywords[i].name; i++) |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 307 | if (strcasecmp(cp, keywords[i].name) == 0) |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 308 | return keywords[i].opcode; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 309 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 310 | fprintf(stderr, "%s: line %d: Bad configuration option: %s\n", |
| 311 | filename, linenum, cp); |
| 312 | return sBadOption; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 313 | } |
| 314 | |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 315 | /* |
| 316 | * add listen address |
| 317 | */ |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 318 | void |
Ben Lindstrom | c510af4 | 2001-04-07 17:25:48 +0000 | [diff] [blame] | 319 | add_listen_addr(ServerOptions *options, char *addr, char *port) |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 320 | { |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 321 | int i; |
| 322 | |
| 323 | if (options->num_ports == 0) |
| 324 | options->ports[options->num_ports++] = SSH_DEFAULT_PORT; |
Ben Lindstrom | c510af4 | 2001-04-07 17:25:48 +0000 | [diff] [blame] | 325 | if (port == NULL) |
| 326 | for (i = 0; i < options->num_ports; i++) |
| 327 | add_one_listen_addr(options, addr, options->ports[i]); |
| 328 | else |
| 329 | add_one_listen_addr(options, addr, atoi(port)); |
| 330 | } |
| 331 | |
| 332 | void |
| 333 | add_one_listen_addr(ServerOptions *options, char *addr, u_short port) |
| 334 | { |
| 335 | struct addrinfo hints, *ai, *aitop; |
| 336 | char strport[NI_MAXSERV]; |
| 337 | int gaierr; |
| 338 | |
| 339 | memset(&hints, 0, sizeof(hints)); |
| 340 | hints.ai_family = IPv4or6; |
| 341 | hints.ai_socktype = SOCK_STREAM; |
| 342 | hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0; |
| 343 | snprintf(strport, sizeof strport, "%d", port); |
| 344 | if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0) |
| 345 | fatal("bad addr or host: %s (%s)", |
| 346 | addr ? addr : "<NULL>", |
| 347 | gai_strerror(gaierr)); |
| 348 | for (ai = aitop; ai->ai_next; ai = ai->ai_next) |
| 349 | ; |
| 350 | ai->ai_next = options->listen_addrs; |
| 351 | options->listen_addrs = aitop; |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 352 | } |
| 353 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 354 | /* Reads the server configuration file. */ |
| 355 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 356 | void |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 357 | read_server_config(ServerOptions *options, const char *filename) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 358 | { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 359 | FILE *f; |
| 360 | char line[1024]; |
Ben Lindstrom | c510af4 | 2001-04-07 17:25:48 +0000 | [diff] [blame] | 361 | char *cp, **charptr, *arg, *p; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 362 | int linenum, *intptr, value; |
| 363 | int bad_options = 0; |
| 364 | ServerOpCodes opcode; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 365 | int i; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 366 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 367 | f = fopen(filename, "r"); |
| 368 | if (!f) { |
| 369 | perror(filename); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 370 | exit(1); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 371 | } |
| 372 | linenum = 0; |
| 373 | while (fgets(line, sizeof(line), f)) { |
| 374 | linenum++; |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 375 | cp = line; |
| 376 | arg = strdelim(&cp); |
| 377 | /* Ignore leading whitespace */ |
| 378 | if (*arg == '\0') |
| 379 | arg = strdelim(&cp); |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 380 | if (!arg || !*arg || *arg == '#') |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 381 | continue; |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 382 | intptr = NULL; |
| 383 | charptr = NULL; |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 384 | opcode = parse_token(arg, filename, linenum); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 385 | switch (opcode) { |
| 386 | case sBadOption: |
| 387 | bad_options++; |
| 388 | continue; |
| 389 | case sPort: |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 390 | /* ignore ports from configfile if cmdline specifies ports */ |
| 391 | if (options->ports_from_cmdline) |
| 392 | continue; |
| 393 | if (options->listen_addrs != NULL) |
| 394 | fatal("%s line %d: ports must be specified before " |
| 395 | "ListenAdress.\n", filename, linenum); |
| 396 | if (options->num_ports >= MAX_PORTS) |
Ben Lindstrom | 6df8ef4 | 2001-03-05 07:47:23 +0000 | [diff] [blame] | 397 | fatal("%s line %d: too many ports.", |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 398 | filename, linenum); |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 399 | arg = strdelim(&cp); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 400 | if (!arg || *arg == '\0') |
Ben Lindstrom | 6df8ef4 | 2001-03-05 07:47:23 +0000 | [diff] [blame] | 401 | fatal("%s line %d: missing port number.", |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 402 | filename, linenum); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 403 | options->ports[options->num_ports++] = atoi(arg); |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 404 | break; |
| 405 | |
| 406 | case sServerKeyBits: |
| 407 | intptr = &options->server_key_bits; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 408 | parse_int: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 409 | arg = strdelim(&cp); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 410 | if (!arg || *arg == '\0') { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 411 | fprintf(stderr, "%s line %d: missing integer value.\n", |
| 412 | filename, linenum); |
| 413 | exit(1); |
| 414 | } |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 415 | value = atoi(arg); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 416 | if (*intptr == -1) |
| 417 | *intptr = value; |
| 418 | break; |
Damien Miller | 3226509 | 1999-11-12 11:33:04 +1100 | [diff] [blame] | 419 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 420 | case sLoginGraceTime: |
| 421 | intptr = &options->login_grace_time; |
| 422 | goto parse_int; |
| 423 | |
| 424 | case sKeyRegenerationTime: |
| 425 | intptr = &options->key_regeneration_time; |
| 426 | goto parse_int; |
| 427 | |
| 428 | case sListenAddress: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 429 | arg = strdelim(&cp); |
Ben Lindstrom | c510af4 | 2001-04-07 17:25:48 +0000 | [diff] [blame] | 430 | if (!arg || *arg == '\0' || strncmp(arg, "[]", 2) == 0) |
Ben Lindstrom | 6df8ef4 | 2001-03-05 07:47:23 +0000 | [diff] [blame] | 431 | fatal("%s line %d: missing inet addr.", |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 432 | filename, linenum); |
Ben Lindstrom | c510af4 | 2001-04-07 17:25:48 +0000 | [diff] [blame] | 433 | if (*arg == '[') { |
| 434 | if ((p = strchr(arg, ']')) == NULL) |
| 435 | fatal("%s line %d: bad ipv6 inet addr usage.", |
| 436 | filename, linenum); |
| 437 | arg++; |
| 438 | memmove(p, p+1, strlen(p+1)+1); |
| 439 | } else if (((p = strchr(arg, ':')) == NULL) || |
| 440 | (strchr(p+1, ':') != NULL)) { |
| 441 | add_listen_addr(options, arg, NULL); |
| 442 | break; |
| 443 | } |
| 444 | if (*p == ':') { |
| 445 | p++; |
| 446 | if (*p == '\0') |
| 447 | fatal("%s line %d: bad inet addr:port usage.", |
| 448 | filename, linenum); |
| 449 | else { |
| 450 | *(p-1) = '\0'; |
| 451 | add_listen_addr(options, arg, p); |
| 452 | } |
| 453 | } else if (*p == '\0') |
| 454 | add_listen_addr(options, arg, NULL); |
| 455 | else |
| 456 | fatal("%s line %d: bad inet addr usage.", |
| 457 | filename, linenum); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 458 | break; |
| 459 | |
| 460 | case sHostKeyFile: |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 461 | intptr = &options->num_host_key_files; |
| 462 | if (*intptr >= MAX_HOSTKEYS) { |
Ben Lindstrom | 33a3cc3 | 2001-03-05 05:07:52 +0000 | [diff] [blame] | 463 | fprintf(stderr, |
| 464 | "%s line %d: too many host keys specified (max %d).\n", |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 465 | filename, linenum, MAX_HOSTKEYS); |
| 466 | exit(1); |
| 467 | } |
| 468 | charptr = &options->host_key_files[*intptr]; |
Damien Miller | d3a1857 | 2000-06-07 19:55:44 +1000 | [diff] [blame] | 469 | parse_filename: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 470 | arg = strdelim(&cp); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 471 | if (!arg || *arg == '\0') { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 472 | fprintf(stderr, "%s line %d: missing file name.\n", |
Damien Miller | 6f83b8e | 2000-05-02 09:23:45 +1000 | [diff] [blame] | 473 | filename, linenum); |
| 474 | exit(1); |
| 475 | } |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 476 | if (*charptr == NULL) { |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 477 | *charptr = tilde_expand_filename(arg, getuid()); |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 478 | /* increase optional counter */ |
| 479 | if (intptr != NULL) |
| 480 | *intptr = *intptr + 1; |
| 481 | } |
Damien Miller | 6f83b8e | 2000-05-02 09:23:45 +1000 | [diff] [blame] | 482 | break; |
| 483 | |
| 484 | case sPidFile: |
| 485 | charptr = &options->pid_file; |
Damien Miller | d3a1857 | 2000-06-07 19:55:44 +1000 | [diff] [blame] | 486 | goto parse_filename; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 487 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 488 | case sPermitRootLogin: |
| 489 | intptr = &options->permit_root_login; |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 490 | arg = strdelim(&cp); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 491 | if (!arg || *arg == '\0') { |
Ben Lindstrom | 35f1f4e | 2001-03-06 01:02:41 +0000 | [diff] [blame] | 492 | fprintf(stderr, "%s line %d: missing yes/" |
| 493 | "without-password/forced-commands-only/no " |
| 494 | "argument.\n", filename, linenum); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 495 | exit(1); |
| 496 | } |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 497 | if (strcmp(arg, "without-password") == 0) |
Ben Lindstrom | d8a9021 | 2001-02-15 03:08:27 +0000 | [diff] [blame] | 498 | value = PERMIT_NO_PASSWD; |
| 499 | else if (strcmp(arg, "forced-commands-only") == 0) |
| 500 | value = PERMIT_FORCED_ONLY; |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 501 | else if (strcmp(arg, "yes") == 0) |
Ben Lindstrom | d8a9021 | 2001-02-15 03:08:27 +0000 | [diff] [blame] | 502 | value = PERMIT_YES; |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 503 | else if (strcmp(arg, "no") == 0) |
Ben Lindstrom | d8a9021 | 2001-02-15 03:08:27 +0000 | [diff] [blame] | 504 | value = PERMIT_NO; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 505 | else { |
Ben Lindstrom | d8a9021 | 2001-02-15 03:08:27 +0000 | [diff] [blame] | 506 | fprintf(stderr, "%s line %d: Bad yes/" |
| 507 | "without-password/forced-commands-only/no " |
| 508 | "argument: %s\n", filename, linenum, arg); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 509 | exit(1); |
| 510 | } |
| 511 | if (*intptr == -1) |
| 512 | *intptr = value; |
| 513 | break; |
| 514 | |
| 515 | case sIgnoreRhosts: |
| 516 | intptr = &options->ignore_rhosts; |
| 517 | parse_flag: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 518 | arg = strdelim(&cp); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 519 | if (!arg || *arg == '\0') { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 520 | fprintf(stderr, "%s line %d: missing yes/no argument.\n", |
| 521 | filename, linenum); |
| 522 | exit(1); |
| 523 | } |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 524 | if (strcmp(arg, "yes") == 0) |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 525 | value = 1; |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 526 | else if (strcmp(arg, "no") == 0) |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 527 | value = 0; |
| 528 | else { |
| 529 | fprintf(stderr, "%s line %d: Bad yes/no argument: %s\n", |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 530 | filename, linenum, arg); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 531 | exit(1); |
| 532 | } |
| 533 | if (*intptr == -1) |
| 534 | *intptr = value; |
| 535 | break; |
| 536 | |
| 537 | case sIgnoreUserKnownHosts: |
| 538 | intptr = &options->ignore_user_known_hosts; |
Damien Miller | 98c7ad6 | 2000-03-09 21:27:49 +1100 | [diff] [blame] | 539 | goto parse_flag; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 540 | |
| 541 | case sRhostsAuthentication: |
| 542 | intptr = &options->rhosts_authentication; |
| 543 | goto parse_flag; |
| 544 | |
| 545 | case sRhostsRSAAuthentication: |
| 546 | intptr = &options->rhosts_rsa_authentication; |
| 547 | goto parse_flag; |
| 548 | |
Ben Lindstrom | 5eabda3 | 2001-04-12 23:34:34 +0000 | [diff] [blame] | 549 | case sHostbasedAuthentication: |
| 550 | intptr = &options->hostbased_authentication; |
| 551 | goto parse_flag; |
| 552 | |
| 553 | case sHostbasedUsesNameFromPacketOnly: |
| 554 | intptr = &options->hostbased_uses_name_from_packet_only; |
| 555 | goto parse_flag; |
| 556 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 557 | case sRSAAuthentication: |
| 558 | intptr = &options->rsa_authentication; |
| 559 | goto parse_flag; |
| 560 | |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 561 | case sPubkeyAuthentication: |
| 562 | intptr = &options->pubkey_authentication; |
Damien Miller | e247cc4 | 2000-05-07 12:03:14 +1000 | [diff] [blame] | 563 | goto parse_flag; |
| 564 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 565 | #ifdef KRB4 |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 566 | case sKerberosAuthentication: |
| 567 | intptr = &options->kerberos_authentication; |
| 568 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 569 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 570 | case sKerberosOrLocalPasswd: |
| 571 | intptr = &options->kerberos_or_local_passwd; |
| 572 | goto parse_flag; |
| 573 | |
| 574 | case sKerberosTicketCleanup: |
| 575 | intptr = &options->kerberos_ticket_cleanup; |
| 576 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 577 | #endif |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 578 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 579 | #ifdef AFS |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 580 | case sKerberosTgtPassing: |
| 581 | intptr = &options->kerberos_tgt_passing; |
| 582 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 583 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 584 | case sAFSTokenPassing: |
| 585 | intptr = &options->afs_token_passing; |
| 586 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 587 | #endif |
| 588 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 589 | case sPasswordAuthentication: |
| 590 | intptr = &options->password_authentication; |
| 591 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 592 | |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 593 | case sKbdInteractiveAuthentication: |
| 594 | intptr = &options->kbd_interactive_authentication; |
| 595 | goto parse_flag; |
| 596 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 597 | case sCheckMail: |
| 598 | intptr = &options->check_mail; |
| 599 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 600 | |
Ben Lindstrom | 95fb2dd | 2001-01-23 03:12:10 +0000 | [diff] [blame] | 601 | case sChallengeResponseAuthentication: |
| 602 | intptr = &options->challenge_reponse_authentication; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 603 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 604 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 605 | case sPrintMotd: |
| 606 | intptr = &options->print_motd; |
| 607 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 608 | |
Ben Lindstrom | 7bfff36 | 2001-03-26 05:45:53 +0000 | [diff] [blame] | 609 | case sPrintLastLog: |
| 610 | intptr = &options->print_lastlog; |
| 611 | goto parse_flag; |
| 612 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 613 | case sX11Forwarding: |
| 614 | intptr = &options->x11_forwarding; |
| 615 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 616 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 617 | case sX11DisplayOffset: |
| 618 | intptr = &options->x11_display_offset; |
| 619 | goto parse_int; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 620 | |
Damien Miller | d3a1857 | 2000-06-07 19:55:44 +1000 | [diff] [blame] | 621 | case sXAuthLocation: |
| 622 | charptr = &options->xauth_location; |
| 623 | goto parse_filename; |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 624 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 625 | case sStrictModes: |
| 626 | intptr = &options->strict_modes; |
| 627 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 628 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 629 | case sKeepAlives: |
| 630 | intptr = &options->keepalives; |
| 631 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 632 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 633 | case sEmptyPasswd: |
| 634 | intptr = &options->permit_empty_passwd; |
| 635 | goto parse_flag; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 636 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 637 | case sUseLogin: |
| 638 | intptr = &options->use_login; |
| 639 | goto parse_flag; |
Damien Miller | 5ce662a | 1999-11-11 17:57:39 +1100 | [diff] [blame] | 640 | |
Damien Miller | e247cc4 | 2000-05-07 12:03:14 +1000 | [diff] [blame] | 641 | case sGatewayPorts: |
| 642 | intptr = &options->gateway_ports; |
| 643 | goto parse_flag; |
| 644 | |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 645 | case sReverseMappingCheck: |
| 646 | intptr = &options->reverse_mapping_check; |
| 647 | goto parse_flag; |
| 648 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 649 | case sLogFacility: |
| 650 | intptr = (int *) &options->log_facility; |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 651 | arg = strdelim(&cp); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 652 | value = log_facility_number(arg); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 653 | if (value == (SyslogFacility) - 1) |
Ben Lindstrom | 6df8ef4 | 2001-03-05 07:47:23 +0000 | [diff] [blame] | 654 | fatal("%.200s line %d: unsupported log facility '%s'", |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 655 | filename, linenum, arg ? arg : "<NONE>"); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 656 | if (*intptr == -1) |
| 657 | *intptr = (SyslogFacility) value; |
| 658 | break; |
| 659 | |
| 660 | case sLogLevel: |
| 661 | intptr = (int *) &options->log_level; |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 662 | arg = strdelim(&cp); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 663 | value = log_level_number(arg); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 664 | if (value == (LogLevel) - 1) |
Ben Lindstrom | 6df8ef4 | 2001-03-05 07:47:23 +0000 | [diff] [blame] | 665 | fatal("%.200s line %d: unsupported log level '%s'", |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 666 | filename, linenum, arg ? arg : "<NONE>"); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 667 | if (*intptr == -1) |
| 668 | *intptr = (LogLevel) value; |
| 669 | break; |
| 670 | |
Damien Miller | 50a41ed | 2000-10-16 12:14:42 +1100 | [diff] [blame] | 671 | case sAllowTcpForwarding: |
| 672 | intptr = &options->allow_tcp_forwarding; |
| 673 | goto parse_flag; |
| 674 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 675 | case sAllowUsers: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 676 | while ((arg = strdelim(&cp)) && *arg != '\0') { |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 677 | if (options->num_allow_users >= MAX_ALLOW_USERS) |
Ben Lindstrom | 6df8ef4 | 2001-03-05 07:47:23 +0000 | [diff] [blame] | 678 | fatal("%s line %d: too many allow users.", |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 679 | filename, linenum); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 680 | options->allow_users[options->num_allow_users++] = xstrdup(arg); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 681 | } |
| 682 | break; |
| 683 | |
| 684 | case sDenyUsers: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 685 | while ((arg = strdelim(&cp)) && *arg != '\0') { |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 686 | if (options->num_deny_users >= MAX_DENY_USERS) |
Ben Lindstrom | 6df8ef4 | 2001-03-05 07:47:23 +0000 | [diff] [blame] | 687 | fatal( "%s line %d: too many deny users.", |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 688 | filename, linenum); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 689 | options->deny_users[options->num_deny_users++] = xstrdup(arg); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 690 | } |
| 691 | break; |
| 692 | |
| 693 | case sAllowGroups: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 694 | while ((arg = strdelim(&cp)) && *arg != '\0') { |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 695 | if (options->num_allow_groups >= MAX_ALLOW_GROUPS) |
Ben Lindstrom | 6df8ef4 | 2001-03-05 07:47:23 +0000 | [diff] [blame] | 696 | fatal("%s line %d: too many allow groups.", |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 697 | filename, linenum); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 698 | options->allow_groups[options->num_allow_groups++] = xstrdup(arg); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 699 | } |
| 700 | break; |
| 701 | |
| 702 | case sDenyGroups: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 703 | while ((arg = strdelim(&cp)) && *arg != '\0') { |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 704 | if (options->num_deny_groups >= MAX_DENY_GROUPS) |
Ben Lindstrom | 6df8ef4 | 2001-03-05 07:47:23 +0000 | [diff] [blame] | 705 | fatal("%s line %d: too many deny groups.", |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 706 | filename, linenum); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 707 | options->deny_groups[options->num_deny_groups++] = xstrdup(arg); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 708 | } |
| 709 | break; |
| 710 | |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 711 | case sCiphers: |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 712 | arg = strdelim(&cp); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 713 | if (!arg || *arg == '\0') |
Damien Miller | b1715dc | 2000-05-30 13:44:51 +1000 | [diff] [blame] | 714 | fatal("%s line %d: Missing argument.", filename, linenum); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 715 | if (!ciphers_valid(arg)) |
Damien Miller | 30c3d42 | 2000-05-09 11:02:59 +1000 | [diff] [blame] | 716 | fatal("%s line %d: Bad SSH2 cipher spec '%s'.", |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 717 | filename, linenum, arg ? arg : "<NONE>"); |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 718 | if (options->ciphers == NULL) |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 719 | options->ciphers = xstrdup(arg); |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 720 | break; |
| 721 | |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 722 | case sMacs: |
| 723 | arg = strdelim(&cp); |
| 724 | if (!arg || *arg == '\0') |
| 725 | fatal("%s line %d: Missing argument.", filename, linenum); |
| 726 | if (!mac_valid(arg)) |
| 727 | fatal("%s line %d: Bad SSH2 mac spec '%s'.", |
| 728 | filename, linenum, arg ? arg : "<NONE>"); |
| 729 | if (options->macs == NULL) |
| 730 | options->macs = xstrdup(arg); |
| 731 | break; |
| 732 | |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 733 | case sProtocol: |
| 734 | intptr = &options->protocol; |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 735 | arg = strdelim(&cp); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 736 | if (!arg || *arg == '\0') |
Damien Miller | b1715dc | 2000-05-30 13:44:51 +1000 | [diff] [blame] | 737 | fatal("%s line %d: Missing argument.", filename, linenum); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 738 | value = proto_spec(arg); |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 739 | if (value == SSH_PROTO_UNKNOWN) |
| 740 | fatal("%s line %d: Bad protocol spec '%s'.", |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 741 | filename, linenum, arg ? arg : "<NONE>"); |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 742 | if (*intptr == SSH_PROTO_UNKNOWN) |
| 743 | *intptr = value; |
| 744 | break; |
| 745 | |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 746 | case sSubsystem: |
| 747 | if(options->num_subsystems >= MAX_SUBSYSTEMS) { |
| 748 | fatal("%s line %d: too many subsystems defined.", |
| 749 | filename, linenum); |
| 750 | } |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 751 | arg = strdelim(&cp); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 752 | if (!arg || *arg == '\0') |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 753 | fatal("%s line %d: Missing subsystem name.", |
| 754 | filename, linenum); |
| 755 | for (i = 0; i < options->num_subsystems; i++) |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 756 | if(strcmp(arg, options->subsystem_name[i]) == 0) |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 757 | fatal("%s line %d: Subsystem '%s' already defined.", |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 758 | filename, linenum, arg); |
| 759 | options->subsystem_name[options->num_subsystems] = xstrdup(arg); |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 760 | arg = strdelim(&cp); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 761 | if (!arg || *arg == '\0') |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 762 | fatal("%s line %d: Missing subsystem command.", |
| 763 | filename, linenum); |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 764 | options->subsystem_command[options->num_subsystems] = xstrdup(arg); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 765 | options->num_subsystems++; |
| 766 | break; |
| 767 | |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 768 | case sMaxStartups: |
Damien Miller | 942da03 | 2000-08-18 13:59:06 +1000 | [diff] [blame] | 769 | arg = strdelim(&cp); |
| 770 | if (!arg || *arg == '\0') |
| 771 | fatal("%s line %d: Missing MaxStartups spec.", |
| 772 | filename, linenum); |
| 773 | if (sscanf(arg, "%d:%d:%d", |
| 774 | &options->max_startups_begin, |
| 775 | &options->max_startups_rate, |
| 776 | &options->max_startups) == 3) { |
| 777 | if (options->max_startups_begin > |
| 778 | options->max_startups || |
| 779 | options->max_startups_rate > 100 || |
| 780 | options->max_startups_rate < 1) |
| 781 | fatal("%s line %d: Illegal MaxStartups spec.", |
| 782 | filename, linenum); |
| 783 | break; |
| 784 | } |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 785 | intptr = &options->max_startups; |
| 786 | goto parse_int; |
| 787 | |
Ben Lindstrom | 48bd7c1 | 2001-01-09 00:35:42 +0000 | [diff] [blame] | 788 | case sBanner: |
| 789 | charptr = &options->banner; |
| 790 | goto parse_filename; |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 791 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 792 | default: |
| 793 | fprintf(stderr, "%s line %d: Missing handler for opcode %s (%d)\n", |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 794 | filename, linenum, arg, opcode); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 795 | exit(1); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 796 | } |
Damien Miller | be484b5 | 2000-07-15 14:14:16 +1000 | [diff] [blame] | 797 | if ((arg = strdelim(&cp)) != NULL && *arg != '\0') { |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 798 | fprintf(stderr, |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 799 | "%s line %d: garbage at end of line; \"%.200s\".\n", |
| 800 | filename, linenum, arg); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 801 | exit(1); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 802 | } |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 803 | } |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 804 | fclose(f); |
| 805 | if (bad_options > 0) { |
| 806 | fprintf(stderr, "%s: terminating, %d bad configuration options\n", |
| 807 | filename, bad_options); |
| 808 | exit(1); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 809 | } |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 810 | } |