blob: b90dba63b0c170ff1c514dcf1f730061fbedc0fe [file] [log] [blame]
Darren Tuckerfbcf8272012-05-19 19:37:01 +10001
Damien Millera6e3f012012-11-04 23:21:40 +11002/* $OpenBSD: servconf.c,v 1.232 2012/11/04 11:09:15 djm Exp $ */
Damien Millerd4a8b7e1999-10-27 13:42:43 +10003/*
Damien Miller95def091999-11-25 00:26:21 +11004 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * All rights reserved
Damien Miller4af51302000-04-16 11:18:38 +10006 *
Damien Millere4340be2000-09-16 13:29:08 +11007 * As far as I am concerned, the code I have written for this software
8 * can be used freely for any purpose. Any derived versions of this
9 * software must be clearly marked as such, and if the derived work is
10 * incompatible with the protocol description in the RFC file, it must be
11 * called by a name other than "ssh" or "Secure Shell".
Damien Miller95def091999-11-25 00:26:21 +110012 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +100013
14#include "includes.h"
Damien Millerd4a8b7e1999-10-27 13:42:43 +100015
Damien Millere3b60b52006-07-10 21:08:03 +100016#include <sys/types.h>
17#include <sys/socket.h>
18
Damien Miller0dac6fb2010-11-20 15:19:38 +110019#include <netinet/in.h>
20#include <netinet/in_systm.h>
21#include <netinet/ip.h>
22
Damien Millerb8fe89c2006-07-24 14:51:00 +100023#include <netdb.h>
Damien Miller565ca3f2006-08-19 00:23:15 +100024#include <pwd.h>
Damien Millera7a73ee2006-08-05 11:37:59 +100025#include <stdio.h>
Damien Millere7a1e5c2006-08-05 11:34:19 +100026#include <stdlib.h>
Damien Millere3476ed2006-07-24 14:13:33 +100027#include <string.h>
Damien Millerd7834352006-08-05 12:39:39 +100028#include <signal.h>
Damien Millere6b3b612006-07-24 14:01:23 +100029#include <unistd.h>
Damien Millerd7834352006-08-05 12:39:39 +100030#include <stdarg.h>
Darren Tuckere7140f22008-06-10 23:01:51 +100031#include <errno.h>
Damien Millerbe43ebf2006-07-24 13:51:51 +100032
Damien Millerb84886b2008-05-19 15:05:07 +100033#include "openbsd-compat/sys-queue.h"
Damien Millerd7834352006-08-05 12:39:39 +100034#include "xmalloc.h"
Damien Millerd4a8b7e1999-10-27 13:42:43 +100035#include "ssh.h"
Ben Lindstrom226cfa02001-01-22 05:34:40 +000036#include "log.h"
Damien Millerd7834352006-08-05 12:39:39 +100037#include "buffer.h"
Damien Millerd4a8b7e1999-10-27 13:42:43 +100038#include "servconf.h"
Damien Miller78928792000-04-12 20:17:38 +100039#include "compat.h"
Ben Lindstrom226cfa02001-01-22 05:34:40 +000040#include "pathnames.h"
Ben Lindstrom226cfa02001-01-22 05:34:40 +000041#include "misc.h"
42#include "cipher.h"
Damien Millerd7834352006-08-05 12:39:39 +100043#include "key.h"
Ben Lindstrom06b33aa2001-02-15 03:01:59 +000044#include "kex.h"
45#include "mac.h"
Darren Tucker45150472006-07-12 22:34:17 +100046#include "match.h"
Damien Miller9b439df2006-07-24 14:04:00 +100047#include "channels.h"
Damien Miller565ca3f2006-08-19 00:23:15 +100048#include "groupaccess.h"
Darren Tuckerfbcf8272012-05-19 19:37:01 +100049#include "canohost.h"
50#include "packet.h"
Damien Millera6e3f012012-11-04 23:21:40 +110051#include "hostfile.h"
52#include "auth.h"
Ben Lindstrom226cfa02001-01-22 05:34:40 +000053
Damien Miller3dc71ad2009-01-28 16:31:22 +110054static void add_listen_addr(ServerOptions *, char *, int);
55static void add_one_listen_addr(ServerOptions *, char *, int);
Damien Miller34132e52000-01-14 15:45:46 +110056
Ben Lindstrom7a2073c2002-03-22 02:30:41 +000057/* Use of privilege separation or not */
58extern int use_privsep;
Darren Tucker45150472006-07-12 22:34:17 +100059extern Buffer cfg;
Ben Lindstrom226cfa02001-01-22 05:34:40 +000060
Damien Millerd4a8b7e1999-10-27 13:42:43 +100061/* Initializes the server options to their default values. */
62
Damien Miller4af51302000-04-16 11:18:38 +100063void
Damien Miller95def091999-11-25 00:26:21 +110064initialize_server_options(ServerOptions *options)
Damien Millerd4a8b7e1999-10-27 13:42:43 +100065{
Damien Miller95def091999-11-25 00:26:21 +110066 memset(options, 0, sizeof(*options));
Damien Miller726273e2001-11-12 11:40:11 +110067
68 /* Portable-specific options */
Damien Miller4e448a32003-05-14 15:11:48 +100069 options->use_pam = -1;
Damien Miller726273e2001-11-12 11:40:11 +110070
71 /* Standard Options */
Damien Miller34132e52000-01-14 15:45:46 +110072 options->num_ports = 0;
73 options->ports_from_cmdline = 0;
74 options->listen_addrs = NULL;
Darren Tucker0f383232005-01-20 10:57:56 +110075 options->address_family = -1;
Damien Miller0bc1bd82000-11-13 22:57:25 +110076 options->num_host_key_files = 0;
Damien Miller0a80ca12010-02-27 07:55:05 +110077 options->num_host_cert_files = 0;
Damien Miller6f83b8e2000-05-02 09:23:45 +100078 options->pid_file = NULL;
Damien Miller95def091999-11-25 00:26:21 +110079 options->server_key_bits = -1;
80 options->login_grace_time = -1;
81 options->key_regeneration_time = -1;
Ben Lindstromd8a90212001-02-15 03:08:27 +000082 options->permit_root_login = PERMIT_NOT_SET;
Damien Miller95def091999-11-25 00:26:21 +110083 options->ignore_rhosts = -1;
84 options->ignore_user_known_hosts = -1;
85 options->print_motd = -1;
Ben Lindstrom7bfff362001-03-26 05:45:53 +000086 options->print_lastlog = -1;
Damien Miller95def091999-11-25 00:26:21 +110087 options->x11_forwarding = -1;
88 options->x11_display_offset = -1;
Damien Miller95c249f2002-02-05 12:11:34 +110089 options->x11_use_localhost = -1;
Damien Millerd3a18572000-06-07 19:55:44 +100090 options->xauth_location = NULL;
Damien Miller95def091999-11-25 00:26:21 +110091 options->strict_modes = -1;
Damien Miller12c150e2003-12-17 16:31:10 +110092 options->tcp_keep_alive = -1;
Damien Millerfcd93202002-02-05 12:26:34 +110093 options->log_facility = SYSLOG_FACILITY_NOT_SET;
94 options->log_level = SYSLOG_LEVEL_NOT_SET;
Damien Miller95def091999-11-25 00:26:21 +110095 options->rhosts_rsa_authentication = -1;
Ben Lindstrom5eabda32001-04-12 23:34:34 +000096 options->hostbased_authentication = -1;
97 options->hostbased_uses_name_from_packet_only = -1;
Damien Miller95def091999-11-25 00:26:21 +110098 options->rsa_authentication = -1;
Damien Miller0bc1bd82000-11-13 22:57:25 +110099 options->pubkey_authentication = -1;
Damien Miller95def091999-11-25 00:26:21 +1100100 options->kerberos_authentication = -1;
101 options->kerberos_or_local_passwd = -1;
102 options->kerberos_ticket_cleanup = -1;
Darren Tucker22ef5082003-12-31 11:37:34 +1100103 options->kerberos_get_afs_token = -1;
Darren Tucker0efd1552003-08-26 11:49:55 +1000104 options->gss_authentication=-1;
105 options->gss_cleanup_creds = -1;
Damien Miller95def091999-11-25 00:26:21 +1100106 options->password_authentication = -1;
Damien Miller874d77b2000-10-14 16:23:11 +1100107 options->kbd_interactive_authentication = -1;
Ben Lindstrom551ea372001-06-05 18:56:16 +0000108 options->challenge_response_authentication = -1;
Damien Miller95def091999-11-25 00:26:21 +1100109 options->permit_empty_passwd = -1;
Ben Lindstrom5d860f02002-08-01 01:28:38 +0000110 options->permit_user_env = -1;
Damien Miller95def091999-11-25 00:26:21 +1100111 options->use_login = -1;
Ben Lindstrom23e0f662002-06-21 01:09:47 +0000112 options->compression = -1;
Damien Miller50a41ed2000-10-16 12:14:42 +1100113 options->allow_tcp_forwarding = -1;
Damien Miller4f755cd2008-05-19 14:57:41 +1000114 options->allow_agent_forwarding = -1;
Damien Miller95def091999-11-25 00:26:21 +1100115 options->num_allow_users = 0;
116 options->num_deny_users = 0;
117 options->num_allow_groups = 0;
118 options->num_deny_groups = 0;
Damien Miller78928792000-04-12 20:17:38 +1000119 options->ciphers = NULL;
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000120 options->macs = NULL;
Damien Millerd5f62bf2010-09-24 22:11:14 +1000121 options->kex_algorithms = NULL;
Damien Miller78928792000-04-12 20:17:38 +1000122 options->protocol = SSH_PROTO_UNKNOWN;
Damien Millere247cc42000-05-07 12:03:14 +1000123 options->gateway_ports = -1;
Damien Millerf6d9e222000-06-18 14:50:44 +1000124 options->num_subsystems = 0;
Damien Miller942da032000-08-18 13:59:06 +1000125 options->max_startups_begin = -1;
126 options->max_startups_rate = -1;
Damien Miller37023962000-07-11 17:31:38 +1000127 options->max_startups = -1;
Darren Tucker89413db2004-05-24 10:36:23 +1000128 options->max_authtries = -1;
Damien Miller7207f642008-05-19 15:34:50 +1000129 options->max_sessions = -1;
Ben Lindstrom48bd7c12001-01-09 00:35:42 +0000130 options->banner = NULL;
Damien Miller3a961dc2003-06-03 10:25:48 +1000131 options->use_dns = -1;
Ben Lindstrom5744dc42001-04-13 23:28:01 +0000132 options->client_alive_interval = -1;
133 options->client_alive_count_max = -1;
Damien Millerd8478b62011-05-29 21:39:36 +1000134 options->num_authkeys_files = 0;
Darren Tucker46bc0752004-05-02 22:11:30 +1000135 options->num_accept_env = 0;
Damien Millerd27b9472005-12-13 19:29:02 +1100136 options->permit_tun = -1;
Damien Millera765cf42006-07-24 14:08:13 +1000137 options->num_permitted_opens = -1;
Damien Millere2754432006-07-24 14:06:47 +1000138 options->adm_forced_command = NULL;
Damien Millerd8cb1f12008-02-10 22:40:12 +1100139 options->chroot_directory = NULL;
Damien Miller09d3e122012-10-31 08:58:58 +1100140 options->authorized_keys_command = NULL;
141 options->authorized_keys_command_user = NULL;
Damien Miller01ed2272008-11-05 16:20:46 +1100142 options->zero_knowledge_password_authentication = -1;
Damien Miller1aed65e2010-03-04 21:53:35 +1100143 options->revoked_keys_file = NULL;
144 options->trusted_user_ca_keys = NULL;
Damien Miller30da3442010-05-10 11:58:03 +1000145 options->authorized_principals_file = NULL;
Damien Miller0dac6fb2010-11-20 15:19:38 +1100146 options->ip_qos_interactive = -1;
147 options->ip_qos_bulk = -1;
Damien Miller23528812012-04-22 11:24:43 +1000148 options->version_addendum = NULL;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000149}
150
Damien Miller4af51302000-04-16 11:18:38 +1000151void
Damien Miller95def091999-11-25 00:26:21 +1100152fill_default_server_options(ServerOptions *options)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000153{
Damien Miller726273e2001-11-12 11:40:11 +1100154 /* Portable-specific options */
Damien Miller4e448a32003-05-14 15:11:48 +1000155 if (options->use_pam == -1)
Damien Miller5c3a5582003-09-23 22:12:38 +1000156 options->use_pam = 0;
Damien Miller726273e2001-11-12 11:40:11 +1100157
158 /* Standard Options */
Damien Miller0bc1bd82000-11-13 22:57:25 +1100159 if (options->protocol == SSH_PROTO_UNKNOWN)
Darren Tuckerbad50762009-10-11 21:51:08 +1100160 options->protocol = SSH_PROTO_2;
Damien Miller0bc1bd82000-11-13 22:57:25 +1100161 if (options->num_host_key_files == 0) {
162 /* fill default hostkeys for protocols */
163 if (options->protocol & SSH_PROTO_1)
Damien Miller7fc23732002-01-22 23:19:11 +1100164 options->host_key_files[options->num_host_key_files++] =
165 _PATH_HOST_KEY_FILE;
166 if (options->protocol & SSH_PROTO_2) {
167 options->host_key_files[options->num_host_key_files++] =
168 _PATH_HOST_RSA_KEY_FILE;
169 options->host_key_files[options->num_host_key_files++] =
170 _PATH_HOST_DSA_KEY_FILE;
Damien Millerdd190dd2010-11-11 14:17:02 +1100171#ifdef OPENSSL_HAS_ECC
Damien Millere13cadf2010-09-10 11:15:33 +1000172 options->host_key_files[options->num_host_key_files++] =
173 _PATH_HOST_ECDSA_KEY_FILE;
Damien Millerdd190dd2010-11-11 14:17:02 +1100174#endif
Damien Miller7fc23732002-01-22 23:19:11 +1100175 }
Damien Miller0bc1bd82000-11-13 22:57:25 +1100176 }
Damien Miller0a80ca12010-02-27 07:55:05 +1100177 /* No certificates by default */
Damien Miller34132e52000-01-14 15:45:46 +1100178 if (options->num_ports == 0)
179 options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
180 if (options->listen_addrs == NULL)
Ben Lindstrom19066a12001-04-12 23:39:26 +0000181 add_listen_addr(options, NULL, 0);
Damien Miller6f83b8e2000-05-02 09:23:45 +1000182 if (options->pid_file == NULL)
Ben Lindstrom226cfa02001-01-22 05:34:40 +0000183 options->pid_file = _PATH_SSH_DAEMON_PID_FILE;
Damien Miller95def091999-11-25 00:26:21 +1100184 if (options->server_key_bits == -1)
Darren Tucker7499b0c2008-07-02 22:35:43 +1000185 options->server_key_bits = 1024;
Damien Miller95def091999-11-25 00:26:21 +1100186 if (options->login_grace_time == -1)
Damien Millerc1348632002-09-05 14:35:14 +1000187 options->login_grace_time = 120;
Damien Miller95def091999-11-25 00:26:21 +1100188 if (options->key_regeneration_time == -1)
189 options->key_regeneration_time = 3600;
Ben Lindstromd8a90212001-02-15 03:08:27 +0000190 if (options->permit_root_login == PERMIT_NOT_SET)
191 options->permit_root_login = PERMIT_YES;
Damien Miller95def091999-11-25 00:26:21 +1100192 if (options->ignore_rhosts == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100193 options->ignore_rhosts = 1;
Damien Miller95def091999-11-25 00:26:21 +1100194 if (options->ignore_user_known_hosts == -1)
195 options->ignore_user_known_hosts = 0;
Damien Miller95def091999-11-25 00:26:21 +1100196 if (options->print_motd == -1)
197 options->print_motd = 1;
Ben Lindstrom7bfff362001-03-26 05:45:53 +0000198 if (options->print_lastlog == -1)
199 options->print_lastlog = 1;
Damien Miller95def091999-11-25 00:26:21 +1100200 if (options->x11_forwarding == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100201 options->x11_forwarding = 0;
Damien Miller95def091999-11-25 00:26:21 +1100202 if (options->x11_display_offset == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100203 options->x11_display_offset = 10;
Damien Miller95c249f2002-02-05 12:11:34 +1100204 if (options->x11_use_localhost == -1)
205 options->x11_use_localhost = 1;
Damien Millerd3a18572000-06-07 19:55:44 +1000206 if (options->xauth_location == NULL)
Ben Lindstrom1bf11f62001-06-09 01:48:01 +0000207 options->xauth_location = _PATH_XAUTH;
Damien Miller95def091999-11-25 00:26:21 +1100208 if (options->strict_modes == -1)
209 options->strict_modes = 1;
Damien Miller12c150e2003-12-17 16:31:10 +1100210 if (options->tcp_keep_alive == -1)
211 options->tcp_keep_alive = 1;
Damien Millerfcd93202002-02-05 12:26:34 +1100212 if (options->log_facility == SYSLOG_FACILITY_NOT_SET)
Damien Miller95def091999-11-25 00:26:21 +1100213 options->log_facility = SYSLOG_FACILITY_AUTH;
Damien Millerfcd93202002-02-05 12:26:34 +1100214 if (options->log_level == SYSLOG_LEVEL_NOT_SET)
Ben Lindstromdb65e8f2001-01-19 04:26:52 +0000215 options->log_level = SYSLOG_LEVEL_INFO;
Damien Miller95def091999-11-25 00:26:21 +1100216 if (options->rhosts_rsa_authentication == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100217 options->rhosts_rsa_authentication = 0;
Ben Lindstrom5eabda32001-04-12 23:34:34 +0000218 if (options->hostbased_authentication == -1)
219 options->hostbased_authentication = 0;
220 if (options->hostbased_uses_name_from_packet_only == -1)
221 options->hostbased_uses_name_from_packet_only = 0;
Damien Miller95def091999-11-25 00:26:21 +1100222 if (options->rsa_authentication == -1)
223 options->rsa_authentication = 1;
Damien Miller0bc1bd82000-11-13 22:57:25 +1100224 if (options->pubkey_authentication == -1)
225 options->pubkey_authentication = 1;
Damien Miller95def091999-11-25 00:26:21 +1100226 if (options->kerberos_authentication == -1)
Damien Millerd7de14b2002-04-23 21:04:51 +1000227 options->kerberos_authentication = 0;
Damien Miller95def091999-11-25 00:26:21 +1100228 if (options->kerberos_or_local_passwd == -1)
229 options->kerberos_or_local_passwd = 1;
230 if (options->kerberos_ticket_cleanup == -1)
231 options->kerberos_ticket_cleanup = 1;
Darren Tucker22ef5082003-12-31 11:37:34 +1100232 if (options->kerberos_get_afs_token == -1)
233 options->kerberos_get_afs_token = 0;
Darren Tucker0efd1552003-08-26 11:49:55 +1000234 if (options->gss_authentication == -1)
235 options->gss_authentication = 0;
236 if (options->gss_cleanup_creds == -1)
237 options->gss_cleanup_creds = 1;
Damien Miller95def091999-11-25 00:26:21 +1100238 if (options->password_authentication == -1)
239 options->password_authentication = 1;
Damien Miller874d77b2000-10-14 16:23:11 +1100240 if (options->kbd_interactive_authentication == -1)
241 options->kbd_interactive_authentication = 0;
Ben Lindstrom551ea372001-06-05 18:56:16 +0000242 if (options->challenge_response_authentication == -1)
243 options->challenge_response_authentication = 1;
Damien Miller95def091999-11-25 00:26:21 +1100244 if (options->permit_empty_passwd == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100245 options->permit_empty_passwd = 0;
Ben Lindstrom5d860f02002-08-01 01:28:38 +0000246 if (options->permit_user_env == -1)
247 options->permit_user_env = 0;
Damien Miller95def091999-11-25 00:26:21 +1100248 if (options->use_login == -1)
249 options->use_login = 0;
Ben Lindstrom23e0f662002-06-21 01:09:47 +0000250 if (options->compression == -1)
Damien Miller9786e6e2005-07-26 21:54:56 +1000251 options->compression = COMP_DELAYED;
Damien Miller50a41ed2000-10-16 12:14:42 +1100252 if (options->allow_tcp_forwarding == -1)
253 options->allow_tcp_forwarding = 1;
Damien Miller4f755cd2008-05-19 14:57:41 +1000254 if (options->allow_agent_forwarding == -1)
255 options->allow_agent_forwarding = 1;
Damien Millere247cc42000-05-07 12:03:14 +1000256 if (options->gateway_ports == -1)
257 options->gateway_ports = 0;
Damien Miller37023962000-07-11 17:31:38 +1000258 if (options->max_startups == -1)
259 options->max_startups = 10;
Damien Miller942da032000-08-18 13:59:06 +1000260 if (options->max_startups_rate == -1)
261 options->max_startups_rate = 100; /* 100% */
262 if (options->max_startups_begin == -1)
263 options->max_startups_begin = options->max_startups;
Darren Tucker89413db2004-05-24 10:36:23 +1000264 if (options->max_authtries == -1)
265 options->max_authtries = DEFAULT_AUTH_FAIL_MAX;
Damien Miller7207f642008-05-19 15:34:50 +1000266 if (options->max_sessions == -1)
267 options->max_sessions = DEFAULT_SESSIONS_MAX;
Damien Miller3a961dc2003-06-03 10:25:48 +1000268 if (options->use_dns == -1)
269 options->use_dns = 1;
Ben Lindstrom5744dc42001-04-13 23:28:01 +0000270 if (options->client_alive_interval == -1)
Damien Miller9f0f5c62001-12-21 14:45:46 +1100271 options->client_alive_interval = 0;
Ben Lindstrom5744dc42001-04-13 23:28:01 +0000272 if (options->client_alive_count_max == -1)
273 options->client_alive_count_max = 3;
Damien Millerd8478b62011-05-29 21:39:36 +1000274 if (options->num_authkeys_files == 0) {
275 options->authorized_keys_files[options->num_authkeys_files++] =
276 xstrdup(_PATH_SSH_USER_PERMITTED_KEYS);
277 options->authorized_keys_files[options->num_authkeys_files++] =
278 xstrdup(_PATH_SSH_USER_PERMITTED_KEYS2);
279 }
Damien Millerd27b9472005-12-13 19:29:02 +1100280 if (options->permit_tun == -1)
Damien Miller7b58e802005-12-13 19:33:19 +1100281 options->permit_tun = SSH_TUNMODE_NO;
Damien Miller01ed2272008-11-05 16:20:46 +1100282 if (options->zero_knowledge_password_authentication == -1)
283 options->zero_knowledge_password_authentication = 0;
Damien Miller0dac6fb2010-11-20 15:19:38 +1100284 if (options->ip_qos_interactive == -1)
285 options->ip_qos_interactive = IPTOS_LOWDELAY;
286 if (options->ip_qos_bulk == -1)
287 options->ip_qos_bulk = IPTOS_THROUGHPUT;
Damien Miller23528812012-04-22 11:24:43 +1000288 if (options->version_addendum == NULL)
289 options->version_addendum = xstrdup("");
Ben Lindstromfb62a692002-06-06 19:47:11 +0000290 /* Turn privilege separation on by default */
Ben Lindstrom7a2073c2002-03-22 02:30:41 +0000291 if (use_privsep == -1)
Damien Miller5a5c2b92012-07-31 12:21:34 +1000292 use_privsep = PRIVSEP_NOSANDBOX;
Damien Miller4903eb42002-06-21 16:20:44 +1000293
Tim Rice40017b02002-07-14 13:36:49 -0700294#ifndef HAVE_MMAP
Damien Miller4903eb42002-06-21 16:20:44 +1000295 if (use_privsep && options->compression == 1) {
296 error("This platform does not support both privilege "
297 "separation and compression");
298 error("Compression disabled");
299 options->compression = 0;
300 }
301#endif
302
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000303}
304
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000305/* Keyword tokens. */
Damien Miller95def091999-11-25 00:26:21 +1100306typedef enum {
307 sBadOption, /* == unknown option */
Damien Miller726273e2001-11-12 11:40:11 +1100308 /* Portable-specific options */
Damien Miller4e448a32003-05-14 15:11:48 +1000309 sUsePAM,
Damien Miller726273e2001-11-12 11:40:11 +1100310 /* Standard Options */
Damien Miller95def091999-11-25 00:26:21 +1100311 sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime, sKeyRegenerationTime,
312 sPermitRootLogin, sLogFacility, sLogLevel,
Darren Tuckerec960f22003-08-13 20:37:05 +1000313 sRhostsRSAAuthentication, sRSAAuthentication,
Damien Miller95def091999-11-25 00:26:21 +1100314 sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup,
Darren Tucker22ef5082003-12-31 11:37:34 +1100315 sKerberosGetAFSToken,
Darren Tucker6aaa58c2003-08-02 22:24:49 +1000316 sKerberosTgtPassing, sChallengeResponseAuthentication,
Darren Tucker0f383232005-01-20 10:57:56 +1100317 sPasswordAuthentication, sKbdInteractiveAuthentication,
318 sListenAddress, sAddressFamily,
Ben Lindstrom7bfff362001-03-26 05:45:53 +0000319 sPrintMotd, sPrintLastLog, sIgnoreRhosts,
Damien Miller95c249f2002-02-05 12:11:34 +1100320 sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost,
Damien Miller12c150e2003-12-17 16:31:10 +1100321 sStrictModes, sEmptyPasswd, sTCPKeepAlive,
Ben Lindstrom5d860f02002-08-01 01:28:38 +0000322 sPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression,
Damien Miller50a41ed2000-10-16 12:14:42 +1100323 sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000324 sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile,
Darren Tucker89413db2004-05-24 10:36:23 +1000325 sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem,
Damien Miller7207f642008-05-19 15:34:50 +1000326 sMaxStartups, sMaxAuthTries, sMaxSessions,
Damien Miller3a961dc2003-06-03 10:25:48 +1000327 sBanner, sUseDNS, sHostbasedAuthentication,
Damien Miller9f0f5c62001-12-21 14:45:46 +1100328 sHostbasedUsesNameFromPacketOnly, sClientAliveInterval,
Damien Millerec2eaa32011-05-20 18:57:14 +1000329 sClientAliveCountMax, sAuthorizedKeysFile,
Damien Millerd27b9472005-12-13 19:29:02 +1100330 sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel,
Damien Millerd8cb1f12008-02-10 22:40:12 +1100331 sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
Darren Tucker7bd98e72010-01-10 10:31:12 +1100332 sUsePrivilegeSeparation, sAllowAgentForwarding,
Damien Miller0a80ca12010-02-27 07:55:05 +1100333 sZeroKnowledgePasswordAuthentication, sHostCertificate,
Damien Miller30da3442010-05-10 11:58:03 +1000334 sRevokedKeys, sTrustedUserCAKeys, sAuthorizedPrincipalsFile,
Damien Miller23528812012-04-22 11:24:43 +1000335 sKexAlgorithms, sIPQoS, sVersionAddendum,
Damien Miller09d3e122012-10-31 08:58:58 +1100336 sAuthorizedKeysCommand, sAuthorizedKeysCommandUser,
Damien Millera6e3f012012-11-04 23:21:40 +1100337 sAuthenticationMethods,
Damien Millerf9b3feb2003-05-16 11:38:32 +1000338 sDeprecated, sUnsupported
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000339} ServerOpCodes;
340
Darren Tucker45150472006-07-12 22:34:17 +1000341#define SSHCFG_GLOBAL 0x01 /* allowed in main section of sshd_config */
342#define SSHCFG_MATCH 0x02 /* allowed inside a Match section */
343#define SSHCFG_ALL (SSHCFG_GLOBAL|SSHCFG_MATCH)
344
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000345/* Textual representation of the tokens. */
Damien Miller95def091999-11-25 00:26:21 +1100346static struct {
347 const char *name;
348 ServerOpCodes opcode;
Darren Tucker45150472006-07-12 22:34:17 +1000349 u_int flags;
Damien Miller95def091999-11-25 00:26:21 +1100350} keywords[] = {
Damien Miller726273e2001-11-12 11:40:11 +1100351 /* Portable-specific options */
Damien Miller6ac2c482003-05-16 11:42:35 +1000352#ifdef USE_PAM
Darren Tucker45150472006-07-12 22:34:17 +1000353 { "usepam", sUsePAM, SSHCFG_GLOBAL },
Damien Miller6ac2c482003-05-16 11:42:35 +1000354#else
Darren Tucker45150472006-07-12 22:34:17 +1000355 { "usepam", sUnsupported, SSHCFG_GLOBAL },
Damien Miller6ac2c482003-05-16 11:42:35 +1000356#endif
Darren Tucker45150472006-07-12 22:34:17 +1000357 { "pamauthenticationviakbdint", sDeprecated, SSHCFG_GLOBAL },
Damien Miller726273e2001-11-12 11:40:11 +1100358 /* Standard Options */
Darren Tucker45150472006-07-12 22:34:17 +1000359 { "port", sPort, SSHCFG_GLOBAL },
360 { "hostkey", sHostKeyFile, SSHCFG_GLOBAL },
361 { "hostdsakey", sHostKeyFile, SSHCFG_GLOBAL }, /* alias */
362 { "pidfile", sPidFile, SSHCFG_GLOBAL },
363 { "serverkeybits", sServerKeyBits, SSHCFG_GLOBAL },
364 { "logingracetime", sLoginGraceTime, SSHCFG_GLOBAL },
365 { "keyregenerationinterval", sKeyRegenerationTime, SSHCFG_GLOBAL },
Darren Tucker15f94272008-01-01 20:36:56 +1100366 { "permitrootlogin", sPermitRootLogin, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000367 { "syslogfacility", sLogFacility, SSHCFG_GLOBAL },
368 { "loglevel", sLogLevel, SSHCFG_GLOBAL },
369 { "rhostsauthentication", sDeprecated, SSHCFG_GLOBAL },
Darren Tucker1629c072007-02-19 22:25:37 +1100370 { "rhostsrsaauthentication", sRhostsRSAAuthentication, SSHCFG_ALL },
371 { "hostbasedauthentication", sHostbasedAuthentication, SSHCFG_ALL },
Damien Millerab6de352010-06-26 09:38:45 +1000372 { "hostbasedusesnamefrompacketonly", sHostbasedUsesNameFromPacketOnly, SSHCFG_ALL },
Darren Tucker1629c072007-02-19 22:25:37 +1100373 { "rsaauthentication", sRSAAuthentication, SSHCFG_ALL },
374 { "pubkeyauthentication", sPubkeyAuthentication, SSHCFG_ALL },
Darren Tucker64cee362009-06-21 20:26:17 +1000375 { "dsaauthentication", sPubkeyAuthentication, SSHCFG_GLOBAL }, /* alias */
Darren Tucker6aaa58c2003-08-02 22:24:49 +1000376#ifdef KRB5
Darren Tucker1629c072007-02-19 22:25:37 +1100377 { "kerberosauthentication", sKerberosAuthentication, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000378 { "kerberosorlocalpasswd", sKerberosOrLocalPasswd, SSHCFG_GLOBAL },
379 { "kerberosticketcleanup", sKerberosTicketCleanup, SSHCFG_GLOBAL },
Darren Tucker3c78c5e2004-01-23 22:03:10 +1100380#ifdef USE_AFS
Darren Tucker45150472006-07-12 22:34:17 +1000381 { "kerberosgetafstoken", sKerberosGetAFSToken, SSHCFG_GLOBAL },
Damien Millerf9b3feb2003-05-16 11:38:32 +1000382#else
Darren Tucker45150472006-07-12 22:34:17 +1000383 { "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL },
Darren Tucker409cb322004-01-05 22:36:51 +1100384#endif
385#else
Darren Tucker1629c072007-02-19 22:25:37 +1100386 { "kerberosauthentication", sUnsupported, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000387 { "kerberosorlocalpasswd", sUnsupported, SSHCFG_GLOBAL },
388 { "kerberosticketcleanup", sUnsupported, SSHCFG_GLOBAL },
389 { "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL },
Damien Millerf9b3feb2003-05-16 11:38:32 +1000390#endif
Darren Tucker45150472006-07-12 22:34:17 +1000391 { "kerberostgtpassing", sUnsupported, SSHCFG_GLOBAL },
392 { "afstokenpassing", sUnsupported, SSHCFG_GLOBAL },
Darren Tucker0efd1552003-08-26 11:49:55 +1000393#ifdef GSSAPI
Darren Tucker1629c072007-02-19 22:25:37 +1100394 { "gssapiauthentication", sGssAuthentication, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000395 { "gssapicleanupcredentials", sGssCleanupCreds, SSHCFG_GLOBAL },
Darren Tucker0efd1552003-08-26 11:49:55 +1000396#else
Darren Tucker1629c072007-02-19 22:25:37 +1100397 { "gssapiauthentication", sUnsupported, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000398 { "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
Darren Tucker0efd1552003-08-26 11:49:55 +1000399#endif
Darren Tucker1629c072007-02-19 22:25:37 +1100400 { "passwordauthentication", sPasswordAuthentication, SSHCFG_ALL },
401 { "kbdinteractiveauthentication", sKbdInteractiveAuthentication, SSHCFG_ALL },
Darren Tucker1d75f222007-03-01 21:31:28 +1100402 { "challengeresponseauthentication", sChallengeResponseAuthentication, SSHCFG_GLOBAL },
Darren Tucker45150472006-07-12 22:34:17 +1000403 { "skeyauthentication", sChallengeResponseAuthentication, SSHCFG_GLOBAL }, /* alias */
Damien Miller01ed2272008-11-05 16:20:46 +1100404#ifdef JPAKE
405 { "zeroknowledgepasswordauthentication", sZeroKnowledgePasswordAuthentication, SSHCFG_ALL },
406#else
407 { "zeroknowledgepasswordauthentication", sUnsupported, SSHCFG_ALL },
408#endif
Darren Tucker45150472006-07-12 22:34:17 +1000409 { "checkmail", sDeprecated, SSHCFG_GLOBAL },
410 { "listenaddress", sListenAddress, SSHCFG_GLOBAL },
411 { "addressfamily", sAddressFamily, SSHCFG_GLOBAL },
412 { "printmotd", sPrintMotd, SSHCFG_GLOBAL },
413 { "printlastlog", sPrintLastLog, SSHCFG_GLOBAL },
414 { "ignorerhosts", sIgnoreRhosts, SSHCFG_GLOBAL },
415 { "ignoreuserknownhosts", sIgnoreUserKnownHosts, SSHCFG_GLOBAL },
Damien Millerd1de9952006-07-24 14:05:48 +1000416 { "x11forwarding", sX11Forwarding, SSHCFG_ALL },
417 { "x11displayoffset", sX11DisplayOffset, SSHCFG_ALL },
418 { "x11uselocalhost", sX11UseLocalhost, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000419 { "xauthlocation", sXAuthLocation, SSHCFG_GLOBAL },
420 { "strictmodes", sStrictModes, SSHCFG_GLOBAL },
Damien Miller51bde602008-11-03 19:23:10 +1100421 { "permitemptypasswords", sEmptyPasswd, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000422 { "permituserenvironment", sPermitUserEnvironment, SSHCFG_GLOBAL },
423 { "uselogin", sUseLogin, SSHCFG_GLOBAL },
424 { "compression", sCompression, SSHCFG_GLOBAL },
425 { "tcpkeepalive", sTCPKeepAlive, SSHCFG_GLOBAL },
426 { "keepalive", sTCPKeepAlive, SSHCFG_GLOBAL }, /* obsolete alias */
427 { "allowtcpforwarding", sAllowTcpForwarding, SSHCFG_ALL },
Damien Miller4f755cd2008-05-19 14:57:41 +1000428 { "allowagentforwarding", sAllowAgentForwarding, SSHCFG_ALL },
Damien Millerc24da772012-06-20 21:53:58 +1000429 { "allowusers", sAllowUsers, SSHCFG_ALL },
430 { "denyusers", sDenyUsers, SSHCFG_ALL },
431 { "allowgroups", sAllowGroups, SSHCFG_ALL },
432 { "denygroups", sDenyGroups, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000433 { "ciphers", sCiphers, SSHCFG_GLOBAL },
434 { "macs", sMacs, SSHCFG_GLOBAL },
435 { "protocol", sProtocol, SSHCFG_GLOBAL },
436 { "gatewayports", sGatewayPorts, SSHCFG_ALL },
437 { "subsystem", sSubsystem, SSHCFG_GLOBAL },
438 { "maxstartups", sMaxStartups, SSHCFG_GLOBAL },
Damien Miller307c1d12008-06-16 07:56:20 +1000439 { "maxauthtries", sMaxAuthTries, SSHCFG_ALL },
Damien Miller7207f642008-05-19 15:34:50 +1000440 { "maxsessions", sMaxSessions, SSHCFG_ALL },
Darren Tucker1629c072007-02-19 22:25:37 +1100441 { "banner", sBanner, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000442 { "usedns", sUseDNS, SSHCFG_GLOBAL },
443 { "verifyreversemapping", sDeprecated, SSHCFG_GLOBAL },
444 { "reversemappingcheck", sDeprecated, SSHCFG_GLOBAL },
445 { "clientaliveinterval", sClientAliveInterval, SSHCFG_GLOBAL },
446 { "clientalivecountmax", sClientAliveCountMax, SSHCFG_GLOBAL },
Damien Millerab6de352010-06-26 09:38:45 +1000447 { "authorizedkeysfile", sAuthorizedKeysFile, SSHCFG_ALL },
Damien Millerd8478b62011-05-29 21:39:36 +1000448 { "authorizedkeysfile2", sDeprecated, SSHCFG_ALL },
Darren Tucker64cee362009-06-21 20:26:17 +1000449 { "useprivilegeseparation", sUsePrivilegeSeparation, SSHCFG_GLOBAL},
Damien Millerc24da772012-06-20 21:53:58 +1000450 { "acceptenv", sAcceptEnv, SSHCFG_ALL },
Damien Millerab6de352010-06-26 09:38:45 +1000451 { "permittunnel", sPermitTunnel, SSHCFG_ALL },
Darren Tucker64cee362009-06-21 20:26:17 +1000452 { "match", sMatch, SSHCFG_ALL },
Damien Miller9b439df2006-07-24 14:04:00 +1000453 { "permitopen", sPermitOpen, SSHCFG_ALL },
Damien Millere2754432006-07-24 14:06:47 +1000454 { "forcecommand", sForceCommand, SSHCFG_ALL },
Damien Millerd8cb1f12008-02-10 22:40:12 +1100455 { "chrootdirectory", sChrootDirectory, SSHCFG_ALL },
Damien Miller0a80ca12010-02-27 07:55:05 +1100456 { "hostcertificate", sHostCertificate, SSHCFG_GLOBAL },
Damien Miller1aed65e2010-03-04 21:53:35 +1100457 { "revokedkeys", sRevokedKeys, SSHCFG_ALL },
458 { "trustedusercakeys", sTrustedUserCAKeys, SSHCFG_ALL },
Damien Millerab6de352010-06-26 09:38:45 +1000459 { "authorizedprincipalsfile", sAuthorizedPrincipalsFile, SSHCFG_ALL },
Damien Millerd5f62bf2010-09-24 22:11:14 +1000460 { "kexalgorithms", sKexAlgorithms, SSHCFG_GLOBAL },
Damien Miller0dac6fb2010-11-20 15:19:38 +1100461 { "ipqos", sIPQoS, SSHCFG_ALL },
Damien Miller09d3e122012-10-31 08:58:58 +1100462 { "authorizedkeyscommand", sAuthorizedKeysCommand, SSHCFG_ALL },
463 { "authorizedkeyscommanduser", sAuthorizedKeysCommandUser, SSHCFG_ALL },
Damien Miller23528812012-04-22 11:24:43 +1000464 { "versionaddendum", sVersionAddendum, SSHCFG_GLOBAL },
Damien Millera6e3f012012-11-04 23:21:40 +1100465 { "authenticationmethods", sAuthenticationMethods, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000466 { NULL, sBadOption, 0 }
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000467};
468
Darren Tuckere7140f22008-06-10 23:01:51 +1000469static struct {
470 int val;
471 char *text;
472} tunmode_desc[] = {
473 { SSH_TUNMODE_NO, "no" },
474 { SSH_TUNMODE_POINTOPOINT, "point-to-point" },
475 { SSH_TUNMODE_ETHERNET, "ethernet" },
476 { SSH_TUNMODE_YES, "yes" },
477 { -1, NULL }
478};
479
Damien Miller5428f641999-11-25 11:54:57 +1100480/*
Ben Lindstrom3704c262001-04-02 18:20:03 +0000481 * Returns the number of the token pointed to by cp or sBadOption.
Damien Miller5428f641999-11-25 11:54:57 +1100482 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000483
Damien Miller4af51302000-04-16 11:18:38 +1000484static ServerOpCodes
Damien Miller95def091999-11-25 00:26:21 +1100485parse_token(const char *cp, const char *filename,
Darren Tucker45150472006-07-12 22:34:17 +1000486 int linenum, u_int *flags)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000487{
Ben Lindstrom46c16222000-12-22 01:43:59 +0000488 u_int i;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000489
Damien Miller95def091999-11-25 00:26:21 +1100490 for (i = 0; keywords[i].name; i++)
Darren Tucker45150472006-07-12 22:34:17 +1000491 if (strcasecmp(cp, keywords[i].name) == 0) {
492 *flags = keywords[i].flags;
Damien Miller95def091999-11-25 00:26:21 +1100493 return keywords[i].opcode;
Darren Tucker45150472006-07-12 22:34:17 +1000494 }
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000495
Ben Lindstromb5cdc662001-04-16 02:13:26 +0000496 error("%s: line %d: Bad configuration option: %s",
497 filename, linenum, cp);
Damien Miller95def091999-11-25 00:26:21 +1100498 return sBadOption;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000499}
500
Darren Tucker88b6fb22010-01-13 22:44:29 +1100501char *
502derelativise_path(const char *path)
503{
Damien Miller44451d02010-03-26 10:40:04 +1100504 char *expanded, *ret, cwd[MAXPATHLEN];
Darren Tucker88b6fb22010-01-13 22:44:29 +1100505
506 expanded = tilde_expand_filename(path, getuid());
507 if (*expanded == '/')
508 return expanded;
Damien Miller44451d02010-03-26 10:40:04 +1100509 if (getcwd(cwd, sizeof(cwd)) == NULL)
Darren Tucker88b6fb22010-01-13 22:44:29 +1100510 fatal("%s: getcwd: %s", __func__, strerror(errno));
511 xasprintf(&ret, "%s/%s", cwd, expanded);
Darren Tucker88b6fb22010-01-13 22:44:29 +1100512 xfree(expanded);
513 return ret;
514}
515
Ben Lindstrombba81212001-06-25 05:01:22 +0000516static void
Damien Miller3dc71ad2009-01-28 16:31:22 +1100517add_listen_addr(ServerOptions *options, char *addr, int port)
Damien Miller34132e52000-01-14 15:45:46 +1100518{
Damien Millereccb9de2005-06-17 12:59:34 +1000519 u_int i;
Damien Miller34132e52000-01-14 15:45:46 +1100520
521 if (options->num_ports == 0)
522 options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
Darren Tucker0f383232005-01-20 10:57:56 +1100523 if (options->address_family == -1)
524 options->address_family = AF_UNSPEC;
Ben Lindstrom19066a12001-04-12 23:39:26 +0000525 if (port == 0)
Ben Lindstromc510af42001-04-07 17:25:48 +0000526 for (i = 0; i < options->num_ports; i++)
527 add_one_listen_addr(options, addr, options->ports[i]);
528 else
Ben Lindstrom19066a12001-04-12 23:39:26 +0000529 add_one_listen_addr(options, addr, port);
Ben Lindstromc510af42001-04-07 17:25:48 +0000530}
531
Ben Lindstrombba81212001-06-25 05:01:22 +0000532static void
Damien Miller3dc71ad2009-01-28 16:31:22 +1100533add_one_listen_addr(ServerOptions *options, char *addr, int port)
Ben Lindstromc510af42001-04-07 17:25:48 +0000534{
535 struct addrinfo hints, *ai, *aitop;
536 char strport[NI_MAXSERV];
537 int gaierr;
538
539 memset(&hints, 0, sizeof(hints));
Darren Tucker0f383232005-01-20 10:57:56 +1100540 hints.ai_family = options->address_family;
Ben Lindstromc510af42001-04-07 17:25:48 +0000541 hints.ai_socktype = SOCK_STREAM;
542 hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0;
Damien Miller3dc71ad2009-01-28 16:31:22 +1100543 snprintf(strport, sizeof strport, "%d", port);
Ben Lindstromc510af42001-04-07 17:25:48 +0000544 if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
545 fatal("bad addr or host: %s (%s)",
546 addr ? addr : "<NULL>",
Darren Tucker4abde772007-12-29 02:43:51 +1100547 ssh_gai_strerror(gaierr));
Ben Lindstromc510af42001-04-07 17:25:48 +0000548 for (ai = aitop; ai->ai_next; ai = ai->ai_next)
549 ;
550 ai->ai_next = options->listen_addrs;
551 options->listen_addrs = aitop;
Damien Miller34132e52000-01-14 15:45:46 +1100552}
553
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000554struct connection_info *
555get_connection_info(int populate, int use_dns)
556{
557 static struct connection_info ci;
558
559 if (!populate)
560 return &ci;
561 ci.host = get_canonical_hostname(use_dns);
562 ci.address = get_remote_ipaddr();
563 ci.laddress = get_local_ipaddr(packet_get_connection_in());
564 ci.lport = get_local_port();
565 return &ci;
566}
567
Darren Tucker45150472006-07-12 22:34:17 +1000568/*
569 * The strategy for the Match blocks is that the config file is parsed twice.
570 *
571 * The first time is at startup. activep is initialized to 1 and the
572 * directives in the global context are processed and acted on. Hitting a
573 * Match directive unsets activep and the directives inside the block are
574 * checked for syntax only.
575 *
576 * The second time is after a connection has been established but before
577 * authentication. activep is initialized to 2 and global config directives
578 * are ignored since they have already been processed. If the criteria in a
579 * Match block is met, activep is set and the subsequent directives
580 * processed and actioned until EOF or another Match block unsets it. Any
581 * options set are copied into the main server config.
582 *
583 * Potential additions/improvements:
584 * - Add Match support for pre-kex directives, eg Protocol, Ciphers.
585 *
586 * - Add a Tag directive (idea from David Leonard) ala pf, eg:
587 * Match Address 192.168.0.*
588 * Tag trusted
589 * Match Group wheel
590 * Tag trusted
591 * Match Tag trusted
592 * AllowTcpForwarding yes
593 * GatewayPorts clientspecified
594 * [...]
595 *
596 * - Add a PermittedChannelRequests directive
597 * Match Group shell
598 * PermittedChannelRequests session,forwarded-tcpip
599 */
600
601static int
Damien Miller565ca3f2006-08-19 00:23:15 +1000602match_cfg_line_group(const char *grps, int line, const char *user)
603{
604 int result = 0;
Damien Miller565ca3f2006-08-19 00:23:15 +1000605 struct passwd *pw;
606
Damien Miller565ca3f2006-08-19 00:23:15 +1000607 if (user == NULL)
608 goto out;
609
610 if ((pw = getpwnam(user)) == NULL) {
611 debug("Can't match group at line %d because user %.100s does "
612 "not exist", line, user);
613 } else if (ga_init(pw->pw_name, pw->pw_gid) == 0) {
614 debug("Can't Match group because user %.100s not in any group "
615 "at line %d", user, line);
Darren Tuckerb03fd022008-07-04 13:51:12 +1000616 } else if (ga_match_pattern_list(grps) != 1) {
617 debug("user %.100s does not match group list %.100s at line %d",
618 user, grps, line);
Damien Miller565ca3f2006-08-19 00:23:15 +1000619 } else {
Darren Tuckerb03fd022008-07-04 13:51:12 +1000620 debug("user %.100s matched group list %.100s at line %d", user,
621 grps, line);
Damien Miller565ca3f2006-08-19 00:23:15 +1000622 result = 1;
623 }
624out:
625 ga_free();
Damien Miller565ca3f2006-08-19 00:23:15 +1000626 return result;
627}
628
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000629/*
Darren Tuckerbb6cc072012-09-17 13:25:06 +1000630 * All of the attributes on a single Match line are ANDed together, so we need
631 * to check every * attribute and set the result to zero if any attribute does
632 * not match.
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000633 */
Damien Miller565ca3f2006-08-19 00:23:15 +1000634static int
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000635match_cfg_line(char **condition, int line, struct connection_info *ci)
Darren Tucker45150472006-07-12 22:34:17 +1000636{
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000637 int result = 1, port;
Darren Tucker45150472006-07-12 22:34:17 +1000638 char *arg, *attrib, *cp = *condition;
639 size_t len;
640
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000641 if (ci == NULL)
Darren Tucker45150472006-07-12 22:34:17 +1000642 debug3("checking syntax for 'Match %s'", cp);
643 else
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000644 debug3("checking match for '%s' user %s host %s addr %s "
645 "laddr %s lport %d", cp, ci->user ? ci->user : "(null)",
646 ci->host ? ci->host : "(null)",
647 ci->address ? ci->address : "(null)",
648 ci->laddress ? ci->laddress : "(null)", ci->lport);
Darren Tucker45150472006-07-12 22:34:17 +1000649
650 while ((attrib = strdelim(&cp)) && *attrib != '\0') {
651 if ((arg = strdelim(&cp)) == NULL || *arg == '\0') {
652 error("Missing Match criteria for %s", attrib);
653 return -1;
654 }
655 len = strlen(arg);
656 if (strcasecmp(attrib, "user") == 0) {
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000657 if (ci == NULL || ci->user == NULL) {
Darren Tucker45150472006-07-12 22:34:17 +1000658 result = 0;
659 continue;
660 }
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000661 if (match_pattern_list(ci->user, arg, len, 0) != 1)
Darren Tucker45150472006-07-12 22:34:17 +1000662 result = 0;
663 else
664 debug("user %.100s matched 'User %.100s' at "
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000665 "line %d", ci->user, arg, line);
Damien Miller565ca3f2006-08-19 00:23:15 +1000666 } else if (strcasecmp(attrib, "group") == 0) {
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000667 if (ci == NULL || ci->user == NULL) {
668 result = 0;
669 continue;
670 }
671 switch (match_cfg_line_group(arg, line, ci->user)) {
Damien Miller565ca3f2006-08-19 00:23:15 +1000672 case -1:
673 return -1;
674 case 0:
675 result = 0;
676 }
Darren Tucker45150472006-07-12 22:34:17 +1000677 } else if (strcasecmp(attrib, "host") == 0) {
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000678 if (ci == NULL || ci->host == NULL) {
Darren Tucker45150472006-07-12 22:34:17 +1000679 result = 0;
680 continue;
681 }
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000682 if (match_hostname(ci->host, arg, len) != 1)
Darren Tucker45150472006-07-12 22:34:17 +1000683 result = 0;
684 else
685 debug("connection from %.100s matched 'Host "
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000686 "%.100s' at line %d", ci->host, arg, line);
Darren Tucker45150472006-07-12 22:34:17 +1000687 } else if (strcasecmp(attrib, "address") == 0) {
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000688 if (ci == NULL || ci->address == NULL) {
689 result = 0;
690 continue;
691 }
692 switch (addr_match_list(ci->address, arg)) {
Darren Tucker7a3935d2008-06-10 22:59:10 +1000693 case 1:
Darren Tucker45150472006-07-12 22:34:17 +1000694 debug("connection from %.100s matched 'Address "
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000695 "%.100s' at line %d", ci->address, arg, line);
Darren Tucker7a3935d2008-06-10 22:59:10 +1000696 break;
697 case 0:
Darren Tucker896ad5a2008-06-11 09:34:46 +1000698 case -1:
Darren Tucker7a3935d2008-06-10 22:59:10 +1000699 result = 0;
700 break;
Darren Tucker896ad5a2008-06-11 09:34:46 +1000701 case -2:
Darren Tucker7a3935d2008-06-10 22:59:10 +1000702 return -1;
703 }
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000704 } else if (strcasecmp(attrib, "localaddress") == 0){
705 if (ci == NULL || ci->laddress == NULL) {
706 result = 0;
707 continue;
708 }
709 switch (addr_match_list(ci->laddress, arg)) {
710 case 1:
711 debug("connection from %.100s matched "
712 "'LocalAddress %.100s' at line %d",
713 ci->laddress, arg, line);
714 break;
715 case 0:
716 case -1:
717 result = 0;
718 break;
719 case -2:
720 return -1;
721 }
722 } else if (strcasecmp(attrib, "localport") == 0) {
723 if ((port = a2port(arg)) == -1) {
724 error("Invalid LocalPort '%s' on Match line",
725 arg);
726 return -1;
727 }
728 if (ci == NULL || ci->lport == 0) {
729 result = 0;
730 continue;
731 }
732 /* TODO support port lists */
733 if (port == ci->lport)
734 debug("connection from %.100s matched "
735 "'LocalPort %d' at line %d",
736 ci->laddress, port, line);
737 else
738 result = 0;
Darren Tucker45150472006-07-12 22:34:17 +1000739 } else {
740 error("Unsupported Match attribute %s", attrib);
741 return -1;
742 }
743 }
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000744 if (ci != NULL)
Darren Tucker45150472006-07-12 22:34:17 +1000745 debug3("match %sfound", result ? "" : "not ");
746 *condition = cp;
747 return result;
748}
749
Damien Millere2754432006-07-24 14:06:47 +1000750#define WHITESPACE " \t\r\n"
751
Damien Miller33322122011-06-20 14:43:11 +1000752/* Multistate option parsing */
753struct multistate {
754 char *key;
755 int value;
756};
757static const struct multistate multistate_addressfamily[] = {
758 { "inet", AF_INET },
759 { "inet6", AF_INET6 },
760 { "any", AF_UNSPEC },
761 { NULL, -1 }
762};
763static const struct multistate multistate_permitrootlogin[] = {
764 { "without-password", PERMIT_NO_PASSWD },
765 { "forced-commands-only", PERMIT_FORCED_ONLY },
766 { "yes", PERMIT_YES },
767 { "no", PERMIT_NO },
768 { NULL, -1 }
769};
770static const struct multistate multistate_compression[] = {
771 { "delayed", COMP_DELAYED },
772 { "yes", COMP_ZLIB },
773 { "no", COMP_NONE },
774 { NULL, -1 }
775};
776static const struct multistate multistate_gatewayports[] = {
777 { "clientspecified", 2 },
778 { "yes", 1 },
779 { "no", 0 },
780 { NULL, -1 }
781};
Damien Miller69ff1df2011-06-23 08:30:03 +1000782static const struct multistate multistate_privsep[] = {
Damien Miller5a5c2b92012-07-31 12:21:34 +1000783 { "yes", PRIVSEP_NOSANDBOX },
784 { "sandbox", PRIVSEP_ON },
785 { "nosandbox", PRIVSEP_NOSANDBOX },
Damien Miller69ff1df2011-06-23 08:30:03 +1000786 { "no", PRIVSEP_OFF },
787 { NULL, -1 }
788};
Damien Miller33322122011-06-20 14:43:11 +1000789
Ben Lindstromade03f62001-12-06 18:22:17 +0000790int
791process_server_config_line(ServerOptions *options, char *line,
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000792 const char *filename, int linenum, int *activep,
793 struct connection_info *connectinfo)
Ben Lindstromade03f62001-12-06 18:22:17 +0000794{
795 char *cp, **charptr, *arg, *p;
Damien Miller0dac6fb2010-11-20 15:19:38 +1100796 int cmdline = 0, *intptr, value, value2, n;
Darren Tucker1e44c5d2008-01-01 20:32:26 +1100797 SyslogFacility *log_facility_ptr;
798 LogLevel *log_level_ptr;
Ben Lindstromade03f62001-12-06 18:22:17 +0000799 ServerOpCodes opcode;
Damien Miller3dc71ad2009-01-28 16:31:22 +1100800 int port;
Darren Tucker45150472006-07-12 22:34:17 +1000801 u_int i, flags = 0;
Damien Miller917f9b62006-07-10 20:36:47 +1000802 size_t len;
Damien Miller33322122011-06-20 14:43:11 +1000803 const struct multistate *multistate_ptr;
Ben Lindstromade03f62001-12-06 18:22:17 +0000804
805 cp = line;
Damien Miller78f16cb2006-03-26 13:54:37 +1100806 if ((arg = strdelim(&cp)) == NULL)
Damien Miller928b2362006-03-26 13:53:32 +1100807 return 0;
Ben Lindstromade03f62001-12-06 18:22:17 +0000808 /* Ignore leading whitespace */
809 if (*arg == '\0')
810 arg = strdelim(&cp);
811 if (!arg || !*arg || *arg == '#')
812 return 0;
813 intptr = NULL;
814 charptr = NULL;
Darren Tucker45150472006-07-12 22:34:17 +1000815 opcode = parse_token(arg, filename, linenum, &flags);
816
817 if (activep == NULL) { /* We are processing a command line directive */
818 cmdline = 1;
819 activep = &cmdline;
820 }
821 if (*activep && opcode != sMatch)
822 debug3("%s:%d setting %s %s", filename, linenum, arg, cp);
823 if (*activep == 0 && !(flags & SSHCFG_MATCH)) {
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000824 if (connectinfo == NULL) {
Darren Tucker45150472006-07-12 22:34:17 +1000825 fatal("%s line %d: Directive '%s' is not allowed "
826 "within a Match block", filename, linenum, arg);
827 } else { /* this is a directive we have already processed */
828 while (arg)
829 arg = strdelim(&cp);
830 return 0;
831 }
832 }
833
Ben Lindstromade03f62001-12-06 18:22:17 +0000834 switch (opcode) {
835 /* Portable-specific options */
Damien Miller4e448a32003-05-14 15:11:48 +1000836 case sUsePAM:
837 intptr = &options->use_pam;
Ben Lindstromade03f62001-12-06 18:22:17 +0000838 goto parse_flag;
839
840 /* Standard Options */
841 case sBadOption:
842 return -1;
843 case sPort:
844 /* ignore ports from configfile if cmdline specifies ports */
845 if (options->ports_from_cmdline)
846 return 0;
847 if (options->listen_addrs != NULL)
848 fatal("%s line %d: ports must be specified before "
Damien Miller4fbf08a2002-01-22 23:35:09 +1100849 "ListenAddress.", filename, linenum);
Ben Lindstromade03f62001-12-06 18:22:17 +0000850 if (options->num_ports >= MAX_PORTS)
851 fatal("%s line %d: too many ports.",
852 filename, linenum);
853 arg = strdelim(&cp);
854 if (!arg || *arg == '\0')
855 fatal("%s line %d: missing port number.",
856 filename, linenum);
857 options->ports[options->num_ports++] = a2port(arg);
Damien Miller3dc71ad2009-01-28 16:31:22 +1100858 if (options->ports[options->num_ports-1] <= 0)
Ben Lindstromade03f62001-12-06 18:22:17 +0000859 fatal("%s line %d: Badly formatted port number.",
860 filename, linenum);
861 break;
862
863 case sServerKeyBits:
864 intptr = &options->server_key_bits;
Damien Miller7207f642008-05-19 15:34:50 +1000865 parse_int:
Ben Lindstromade03f62001-12-06 18:22:17 +0000866 arg = strdelim(&cp);
867 if (!arg || *arg == '\0')
868 fatal("%s line %d: missing integer value.",
869 filename, linenum);
870 value = atoi(arg);
Darren Tucker45150472006-07-12 22:34:17 +1000871 if (*activep && *intptr == -1)
Ben Lindstromade03f62001-12-06 18:22:17 +0000872 *intptr = value;
873 break;
874
875 case sLoginGraceTime:
876 intptr = &options->login_grace_time;
Damien Miller7207f642008-05-19 15:34:50 +1000877 parse_time:
Ben Lindstromade03f62001-12-06 18:22:17 +0000878 arg = strdelim(&cp);
879 if (!arg || *arg == '\0')
880 fatal("%s line %d: missing time value.",
881 filename, linenum);
882 if ((value = convtime(arg)) == -1)
883 fatal("%s line %d: invalid time value.",
884 filename, linenum);
885 if (*intptr == -1)
886 *intptr = value;
887 break;
888
889 case sKeyRegenerationTime:
890 intptr = &options->key_regeneration_time;
891 goto parse_time;
892
893 case sListenAddress:
894 arg = strdelim(&cp);
Damien Millerf91ee4c2005-03-01 21:24:33 +1100895 if (arg == NULL || *arg == '\0')
896 fatal("%s line %d: missing address",
Ben Lindstromade03f62001-12-06 18:22:17 +0000897 filename, linenum);
Damien Miller203c7052005-08-12 22:11:37 +1000898 /* check for bare IPv6 address: no "[]" and 2 or more ":" */
899 if (strchr(arg, '[') == NULL && (p = strchr(arg, ':')) != NULL
900 && strchr(p+1, ':') != NULL) {
901 add_listen_addr(options, arg, 0);
902 break;
903 }
Damien Millerf91ee4c2005-03-01 21:24:33 +1100904 p = hpdelim(&arg);
905 if (p == NULL)
906 fatal("%s line %d: bad address:port usage",
907 filename, linenum);
908 p = cleanhostname(p);
909 if (arg == NULL)
910 port = 0;
Damien Miller3dc71ad2009-01-28 16:31:22 +1100911 else if ((port = a2port(arg)) <= 0)
Damien Millerf91ee4c2005-03-01 21:24:33 +1100912 fatal("%s line %d: bad port number", filename, linenum);
Ben Lindstromade03f62001-12-06 18:22:17 +0000913
Damien Millerf91ee4c2005-03-01 21:24:33 +1100914 add_listen_addr(options, p, port);
915
Ben Lindstromade03f62001-12-06 18:22:17 +0000916 break;
917
Darren Tucker0f383232005-01-20 10:57:56 +1100918 case sAddressFamily:
Damien Miller33322122011-06-20 14:43:11 +1000919 intptr = &options->address_family;
920 multistate_ptr = multistate_addressfamily;
921 if (options->listen_addrs != NULL)
922 fatal("%s line %d: address family must be specified "
923 "before ListenAddress.", filename, linenum);
924 parse_multistate:
Darren Tucker0f383232005-01-20 10:57:56 +1100925 arg = strdelim(&cp);
Damien Miller17b23d82005-05-26 12:11:56 +1000926 if (!arg || *arg == '\0')
Damien Miller33322122011-06-20 14:43:11 +1000927 fatal("%s line %d: missing argument.",
Damien Miller17b23d82005-05-26 12:11:56 +1000928 filename, linenum);
Damien Miller33322122011-06-20 14:43:11 +1000929 value = -1;
930 for (i = 0; multistate_ptr[i].key != NULL; i++) {
931 if (strcasecmp(arg, multistate_ptr[i].key) == 0) {
932 value = multistate_ptr[i].value;
933 break;
934 }
935 }
936 if (value == -1)
937 fatal("%s line %d: unsupported option \"%s\".",
Darren Tucker0f383232005-01-20 10:57:56 +1100938 filename, linenum, arg);
Damien Miller33322122011-06-20 14:43:11 +1000939 if (*activep && *intptr == -1)
Darren Tucker0f383232005-01-20 10:57:56 +1100940 *intptr = value;
941 break;
942
Ben Lindstromade03f62001-12-06 18:22:17 +0000943 case sHostKeyFile:
944 intptr = &options->num_host_key_files;
945 if (*intptr >= MAX_HOSTKEYS)
946 fatal("%s line %d: too many host keys specified (max %d).",
947 filename, linenum, MAX_HOSTKEYS);
948 charptr = &options->host_key_files[*intptr];
Damien Miller7207f642008-05-19 15:34:50 +1000949 parse_filename:
Ben Lindstromade03f62001-12-06 18:22:17 +0000950 arg = strdelim(&cp);
951 if (!arg || *arg == '\0')
952 fatal("%s line %d: missing file name.",
953 filename, linenum);
Darren Tucker45150472006-07-12 22:34:17 +1000954 if (*activep && *charptr == NULL) {
Darren Tucker88b6fb22010-01-13 22:44:29 +1100955 *charptr = derelativise_path(arg);
Ben Lindstromade03f62001-12-06 18:22:17 +0000956 /* increase optional counter */
957 if (intptr != NULL)
958 *intptr = *intptr + 1;
959 }
960 break;
961
Damien Miller0a80ca12010-02-27 07:55:05 +1100962 case sHostCertificate:
963 intptr = &options->num_host_cert_files;
964 if (*intptr >= MAX_HOSTKEYS)
965 fatal("%s line %d: too many host certificates "
966 "specified (max %d).", filename, linenum,
967 MAX_HOSTCERTS);
968 charptr = &options->host_cert_files[*intptr];
969 goto parse_filename;
970 break;
971
Ben Lindstromade03f62001-12-06 18:22:17 +0000972 case sPidFile:
973 charptr = &options->pid_file;
974 goto parse_filename;
975
976 case sPermitRootLogin:
977 intptr = &options->permit_root_login;
Damien Miller33322122011-06-20 14:43:11 +1000978 multistate_ptr = multistate_permitrootlogin;
979 goto parse_multistate;
Ben Lindstromade03f62001-12-06 18:22:17 +0000980
981 case sIgnoreRhosts:
982 intptr = &options->ignore_rhosts;
Damien Miller7207f642008-05-19 15:34:50 +1000983 parse_flag:
Ben Lindstromade03f62001-12-06 18:22:17 +0000984 arg = strdelim(&cp);
985 if (!arg || *arg == '\0')
986 fatal("%s line %d: missing yes/no argument.",
987 filename, linenum);
988 value = 0; /* silence compiler */
989 if (strcmp(arg, "yes") == 0)
990 value = 1;
991 else if (strcmp(arg, "no") == 0)
992 value = 0;
993 else
994 fatal("%s line %d: Bad yes/no argument: %s",
995 filename, linenum, arg);
Darren Tucker45150472006-07-12 22:34:17 +1000996 if (*activep && *intptr == -1)
Ben Lindstromade03f62001-12-06 18:22:17 +0000997 *intptr = value;
998 break;
999
1000 case sIgnoreUserKnownHosts:
1001 intptr = &options->ignore_user_known_hosts;
1002 goto parse_flag;
1003
Ben Lindstromade03f62001-12-06 18:22:17 +00001004 case sRhostsRSAAuthentication:
1005 intptr = &options->rhosts_rsa_authentication;
1006 goto parse_flag;
1007
1008 case sHostbasedAuthentication:
1009 intptr = &options->hostbased_authentication;
1010 goto parse_flag;
1011
1012 case sHostbasedUsesNameFromPacketOnly:
1013 intptr = &options->hostbased_uses_name_from_packet_only;
1014 goto parse_flag;
1015
1016 case sRSAAuthentication:
1017 intptr = &options->rsa_authentication;
1018 goto parse_flag;
1019
1020 case sPubkeyAuthentication:
1021 intptr = &options->pubkey_authentication;
1022 goto parse_flag;
Damien Miller2aa0ab42003-05-15 12:05:28 +10001023
Ben Lindstromade03f62001-12-06 18:22:17 +00001024 case sKerberosAuthentication:
1025 intptr = &options->kerberos_authentication;
1026 goto parse_flag;
1027
1028 case sKerberosOrLocalPasswd:
1029 intptr = &options->kerberos_or_local_passwd;
1030 goto parse_flag;
1031
1032 case sKerberosTicketCleanup:
1033 intptr = &options->kerberos_ticket_cleanup;
1034 goto parse_flag;
Damien Miller2aa0ab42003-05-15 12:05:28 +10001035
Darren Tucker22ef5082003-12-31 11:37:34 +11001036 case sKerberosGetAFSToken:
1037 intptr = &options->kerberos_get_afs_token;
1038 goto parse_flag;
1039
Darren Tucker0efd1552003-08-26 11:49:55 +10001040 case sGssAuthentication:
1041 intptr = &options->gss_authentication;
1042 goto parse_flag;
1043
1044 case sGssCleanupCreds:
1045 intptr = &options->gss_cleanup_creds;
1046 goto parse_flag;
1047
Ben Lindstromade03f62001-12-06 18:22:17 +00001048 case sPasswordAuthentication:
1049 intptr = &options->password_authentication;
1050 goto parse_flag;
1051
Damien Miller01ed2272008-11-05 16:20:46 +11001052 case sZeroKnowledgePasswordAuthentication:
1053 intptr = &options->zero_knowledge_password_authentication;
1054 goto parse_flag;
1055
Ben Lindstromade03f62001-12-06 18:22:17 +00001056 case sKbdInteractiveAuthentication:
1057 intptr = &options->kbd_interactive_authentication;
1058 goto parse_flag;
1059
1060 case sChallengeResponseAuthentication:
1061 intptr = &options->challenge_response_authentication;
1062 goto parse_flag;
1063
1064 case sPrintMotd:
1065 intptr = &options->print_motd;
1066 goto parse_flag;
1067
1068 case sPrintLastLog:
1069 intptr = &options->print_lastlog;
1070 goto parse_flag;
1071
1072 case sX11Forwarding:
1073 intptr = &options->x11_forwarding;
1074 goto parse_flag;
1075
1076 case sX11DisplayOffset:
1077 intptr = &options->x11_display_offset;
1078 goto parse_int;
1079
Damien Miller95c249f2002-02-05 12:11:34 +11001080 case sX11UseLocalhost:
1081 intptr = &options->x11_use_localhost;
1082 goto parse_flag;
1083
Ben Lindstromade03f62001-12-06 18:22:17 +00001084 case sXAuthLocation:
1085 charptr = &options->xauth_location;
1086 goto parse_filename;
1087
1088 case sStrictModes:
1089 intptr = &options->strict_modes;
1090 goto parse_flag;
1091
Damien Miller12c150e2003-12-17 16:31:10 +11001092 case sTCPKeepAlive:
1093 intptr = &options->tcp_keep_alive;
Ben Lindstromade03f62001-12-06 18:22:17 +00001094 goto parse_flag;
1095
1096 case sEmptyPasswd:
1097 intptr = &options->permit_empty_passwd;
1098 goto parse_flag;
1099
Ben Lindstrom5d860f02002-08-01 01:28:38 +00001100 case sPermitUserEnvironment:
1101 intptr = &options->permit_user_env;
1102 goto parse_flag;
1103
Ben Lindstromade03f62001-12-06 18:22:17 +00001104 case sUseLogin:
1105 intptr = &options->use_login;
1106 goto parse_flag;
1107
Ben Lindstrom23e0f662002-06-21 01:09:47 +00001108 case sCompression:
1109 intptr = &options->compression;
Damien Miller33322122011-06-20 14:43:11 +10001110 multistate_ptr = multistate_compression;
1111 goto parse_multistate;
Ben Lindstrom23e0f662002-06-21 01:09:47 +00001112
Ben Lindstromade03f62001-12-06 18:22:17 +00001113 case sGatewayPorts:
1114 intptr = &options->gateway_ports;
Damien Miller33322122011-06-20 14:43:11 +10001115 multistate_ptr = multistate_gatewayports;
1116 goto parse_multistate;
Ben Lindstromade03f62001-12-06 18:22:17 +00001117
Damien Miller3a961dc2003-06-03 10:25:48 +10001118 case sUseDNS:
1119 intptr = &options->use_dns;
Ben Lindstromade03f62001-12-06 18:22:17 +00001120 goto parse_flag;
1121
1122 case sLogFacility:
Darren Tucker1e44c5d2008-01-01 20:32:26 +11001123 log_facility_ptr = &options->log_facility;
Ben Lindstromade03f62001-12-06 18:22:17 +00001124 arg = strdelim(&cp);
1125 value = log_facility_number(arg);
Damien Millerfcd93202002-02-05 12:26:34 +11001126 if (value == SYSLOG_FACILITY_NOT_SET)
Ben Lindstromade03f62001-12-06 18:22:17 +00001127 fatal("%.200s line %d: unsupported log facility '%s'",
1128 filename, linenum, arg ? arg : "<NONE>");
Darren Tucker1e44c5d2008-01-01 20:32:26 +11001129 if (*log_facility_ptr == -1)
1130 *log_facility_ptr = (SyslogFacility) value;
Ben Lindstromade03f62001-12-06 18:22:17 +00001131 break;
1132
1133 case sLogLevel:
Darren Tucker1e44c5d2008-01-01 20:32:26 +11001134 log_level_ptr = &options->log_level;
Ben Lindstromade03f62001-12-06 18:22:17 +00001135 arg = strdelim(&cp);
1136 value = log_level_number(arg);
Damien Millerfcd93202002-02-05 12:26:34 +11001137 if (value == SYSLOG_LEVEL_NOT_SET)
Ben Lindstromade03f62001-12-06 18:22:17 +00001138 fatal("%.200s line %d: unsupported log level '%s'",
1139 filename, linenum, arg ? arg : "<NONE>");
Darren Tucker1e44c5d2008-01-01 20:32:26 +11001140 if (*log_level_ptr == -1)
1141 *log_level_ptr = (LogLevel) value;
Ben Lindstromade03f62001-12-06 18:22:17 +00001142 break;
1143
1144 case sAllowTcpForwarding:
1145 intptr = &options->allow_tcp_forwarding;
1146 goto parse_flag;
1147
Damien Miller4f755cd2008-05-19 14:57:41 +10001148 case sAllowAgentForwarding:
1149 intptr = &options->allow_agent_forwarding;
1150 goto parse_flag;
1151
Ben Lindstrom7a2073c2002-03-22 02:30:41 +00001152 case sUsePrivilegeSeparation:
1153 intptr = &use_privsep;
Damien Miller69ff1df2011-06-23 08:30:03 +10001154 multistate_ptr = multistate_privsep;
1155 goto parse_multistate;
Ben Lindstrom7a2073c2002-03-22 02:30:41 +00001156
Ben Lindstromade03f62001-12-06 18:22:17 +00001157 case sAllowUsers:
1158 while ((arg = strdelim(&cp)) && *arg != '\0') {
1159 if (options->num_allow_users >= MAX_ALLOW_USERS)
1160 fatal("%s line %d: too many allow users.",
1161 filename, linenum);
Damien Millerc24da772012-06-20 21:53:58 +10001162 if (!*activep)
1163 continue;
Ben Lindstrome1353632002-06-23 21:29:23 +00001164 options->allow_users[options->num_allow_users++] =
1165 xstrdup(arg);
Ben Lindstromade03f62001-12-06 18:22:17 +00001166 }
1167 break;
1168
1169 case sDenyUsers:
1170 while ((arg = strdelim(&cp)) && *arg != '\0') {
1171 if (options->num_deny_users >= MAX_DENY_USERS)
Damien Miller4dec5d72006-08-05 11:38:40 +10001172 fatal("%s line %d: too many deny users.",
Ben Lindstromade03f62001-12-06 18:22:17 +00001173 filename, linenum);
Damien Millerc24da772012-06-20 21:53:58 +10001174 if (!*activep)
1175 continue;
Ben Lindstrome1353632002-06-23 21:29:23 +00001176 options->deny_users[options->num_deny_users++] =
1177 xstrdup(arg);
Ben Lindstromade03f62001-12-06 18:22:17 +00001178 }
1179 break;
1180
1181 case sAllowGroups:
1182 while ((arg = strdelim(&cp)) && *arg != '\0') {
1183 if (options->num_allow_groups >= MAX_ALLOW_GROUPS)
1184 fatal("%s line %d: too many allow groups.",
1185 filename, linenum);
Damien Millerc24da772012-06-20 21:53:58 +10001186 if (!*activep)
1187 continue;
Ben Lindstrome1353632002-06-23 21:29:23 +00001188 options->allow_groups[options->num_allow_groups++] =
1189 xstrdup(arg);
Ben Lindstromade03f62001-12-06 18:22:17 +00001190 }
1191 break;
1192
1193 case sDenyGroups:
1194 while ((arg = strdelim(&cp)) && *arg != '\0') {
1195 if (options->num_deny_groups >= MAX_DENY_GROUPS)
1196 fatal("%s line %d: too many deny groups.",
1197 filename, linenum);
Damien Millerc24da772012-06-20 21:53:58 +10001198 if (!*activep)
1199 continue;
1200 options->deny_groups[options->num_deny_groups++] =
1201 xstrdup(arg);
Ben Lindstromade03f62001-12-06 18:22:17 +00001202 }
1203 break;
1204
1205 case sCiphers:
1206 arg = strdelim(&cp);
1207 if (!arg || *arg == '\0')
1208 fatal("%s line %d: Missing argument.", filename, linenum);
1209 if (!ciphers_valid(arg))
1210 fatal("%s line %d: Bad SSH2 cipher spec '%s'.",
1211 filename, linenum, arg ? arg : "<NONE>");
1212 if (options->ciphers == NULL)
1213 options->ciphers = xstrdup(arg);
1214 break;
1215
1216 case sMacs:
1217 arg = strdelim(&cp);
1218 if (!arg || *arg == '\0')
1219 fatal("%s line %d: Missing argument.", filename, linenum);
1220 if (!mac_valid(arg))
1221 fatal("%s line %d: Bad SSH2 mac spec '%s'.",
1222 filename, linenum, arg ? arg : "<NONE>");
1223 if (options->macs == NULL)
1224 options->macs = xstrdup(arg);
1225 break;
1226
Damien Millerd5f62bf2010-09-24 22:11:14 +10001227 case sKexAlgorithms:
1228 arg = strdelim(&cp);
1229 if (!arg || *arg == '\0')
1230 fatal("%s line %d: Missing argument.",
1231 filename, linenum);
1232 if (!kex_names_valid(arg))
1233 fatal("%s line %d: Bad SSH2 KexAlgorithms '%s'.",
1234 filename, linenum, arg ? arg : "<NONE>");
1235 if (options->kex_algorithms == NULL)
1236 options->kex_algorithms = xstrdup(arg);
1237 break;
1238
Ben Lindstromade03f62001-12-06 18:22:17 +00001239 case sProtocol:
1240 intptr = &options->protocol;
1241 arg = strdelim(&cp);
1242 if (!arg || *arg == '\0')
1243 fatal("%s line %d: Missing argument.", filename, linenum);
1244 value = proto_spec(arg);
1245 if (value == SSH_PROTO_UNKNOWN)
1246 fatal("%s line %d: Bad protocol spec '%s'.",
Damien Miller9f0f5c62001-12-21 14:45:46 +11001247 filename, linenum, arg ? arg : "<NONE>");
Ben Lindstromade03f62001-12-06 18:22:17 +00001248 if (*intptr == SSH_PROTO_UNKNOWN)
1249 *intptr = value;
1250 break;
1251
1252 case sSubsystem:
1253 if (options->num_subsystems >= MAX_SUBSYSTEMS) {
1254 fatal("%s line %d: too many subsystems defined.",
Damien Miller9f0f5c62001-12-21 14:45:46 +11001255 filename, linenum);
Ben Lindstromade03f62001-12-06 18:22:17 +00001256 }
1257 arg = strdelim(&cp);
1258 if (!arg || *arg == '\0')
1259 fatal("%s line %d: Missing subsystem name.",
Damien Miller9f0f5c62001-12-21 14:45:46 +11001260 filename, linenum);
Darren Tucker45150472006-07-12 22:34:17 +10001261 if (!*activep) {
1262 arg = strdelim(&cp);
1263 break;
1264 }
Ben Lindstromade03f62001-12-06 18:22:17 +00001265 for (i = 0; i < options->num_subsystems; i++)
1266 if (strcmp(arg, options->subsystem_name[i]) == 0)
1267 fatal("%s line %d: Subsystem '%s' already defined.",
Damien Miller9f0f5c62001-12-21 14:45:46 +11001268 filename, linenum, arg);
Ben Lindstromade03f62001-12-06 18:22:17 +00001269 options->subsystem_name[options->num_subsystems] = xstrdup(arg);
1270 arg = strdelim(&cp);
1271 if (!arg || *arg == '\0')
1272 fatal("%s line %d: Missing subsystem command.",
Damien Miller9f0f5c62001-12-21 14:45:46 +11001273 filename, linenum);
Ben Lindstromade03f62001-12-06 18:22:17 +00001274 options->subsystem_command[options->num_subsystems] = xstrdup(arg);
Damien Miller917f9b62006-07-10 20:36:47 +10001275
1276 /* Collect arguments (separate to executable) */
1277 p = xstrdup(arg);
1278 len = strlen(p) + 1;
1279 while ((arg = strdelim(&cp)) != NULL && *arg != '\0') {
1280 len += 1 + strlen(arg);
1281 p = xrealloc(p, 1, len);
1282 strlcat(p, " ", len);
1283 strlcat(p, arg, len);
1284 }
1285 options->subsystem_args[options->num_subsystems] = p;
Ben Lindstromade03f62001-12-06 18:22:17 +00001286 options->num_subsystems++;
1287 break;
1288
1289 case sMaxStartups:
1290 arg = strdelim(&cp);
1291 if (!arg || *arg == '\0')
1292 fatal("%s line %d: Missing MaxStartups spec.",
Damien Miller9f0f5c62001-12-21 14:45:46 +11001293 filename, linenum);
Ben Lindstromade03f62001-12-06 18:22:17 +00001294 if ((n = sscanf(arg, "%d:%d:%d",
1295 &options->max_startups_begin,
1296 &options->max_startups_rate,
1297 &options->max_startups)) == 3) {
1298 if (options->max_startups_begin >
1299 options->max_startups ||
1300 options->max_startups_rate > 100 ||
1301 options->max_startups_rate < 1)
1302 fatal("%s line %d: Illegal MaxStartups spec.",
1303 filename, linenum);
1304 } else if (n != 1)
1305 fatal("%s line %d: Illegal MaxStartups spec.",
1306 filename, linenum);
1307 else
1308 options->max_startups = options->max_startups_begin;
1309 break;
1310
Darren Tucker89413db2004-05-24 10:36:23 +10001311 case sMaxAuthTries:
1312 intptr = &options->max_authtries;
1313 goto parse_int;
1314
Damien Miller7207f642008-05-19 15:34:50 +10001315 case sMaxSessions:
1316 intptr = &options->max_sessions;
1317 goto parse_int;
1318
Ben Lindstromade03f62001-12-06 18:22:17 +00001319 case sBanner:
1320 charptr = &options->banner;
1321 goto parse_filename;
Damien Millerd8cb1f12008-02-10 22:40:12 +11001322
Ben Lindstromade03f62001-12-06 18:22:17 +00001323 /*
1324 * These options can contain %X options expanded at
1325 * connect time, so that you can specify paths like:
1326 *
1327 * AuthorizedKeysFile /etc/ssh_keys/%u
1328 */
1329 case sAuthorizedKeysFile:
Damien Millerd8478b62011-05-29 21:39:36 +10001330 if (*activep && options->num_authkeys_files == 0) {
1331 while ((arg = strdelim(&cp)) && *arg != '\0') {
1332 if (options->num_authkeys_files >=
1333 MAX_AUTHKEYS_FILES)
1334 fatal("%s line %d: "
1335 "too many authorized keys files.",
1336 filename, linenum);
1337 options->authorized_keys_files[
1338 options->num_authkeys_files++] =
1339 tilde_expand_filename(arg, getuid());
1340 }
1341 }
1342 return 0;
1343
Damien Miller30da3442010-05-10 11:58:03 +10001344 case sAuthorizedPrincipalsFile:
1345 charptr = &options->authorized_principals_file;
Damien Millerc4cb47b2010-03-22 05:52:26 +11001346 arg = strdelim(&cp);
1347 if (!arg || *arg == '\0')
1348 fatal("%s line %d: missing file name.",
1349 filename, linenum);
1350 if (*activep && *charptr == NULL) {
Damien Miller4a5f0d32010-03-22 05:53:04 +11001351 *charptr = tilde_expand_filename(arg, getuid());
Damien Millerc4cb47b2010-03-22 05:52:26 +11001352 /* increase optional counter */
1353 if (intptr != NULL)
1354 *intptr = *intptr + 1;
1355 }
1356 break;
Ben Lindstromade03f62001-12-06 18:22:17 +00001357
1358 case sClientAliveInterval:
1359 intptr = &options->client_alive_interval;
1360 goto parse_time;
1361
1362 case sClientAliveCountMax:
1363 intptr = &options->client_alive_count_max;
1364 goto parse_int;
1365
Darren Tucker46bc0752004-05-02 22:11:30 +10001366 case sAcceptEnv:
1367 while ((arg = strdelim(&cp)) && *arg != '\0') {
1368 if (strchr(arg, '=') != NULL)
1369 fatal("%s line %d: Invalid environment name.",
1370 filename, linenum);
1371 if (options->num_accept_env >= MAX_ACCEPT_ENV)
1372 fatal("%s line %d: too many allow env.",
1373 filename, linenum);
Darren Tucker45150472006-07-12 22:34:17 +10001374 if (!*activep)
Damien Millerc24da772012-06-20 21:53:58 +10001375 continue;
Darren Tucker46bc0752004-05-02 22:11:30 +10001376 options->accept_env[options->num_accept_env++] =
1377 xstrdup(arg);
1378 }
1379 break;
1380
Damien Millerd27b9472005-12-13 19:29:02 +11001381 case sPermitTunnel:
1382 intptr = &options->permit_tun;
Damien Miller7b58e802005-12-13 19:33:19 +11001383 arg = strdelim(&cp);
1384 if (!arg || *arg == '\0')
1385 fatal("%s line %d: Missing yes/point-to-point/"
1386 "ethernet/no argument.", filename, linenum);
Darren Tuckere7140f22008-06-10 23:01:51 +10001387 value = -1;
1388 for (i = 0; tunmode_desc[i].val != -1; i++)
1389 if (strcmp(tunmode_desc[i].text, arg) == 0) {
1390 value = tunmode_desc[i].val;
1391 break;
1392 }
1393 if (value == -1)
Damien Miller7b58e802005-12-13 19:33:19 +11001394 fatal("%s line %d: Bad yes/point-to-point/ethernet/"
1395 "no argument: %s", filename, linenum, arg);
1396 if (*intptr == -1)
1397 *intptr = value;
1398 break;
Damien Millerd27b9472005-12-13 19:29:02 +11001399
Darren Tucker45150472006-07-12 22:34:17 +10001400 case sMatch:
1401 if (cmdline)
1402 fatal("Match directive not supported as a command-line "
1403 "option");
Darren Tuckerfbcf8272012-05-19 19:37:01 +10001404 value = match_cfg_line(&cp, linenum, connectinfo);
Darren Tucker45150472006-07-12 22:34:17 +10001405 if (value < 0)
1406 fatal("%s line %d: Bad Match condition", filename,
1407 linenum);
1408 *activep = value;
1409 break;
1410
Damien Miller9b439df2006-07-24 14:04:00 +10001411 case sPermitOpen:
1412 arg = strdelim(&cp);
1413 if (!arg || *arg == '\0')
1414 fatal("%s line %d: missing PermitOpen specification",
1415 filename, linenum);
Damien Miller9fc6a562007-01-05 16:29:02 +11001416 n = options->num_permitted_opens; /* modified later */
Damien Miller9b439df2006-07-24 14:04:00 +10001417 if (strcmp(arg, "any") == 0) {
Damien Miller9fc6a562007-01-05 16:29:02 +11001418 if (*activep && n == -1) {
Damien Miller9b439df2006-07-24 14:04:00 +10001419 channel_clear_adm_permitted_opens();
Damien Millera765cf42006-07-24 14:08:13 +10001420 options->num_permitted_opens = 0;
1421 }
Damien Miller9b439df2006-07-24 14:04:00 +10001422 break;
1423 }
Damien Millerc6081482012-04-22 11:18:53 +10001424 if (strcmp(arg, "none") == 0) {
1425 if (*activep && n == -1) {
1426 channel_clear_adm_permitted_opens();
1427 options->num_permitted_opens = 1;
1428 channel_disable_adm_local_opens();
1429 }
1430 break;
1431 }
Damien Millera29b95e2007-01-05 16:28:36 +11001432 if (*activep && n == -1)
1433 channel_clear_adm_permitted_opens();
Damien Millera765cf42006-07-24 14:08:13 +10001434 for (; arg != NULL && *arg != '\0'; arg = strdelim(&cp)) {
1435 p = hpdelim(&arg);
1436 if (p == NULL)
1437 fatal("%s line %d: missing host in PermitOpen",
1438 filename, linenum);
1439 p = cleanhostname(p);
Darren Tucker1338b9e2011-10-02 18:57:35 +11001440 if (arg == NULL || ((port = permitopen_port(arg)) < 0))
Damien Millera765cf42006-07-24 14:08:13 +10001441 fatal("%s line %d: bad port number in "
1442 "PermitOpen", filename, linenum);
Damien Millera29b95e2007-01-05 16:28:36 +11001443 if (*activep && n == -1)
Damien Millera765cf42006-07-24 14:08:13 +10001444 options->num_permitted_opens =
1445 channel_add_adm_permitted_opens(p, port);
Damien Millera765cf42006-07-24 14:08:13 +10001446 }
Damien Miller9b439df2006-07-24 14:04:00 +10001447 break;
1448
Damien Millere2754432006-07-24 14:06:47 +10001449 case sForceCommand:
1450 if (cp == NULL)
1451 fatal("%.200s line %d: Missing argument.", filename,
1452 linenum);
1453 len = strspn(cp, WHITESPACE);
1454 if (*activep && options->adm_forced_command == NULL)
1455 options->adm_forced_command = xstrdup(cp + len);
1456 return 0;
1457
Damien Millerd8cb1f12008-02-10 22:40:12 +11001458 case sChrootDirectory:
1459 charptr = &options->chroot_directory;
Damien Miller54e37732008-02-10 22:48:55 +11001460
1461 arg = strdelim(&cp);
1462 if (!arg || *arg == '\0')
1463 fatal("%s line %d: missing file name.",
1464 filename, linenum);
1465 if (*activep && *charptr == NULL)
1466 *charptr = xstrdup(arg);
1467 break;
Damien Millerd8cb1f12008-02-10 22:40:12 +11001468
Damien Miller1aed65e2010-03-04 21:53:35 +11001469 case sTrustedUserCAKeys:
1470 charptr = &options->trusted_user_ca_keys;
1471 goto parse_filename;
1472
1473 case sRevokedKeys:
1474 charptr = &options->revoked_keys_file;
1475 goto parse_filename;
1476
Damien Miller0dac6fb2010-11-20 15:19:38 +11001477 case sIPQoS:
1478 arg = strdelim(&cp);
1479 if ((value = parse_ipqos(arg)) == -1)
1480 fatal("%s line %d: Bad IPQoS value: %s",
1481 filename, linenum, arg);
1482 arg = strdelim(&cp);
1483 if (arg == NULL)
1484 value2 = value;
1485 else if ((value2 = parse_ipqos(arg)) == -1)
1486 fatal("%s line %d: Bad IPQoS value: %s",
1487 filename, linenum, arg);
1488 if (*activep) {
1489 options->ip_qos_interactive = value;
1490 options->ip_qos_bulk = value2;
1491 }
1492 break;
1493
Damien Miller23528812012-04-22 11:24:43 +10001494 case sVersionAddendum:
1495 if (cp == NULL)
1496 fatal("%.200s line %d: Missing argument.", filename,
1497 linenum);
1498 len = strspn(cp, WHITESPACE);
1499 if (*activep && options->version_addendum == NULL) {
1500 if (strcasecmp(cp + len, "none") == 0)
1501 options->version_addendum = xstrdup("");
1502 else if (strchr(cp + len, '\r') != NULL)
1503 fatal("%.200s line %d: Invalid argument",
1504 filename, linenum);
1505 else
1506 options->version_addendum = xstrdup(cp + len);
1507 }
1508 return 0;
1509
Damien Miller09d3e122012-10-31 08:58:58 +11001510 case sAuthorizedKeysCommand:
1511 len = strspn(cp, WHITESPACE);
1512 if (*activep && options->authorized_keys_command == NULL) {
1513 if (cp[len] != '/' && strcasecmp(cp + len, "none") != 0)
1514 fatal("%.200s line %d: AuthorizedKeysCommand "
1515 "must be an absolute path",
1516 filename, linenum);
1517 options->authorized_keys_command = xstrdup(cp + len);
1518 }
1519 return 0;
1520
1521 case sAuthorizedKeysCommandUser:
1522 charptr = &options->authorized_keys_command_user;
1523
1524 arg = strdelim(&cp);
1525 if (*activep && *charptr == NULL)
1526 *charptr = xstrdup(arg);
1527 break;
1528
Damien Millera6e3f012012-11-04 23:21:40 +11001529 case sAuthenticationMethods:
1530 if (*activep && options->num_auth_methods == 0) {
1531 while ((arg = strdelim(&cp)) && *arg != '\0') {
1532 if (options->num_auth_methods >=
1533 MAX_AUTH_METHODS)
1534 fatal("%s line %d: "
1535 "too many authentication methods.",
1536 filename, linenum);
1537 if (auth2_methods_valid(arg, 0) != 0)
1538 fatal("%s line %d: invalid "
1539 "authentication method list.",
1540 filename, linenum);
1541 options->auth_methods[
1542 options->num_auth_methods++] = xstrdup(arg);
1543 }
1544 }
1545 return 0;
1546
Ben Lindstromade03f62001-12-06 18:22:17 +00001547 case sDeprecated:
Damien Miller996acd22003-04-09 20:59:48 +10001548 logit("%s line %d: Deprecated option %s",
Ben Lindstromade03f62001-12-06 18:22:17 +00001549 filename, linenum, arg);
1550 while (arg)
1551 arg = strdelim(&cp);
1552 break;
1553
Damien Millerf9b3feb2003-05-16 11:38:32 +10001554 case sUnsupported:
1555 logit("%s line %d: Unsupported option %s",
1556 filename, linenum, arg);
1557 while (arg)
1558 arg = strdelim(&cp);
1559 break;
1560
Ben Lindstromade03f62001-12-06 18:22:17 +00001561 default:
1562 fatal("%s line %d: Missing handler for opcode %s (%d)",
1563 filename, linenum, arg, opcode);
1564 }
1565 if ((arg = strdelim(&cp)) != NULL && *arg != '\0')
1566 fatal("%s line %d: garbage at end of line; \"%.200s\".",
1567 filename, linenum, arg);
1568 return 0;
1569}
1570
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001571/* Reads the server configuration file. */
1572
Damien Miller4af51302000-04-16 11:18:38 +10001573void
Darren Tucker645ab752004-06-25 13:33:20 +10001574load_server_config(const char *filename, Buffer *conf)
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001575{
Damien Miller46cb75a2012-07-31 12:22:37 +10001576 char line[4096], *cp;
Ben Lindstrome1353632002-06-23 21:29:23 +00001577 FILE *f;
Damien Miller46cb75a2012-07-31 12:22:37 +10001578 int lineno = 0;
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001579
Darren Tucker645ab752004-06-25 13:33:20 +10001580 debug2("%s: filename %s", __func__, filename);
1581 if ((f = fopen(filename, "r")) == NULL) {
Damien Miller95def091999-11-25 00:26:21 +11001582 perror(filename);
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001583 exit(1);
Damien Miller95def091999-11-25 00:26:21 +11001584 }
Darren Tucker645ab752004-06-25 13:33:20 +10001585 buffer_clear(conf);
Damien Miller95def091999-11-25 00:26:21 +11001586 while (fgets(line, sizeof(line), f)) {
Damien Miller46cb75a2012-07-31 12:22:37 +10001587 lineno++;
1588 if (strlen(line) == sizeof(line) - 1)
1589 fatal("%s line %d too long", filename, lineno);
Darren Tucker645ab752004-06-25 13:33:20 +10001590 /*
1591 * Trim out comments and strip whitespace
Darren Tuckerfc959702004-07-17 16:12:08 +10001592 * NB - preserve newlines, they are needed to reproduce
Darren Tucker645ab752004-06-25 13:33:20 +10001593 * line numbers later for error messages
1594 */
1595 if ((cp = strchr(line, '#')) != NULL)
1596 memcpy(cp, "\n", 2);
1597 cp = line + strspn(line, " \t\r");
1598
1599 buffer_append(conf, cp, strlen(cp));
1600 }
1601 buffer_append(conf, "\0", 1);
1602 fclose(f);
1603 debug2("%s: done config len = %d", __func__, buffer_len(conf));
1604}
1605
1606void
Darren Tuckerfbcf8272012-05-19 19:37:01 +10001607parse_server_match_config(ServerOptions *options,
1608 struct connection_info *connectinfo)
Darren Tucker645ab752004-06-25 13:33:20 +10001609{
Darren Tucker45150472006-07-12 22:34:17 +10001610 ServerOptions mo;
1611
1612 initialize_server_options(&mo);
Darren Tuckerfbcf8272012-05-19 19:37:01 +10001613 parse_server_config(&mo, "reprocess config", &cfg, connectinfo);
Darren Tucker1629c072007-02-19 22:25:37 +11001614 copy_set_server_options(options, &mo, 0);
Darren Tucker45150472006-07-12 22:34:17 +10001615}
1616
Darren Tuckerfbcf8272012-05-19 19:37:01 +10001617int parse_server_match_testspec(struct connection_info *ci, char *spec)
1618{
1619 char *p;
1620
1621 while ((p = strsep(&spec, ",")) && *p != '\0') {
1622 if (strncmp(p, "addr=", 5) == 0) {
1623 ci->address = xstrdup(p + 5);
1624 } else if (strncmp(p, "host=", 5) == 0) {
1625 ci->host = xstrdup(p + 5);
1626 } else if (strncmp(p, "user=", 5) == 0) {
1627 ci->user = xstrdup(p + 5);
1628 } else if (strncmp(p, "laddr=", 6) == 0) {
1629 ci->laddress = xstrdup(p + 6);
1630 } else if (strncmp(p, "lport=", 6) == 0) {
1631 ci->lport = a2port(p + 6);
1632 if (ci->lport == -1) {
1633 fprintf(stderr, "Invalid port '%s' in test mode"
1634 " specification %s\n", p+6, p);
1635 return -1;
1636 }
1637 } else {
1638 fprintf(stderr, "Invalid test mode specification %s\n",
1639 p);
1640 return -1;
1641 }
1642 }
1643 return 0;
1644}
1645
1646/*
1647 * returns 1 for a complete spec, 0 for partial spec and -1 for an
1648 * empty spec.
1649 */
1650int server_match_spec_complete(struct connection_info *ci)
1651{
1652 if (ci->user && ci->host && ci->address)
1653 return 1; /* complete */
1654 if (!ci->user && !ci->host && !ci->address)
1655 return -1; /* empty */
1656 return 0; /* partial */
1657}
1658
Darren Tucker1629c072007-02-19 22:25:37 +11001659/* Helper macros */
1660#define M_CP_INTOPT(n) do {\
1661 if (src->n != -1) \
1662 dst->n = src->n; \
1663} while (0)
1664#define M_CP_STROPT(n) do {\
1665 if (src->n != NULL) { \
1666 if (dst->n != NULL) \
1667 xfree(dst->n); \
1668 dst->n = src->n; \
1669 } \
1670} while(0)
Damien Millerd8478b62011-05-29 21:39:36 +10001671#define M_CP_STRARRAYOPT(n, num_n) do {\
1672 if (src->num_n != 0) { \
1673 for (dst->num_n = 0; dst->num_n < src->num_n; dst->num_n++) \
1674 dst->n[dst->num_n] = xstrdup(src->n[dst->num_n]); \
1675 } \
1676} while(0)
Darren Tucker1629c072007-02-19 22:25:37 +11001677
1678/*
1679 * Copy any supported values that are set.
1680 *
Darren Tucker3b59dfa2009-06-21 17:54:47 +10001681 * If the preauth flag is set, we do not bother copying the string or
Darren Tucker1629c072007-02-19 22:25:37 +11001682 * array values that are not used pre-authentication, because any that we
1683 * do use must be explictly sent in mm_getpwnamallow().
1684 */
Darren Tucker45150472006-07-12 22:34:17 +10001685void
Darren Tucker1629c072007-02-19 22:25:37 +11001686copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth)
Darren Tucker45150472006-07-12 22:34:17 +10001687{
Darren Tucker1629c072007-02-19 22:25:37 +11001688 M_CP_INTOPT(password_authentication);
1689 M_CP_INTOPT(gss_authentication);
1690 M_CP_INTOPT(rsa_authentication);
1691 M_CP_INTOPT(pubkey_authentication);
1692 M_CP_INTOPT(kerberos_authentication);
1693 M_CP_INTOPT(hostbased_authentication);
Damien Millerab6de352010-06-26 09:38:45 +10001694 M_CP_INTOPT(hostbased_uses_name_from_packet_only);
Darren Tucker1629c072007-02-19 22:25:37 +11001695 M_CP_INTOPT(kbd_interactive_authentication);
Damien Miller01ed2272008-11-05 16:20:46 +11001696 M_CP_INTOPT(zero_knowledge_password_authentication);
Damien Miller09d3e122012-10-31 08:58:58 +11001697 M_CP_STROPT(authorized_keys_command);
1698 M_CP_STROPT(authorized_keys_command_user);
Darren Tucker15f94272008-01-01 20:36:56 +11001699 M_CP_INTOPT(permit_root_login);
Damien Miller51bde602008-11-03 19:23:10 +11001700 M_CP_INTOPT(permit_empty_passwd);
Darren Tucker1629c072007-02-19 22:25:37 +11001701
1702 M_CP_INTOPT(allow_tcp_forwarding);
Damien Miller4f755cd2008-05-19 14:57:41 +10001703 M_CP_INTOPT(allow_agent_forwarding);
Damien Millerab6de352010-06-26 09:38:45 +10001704 M_CP_INTOPT(permit_tun);
Darren Tucker1629c072007-02-19 22:25:37 +11001705 M_CP_INTOPT(gateway_ports);
1706 M_CP_INTOPT(x11_display_offset);
1707 M_CP_INTOPT(x11_forwarding);
1708 M_CP_INTOPT(x11_use_localhost);
Damien Miller7207f642008-05-19 15:34:50 +10001709 M_CP_INTOPT(max_sessions);
Damien Miller307c1d12008-06-16 07:56:20 +10001710 M_CP_INTOPT(max_authtries);
Damien Miller0dac6fb2010-11-20 15:19:38 +11001711 M_CP_INTOPT(ip_qos_interactive);
1712 M_CP_INTOPT(ip_qos_bulk);
Darren Tucker1629c072007-02-19 22:25:37 +11001713
Damien Millerf2e407e2011-05-20 19:04:14 +10001714 /* See comment in servconf.h */
1715 COPY_MATCH_STRING_OPTS();
Damien Miller5d74e582011-05-20 19:03:31 +10001716
Damien Millerc2411902011-05-20 19:03:49 +10001717 /*
1718 * The only things that should be below this point are string options
1719 * which are only used after authentication.
1720 */
Damien Miller5d74e582011-05-20 19:03:31 +10001721 if (preauth)
1722 return;
Damien Millerd8478b62011-05-29 21:39:36 +10001723
Damien Miller5d74e582011-05-20 19:03:31 +10001724 M_CP_STROPT(adm_forced_command);
1725 M_CP_STROPT(chroot_directory);
Darren Tucker45150472006-07-12 22:34:17 +10001726}
1727
Darren Tucker1629c072007-02-19 22:25:37 +11001728#undef M_CP_INTOPT
1729#undef M_CP_STROPT
Damien Millerd8478b62011-05-29 21:39:36 +10001730#undef M_CP_STRARRAYOPT
Darren Tucker1629c072007-02-19 22:25:37 +11001731
Darren Tucker45150472006-07-12 22:34:17 +10001732void
1733parse_server_config(ServerOptions *options, const char *filename, Buffer *conf,
Darren Tuckerfbcf8272012-05-19 19:37:01 +10001734 struct connection_info *connectinfo)
Darren Tucker45150472006-07-12 22:34:17 +10001735{
1736 int active, linenum, bad_options = 0;
Darren Tucker9fbac712004-08-12 22:41:44 +10001737 char *cp, *obuf, *cbuf;
Darren Tucker645ab752004-06-25 13:33:20 +10001738
1739 debug2("%s: config %s len %d", __func__, filename, buffer_len(conf));
1740
Darren Tucker9fbac712004-08-12 22:41:44 +10001741 obuf = cbuf = xstrdup(buffer_ptr(conf));
Darren Tuckerfbcf8272012-05-19 19:37:01 +10001742 active = connectinfo ? 0 : 1;
Darren Tucker137e9c92004-08-13 21:30:24 +10001743 linenum = 1;
Darren Tucker47eede72005-03-14 23:08:12 +11001744 while ((cp = strsep(&cbuf, "\n")) != NULL) {
Darren Tucker645ab752004-06-25 13:33:20 +10001745 if (process_server_config_line(options, cp, filename,
Darren Tuckerfbcf8272012-05-19 19:37:01 +10001746 linenum++, &active, connectinfo) != 0)
Damien Miller95def091999-11-25 00:26:21 +11001747 bad_options++;
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001748 }
Darren Tucker9fbac712004-08-12 22:41:44 +10001749 xfree(obuf);
Ben Lindstromb5cdc662001-04-16 02:13:26 +00001750 if (bad_options > 0)
1751 fatal("%s: terminating, %d bad configuration options",
1752 filename, bad_options);
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001753}
Darren Tuckere7140f22008-06-10 23:01:51 +10001754
1755static const char *
Damien Miller82c55872011-06-23 08:20:30 +10001756fmt_multistate_int(int val, const struct multistate *m)
1757{
1758 u_int i;
1759
1760 for (i = 0; m[i].key != NULL; i++) {
1761 if (m[i].value == val)
1762 return m[i].key;
1763 }
1764 return "UNKNOWN";
1765}
1766
1767static const char *
Darren Tuckere7140f22008-06-10 23:01:51 +10001768fmt_intarg(ServerOpCodes code, int val)
1769{
Damien Miller82c55872011-06-23 08:20:30 +10001770 if (val == -1)
1771 return "unset";
1772 switch (code) {
1773 case sAddressFamily:
1774 return fmt_multistate_int(val, multistate_addressfamily);
1775 case sPermitRootLogin:
1776 return fmt_multistate_int(val, multistate_permitrootlogin);
1777 case sGatewayPorts:
1778 return fmt_multistate_int(val, multistate_gatewayports);
1779 case sCompression:
1780 return fmt_multistate_int(val, multistate_compression);
Damien Miller69ff1df2011-06-23 08:30:03 +10001781 case sUsePrivilegeSeparation:
1782 return fmt_multistate_int(val, multistate_privsep);
Damien Miller82c55872011-06-23 08:20:30 +10001783 case sProtocol:
Darren Tuckere7140f22008-06-10 23:01:51 +10001784 switch (val) {
1785 case SSH_PROTO_1:
1786 return "1";
1787 case SSH_PROTO_2:
1788 return "2";
1789 case (SSH_PROTO_1|SSH_PROTO_2):
1790 return "2,1";
1791 default:
1792 return "UNKNOWN";
1793 }
Damien Miller82c55872011-06-23 08:20:30 +10001794 default:
1795 switch (val) {
1796 case 0:
1797 return "no";
1798 case 1:
1799 return "yes";
1800 default:
1801 return "UNKNOWN";
1802 }
Darren Tuckere7140f22008-06-10 23:01:51 +10001803 }
Darren Tuckere7140f22008-06-10 23:01:51 +10001804}
1805
1806static const char *
1807lookup_opcode_name(ServerOpCodes code)
1808{
1809 u_int i;
1810
1811 for (i = 0; keywords[i].name != NULL; i++)
1812 if (keywords[i].opcode == code)
1813 return(keywords[i].name);
1814 return "UNKNOWN";
1815}
1816
1817static void
1818dump_cfg_int(ServerOpCodes code, int val)
1819{
1820 printf("%s %d\n", lookup_opcode_name(code), val);
1821}
1822
1823static void
1824dump_cfg_fmtint(ServerOpCodes code, int val)
1825{
1826 printf("%s %s\n", lookup_opcode_name(code), fmt_intarg(code, val));
1827}
1828
1829static void
1830dump_cfg_string(ServerOpCodes code, const char *val)
1831{
1832 if (val == NULL)
1833 return;
1834 printf("%s %s\n", lookup_opcode_name(code), val);
1835}
1836
1837static void
1838dump_cfg_strarray(ServerOpCodes code, u_int count, char **vals)
1839{
1840 u_int i;
1841
1842 for (i = 0; i < count; i++)
Damien Millerd8478b62011-05-29 21:39:36 +10001843 printf("%s %s\n", lookup_opcode_name(code), vals[i]);
1844}
1845
1846static void
1847dump_cfg_strarray_oneline(ServerOpCodes code, u_int count, char **vals)
1848{
1849 u_int i;
1850
1851 printf("%s", lookup_opcode_name(code));
1852 for (i = 0; i < count; i++)
1853 printf(" %s", vals[i]);
1854 printf("\n");
Darren Tuckere7140f22008-06-10 23:01:51 +10001855}
1856
1857void
1858dump_config(ServerOptions *o)
1859{
1860 u_int i;
1861 int ret;
1862 struct addrinfo *ai;
1863 char addr[NI_MAXHOST], port[NI_MAXSERV], *s = NULL;
1864
1865 /* these are usually at the top of the config */
1866 for (i = 0; i < o->num_ports; i++)
1867 printf("port %d\n", o->ports[i]);
1868 dump_cfg_fmtint(sProtocol, o->protocol);
1869 dump_cfg_fmtint(sAddressFamily, o->address_family);
1870
1871 /* ListenAddress must be after Port */
1872 for (ai = o->listen_addrs; ai; ai = ai->ai_next) {
1873 if ((ret = getnameinfo(ai->ai_addr, ai->ai_addrlen, addr,
1874 sizeof(addr), port, sizeof(port),
1875 NI_NUMERICHOST|NI_NUMERICSERV)) != 0) {
1876 error("getnameinfo failed: %.100s",
1877 (ret != EAI_SYSTEM) ? gai_strerror(ret) :
1878 strerror(errno));
1879 } else {
1880 if (ai->ai_family == AF_INET6)
1881 printf("listenaddress [%s]:%s\n", addr, port);
1882 else
1883 printf("listenaddress %s:%s\n", addr, port);
1884 }
1885 }
1886
1887 /* integer arguments */
Damien Miller212f0b02008-07-23 17:42:29 +10001888#ifdef USE_PAM
1889 dump_cfg_int(sUsePAM, o->use_pam);
1890#endif
Darren Tuckere7140f22008-06-10 23:01:51 +10001891 dump_cfg_int(sServerKeyBits, o->server_key_bits);
1892 dump_cfg_int(sLoginGraceTime, o->login_grace_time);
1893 dump_cfg_int(sKeyRegenerationTime, o->key_regeneration_time);
1894 dump_cfg_int(sX11DisplayOffset, o->x11_display_offset);
1895 dump_cfg_int(sMaxAuthTries, o->max_authtries);
Damien Miller7fc5c0f2008-11-05 16:12:11 +11001896 dump_cfg_int(sMaxSessions, o->max_sessions);
Darren Tuckere7140f22008-06-10 23:01:51 +10001897 dump_cfg_int(sClientAliveInterval, o->client_alive_interval);
1898 dump_cfg_int(sClientAliveCountMax, o->client_alive_count_max);
1899
1900 /* formatted integer arguments */
1901 dump_cfg_fmtint(sPermitRootLogin, o->permit_root_login);
1902 dump_cfg_fmtint(sIgnoreRhosts, o->ignore_rhosts);
1903 dump_cfg_fmtint(sIgnoreUserKnownHosts, o->ignore_user_known_hosts);
1904 dump_cfg_fmtint(sRhostsRSAAuthentication, o->rhosts_rsa_authentication);
1905 dump_cfg_fmtint(sHostbasedAuthentication, o->hostbased_authentication);
1906 dump_cfg_fmtint(sHostbasedUsesNameFromPacketOnly,
1907 o->hostbased_uses_name_from_packet_only);
1908 dump_cfg_fmtint(sRSAAuthentication, o->rsa_authentication);
1909 dump_cfg_fmtint(sPubkeyAuthentication, o->pubkey_authentication);
Damien Miller6ef430d2008-07-23 17:40:04 +10001910#ifdef KRB5
Darren Tuckere7140f22008-06-10 23:01:51 +10001911 dump_cfg_fmtint(sKerberosAuthentication, o->kerberos_authentication);
1912 dump_cfg_fmtint(sKerberosOrLocalPasswd, o->kerberos_or_local_passwd);
1913 dump_cfg_fmtint(sKerberosTicketCleanup, o->kerberos_ticket_cleanup);
Damien Miller6ef430d2008-07-23 17:40:04 +10001914# ifdef USE_AFS
Darren Tuckere7140f22008-06-10 23:01:51 +10001915 dump_cfg_fmtint(sKerberosGetAFSToken, o->kerberos_get_afs_token);
Damien Miller6ef430d2008-07-23 17:40:04 +10001916# endif
1917#endif
1918#ifdef GSSAPI
Darren Tuckere7140f22008-06-10 23:01:51 +10001919 dump_cfg_fmtint(sGssAuthentication, o->gss_authentication);
1920 dump_cfg_fmtint(sGssCleanupCreds, o->gss_cleanup_creds);
Damien Miller6ef430d2008-07-23 17:40:04 +10001921#endif
Damien Miller01ed2272008-11-05 16:20:46 +11001922#ifdef JPAKE
1923 dump_cfg_fmtint(sZeroKnowledgePasswordAuthentication,
1924 o->zero_knowledge_password_authentication);
1925#endif
Darren Tuckere7140f22008-06-10 23:01:51 +10001926 dump_cfg_fmtint(sPasswordAuthentication, o->password_authentication);
1927 dump_cfg_fmtint(sKbdInteractiveAuthentication,
1928 o->kbd_interactive_authentication);
1929 dump_cfg_fmtint(sChallengeResponseAuthentication,
1930 o->challenge_response_authentication);
1931 dump_cfg_fmtint(sPrintMotd, o->print_motd);
1932 dump_cfg_fmtint(sPrintLastLog, o->print_lastlog);
1933 dump_cfg_fmtint(sX11Forwarding, o->x11_forwarding);
1934 dump_cfg_fmtint(sX11UseLocalhost, o->x11_use_localhost);
1935 dump_cfg_fmtint(sStrictModes, o->strict_modes);
1936 dump_cfg_fmtint(sTCPKeepAlive, o->tcp_keep_alive);
1937 dump_cfg_fmtint(sEmptyPasswd, o->permit_empty_passwd);
1938 dump_cfg_fmtint(sPermitUserEnvironment, o->permit_user_env);
1939 dump_cfg_fmtint(sUseLogin, o->use_login);
1940 dump_cfg_fmtint(sCompression, o->compression);
1941 dump_cfg_fmtint(sGatewayPorts, o->gateway_ports);
1942 dump_cfg_fmtint(sUseDNS, o->use_dns);
1943 dump_cfg_fmtint(sAllowTcpForwarding, o->allow_tcp_forwarding);
1944 dump_cfg_fmtint(sUsePrivilegeSeparation, use_privsep);
1945
1946 /* string arguments */
1947 dump_cfg_string(sPidFile, o->pid_file);
1948 dump_cfg_string(sXAuthLocation, o->xauth_location);
1949 dump_cfg_string(sCiphers, o->ciphers);
1950 dump_cfg_string(sMacs, o->macs);
1951 dump_cfg_string(sBanner, o->banner);
Darren Tuckere7140f22008-06-10 23:01:51 +10001952 dump_cfg_string(sForceCommand, o->adm_forced_command);
Darren Tuckerd3300452010-01-10 19:26:43 +11001953 dump_cfg_string(sChrootDirectory, o->chroot_directory);
Damien Miller1aed65e2010-03-04 21:53:35 +11001954 dump_cfg_string(sTrustedUserCAKeys, o->trusted_user_ca_keys);
1955 dump_cfg_string(sRevokedKeys, o->revoked_keys_file);
Damien Miller30da3442010-05-10 11:58:03 +10001956 dump_cfg_string(sAuthorizedPrincipalsFile,
1957 o->authorized_principals_file);
Damien Miller23528812012-04-22 11:24:43 +10001958 dump_cfg_string(sVersionAddendum, o->version_addendum);
Damien Miller09d3e122012-10-31 08:58:58 +11001959 dump_cfg_string(sAuthorizedKeysCommand, o->authorized_keys_command);
1960 dump_cfg_string(sAuthorizedKeysCommandUser, o->authorized_keys_command_user);
Darren Tuckere7140f22008-06-10 23:01:51 +10001961
1962 /* string arguments requiring a lookup */
1963 dump_cfg_string(sLogLevel, log_level_name(o->log_level));
1964 dump_cfg_string(sLogFacility, log_facility_name(o->log_facility));
1965
1966 /* string array arguments */
Damien Millerd8478b62011-05-29 21:39:36 +10001967 dump_cfg_strarray_oneline(sAuthorizedKeysFile, o->num_authkeys_files,
1968 o->authorized_keys_files);
Darren Tuckere7140f22008-06-10 23:01:51 +10001969 dump_cfg_strarray(sHostKeyFile, o->num_host_key_files,
1970 o->host_key_files);
Damien Miller0a80ca12010-02-27 07:55:05 +11001971 dump_cfg_strarray(sHostKeyFile, o->num_host_cert_files,
1972 o->host_cert_files);
Darren Tuckere7140f22008-06-10 23:01:51 +10001973 dump_cfg_strarray(sAllowUsers, o->num_allow_users, o->allow_users);
1974 dump_cfg_strarray(sDenyUsers, o->num_deny_users, o->deny_users);
1975 dump_cfg_strarray(sAllowGroups, o->num_allow_groups, o->allow_groups);
1976 dump_cfg_strarray(sDenyGroups, o->num_deny_groups, o->deny_groups);
1977 dump_cfg_strarray(sAcceptEnv, o->num_accept_env, o->accept_env);
Damien Millera6e3f012012-11-04 23:21:40 +11001978 dump_cfg_strarray_oneline(sAuthenticationMethods,
1979 o->num_auth_methods, o->auth_methods);
Darren Tuckere7140f22008-06-10 23:01:51 +10001980
1981 /* other arguments */
1982 for (i = 0; i < o->num_subsystems; i++)
1983 printf("subsystem %s %s\n", o->subsystem_name[i],
1984 o->subsystem_args[i]);
1985
1986 printf("maxstartups %d:%d:%d\n", o->max_startups_begin,
1987 o->max_startups_rate, o->max_startups);
1988
1989 for (i = 0; tunmode_desc[i].val != -1; i++)
1990 if (tunmode_desc[i].val == o->permit_tun) {
1991 s = tunmode_desc[i].text;
1992 break;
1993 }
1994 dump_cfg_string(sPermitTunnel, s);
1995
Damien Miller91475862011-05-05 14:14:34 +10001996 printf("ipqos %s ", iptos2str(o->ip_qos_interactive));
1997 printf("%s\n", iptos2str(o->ip_qos_bulk));
Damien Miller0dac6fb2010-11-20 15:19:38 +11001998
Darren Tuckere7140f22008-06-10 23:01:51 +10001999 channel_print_adm_permitted_opens();
Darren Tuckere7140f22008-06-10 23:01:51 +10002000}