blob: 5acaf61b1cbaee5f43983e0b4a15de084015a534 [file] [log] [blame]
djm@openbsd.orgbcc50d82015-05-21 06:43:30 +00001/* $OpenBSD: servconf.c,v 1.270 2015/05/21 06:43:30 djm Exp $ */
Damien Millerd4a8b7e1999-10-27 13:42:43 +10002/*
Damien Miller95def091999-11-25 00:26:21 +11003 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved
Damien Miller4af51302000-04-16 11:18:38 +10005 *
Damien Millere4340be2000-09-16 13:29:08 +11006 * As far as I am concerned, the code I have written for this software
7 * can be used freely for any purpose. Any derived versions of this
8 * software must be clearly marked as such, and if the derived work is
9 * incompatible with the protocol description in the RFC file, it must be
10 * called by a name other than "ssh" or "Secure Shell".
Damien Miller95def091999-11-25 00:26:21 +110011 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +100012
13#include "includes.h"
Damien Millerd4a8b7e1999-10-27 13:42:43 +100014
Damien Millere3b60b52006-07-10 21:08:03 +100015#include <sys/types.h>
16#include <sys/socket.h>
17
Damien Miller0dac6fb2010-11-20 15:19:38 +110018#include <netinet/in.h>
19#include <netinet/in_systm.h>
20#include <netinet/ip.h>
21
Darren Tucker5f96f3b2013-05-16 20:29:28 +100022#include <ctype.h>
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>
deraadt@openbsd.org2ae4f332015-01-16 06:40:12 +000030#include <limits.h>
Damien Millerd7834352006-08-05 12:39:39 +100031#include <stdarg.h>
Darren Tuckere7140f22008-06-10 23:01:51 +100032#include <errno.h>
Darren Tuckere194ba42013-05-16 20:47:31 +100033#ifdef HAVE_UTIL_H
Darren Tuckerb7ee8522013-05-16 20:33:10 +100034#include <util.h>
Darren Tuckere194ba42013-05-16 20:47:31 +100035#endif
Damien Millerbe43ebf2006-07-24 13:51:51 +100036
Damien Millerb84886b2008-05-19 15:05:07 +100037#include "openbsd-compat/sys-queue.h"
Damien Millerd7834352006-08-05 12:39:39 +100038#include "xmalloc.h"
Damien Millerd4a8b7e1999-10-27 13:42:43 +100039#include "ssh.h"
Ben Lindstrom226cfa02001-01-22 05:34:40 +000040#include "log.h"
Damien Millerd7834352006-08-05 12:39:39 +100041#include "buffer.h"
Damien Miller7acefbb2014-07-18 14:11:24 +100042#include "misc.h"
Damien Millerd4a8b7e1999-10-27 13:42:43 +100043#include "servconf.h"
Damien Miller78928792000-04-12 20:17:38 +100044#include "compat.h"
Ben Lindstrom226cfa02001-01-22 05:34:40 +000045#include "pathnames.h"
Ben Lindstrom226cfa02001-01-22 05:34:40 +000046#include "cipher.h"
Damien Millerd7834352006-08-05 12:39:39 +100047#include "key.h"
Ben Lindstrom06b33aa2001-02-15 03:01:59 +000048#include "kex.h"
49#include "mac.h"
Darren Tucker45150472006-07-12 22:34:17 +100050#include "match.h"
Damien Miller9b439df2006-07-24 14:04:00 +100051#include "channels.h"
Damien Miller565ca3f2006-08-19 00:23:15 +100052#include "groupaccess.h"
Darren Tuckerfbcf8272012-05-19 19:37:01 +100053#include "canohost.h"
54#include "packet.h"
Damien Millera6e3f012012-11-04 23:21:40 +110055#include "hostfile.h"
56#include "auth.h"
djm@openbsd.org57d378e2014-08-19 23:58:28 +000057#include "myproposal.h"
djm@openbsd.org56d1c832014-12-21 22:27:55 +000058#include "digest.h"
Ben Lindstrom226cfa02001-01-22 05:34:40 +000059
Damien Miller3dc71ad2009-01-28 16:31:22 +110060static void add_listen_addr(ServerOptions *, char *, int);
61static void add_one_listen_addr(ServerOptions *, char *, int);
Damien Miller34132e52000-01-14 15:45:46 +110062
Ben Lindstrom7a2073c2002-03-22 02:30:41 +000063/* Use of privilege separation or not */
64extern int use_privsep;
Darren Tucker45150472006-07-12 22:34:17 +100065extern Buffer cfg;
Ben Lindstrom226cfa02001-01-22 05:34:40 +000066
Damien Millerd4a8b7e1999-10-27 13:42:43 +100067/* Initializes the server options to their default values. */
68
Damien Miller4af51302000-04-16 11:18:38 +100069void
Damien Miller95def091999-11-25 00:26:21 +110070initialize_server_options(ServerOptions *options)
Damien Millerd4a8b7e1999-10-27 13:42:43 +100071{
Damien Miller95def091999-11-25 00:26:21 +110072 memset(options, 0, sizeof(*options));
Damien Miller726273e2001-11-12 11:40:11 +110073
74 /* Portable-specific options */
Damien Miller4e448a32003-05-14 15:11:48 +100075 options->use_pam = -1;
Damien Miller726273e2001-11-12 11:40:11 +110076
77 /* Standard Options */
Damien Miller34132e52000-01-14 15:45:46 +110078 options->num_ports = 0;
79 options->ports_from_cmdline = 0;
dtucker@openbsd.org531a57a2015-04-29 03:48:56 +000080 options->queued_listen_addrs = NULL;
81 options->num_queued_listens = 0;
Damien Miller34132e52000-01-14 15:45:46 +110082 options->listen_addrs = NULL;
Darren Tucker0f383232005-01-20 10:57:56 +110083 options->address_family = -1;
Damien Miller0bc1bd82000-11-13 22:57:25 +110084 options->num_host_key_files = 0;
Damien Miller0a80ca12010-02-27 07:55:05 +110085 options->num_host_cert_files = 0;
Damien Miller85b45e02013-07-20 13:21:52 +100086 options->host_key_agent = NULL;
Damien Miller6f83b8e2000-05-02 09:23:45 +100087 options->pid_file = NULL;
Damien Miller95def091999-11-25 00:26:21 +110088 options->server_key_bits = -1;
89 options->login_grace_time = -1;
90 options->key_regeneration_time = -1;
Ben Lindstromd8a90212001-02-15 03:08:27 +000091 options->permit_root_login = PERMIT_NOT_SET;
Damien Miller95def091999-11-25 00:26:21 +110092 options->ignore_rhosts = -1;
93 options->ignore_user_known_hosts = -1;
94 options->print_motd = -1;
Ben Lindstrom7bfff362001-03-26 05:45:53 +000095 options->print_lastlog = -1;
Damien Miller95def091999-11-25 00:26:21 +110096 options->x11_forwarding = -1;
97 options->x11_display_offset = -1;
Damien Miller95c249f2002-02-05 12:11:34 +110098 options->x11_use_localhost = -1;
Damien Miller5ff30c62013-10-30 22:21:50 +110099 options->permit_tty = -1;
Damien Miller72e6b5c2014-07-04 09:00:04 +1000100 options->permit_user_rc = -1;
Damien Millerd3a18572000-06-07 19:55:44 +1000101 options->xauth_location = NULL;
Damien Miller95def091999-11-25 00:26:21 +1100102 options->strict_modes = -1;
Damien Miller12c150e2003-12-17 16:31:10 +1100103 options->tcp_keep_alive = -1;
Damien Millerfcd93202002-02-05 12:26:34 +1100104 options->log_facility = SYSLOG_FACILITY_NOT_SET;
105 options->log_level = SYSLOG_LEVEL_NOT_SET;
Damien Miller95def091999-11-25 00:26:21 +1100106 options->rhosts_rsa_authentication = -1;
Ben Lindstrom5eabda32001-04-12 23:34:34 +0000107 options->hostbased_authentication = -1;
108 options->hostbased_uses_name_from_packet_only = -1;
djm@openbsd.org1f729f02015-01-13 07:39:19 +0000109 options->hostbased_key_types = NULL;
Damien Miller95def091999-11-25 00:26:21 +1100110 options->rsa_authentication = -1;
Damien Miller0bc1bd82000-11-13 22:57:25 +1100111 options->pubkey_authentication = -1;
djm@openbsd.org1f729f02015-01-13 07:39:19 +0000112 options->pubkey_key_types = NULL;
Damien Miller95def091999-11-25 00:26:21 +1100113 options->kerberos_authentication = -1;
114 options->kerberos_or_local_passwd = -1;
115 options->kerberos_ticket_cleanup = -1;
Darren Tucker22ef5082003-12-31 11:37:34 +1100116 options->kerberos_get_afs_token = -1;
Darren Tucker0efd1552003-08-26 11:49:55 +1000117 options->gss_authentication=-1;
118 options->gss_cleanup_creds = -1;
Damien Miller95def091999-11-25 00:26:21 +1100119 options->password_authentication = -1;
Damien Miller874d77b2000-10-14 16:23:11 +1100120 options->kbd_interactive_authentication = -1;
Ben Lindstrom551ea372001-06-05 18:56:16 +0000121 options->challenge_response_authentication = -1;
Damien Miller95def091999-11-25 00:26:21 +1100122 options->permit_empty_passwd = -1;
Ben Lindstrom5d860f02002-08-01 01:28:38 +0000123 options->permit_user_env = -1;
Damien Miller95def091999-11-25 00:26:21 +1100124 options->use_login = -1;
Ben Lindstrom23e0f662002-06-21 01:09:47 +0000125 options->compression = -1;
Darren Tucker5f96f3b2013-05-16 20:29:28 +1000126 options->rekey_limit = -1;
127 options->rekey_interval = -1;
Damien Miller50a41ed2000-10-16 12:14:42 +1100128 options->allow_tcp_forwarding = -1;
Damien Miller7acefbb2014-07-18 14:11:24 +1000129 options->allow_streamlocal_forwarding = -1;
Damien Miller4f755cd2008-05-19 14:57:41 +1000130 options->allow_agent_forwarding = -1;
Damien Miller95def091999-11-25 00:26:21 +1100131 options->num_allow_users = 0;
132 options->num_deny_users = 0;
133 options->num_allow_groups = 0;
134 options->num_deny_groups = 0;
Damien Miller78928792000-04-12 20:17:38 +1000135 options->ciphers = NULL;
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000136 options->macs = NULL;
Damien Millerd5f62bf2010-09-24 22:11:14 +1000137 options->kex_algorithms = NULL;
Damien Miller78928792000-04-12 20:17:38 +1000138 options->protocol = SSH_PROTO_UNKNOWN;
Damien Miller7acefbb2014-07-18 14:11:24 +1000139 options->fwd_opts.gateway_ports = -1;
140 options->fwd_opts.streamlocal_bind_mask = (mode_t)-1;
141 options->fwd_opts.streamlocal_bind_unlink = -1;
Damien Millerf6d9e222000-06-18 14:50:44 +1000142 options->num_subsystems = 0;
Damien Miller942da032000-08-18 13:59:06 +1000143 options->max_startups_begin = -1;
144 options->max_startups_rate = -1;
Damien Miller37023962000-07-11 17:31:38 +1000145 options->max_startups = -1;
Darren Tucker89413db2004-05-24 10:36:23 +1000146 options->max_authtries = -1;
Damien Miller7207f642008-05-19 15:34:50 +1000147 options->max_sessions = -1;
Ben Lindstrom48bd7c12001-01-09 00:35:42 +0000148 options->banner = NULL;
Damien Miller3a961dc2003-06-03 10:25:48 +1000149 options->use_dns = -1;
Ben Lindstrom5744dc42001-04-13 23:28:01 +0000150 options->client_alive_interval = -1;
151 options->client_alive_count_max = -1;
Damien Millerd8478b62011-05-29 21:39:36 +1000152 options->num_authkeys_files = 0;
Darren Tucker46bc0752004-05-02 22:11:30 +1000153 options->num_accept_env = 0;
Damien Millerd27b9472005-12-13 19:29:02 +1100154 options->permit_tun = -1;
Damien Millera765cf42006-07-24 14:08:13 +1000155 options->num_permitted_opens = -1;
Damien Millere2754432006-07-24 14:06:47 +1000156 options->adm_forced_command = NULL;
Damien Millerd8cb1f12008-02-10 22:40:12 +1100157 options->chroot_directory = NULL;
Damien Miller09d3e122012-10-31 08:58:58 +1100158 options->authorized_keys_command = NULL;
159 options->authorized_keys_command_user = NULL;
Damien Miller1aed65e2010-03-04 21:53:35 +1100160 options->revoked_keys_file = NULL;
161 options->trusted_user_ca_keys = NULL;
Damien Miller30da3442010-05-10 11:58:03 +1000162 options->authorized_principals_file = NULL;
djm@openbsd.orgbcc50d82015-05-21 06:43:30 +0000163 options->authorized_principals_command = NULL;
164 options->authorized_principals_command_user = NULL;
Damien Miller0dac6fb2010-11-20 15:19:38 +1100165 options->ip_qos_interactive = -1;
166 options->ip_qos_bulk = -1;
Damien Miller23528812012-04-22 11:24:43 +1000167 options->version_addendum = NULL;
djm@openbsd.org56d1c832014-12-21 22:27:55 +0000168 options->fingerprint_hash = -1;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000169}
170
djm@openbsd.org161cf412014-12-22 07:55:51 +0000171/* Returns 1 if a string option is unset or set to "none" or 0 otherwise. */
172static int
173option_clear_or_none(const char *o)
174{
175 return o == NULL || strcasecmp(o, "none") == 0;
176}
177
Damien Miller4af51302000-04-16 11:18:38 +1000178void
Damien Miller95def091999-11-25 00:26:21 +1100179fill_default_server_options(ServerOptions *options)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000180{
djm@openbsd.org161cf412014-12-22 07:55:51 +0000181 int i;
182
Damien Miller726273e2001-11-12 11:40:11 +1100183 /* Portable-specific options */
Damien Miller4e448a32003-05-14 15:11:48 +1000184 if (options->use_pam == -1)
Damien Miller5c3a5582003-09-23 22:12:38 +1000185 options->use_pam = 0;
Damien Miller726273e2001-11-12 11:40:11 +1100186
187 /* Standard Options */
Damien Miller0bc1bd82000-11-13 22:57:25 +1100188 if (options->protocol == SSH_PROTO_UNKNOWN)
Darren Tuckerbad50762009-10-11 21:51:08 +1100189 options->protocol = SSH_PROTO_2;
Damien Miller0bc1bd82000-11-13 22:57:25 +1100190 if (options->num_host_key_files == 0) {
191 /* fill default hostkeys for protocols */
192 if (options->protocol & SSH_PROTO_1)
Damien Miller7fc23732002-01-22 23:19:11 +1100193 options->host_key_files[options->num_host_key_files++] =
194 _PATH_HOST_KEY_FILE;
195 if (options->protocol & SSH_PROTO_2) {
196 options->host_key_files[options->num_host_key_files++] =
197 _PATH_HOST_RSA_KEY_FILE;
198 options->host_key_files[options->num_host_key_files++] =
199 _PATH_HOST_DSA_KEY_FILE;
Damien Millerdd190dd2010-11-11 14:17:02 +1100200#ifdef OPENSSL_HAS_ECC
Damien Millere13cadf2010-09-10 11:15:33 +1000201 options->host_key_files[options->num_host_key_files++] =
202 _PATH_HOST_ECDSA_KEY_FILE;
Damien Millerdd190dd2010-11-11 14:17:02 +1100203#endif
Damien Miller5be9d9e2013-12-07 11:24:01 +1100204 options->host_key_files[options->num_host_key_files++] =
205 _PATH_HOST_ED25519_KEY_FILE;
Damien Miller7fc23732002-01-22 23:19:11 +1100206 }
Damien Miller0bc1bd82000-11-13 22:57:25 +1100207 }
Damien Miller0a80ca12010-02-27 07:55:05 +1100208 /* No certificates by default */
Damien Miller34132e52000-01-14 15:45:46 +1100209 if (options->num_ports == 0)
210 options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
dtucker@openbsd.org531a57a2015-04-29 03:48:56 +0000211 if (options->address_family == -1)
212 options->address_family = AF_UNSPEC;
Damien Miller34132e52000-01-14 15:45:46 +1100213 if (options->listen_addrs == NULL)
Ben Lindstrom19066a12001-04-12 23:39:26 +0000214 add_listen_addr(options, NULL, 0);
Damien Miller6f83b8e2000-05-02 09:23:45 +1000215 if (options->pid_file == NULL)
djm@openbsd.org161cf412014-12-22 07:55:51 +0000216 options->pid_file = xstrdup(_PATH_SSH_DAEMON_PID_FILE);
Damien Miller95def091999-11-25 00:26:21 +1100217 if (options->server_key_bits == -1)
Darren Tucker7499b0c2008-07-02 22:35:43 +1000218 options->server_key_bits = 1024;
Damien Miller95def091999-11-25 00:26:21 +1100219 if (options->login_grace_time == -1)
Damien Millerc1348632002-09-05 14:35:14 +1000220 options->login_grace_time = 120;
Damien Miller95def091999-11-25 00:26:21 +1100221 if (options->key_regeneration_time == -1)
222 options->key_regeneration_time = 3600;
Ben Lindstromd8a90212001-02-15 03:08:27 +0000223 if (options->permit_root_login == PERMIT_NOT_SET)
djm@openbsd.org88a7c592015-04-27 21:42:48 +0000224 options->permit_root_login = PERMIT_NO;
Damien Miller95def091999-11-25 00:26:21 +1100225 if (options->ignore_rhosts == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100226 options->ignore_rhosts = 1;
Damien Miller95def091999-11-25 00:26:21 +1100227 if (options->ignore_user_known_hosts == -1)
228 options->ignore_user_known_hosts = 0;
Damien Miller95def091999-11-25 00:26:21 +1100229 if (options->print_motd == -1)
230 options->print_motd = 1;
Ben Lindstrom7bfff362001-03-26 05:45:53 +0000231 if (options->print_lastlog == -1)
232 options->print_lastlog = 1;
Damien Miller95def091999-11-25 00:26:21 +1100233 if (options->x11_forwarding == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100234 options->x11_forwarding = 0;
Damien Miller95def091999-11-25 00:26:21 +1100235 if (options->x11_display_offset == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100236 options->x11_display_offset = 10;
Damien Miller95c249f2002-02-05 12:11:34 +1100237 if (options->x11_use_localhost == -1)
238 options->x11_use_localhost = 1;
Damien Millerd3a18572000-06-07 19:55:44 +1000239 if (options->xauth_location == NULL)
djm@openbsd.org161cf412014-12-22 07:55:51 +0000240 options->xauth_location = xstrdup(_PATH_XAUTH);
Damien Miller5ff30c62013-10-30 22:21:50 +1100241 if (options->permit_tty == -1)
242 options->permit_tty = 1;
Damien Miller72e6b5c2014-07-04 09:00:04 +1000243 if (options->permit_user_rc == -1)
244 options->permit_user_rc = 1;
Damien Miller95def091999-11-25 00:26:21 +1100245 if (options->strict_modes == -1)
246 options->strict_modes = 1;
Damien Miller12c150e2003-12-17 16:31:10 +1100247 if (options->tcp_keep_alive == -1)
248 options->tcp_keep_alive = 1;
Damien Millerfcd93202002-02-05 12:26:34 +1100249 if (options->log_facility == SYSLOG_FACILITY_NOT_SET)
Damien Miller95def091999-11-25 00:26:21 +1100250 options->log_facility = SYSLOG_FACILITY_AUTH;
Damien Millerfcd93202002-02-05 12:26:34 +1100251 if (options->log_level == SYSLOG_LEVEL_NOT_SET)
Ben Lindstromdb65e8f2001-01-19 04:26:52 +0000252 options->log_level = SYSLOG_LEVEL_INFO;
Damien Miller95def091999-11-25 00:26:21 +1100253 if (options->rhosts_rsa_authentication == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100254 options->rhosts_rsa_authentication = 0;
Ben Lindstrom5eabda32001-04-12 23:34:34 +0000255 if (options->hostbased_authentication == -1)
256 options->hostbased_authentication = 0;
257 if (options->hostbased_uses_name_from_packet_only == -1)
258 options->hostbased_uses_name_from_packet_only = 0;
djm@openbsd.org1f729f02015-01-13 07:39:19 +0000259 if (options->hostbased_key_types == NULL)
260 options->hostbased_key_types = xstrdup("*");
Damien Miller95def091999-11-25 00:26:21 +1100261 if (options->rsa_authentication == -1)
262 options->rsa_authentication = 1;
Damien Miller0bc1bd82000-11-13 22:57:25 +1100263 if (options->pubkey_authentication == -1)
264 options->pubkey_authentication = 1;
djm@openbsd.org1f729f02015-01-13 07:39:19 +0000265 if (options->pubkey_key_types == NULL)
266 options->pubkey_key_types = xstrdup("*");
Damien Miller95def091999-11-25 00:26:21 +1100267 if (options->kerberos_authentication == -1)
Damien Millerd7de14b2002-04-23 21:04:51 +1000268 options->kerberos_authentication = 0;
Damien Miller95def091999-11-25 00:26:21 +1100269 if (options->kerberos_or_local_passwd == -1)
270 options->kerberos_or_local_passwd = 1;
271 if (options->kerberos_ticket_cleanup == -1)
272 options->kerberos_ticket_cleanup = 1;
Darren Tucker22ef5082003-12-31 11:37:34 +1100273 if (options->kerberos_get_afs_token == -1)
274 options->kerberos_get_afs_token = 0;
Darren Tucker0efd1552003-08-26 11:49:55 +1000275 if (options->gss_authentication == -1)
276 options->gss_authentication = 0;
277 if (options->gss_cleanup_creds == -1)
278 options->gss_cleanup_creds = 1;
Damien Miller95def091999-11-25 00:26:21 +1100279 if (options->password_authentication == -1)
280 options->password_authentication = 1;
Damien Miller874d77b2000-10-14 16:23:11 +1100281 if (options->kbd_interactive_authentication == -1)
282 options->kbd_interactive_authentication = 0;
Ben Lindstrom551ea372001-06-05 18:56:16 +0000283 if (options->challenge_response_authentication == -1)
284 options->challenge_response_authentication = 1;
Damien Miller95def091999-11-25 00:26:21 +1100285 if (options->permit_empty_passwd == -1)
Damien Miller98c7ad62000-03-09 21:27:49 +1100286 options->permit_empty_passwd = 0;
Ben Lindstrom5d860f02002-08-01 01:28:38 +0000287 if (options->permit_user_env == -1)
288 options->permit_user_env = 0;
Damien Miller95def091999-11-25 00:26:21 +1100289 if (options->use_login == -1)
290 options->use_login = 0;
Ben Lindstrom23e0f662002-06-21 01:09:47 +0000291 if (options->compression == -1)
Damien Miller9786e6e2005-07-26 21:54:56 +1000292 options->compression = COMP_DELAYED;
Darren Tucker5f96f3b2013-05-16 20:29:28 +1000293 if (options->rekey_limit == -1)
294 options->rekey_limit = 0;
295 if (options->rekey_interval == -1)
296 options->rekey_interval = 0;
Damien Miller50a41ed2000-10-16 12:14:42 +1100297 if (options->allow_tcp_forwarding == -1)
Damien Milleraa5b3f82012-12-03 09:50:54 +1100298 options->allow_tcp_forwarding = FORWARD_ALLOW;
Damien Miller7acefbb2014-07-18 14:11:24 +1000299 if (options->allow_streamlocal_forwarding == -1)
300 options->allow_streamlocal_forwarding = FORWARD_ALLOW;
Damien Miller4f755cd2008-05-19 14:57:41 +1000301 if (options->allow_agent_forwarding == -1)
302 options->allow_agent_forwarding = 1;
Damien Miller7acefbb2014-07-18 14:11:24 +1000303 if (options->fwd_opts.gateway_ports == -1)
304 options->fwd_opts.gateway_ports = 0;
Damien Miller37023962000-07-11 17:31:38 +1000305 if (options->max_startups == -1)
Damien Miller1f583df2013-02-12 11:02:08 +1100306 options->max_startups = 100;
Damien Miller942da032000-08-18 13:59:06 +1000307 if (options->max_startups_rate == -1)
Damien Miller1f583df2013-02-12 11:02:08 +1100308 options->max_startups_rate = 30; /* 30% */
Damien Miller942da032000-08-18 13:59:06 +1000309 if (options->max_startups_begin == -1)
Damien Miller1f583df2013-02-12 11:02:08 +1100310 options->max_startups_begin = 10;
Darren Tucker89413db2004-05-24 10:36:23 +1000311 if (options->max_authtries == -1)
312 options->max_authtries = DEFAULT_AUTH_FAIL_MAX;
Damien Miller7207f642008-05-19 15:34:50 +1000313 if (options->max_sessions == -1)
314 options->max_sessions = DEFAULT_SESSIONS_MAX;
Damien Miller3a961dc2003-06-03 10:25:48 +1000315 if (options->use_dns == -1)
deraadt@openbsd.org3cd51032015-02-02 01:57:44 +0000316 options->use_dns = 0;
Ben Lindstrom5744dc42001-04-13 23:28:01 +0000317 if (options->client_alive_interval == -1)
Damien Miller9f0f5c62001-12-21 14:45:46 +1100318 options->client_alive_interval = 0;
Ben Lindstrom5744dc42001-04-13 23:28:01 +0000319 if (options->client_alive_count_max == -1)
320 options->client_alive_count_max = 3;
Damien Millerd8478b62011-05-29 21:39:36 +1000321 if (options->num_authkeys_files == 0) {
322 options->authorized_keys_files[options->num_authkeys_files++] =
323 xstrdup(_PATH_SSH_USER_PERMITTED_KEYS);
324 options->authorized_keys_files[options->num_authkeys_files++] =
325 xstrdup(_PATH_SSH_USER_PERMITTED_KEYS2);
326 }
Damien Millerd27b9472005-12-13 19:29:02 +1100327 if (options->permit_tun == -1)
Damien Miller7b58e802005-12-13 19:33:19 +1100328 options->permit_tun = SSH_TUNMODE_NO;
Damien Miller0dac6fb2010-11-20 15:19:38 +1100329 if (options->ip_qos_interactive == -1)
330 options->ip_qos_interactive = IPTOS_LOWDELAY;
331 if (options->ip_qos_bulk == -1)
332 options->ip_qos_bulk = IPTOS_THROUGHPUT;
Damien Miller23528812012-04-22 11:24:43 +1000333 if (options->version_addendum == NULL)
334 options->version_addendum = xstrdup("");
Damien Miller7acefbb2014-07-18 14:11:24 +1000335 if (options->fwd_opts.streamlocal_bind_mask == (mode_t)-1)
336 options->fwd_opts.streamlocal_bind_mask = 0177;
337 if (options->fwd_opts.streamlocal_bind_unlink == -1)
338 options->fwd_opts.streamlocal_bind_unlink = 0;
djm@openbsd.org56d1c832014-12-21 22:27:55 +0000339 if (options->fingerprint_hash == -1)
340 options->fingerprint_hash = SSH_FP_HASH_DEFAULT;
Ben Lindstromfb62a692002-06-06 19:47:11 +0000341 /* Turn privilege separation on by default */
Ben Lindstrom7a2073c2002-03-22 02:30:41 +0000342 if (use_privsep == -1)
Damien Miller5a5c2b92012-07-31 12:21:34 +1000343 use_privsep = PRIVSEP_NOSANDBOX;
Damien Miller4903eb42002-06-21 16:20:44 +1000344
djm@openbsd.org161cf412014-12-22 07:55:51 +0000345#define CLEAR_ON_NONE(v) \
346 do { \
347 if (option_clear_or_none(v)) { \
348 free(v); \
349 v = NULL; \
350 } \
351 } while(0)
352 CLEAR_ON_NONE(options->pid_file);
353 CLEAR_ON_NONE(options->xauth_location);
354 CLEAR_ON_NONE(options->banner);
355 CLEAR_ON_NONE(options->trusted_user_ca_keys);
356 CLEAR_ON_NONE(options->revoked_keys_file);
djm@openbsd.org7e8528c2015-05-01 04:17:51 +0000357 CLEAR_ON_NONE(options->authorized_principals_file);
djm@openbsd.org161cf412014-12-22 07:55:51 +0000358 for (i = 0; i < options->num_host_key_files; i++)
359 CLEAR_ON_NONE(options->host_key_files[i]);
360 for (i = 0; i < options->num_host_cert_files; i++)
361 CLEAR_ON_NONE(options->host_cert_files[i]);
362#undef CLEAR_ON_NONE
363
Tim Rice40017b02002-07-14 13:36:49 -0700364#ifndef HAVE_MMAP
Damien Miller4903eb42002-06-21 16:20:44 +1000365 if (use_privsep && options->compression == 1) {
366 error("This platform does not support both privilege "
367 "separation and compression");
368 error("Compression disabled");
369 options->compression = 0;
370 }
371#endif
372
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000373}
374
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000375/* Keyword tokens. */
Damien Miller95def091999-11-25 00:26:21 +1100376typedef enum {
377 sBadOption, /* == unknown option */
Damien Miller726273e2001-11-12 11:40:11 +1100378 /* Portable-specific options */
Damien Miller4e448a32003-05-14 15:11:48 +1000379 sUsePAM,
Damien Miller726273e2001-11-12 11:40:11 +1100380 /* Standard Options */
djm@openbsd.org1f729f02015-01-13 07:39:19 +0000381 sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime,
382 sKeyRegenerationTime, sPermitRootLogin, sLogFacility, sLogLevel,
Darren Tuckerec960f22003-08-13 20:37:05 +1000383 sRhostsRSAAuthentication, sRSAAuthentication,
Damien Miller95def091999-11-25 00:26:21 +1100384 sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup,
Darren Tucker22ef5082003-12-31 11:37:34 +1100385 sKerberosGetAFSToken,
Darren Tucker6aaa58c2003-08-02 22:24:49 +1000386 sKerberosTgtPassing, sChallengeResponseAuthentication,
Darren Tucker0f383232005-01-20 10:57:56 +1100387 sPasswordAuthentication, sKbdInteractiveAuthentication,
388 sListenAddress, sAddressFamily,
Ben Lindstrom7bfff362001-03-26 05:45:53 +0000389 sPrintMotd, sPrintLastLog, sIgnoreRhosts,
Damien Miller95c249f2002-02-05 12:11:34 +1100390 sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost,
Damien Miller5ff30c62013-10-30 22:21:50 +1100391 sPermitTTY, sStrictModes, sEmptyPasswd, sTCPKeepAlive,
Ben Lindstrom5d860f02002-08-01 01:28:38 +0000392 sPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression,
Darren Tucker5f96f3b2013-05-16 20:29:28 +1000393 sRekeyLimit, sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
Ben Lindstrom06b33aa2001-02-15 03:01:59 +0000394 sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile,
djm@openbsd.org1f729f02015-01-13 07:39:19 +0000395 sGatewayPorts, sPubkeyAuthentication, sPubkeyAcceptedKeyTypes,
396 sXAuthLocation, sSubsystem, sMaxStartups, sMaxAuthTries, sMaxSessions,
Damien Miller3a961dc2003-06-03 10:25:48 +1000397 sBanner, sUseDNS, sHostbasedAuthentication,
djm@openbsd.org1f729f02015-01-13 07:39:19 +0000398 sHostbasedUsesNameFromPacketOnly, sHostbasedAcceptedKeyTypes,
399 sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile,
Damien Millerd27b9472005-12-13 19:29:02 +1100400 sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel,
Damien Millerd8cb1f12008-02-10 22:40:12 +1100401 sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
Darren Tucker7bd98e72010-01-10 10:31:12 +1100402 sUsePrivilegeSeparation, sAllowAgentForwarding,
Damien Miller7cc194f2014-02-04 11:12:56 +1100403 sHostCertificate,
Damien Miller30da3442010-05-10 11:58:03 +1000404 sRevokedKeys, sTrustedUserCAKeys, sAuthorizedPrincipalsFile,
djm@openbsd.orgbcc50d82015-05-21 06:43:30 +0000405 sAuthorizedPrincipalsCommand, sAuthorizedPrincipalsCommandUser,
Damien Miller23528812012-04-22 11:24:43 +1000406 sKexAlgorithms, sIPQoS, sVersionAddendum,
Damien Miller09d3e122012-10-31 08:58:58 +1100407 sAuthorizedKeysCommand, sAuthorizedKeysCommandUser,
Damien Miller72e6b5c2014-07-04 09:00:04 +1000408 sAuthenticationMethods, sHostKeyAgent, sPermitUserRC,
Damien Miller7acefbb2014-07-18 14:11:24 +1000409 sStreamLocalBindMask, sStreamLocalBindUnlink,
djm@openbsd.org56d1c832014-12-21 22:27:55 +0000410 sAllowStreamLocalForwarding, sFingerprintHash,
Damien Millerf9b3feb2003-05-16 11:38:32 +1000411 sDeprecated, sUnsupported
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000412} ServerOpCodes;
413
Darren Tucker45150472006-07-12 22:34:17 +1000414#define SSHCFG_GLOBAL 0x01 /* allowed in main section of sshd_config */
415#define SSHCFG_MATCH 0x02 /* allowed inside a Match section */
416#define SSHCFG_ALL (SSHCFG_GLOBAL|SSHCFG_MATCH)
417
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000418/* Textual representation of the tokens. */
Damien Miller95def091999-11-25 00:26:21 +1100419static struct {
420 const char *name;
421 ServerOpCodes opcode;
Darren Tucker45150472006-07-12 22:34:17 +1000422 u_int flags;
Damien Miller95def091999-11-25 00:26:21 +1100423} keywords[] = {
Damien Miller726273e2001-11-12 11:40:11 +1100424 /* Portable-specific options */
Damien Miller6ac2c482003-05-16 11:42:35 +1000425#ifdef USE_PAM
Darren Tucker45150472006-07-12 22:34:17 +1000426 { "usepam", sUsePAM, SSHCFG_GLOBAL },
Damien Miller6ac2c482003-05-16 11:42:35 +1000427#else
Darren Tucker45150472006-07-12 22:34:17 +1000428 { "usepam", sUnsupported, SSHCFG_GLOBAL },
Damien Miller6ac2c482003-05-16 11:42:35 +1000429#endif
Darren Tucker45150472006-07-12 22:34:17 +1000430 { "pamauthenticationviakbdint", sDeprecated, SSHCFG_GLOBAL },
Damien Miller726273e2001-11-12 11:40:11 +1100431 /* Standard Options */
Darren Tucker45150472006-07-12 22:34:17 +1000432 { "port", sPort, SSHCFG_GLOBAL },
433 { "hostkey", sHostKeyFile, SSHCFG_GLOBAL },
434 { "hostdsakey", sHostKeyFile, SSHCFG_GLOBAL }, /* alias */
Damien Miller85b45e02013-07-20 13:21:52 +1000435 { "hostkeyagent", sHostKeyAgent, SSHCFG_GLOBAL },
Darren Tucker45150472006-07-12 22:34:17 +1000436 { "pidfile", sPidFile, SSHCFG_GLOBAL },
437 { "serverkeybits", sServerKeyBits, SSHCFG_GLOBAL },
438 { "logingracetime", sLoginGraceTime, SSHCFG_GLOBAL },
439 { "keyregenerationinterval", sKeyRegenerationTime, SSHCFG_GLOBAL },
Darren Tucker15f94272008-01-01 20:36:56 +1100440 { "permitrootlogin", sPermitRootLogin, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000441 { "syslogfacility", sLogFacility, SSHCFG_GLOBAL },
442 { "loglevel", sLogLevel, SSHCFG_GLOBAL },
443 { "rhostsauthentication", sDeprecated, SSHCFG_GLOBAL },
Darren Tucker1629c072007-02-19 22:25:37 +1100444 { "rhostsrsaauthentication", sRhostsRSAAuthentication, SSHCFG_ALL },
445 { "hostbasedauthentication", sHostbasedAuthentication, SSHCFG_ALL },
Damien Millerab6de352010-06-26 09:38:45 +1000446 { "hostbasedusesnamefrompacketonly", sHostbasedUsesNameFromPacketOnly, SSHCFG_ALL },
djm@openbsd.org1f729f02015-01-13 07:39:19 +0000447 { "hostbasedacceptedkeytypes", sHostbasedAcceptedKeyTypes, SSHCFG_ALL },
Darren Tucker1629c072007-02-19 22:25:37 +1100448 { "rsaauthentication", sRSAAuthentication, SSHCFG_ALL },
449 { "pubkeyauthentication", sPubkeyAuthentication, SSHCFG_ALL },
djm@openbsd.org1f729f02015-01-13 07:39:19 +0000450 { "pubkeyacceptedkeytypes", sPubkeyAcceptedKeyTypes, SSHCFG_ALL },
Darren Tucker64cee362009-06-21 20:26:17 +1000451 { "dsaauthentication", sPubkeyAuthentication, SSHCFG_GLOBAL }, /* alias */
Darren Tucker6aaa58c2003-08-02 22:24:49 +1000452#ifdef KRB5
Darren Tucker1629c072007-02-19 22:25:37 +1100453 { "kerberosauthentication", sKerberosAuthentication, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000454 { "kerberosorlocalpasswd", sKerberosOrLocalPasswd, SSHCFG_GLOBAL },
455 { "kerberosticketcleanup", sKerberosTicketCleanup, SSHCFG_GLOBAL },
Darren Tucker3c78c5e2004-01-23 22:03:10 +1100456#ifdef USE_AFS
Darren Tucker45150472006-07-12 22:34:17 +1000457 { "kerberosgetafstoken", sKerberosGetAFSToken, SSHCFG_GLOBAL },
Damien Millerf9b3feb2003-05-16 11:38:32 +1000458#else
Darren Tucker45150472006-07-12 22:34:17 +1000459 { "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL },
Darren Tucker409cb322004-01-05 22:36:51 +1100460#endif
461#else
Darren Tucker1629c072007-02-19 22:25:37 +1100462 { "kerberosauthentication", sUnsupported, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000463 { "kerberosorlocalpasswd", sUnsupported, SSHCFG_GLOBAL },
464 { "kerberosticketcleanup", sUnsupported, SSHCFG_GLOBAL },
465 { "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL },
Damien Millerf9b3feb2003-05-16 11:38:32 +1000466#endif
Darren Tucker45150472006-07-12 22:34:17 +1000467 { "kerberostgtpassing", sUnsupported, SSHCFG_GLOBAL },
468 { "afstokenpassing", sUnsupported, SSHCFG_GLOBAL },
Darren Tucker0efd1552003-08-26 11:49:55 +1000469#ifdef GSSAPI
Darren Tucker1629c072007-02-19 22:25:37 +1100470 { "gssapiauthentication", sGssAuthentication, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000471 { "gssapicleanupcredentials", sGssCleanupCreds, SSHCFG_GLOBAL },
Darren Tucker0efd1552003-08-26 11:49:55 +1000472#else
Darren Tucker1629c072007-02-19 22:25:37 +1100473 { "gssapiauthentication", sUnsupported, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000474 { "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
Darren Tucker0efd1552003-08-26 11:49:55 +1000475#endif
Darren Tucker1629c072007-02-19 22:25:37 +1100476 { "passwordauthentication", sPasswordAuthentication, SSHCFG_ALL },
477 { "kbdinteractiveauthentication", sKbdInteractiveAuthentication, SSHCFG_ALL },
Darren Tucker1d75f222007-03-01 21:31:28 +1100478 { "challengeresponseauthentication", sChallengeResponseAuthentication, SSHCFG_GLOBAL },
Darren Tucker45150472006-07-12 22:34:17 +1000479 { "skeyauthentication", sChallengeResponseAuthentication, SSHCFG_GLOBAL }, /* alias */
480 { "checkmail", sDeprecated, SSHCFG_GLOBAL },
481 { "listenaddress", sListenAddress, SSHCFG_GLOBAL },
482 { "addressfamily", sAddressFamily, SSHCFG_GLOBAL },
483 { "printmotd", sPrintMotd, SSHCFG_GLOBAL },
484 { "printlastlog", sPrintLastLog, SSHCFG_GLOBAL },
485 { "ignorerhosts", sIgnoreRhosts, SSHCFG_GLOBAL },
486 { "ignoreuserknownhosts", sIgnoreUserKnownHosts, SSHCFG_GLOBAL },
Damien Millerd1de9952006-07-24 14:05:48 +1000487 { "x11forwarding", sX11Forwarding, SSHCFG_ALL },
488 { "x11displayoffset", sX11DisplayOffset, SSHCFG_ALL },
489 { "x11uselocalhost", sX11UseLocalhost, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000490 { "xauthlocation", sXAuthLocation, SSHCFG_GLOBAL },
491 { "strictmodes", sStrictModes, SSHCFG_GLOBAL },
Damien Miller51bde602008-11-03 19:23:10 +1100492 { "permitemptypasswords", sEmptyPasswd, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000493 { "permituserenvironment", sPermitUserEnvironment, SSHCFG_GLOBAL },
494 { "uselogin", sUseLogin, SSHCFG_GLOBAL },
495 { "compression", sCompression, SSHCFG_GLOBAL },
Darren Tucker5f96f3b2013-05-16 20:29:28 +1000496 { "rekeylimit", sRekeyLimit, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000497 { "tcpkeepalive", sTCPKeepAlive, SSHCFG_GLOBAL },
498 { "keepalive", sTCPKeepAlive, SSHCFG_GLOBAL }, /* obsolete alias */
499 { "allowtcpforwarding", sAllowTcpForwarding, SSHCFG_ALL },
Damien Miller4f755cd2008-05-19 14:57:41 +1000500 { "allowagentforwarding", sAllowAgentForwarding, SSHCFG_ALL },
Damien Millerc24da772012-06-20 21:53:58 +1000501 { "allowusers", sAllowUsers, SSHCFG_ALL },
502 { "denyusers", sDenyUsers, SSHCFG_ALL },
503 { "allowgroups", sAllowGroups, SSHCFG_ALL },
504 { "denygroups", sDenyGroups, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000505 { "ciphers", sCiphers, SSHCFG_GLOBAL },
506 { "macs", sMacs, SSHCFG_GLOBAL },
507 { "protocol", sProtocol, SSHCFG_GLOBAL },
508 { "gatewayports", sGatewayPorts, SSHCFG_ALL },
509 { "subsystem", sSubsystem, SSHCFG_GLOBAL },
510 { "maxstartups", sMaxStartups, SSHCFG_GLOBAL },
Damien Miller307c1d12008-06-16 07:56:20 +1000511 { "maxauthtries", sMaxAuthTries, SSHCFG_ALL },
Damien Miller7207f642008-05-19 15:34:50 +1000512 { "maxsessions", sMaxSessions, SSHCFG_ALL },
Darren Tucker1629c072007-02-19 22:25:37 +1100513 { "banner", sBanner, SSHCFG_ALL },
Darren Tucker45150472006-07-12 22:34:17 +1000514 { "usedns", sUseDNS, SSHCFG_GLOBAL },
515 { "verifyreversemapping", sDeprecated, SSHCFG_GLOBAL },
516 { "reversemappingcheck", sDeprecated, SSHCFG_GLOBAL },
517 { "clientaliveinterval", sClientAliveInterval, SSHCFG_GLOBAL },
518 { "clientalivecountmax", sClientAliveCountMax, SSHCFG_GLOBAL },
Damien Millerab6de352010-06-26 09:38:45 +1000519 { "authorizedkeysfile", sAuthorizedKeysFile, SSHCFG_ALL },
Damien Millerd8478b62011-05-29 21:39:36 +1000520 { "authorizedkeysfile2", sDeprecated, SSHCFG_ALL },
Darren Tucker64cee362009-06-21 20:26:17 +1000521 { "useprivilegeseparation", sUsePrivilegeSeparation, SSHCFG_GLOBAL},
Damien Millerc24da772012-06-20 21:53:58 +1000522 { "acceptenv", sAcceptEnv, SSHCFG_ALL },
Damien Millerab6de352010-06-26 09:38:45 +1000523 { "permittunnel", sPermitTunnel, SSHCFG_ALL },
Damien Miller5ff30c62013-10-30 22:21:50 +1100524 { "permittty", sPermitTTY, SSHCFG_ALL },
Damien Miller72e6b5c2014-07-04 09:00:04 +1000525 { "permituserrc", sPermitUserRC, SSHCFG_ALL },
Darren Tucker64cee362009-06-21 20:26:17 +1000526 { "match", sMatch, SSHCFG_ALL },
Damien Miller9b439df2006-07-24 14:04:00 +1000527 { "permitopen", sPermitOpen, SSHCFG_ALL },
Damien Millere2754432006-07-24 14:06:47 +1000528 { "forcecommand", sForceCommand, SSHCFG_ALL },
Damien Millerd8cb1f12008-02-10 22:40:12 +1100529 { "chrootdirectory", sChrootDirectory, SSHCFG_ALL },
Damien Miller0a80ca12010-02-27 07:55:05 +1100530 { "hostcertificate", sHostCertificate, SSHCFG_GLOBAL },
Damien Miller1aed65e2010-03-04 21:53:35 +1100531 { "revokedkeys", sRevokedKeys, SSHCFG_ALL },
532 { "trustedusercakeys", sTrustedUserCAKeys, SSHCFG_ALL },
Damien Millerab6de352010-06-26 09:38:45 +1000533 { "authorizedprincipalsfile", sAuthorizedPrincipalsFile, SSHCFG_ALL },
Damien Millerd5f62bf2010-09-24 22:11:14 +1000534 { "kexalgorithms", sKexAlgorithms, SSHCFG_GLOBAL },
Damien Miller0dac6fb2010-11-20 15:19:38 +1100535 { "ipqos", sIPQoS, SSHCFG_ALL },
Damien Miller09d3e122012-10-31 08:58:58 +1100536 { "authorizedkeyscommand", sAuthorizedKeysCommand, SSHCFG_ALL },
537 { "authorizedkeyscommanduser", sAuthorizedKeysCommandUser, SSHCFG_ALL },
djm@openbsd.orgbcc50d82015-05-21 06:43:30 +0000538 { "authorizedprincipalscommand", sAuthorizedPrincipalsCommand, SSHCFG_ALL },
539 { "authorizedprincipalscommanduser", sAuthorizedPrincipalsCommandUser, SSHCFG_ALL },
Damien Miller23528812012-04-22 11:24:43 +1000540 { "versionaddendum", sVersionAddendum, SSHCFG_GLOBAL },
Damien Millera6e3f012012-11-04 23:21:40 +1100541 { "authenticationmethods", sAuthenticationMethods, SSHCFG_ALL },
Damien Miller7acefbb2014-07-18 14:11:24 +1000542 { "streamlocalbindmask", sStreamLocalBindMask, SSHCFG_ALL },
543 { "streamlocalbindunlink", sStreamLocalBindUnlink, SSHCFG_ALL },
544 { "allowstreamlocalforwarding", sAllowStreamLocalForwarding, SSHCFG_ALL },
djm@openbsd.org56d1c832014-12-21 22:27:55 +0000545 { "fingerprinthash", sFingerprintHash, SSHCFG_GLOBAL },
Darren Tucker45150472006-07-12 22:34:17 +1000546 { NULL, sBadOption, 0 }
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000547};
548
Darren Tuckere7140f22008-06-10 23:01:51 +1000549static struct {
550 int val;
551 char *text;
552} tunmode_desc[] = {
553 { SSH_TUNMODE_NO, "no" },
554 { SSH_TUNMODE_POINTOPOINT, "point-to-point" },
555 { SSH_TUNMODE_ETHERNET, "ethernet" },
556 { SSH_TUNMODE_YES, "yes" },
557 { -1, NULL }
558};
559
Damien Miller5428f641999-11-25 11:54:57 +1100560/*
Ben Lindstrom3704c262001-04-02 18:20:03 +0000561 * Returns the number of the token pointed to by cp or sBadOption.
Damien Miller5428f641999-11-25 11:54:57 +1100562 */
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000563
Damien Miller4af51302000-04-16 11:18:38 +1000564static ServerOpCodes
Damien Miller95def091999-11-25 00:26:21 +1100565parse_token(const char *cp, const char *filename,
Darren Tucker45150472006-07-12 22:34:17 +1000566 int linenum, u_int *flags)
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000567{
Ben Lindstrom46c16222000-12-22 01:43:59 +0000568 u_int i;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000569
Damien Miller95def091999-11-25 00:26:21 +1100570 for (i = 0; keywords[i].name; i++)
Darren Tucker45150472006-07-12 22:34:17 +1000571 if (strcasecmp(cp, keywords[i].name) == 0) {
572 *flags = keywords[i].flags;
Damien Miller95def091999-11-25 00:26:21 +1100573 return keywords[i].opcode;
Darren Tucker45150472006-07-12 22:34:17 +1000574 }
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000575
Ben Lindstromb5cdc662001-04-16 02:13:26 +0000576 error("%s: line %d: Bad configuration option: %s",
577 filename, linenum, cp);
Damien Miller95def091999-11-25 00:26:21 +1100578 return sBadOption;
Damien Millerd4a8b7e1999-10-27 13:42:43 +1000579}
580
Darren Tucker88b6fb22010-01-13 22:44:29 +1100581char *
582derelativise_path(const char *path)
583{
deraadt@openbsd.org2ae4f332015-01-16 06:40:12 +0000584 char *expanded, *ret, cwd[PATH_MAX];
Darren Tucker88b6fb22010-01-13 22:44:29 +1100585
djm@openbsd.org161cf412014-12-22 07:55:51 +0000586 if (strcasecmp(path, "none") == 0)
587 return xstrdup("none");
Darren Tucker88b6fb22010-01-13 22:44:29 +1100588 expanded = tilde_expand_filename(path, getuid());
589 if (*expanded == '/')
590 return expanded;
Damien Miller44451d02010-03-26 10:40:04 +1100591 if (getcwd(cwd, sizeof(cwd)) == NULL)
Darren Tucker88b6fb22010-01-13 22:44:29 +1100592 fatal("%s: getcwd: %s", __func__, strerror(errno));
593 xasprintf(&ret, "%s/%s", cwd, expanded);
Darren Tuckera627d422013-06-02 07:31:17 +1000594 free(expanded);
Darren Tucker88b6fb22010-01-13 22:44:29 +1100595 return ret;
596}
597
Ben Lindstrombba81212001-06-25 05:01:22 +0000598static void
Damien Miller3dc71ad2009-01-28 16:31:22 +1100599add_listen_addr(ServerOptions *options, char *addr, int port)
Damien Miller34132e52000-01-14 15:45:46 +1100600{
Damien Millereccb9de2005-06-17 12:59:34 +1000601 u_int i;
Damien Miller34132e52000-01-14 15:45:46 +1100602
Ben Lindstrom19066a12001-04-12 23:39:26 +0000603 if (port == 0)
Ben Lindstromc510af42001-04-07 17:25:48 +0000604 for (i = 0; i < options->num_ports; i++)
605 add_one_listen_addr(options, addr, options->ports[i]);
606 else
Ben Lindstrom19066a12001-04-12 23:39:26 +0000607 add_one_listen_addr(options, addr, port);
Ben Lindstromc510af42001-04-07 17:25:48 +0000608}
609
Ben Lindstrombba81212001-06-25 05:01:22 +0000610static void
Damien Miller3dc71ad2009-01-28 16:31:22 +1100611add_one_listen_addr(ServerOptions *options, char *addr, int port)
Ben Lindstromc510af42001-04-07 17:25:48 +0000612{
613 struct addrinfo hints, *ai, *aitop;
614 char strport[NI_MAXSERV];
615 int gaierr;
616
617 memset(&hints, 0, sizeof(hints));
Darren Tucker0f383232005-01-20 10:57:56 +1100618 hints.ai_family = options->address_family;
Ben Lindstromc510af42001-04-07 17:25:48 +0000619 hints.ai_socktype = SOCK_STREAM;
620 hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0;
Damien Miller3dc71ad2009-01-28 16:31:22 +1100621 snprintf(strport, sizeof strport, "%d", port);
Ben Lindstromc510af42001-04-07 17:25:48 +0000622 if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
623 fatal("bad addr or host: %s (%s)",
624 addr ? addr : "<NULL>",
Darren Tucker4abde772007-12-29 02:43:51 +1100625 ssh_gai_strerror(gaierr));
Ben Lindstromc510af42001-04-07 17:25:48 +0000626 for (ai = aitop; ai->ai_next; ai = ai->ai_next)
627 ;
628 ai->ai_next = options->listen_addrs;
629 options->listen_addrs = aitop;
Damien Miller34132e52000-01-14 15:45:46 +1100630}
631
dtucker@openbsd.org531a57a2015-04-29 03:48:56 +0000632/*
633 * Queue a ListenAddress to be processed once we have all of the Ports
634 * and AddressFamily options.
635 */
636static void
637queue_listen_addr(ServerOptions *options, char *addr, int port)
638{
639 options->queued_listen_addrs = xreallocarray(
640 options->queued_listen_addrs, options->num_queued_listens + 1,
641 sizeof(addr));
642 options->queued_listen_ports = xreallocarray(
643 options->queued_listen_ports, options->num_queued_listens + 1,
644 sizeof(port));
645 options->queued_listen_addrs[options->num_queued_listens] =
646 xstrdup(addr);
647 options->queued_listen_ports[options->num_queued_listens] = port;
648 options->num_queued_listens++;
649}
650
651/*
652 * Process queued (text) ListenAddress entries.
653 */
654static void
655process_queued_listen_addrs(ServerOptions *options)
656{
657 u_int i;
658
659 if (options->num_ports == 0)
660 options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
661 if (options->address_family == -1)
662 options->address_family = AF_UNSPEC;
663
664 for (i = 0; i < options->num_queued_listens; i++) {
665 add_listen_addr(options, options->queued_listen_addrs[i],
666 options->queued_listen_ports[i]);
667 free(options->queued_listen_addrs[i]);
668 options->queued_listen_addrs[i] = NULL;
669 }
670 free(options->queued_listen_addrs);
671 options->queued_listen_addrs = NULL;
672 free(options->queued_listen_ports);
673 options->queued_listen_ports = NULL;
674 options->num_queued_listens = 0;
675}
676
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000677struct connection_info *
678get_connection_info(int populate, int use_dns)
679{
680 static struct connection_info ci;
681
682 if (!populate)
683 return &ci;
684 ci.host = get_canonical_hostname(use_dns);
685 ci.address = get_remote_ipaddr();
686 ci.laddress = get_local_ipaddr(packet_get_connection_in());
687 ci.lport = get_local_port();
688 return &ci;
689}
690
Darren Tucker45150472006-07-12 22:34:17 +1000691/*
692 * The strategy for the Match blocks is that the config file is parsed twice.
693 *
694 * The first time is at startup. activep is initialized to 1 and the
695 * directives in the global context are processed and acted on. Hitting a
696 * Match directive unsets activep and the directives inside the block are
697 * checked for syntax only.
698 *
699 * The second time is after a connection has been established but before
700 * authentication. activep is initialized to 2 and global config directives
701 * are ignored since they have already been processed. If the criteria in a
702 * Match block is met, activep is set and the subsequent directives
703 * processed and actioned until EOF or another Match block unsets it. Any
704 * options set are copied into the main server config.
705 *
706 * Potential additions/improvements:
707 * - Add Match support for pre-kex directives, eg Protocol, Ciphers.
708 *
709 * - Add a Tag directive (idea from David Leonard) ala pf, eg:
710 * Match Address 192.168.0.*
711 * Tag trusted
712 * Match Group wheel
713 * Tag trusted
714 * Match Tag trusted
715 * AllowTcpForwarding yes
716 * GatewayPorts clientspecified
717 * [...]
718 *
719 * - Add a PermittedChannelRequests directive
720 * Match Group shell
721 * PermittedChannelRequests session,forwarded-tcpip
722 */
723
724static int
Damien Miller565ca3f2006-08-19 00:23:15 +1000725match_cfg_line_group(const char *grps, int line, const char *user)
726{
727 int result = 0;
Damien Miller565ca3f2006-08-19 00:23:15 +1000728 struct passwd *pw;
729
Damien Miller565ca3f2006-08-19 00:23:15 +1000730 if (user == NULL)
731 goto out;
732
733 if ((pw = getpwnam(user)) == NULL) {
734 debug("Can't match group at line %d because user %.100s does "
735 "not exist", line, user);
736 } else if (ga_init(pw->pw_name, pw->pw_gid) == 0) {
737 debug("Can't Match group because user %.100s not in any group "
738 "at line %d", user, line);
Darren Tuckerb03fd022008-07-04 13:51:12 +1000739 } else if (ga_match_pattern_list(grps) != 1) {
740 debug("user %.100s does not match group list %.100s at line %d",
741 user, grps, line);
Damien Miller565ca3f2006-08-19 00:23:15 +1000742 } else {
Darren Tuckerb03fd022008-07-04 13:51:12 +1000743 debug("user %.100s matched group list %.100s at line %d", user,
744 grps, line);
Damien Miller565ca3f2006-08-19 00:23:15 +1000745 result = 1;
746 }
747out:
748 ga_free();
Damien Miller565ca3f2006-08-19 00:23:15 +1000749 return result;
750}
751
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000752/*
Darren Tuckerbb6cc072012-09-17 13:25:06 +1000753 * All of the attributes on a single Match line are ANDed together, so we need
Damien Miller03bf2e62013-10-24 21:01:26 +1100754 * to check every attribute and set the result to zero if any attribute does
Darren Tuckerbb6cc072012-09-17 13:25:06 +1000755 * not match.
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000756 */
Damien Miller565ca3f2006-08-19 00:23:15 +1000757static int
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000758match_cfg_line(char **condition, int line, struct connection_info *ci)
Darren Tucker45150472006-07-12 22:34:17 +1000759{
Damien Millercf31f382013-10-24 21:02:56 +1100760 int result = 1, attributes = 0, port;
Darren Tucker45150472006-07-12 22:34:17 +1000761 char *arg, *attrib, *cp = *condition;
Darren Tucker45150472006-07-12 22:34:17 +1000762
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000763 if (ci == NULL)
Darren Tucker45150472006-07-12 22:34:17 +1000764 debug3("checking syntax for 'Match %s'", cp);
765 else
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000766 debug3("checking match for '%s' user %s host %s addr %s "
767 "laddr %s lport %d", cp, ci->user ? ci->user : "(null)",
768 ci->host ? ci->host : "(null)",
769 ci->address ? ci->address : "(null)",
770 ci->laddress ? ci->laddress : "(null)", ci->lport);
Darren Tucker45150472006-07-12 22:34:17 +1000771
772 while ((attrib = strdelim(&cp)) && *attrib != '\0') {
Damien Millercf31f382013-10-24 21:02:56 +1100773 attributes++;
774 if (strcasecmp(attrib, "all") == 0) {
775 if (attributes != 1 ||
776 ((arg = strdelim(&cp)) != NULL && *arg != '\0')) {
777 error("'all' cannot be combined with other "
778 "Match attributes");
779 return -1;
780 }
781 *condition = cp;
782 return 1;
783 }
Darren Tucker45150472006-07-12 22:34:17 +1000784 if ((arg = strdelim(&cp)) == NULL || *arg == '\0') {
785 error("Missing Match criteria for %s", attrib);
786 return -1;
787 }
Darren Tucker45150472006-07-12 22:34:17 +1000788 if (strcasecmp(attrib, "user") == 0) {
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000789 if (ci == NULL || ci->user == NULL) {
Darren Tucker45150472006-07-12 22:34:17 +1000790 result = 0;
791 continue;
792 }
djm@openbsd.orge661a862015-05-04 06:10:48 +0000793 if (match_pattern_list(ci->user, arg, 0) != 1)
Darren Tucker45150472006-07-12 22:34:17 +1000794 result = 0;
795 else
796 debug("user %.100s matched 'User %.100s' at "
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000797 "line %d", ci->user, arg, line);
Damien Miller565ca3f2006-08-19 00:23:15 +1000798 } else if (strcasecmp(attrib, "group") == 0) {
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000799 if (ci == NULL || ci->user == NULL) {
800 result = 0;
801 continue;
802 }
803 switch (match_cfg_line_group(arg, line, ci->user)) {
Damien Miller565ca3f2006-08-19 00:23:15 +1000804 case -1:
805 return -1;
806 case 0:
807 result = 0;
808 }
Darren Tucker45150472006-07-12 22:34:17 +1000809 } else if (strcasecmp(attrib, "host") == 0) {
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000810 if (ci == NULL || ci->host == NULL) {
Darren Tucker45150472006-07-12 22:34:17 +1000811 result = 0;
812 continue;
813 }
djm@openbsd.orge661a862015-05-04 06:10:48 +0000814 if (match_hostname(ci->host, arg) != 1)
Darren Tucker45150472006-07-12 22:34:17 +1000815 result = 0;
816 else
817 debug("connection from %.100s matched 'Host "
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000818 "%.100s' at line %d", ci->host, arg, line);
Darren Tucker45150472006-07-12 22:34:17 +1000819 } else if (strcasecmp(attrib, "address") == 0) {
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000820 if (ci == NULL || ci->address == NULL) {
821 result = 0;
822 continue;
823 }
824 switch (addr_match_list(ci->address, arg)) {
Darren Tucker7a3935d2008-06-10 22:59:10 +1000825 case 1:
Darren Tucker45150472006-07-12 22:34:17 +1000826 debug("connection from %.100s matched 'Address "
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000827 "%.100s' at line %d", ci->address, arg, line);
Darren Tucker7a3935d2008-06-10 22:59:10 +1000828 break;
829 case 0:
Darren Tucker896ad5a2008-06-11 09:34:46 +1000830 case -1:
Darren Tucker7a3935d2008-06-10 22:59:10 +1000831 result = 0;
832 break;
Darren Tucker896ad5a2008-06-11 09:34:46 +1000833 case -2:
Darren Tucker7a3935d2008-06-10 22:59:10 +1000834 return -1;
835 }
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000836 } else if (strcasecmp(attrib, "localaddress") == 0){
837 if (ci == NULL || ci->laddress == NULL) {
838 result = 0;
839 continue;
840 }
841 switch (addr_match_list(ci->laddress, arg)) {
842 case 1:
843 debug("connection from %.100s matched "
844 "'LocalAddress %.100s' at line %d",
845 ci->laddress, arg, line);
846 break;
847 case 0:
848 case -1:
849 result = 0;
850 break;
851 case -2:
852 return -1;
853 }
854 } else if (strcasecmp(attrib, "localport") == 0) {
855 if ((port = a2port(arg)) == -1) {
856 error("Invalid LocalPort '%s' on Match line",
857 arg);
858 return -1;
859 }
860 if (ci == NULL || ci->lport == 0) {
861 result = 0;
862 continue;
863 }
864 /* TODO support port lists */
865 if (port == ci->lport)
866 debug("connection from %.100s matched "
867 "'LocalPort %d' at line %d",
868 ci->laddress, port, line);
869 else
870 result = 0;
Darren Tucker45150472006-07-12 22:34:17 +1000871 } else {
872 error("Unsupported Match attribute %s", attrib);
873 return -1;
874 }
875 }
Damien Millercf31f382013-10-24 21:02:56 +1100876 if (attributes == 0) {
877 error("One or more attributes required for Match");
878 return -1;
879 }
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000880 if (ci != NULL)
Darren Tucker45150472006-07-12 22:34:17 +1000881 debug3("match %sfound", result ? "" : "not ");
882 *condition = cp;
883 return result;
884}
885
Damien Millere2754432006-07-24 14:06:47 +1000886#define WHITESPACE " \t\r\n"
887
Damien Miller33322122011-06-20 14:43:11 +1000888/* Multistate option parsing */
889struct multistate {
890 char *key;
891 int value;
892};
893static const struct multistate multistate_addressfamily[] = {
894 { "inet", AF_INET },
895 { "inet6", AF_INET6 },
896 { "any", AF_UNSPEC },
897 { NULL, -1 }
898};
899static const struct multistate multistate_permitrootlogin[] = {
900 { "without-password", PERMIT_NO_PASSWD },
901 { "forced-commands-only", PERMIT_FORCED_ONLY },
902 { "yes", PERMIT_YES },
903 { "no", PERMIT_NO },
904 { NULL, -1 }
905};
906static const struct multistate multistate_compression[] = {
907 { "delayed", COMP_DELAYED },
908 { "yes", COMP_ZLIB },
909 { "no", COMP_NONE },
910 { NULL, -1 }
911};
912static const struct multistate multistate_gatewayports[] = {
913 { "clientspecified", 2 },
914 { "yes", 1 },
915 { "no", 0 },
916 { NULL, -1 }
917};
Damien Miller69ff1df2011-06-23 08:30:03 +1000918static const struct multistate multistate_privsep[] = {
Damien Miller5a5c2b92012-07-31 12:21:34 +1000919 { "yes", PRIVSEP_NOSANDBOX },
920 { "sandbox", PRIVSEP_ON },
921 { "nosandbox", PRIVSEP_NOSANDBOX },
Damien Miller69ff1df2011-06-23 08:30:03 +1000922 { "no", PRIVSEP_OFF },
923 { NULL, -1 }
924};
Damien Milleraa5b3f82012-12-03 09:50:54 +1100925static const struct multistate multistate_tcpfwd[] = {
926 { "yes", FORWARD_ALLOW },
927 { "all", FORWARD_ALLOW },
928 { "no", FORWARD_DENY },
929 { "remote", FORWARD_REMOTE },
930 { "local", FORWARD_LOCAL },
931 { NULL, -1 }
932};
Damien Miller33322122011-06-20 14:43:11 +1000933
Ben Lindstromade03f62001-12-06 18:22:17 +0000934int
935process_server_config_line(ServerOptions *options, char *line,
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000936 const char *filename, int linenum, int *activep,
937 struct connection_info *connectinfo)
Ben Lindstromade03f62001-12-06 18:22:17 +0000938{
Darren Tucker09c0f032013-05-16 20:48:57 +1000939 char *cp, **charptr, *arg, *p;
Darren Tucker9113d0c2013-05-16 20:48:14 +1000940 int cmdline = 0, *intptr, value, value2, n, port;
Darren Tucker1e44c5d2008-01-01 20:32:26 +1100941 SyslogFacility *log_facility_ptr;
942 LogLevel *log_level_ptr;
Ben Lindstromade03f62001-12-06 18:22:17 +0000943 ServerOpCodes opcode;
Darren Tucker45150472006-07-12 22:34:17 +1000944 u_int i, flags = 0;
Damien Miller917f9b62006-07-10 20:36:47 +1000945 size_t len;
Darren Tucker9113d0c2013-05-16 20:48:14 +1000946 long long val64;
Damien Miller33322122011-06-20 14:43:11 +1000947 const struct multistate *multistate_ptr;
Ben Lindstromade03f62001-12-06 18:22:17 +0000948
949 cp = line;
Damien Miller78f16cb2006-03-26 13:54:37 +1100950 if ((arg = strdelim(&cp)) == NULL)
Damien Miller928b2362006-03-26 13:53:32 +1100951 return 0;
Ben Lindstromade03f62001-12-06 18:22:17 +0000952 /* Ignore leading whitespace */
953 if (*arg == '\0')
954 arg = strdelim(&cp);
955 if (!arg || !*arg || *arg == '#')
956 return 0;
957 intptr = NULL;
958 charptr = NULL;
Darren Tucker45150472006-07-12 22:34:17 +1000959 opcode = parse_token(arg, filename, linenum, &flags);
960
961 if (activep == NULL) { /* We are processing a command line directive */
962 cmdline = 1;
963 activep = &cmdline;
964 }
965 if (*activep && opcode != sMatch)
966 debug3("%s:%d setting %s %s", filename, linenum, arg, cp);
967 if (*activep == 0 && !(flags & SSHCFG_MATCH)) {
Darren Tuckerfbcf8272012-05-19 19:37:01 +1000968 if (connectinfo == NULL) {
Darren Tucker45150472006-07-12 22:34:17 +1000969 fatal("%s line %d: Directive '%s' is not allowed "
970 "within a Match block", filename, linenum, arg);
971 } else { /* this is a directive we have already processed */
972 while (arg)
973 arg = strdelim(&cp);
974 return 0;
975 }
976 }
977
Ben Lindstromade03f62001-12-06 18:22:17 +0000978 switch (opcode) {
979 /* Portable-specific options */
Damien Miller4e448a32003-05-14 15:11:48 +1000980 case sUsePAM:
981 intptr = &options->use_pam;
Ben Lindstromade03f62001-12-06 18:22:17 +0000982 goto parse_flag;
983
984 /* Standard Options */
985 case sBadOption:
986 return -1;
987 case sPort:
988 /* ignore ports from configfile if cmdline specifies ports */
989 if (options->ports_from_cmdline)
990 return 0;
Ben Lindstromade03f62001-12-06 18:22:17 +0000991 if (options->num_ports >= MAX_PORTS)
992 fatal("%s line %d: too many ports.",
993 filename, linenum);
994 arg = strdelim(&cp);
995 if (!arg || *arg == '\0')
996 fatal("%s line %d: missing port number.",
997 filename, linenum);
998 options->ports[options->num_ports++] = a2port(arg);
Damien Miller3dc71ad2009-01-28 16:31:22 +1100999 if (options->ports[options->num_ports-1] <= 0)
Ben Lindstromade03f62001-12-06 18:22:17 +00001000 fatal("%s line %d: Badly formatted port number.",
1001 filename, linenum);
1002 break;
1003
1004 case sServerKeyBits:
1005 intptr = &options->server_key_bits;
Damien Miller7207f642008-05-19 15:34:50 +10001006 parse_int:
Ben Lindstromade03f62001-12-06 18:22:17 +00001007 arg = strdelim(&cp);
1008 if (!arg || *arg == '\0')
1009 fatal("%s line %d: missing integer value.",
1010 filename, linenum);
1011 value = atoi(arg);
Darren Tucker45150472006-07-12 22:34:17 +10001012 if (*activep && *intptr == -1)
Ben Lindstromade03f62001-12-06 18:22:17 +00001013 *intptr = value;
1014 break;
1015
1016 case sLoginGraceTime:
1017 intptr = &options->login_grace_time;
Damien Miller7207f642008-05-19 15:34:50 +10001018 parse_time:
Ben Lindstromade03f62001-12-06 18:22:17 +00001019 arg = strdelim(&cp);
1020 if (!arg || *arg == '\0')
1021 fatal("%s line %d: missing time value.",
1022 filename, linenum);
1023 if ((value = convtime(arg)) == -1)
1024 fatal("%s line %d: invalid time value.",
1025 filename, linenum);
djm@openbsd.org9559d7d2015-05-01 07:08:08 +00001026 if (*activep && *intptr == -1)
Ben Lindstromade03f62001-12-06 18:22:17 +00001027 *intptr = value;
1028 break;
1029
1030 case sKeyRegenerationTime:
1031 intptr = &options->key_regeneration_time;
1032 goto parse_time;
1033
1034 case sListenAddress:
1035 arg = strdelim(&cp);
Damien Millerf91ee4c2005-03-01 21:24:33 +11001036 if (arg == NULL || *arg == '\0')
1037 fatal("%s line %d: missing address",
Ben Lindstromade03f62001-12-06 18:22:17 +00001038 filename, linenum);
Damien Miller203c7052005-08-12 22:11:37 +10001039 /* check for bare IPv6 address: no "[]" and 2 or more ":" */
1040 if (strchr(arg, '[') == NULL && (p = strchr(arg, ':')) != NULL
1041 && strchr(p+1, ':') != NULL) {
dtucker@openbsd.org531a57a2015-04-29 03:48:56 +00001042 queue_listen_addr(options, arg, 0);
Damien Miller203c7052005-08-12 22:11:37 +10001043 break;
1044 }
Damien Millerf91ee4c2005-03-01 21:24:33 +11001045 p = hpdelim(&arg);
1046 if (p == NULL)
1047 fatal("%s line %d: bad address:port usage",
1048 filename, linenum);
1049 p = cleanhostname(p);
1050 if (arg == NULL)
1051 port = 0;
Damien Miller3dc71ad2009-01-28 16:31:22 +11001052 else if ((port = a2port(arg)) <= 0)
Damien Millerf91ee4c2005-03-01 21:24:33 +11001053 fatal("%s line %d: bad port number", filename, linenum);
Ben Lindstromade03f62001-12-06 18:22:17 +00001054
dtucker@openbsd.org531a57a2015-04-29 03:48:56 +00001055 queue_listen_addr(options, p, port);
Damien Millerf91ee4c2005-03-01 21:24:33 +11001056
Ben Lindstromade03f62001-12-06 18:22:17 +00001057 break;
1058
Darren Tucker0f383232005-01-20 10:57:56 +11001059 case sAddressFamily:
Damien Miller33322122011-06-20 14:43:11 +10001060 intptr = &options->address_family;
1061 multistate_ptr = multistate_addressfamily;
Damien Miller33322122011-06-20 14:43:11 +10001062 parse_multistate:
Darren Tucker0f383232005-01-20 10:57:56 +11001063 arg = strdelim(&cp);
Damien Miller17b23d82005-05-26 12:11:56 +10001064 if (!arg || *arg == '\0')
Damien Miller33322122011-06-20 14:43:11 +10001065 fatal("%s line %d: missing argument.",
Damien Miller17b23d82005-05-26 12:11:56 +10001066 filename, linenum);
Damien Miller33322122011-06-20 14:43:11 +10001067 value = -1;
1068 for (i = 0; multistate_ptr[i].key != NULL; i++) {
1069 if (strcasecmp(arg, multistate_ptr[i].key) == 0) {
1070 value = multistate_ptr[i].value;
1071 break;
1072 }
1073 }
1074 if (value == -1)
1075 fatal("%s line %d: unsupported option \"%s\".",
Darren Tucker0f383232005-01-20 10:57:56 +11001076 filename, linenum, arg);
Damien Miller33322122011-06-20 14:43:11 +10001077 if (*activep && *intptr == -1)
Darren Tucker0f383232005-01-20 10:57:56 +11001078 *intptr = value;
1079 break;
1080
Ben Lindstromade03f62001-12-06 18:22:17 +00001081 case sHostKeyFile:
1082 intptr = &options->num_host_key_files;
1083 if (*intptr >= MAX_HOSTKEYS)
1084 fatal("%s line %d: too many host keys specified (max %d).",
1085 filename, linenum, MAX_HOSTKEYS);
1086 charptr = &options->host_key_files[*intptr];
Damien Miller7207f642008-05-19 15:34:50 +10001087 parse_filename:
Ben Lindstromade03f62001-12-06 18:22:17 +00001088 arg = strdelim(&cp);
1089 if (!arg || *arg == '\0')
1090 fatal("%s line %d: missing file name.",
1091 filename, linenum);
Darren Tucker45150472006-07-12 22:34:17 +10001092 if (*activep && *charptr == NULL) {
Darren Tucker88b6fb22010-01-13 22:44:29 +11001093 *charptr = derelativise_path(arg);
Ben Lindstromade03f62001-12-06 18:22:17 +00001094 /* increase optional counter */
1095 if (intptr != NULL)
1096 *intptr = *intptr + 1;
1097 }
1098 break;
1099
Damien Miller85b45e02013-07-20 13:21:52 +10001100 case sHostKeyAgent:
1101 charptr = &options->host_key_agent;
1102 arg = strdelim(&cp);
1103 if (!arg || *arg == '\0')
1104 fatal("%s line %d: missing socket name.",
1105 filename, linenum);
1106 if (*activep && *charptr == NULL)
1107 *charptr = !strcmp(arg, SSH_AUTHSOCKET_ENV_NAME) ?
1108 xstrdup(arg) : derelativise_path(arg);
1109 break;
1110
Damien Miller0a80ca12010-02-27 07:55:05 +11001111 case sHostCertificate:
1112 intptr = &options->num_host_cert_files;
1113 if (*intptr >= MAX_HOSTKEYS)
1114 fatal("%s line %d: too many host certificates "
1115 "specified (max %d).", filename, linenum,
1116 MAX_HOSTCERTS);
1117 charptr = &options->host_cert_files[*intptr];
1118 goto parse_filename;
1119 break;
1120
Ben Lindstromade03f62001-12-06 18:22:17 +00001121 case sPidFile:
1122 charptr = &options->pid_file;
1123 goto parse_filename;
1124
1125 case sPermitRootLogin:
1126 intptr = &options->permit_root_login;
Damien Miller33322122011-06-20 14:43:11 +10001127 multistate_ptr = multistate_permitrootlogin;
1128 goto parse_multistate;
Ben Lindstromade03f62001-12-06 18:22:17 +00001129
1130 case sIgnoreRhosts:
1131 intptr = &options->ignore_rhosts;
Damien Miller7207f642008-05-19 15:34:50 +10001132 parse_flag:
Ben Lindstromade03f62001-12-06 18:22:17 +00001133 arg = strdelim(&cp);
1134 if (!arg || *arg == '\0')
1135 fatal("%s line %d: missing yes/no argument.",
1136 filename, linenum);
1137 value = 0; /* silence compiler */
1138 if (strcmp(arg, "yes") == 0)
1139 value = 1;
1140 else if (strcmp(arg, "no") == 0)
1141 value = 0;
1142 else
1143 fatal("%s line %d: Bad yes/no argument: %s",
1144 filename, linenum, arg);
Darren Tucker45150472006-07-12 22:34:17 +10001145 if (*activep && *intptr == -1)
Ben Lindstromade03f62001-12-06 18:22:17 +00001146 *intptr = value;
1147 break;
1148
1149 case sIgnoreUserKnownHosts:
1150 intptr = &options->ignore_user_known_hosts;
1151 goto parse_flag;
1152
Ben Lindstromade03f62001-12-06 18:22:17 +00001153 case sRhostsRSAAuthentication:
1154 intptr = &options->rhosts_rsa_authentication;
1155 goto parse_flag;
1156
1157 case sHostbasedAuthentication:
1158 intptr = &options->hostbased_authentication;
1159 goto parse_flag;
1160
1161 case sHostbasedUsesNameFromPacketOnly:
1162 intptr = &options->hostbased_uses_name_from_packet_only;
1163 goto parse_flag;
1164
djm@openbsd.org1f729f02015-01-13 07:39:19 +00001165 case sHostbasedAcceptedKeyTypes:
1166 charptr = &options->hostbased_key_types;
1167 parse_keytypes:
1168 arg = strdelim(&cp);
1169 if (!arg || *arg == '\0')
1170 fatal("%s line %d: Missing argument.",
1171 filename, linenum);
1172 if (!sshkey_names_valid2(arg, 1))
1173 fatal("%s line %d: Bad key types '%s'.",
1174 filename, linenum, arg ? arg : "<NONE>");
1175 if (*activep && *charptr == NULL)
1176 *charptr = xstrdup(arg);
1177 break;
1178
Ben Lindstromade03f62001-12-06 18:22:17 +00001179 case sRSAAuthentication:
1180 intptr = &options->rsa_authentication;
1181 goto parse_flag;
1182
1183 case sPubkeyAuthentication:
1184 intptr = &options->pubkey_authentication;
1185 goto parse_flag;
Damien Miller2aa0ab42003-05-15 12:05:28 +10001186
djm@openbsd.org1f729f02015-01-13 07:39:19 +00001187 case sPubkeyAcceptedKeyTypes:
1188 charptr = &options->pubkey_key_types;
1189 goto parse_keytypes;
1190
Ben Lindstromade03f62001-12-06 18:22:17 +00001191 case sKerberosAuthentication:
1192 intptr = &options->kerberos_authentication;
1193 goto parse_flag;
1194
1195 case sKerberosOrLocalPasswd:
1196 intptr = &options->kerberos_or_local_passwd;
1197 goto parse_flag;
1198
1199 case sKerberosTicketCleanup:
1200 intptr = &options->kerberos_ticket_cleanup;
1201 goto parse_flag;
Damien Miller2aa0ab42003-05-15 12:05:28 +10001202
Darren Tucker22ef5082003-12-31 11:37:34 +11001203 case sKerberosGetAFSToken:
1204 intptr = &options->kerberos_get_afs_token;
1205 goto parse_flag;
1206
Darren Tucker0efd1552003-08-26 11:49:55 +10001207 case sGssAuthentication:
1208 intptr = &options->gss_authentication;
1209 goto parse_flag;
1210
1211 case sGssCleanupCreds:
1212 intptr = &options->gss_cleanup_creds;
1213 goto parse_flag;
1214
Ben Lindstromade03f62001-12-06 18:22:17 +00001215 case sPasswordAuthentication:
1216 intptr = &options->password_authentication;
1217 goto parse_flag;
1218
1219 case sKbdInteractiveAuthentication:
1220 intptr = &options->kbd_interactive_authentication;
1221 goto parse_flag;
1222
1223 case sChallengeResponseAuthentication:
1224 intptr = &options->challenge_response_authentication;
1225 goto parse_flag;
1226
1227 case sPrintMotd:
1228 intptr = &options->print_motd;
1229 goto parse_flag;
1230
1231 case sPrintLastLog:
1232 intptr = &options->print_lastlog;
1233 goto parse_flag;
1234
1235 case sX11Forwarding:
1236 intptr = &options->x11_forwarding;
1237 goto parse_flag;
1238
1239 case sX11DisplayOffset:
1240 intptr = &options->x11_display_offset;
1241 goto parse_int;
1242
Damien Miller95c249f2002-02-05 12:11:34 +11001243 case sX11UseLocalhost:
1244 intptr = &options->x11_use_localhost;
1245 goto parse_flag;
1246
Ben Lindstromade03f62001-12-06 18:22:17 +00001247 case sXAuthLocation:
1248 charptr = &options->xauth_location;
1249 goto parse_filename;
1250
Damien Miller5ff30c62013-10-30 22:21:50 +11001251 case sPermitTTY:
1252 intptr = &options->permit_tty;
1253 goto parse_flag;
1254
Damien Miller72e6b5c2014-07-04 09:00:04 +10001255 case sPermitUserRC:
1256 intptr = &options->permit_user_rc;
1257 goto parse_flag;
1258
Ben Lindstromade03f62001-12-06 18:22:17 +00001259 case sStrictModes:
1260 intptr = &options->strict_modes;
1261 goto parse_flag;
1262
Damien Miller12c150e2003-12-17 16:31:10 +11001263 case sTCPKeepAlive:
1264 intptr = &options->tcp_keep_alive;
Ben Lindstromade03f62001-12-06 18:22:17 +00001265 goto parse_flag;
1266
1267 case sEmptyPasswd:
1268 intptr = &options->permit_empty_passwd;
1269 goto parse_flag;
1270
Ben Lindstrom5d860f02002-08-01 01:28:38 +00001271 case sPermitUserEnvironment:
1272 intptr = &options->permit_user_env;
1273 goto parse_flag;
1274
Ben Lindstromade03f62001-12-06 18:22:17 +00001275 case sUseLogin:
1276 intptr = &options->use_login;
1277 goto parse_flag;
1278
Ben Lindstrom23e0f662002-06-21 01:09:47 +00001279 case sCompression:
1280 intptr = &options->compression;
Damien Miller33322122011-06-20 14:43:11 +10001281 multistate_ptr = multistate_compression;
1282 goto parse_multistate;
Ben Lindstrom23e0f662002-06-21 01:09:47 +00001283
Darren Tucker5f96f3b2013-05-16 20:29:28 +10001284 case sRekeyLimit:
1285 arg = strdelim(&cp);
1286 if (!arg || *arg == '\0')
1287 fatal("%.200s line %d: Missing argument.", filename,
1288 linenum);
1289 if (strcmp(arg, "default") == 0) {
1290 val64 = 0;
1291 } else {
Darren Tuckerb7ee8522013-05-16 20:33:10 +10001292 if (scan_scaled(arg, &val64) == -1)
1293 fatal("%.200s line %d: Bad number '%s': %s",
1294 filename, linenum, arg, strerror(errno));
1295 /* check for too-large or too-small limits */
1296 if (val64 > UINT_MAX)
Darren Tucker5f96f3b2013-05-16 20:29:28 +10001297 fatal("%.200s line %d: RekeyLimit too large",
1298 filename, linenum);
1299 if (val64 != 0 && val64 < 16)
1300 fatal("%.200s line %d: RekeyLimit too small",
1301 filename, linenum);
1302 }
1303 if (*activep && options->rekey_limit == -1)
1304 options->rekey_limit = (u_int32_t)val64;
1305 if (cp != NULL) { /* optional rekey interval present */
1306 if (strcmp(cp, "none") == 0) {
1307 (void)strdelim(&cp); /* discard */
1308 break;
1309 }
1310 intptr = &options->rekey_interval;
1311 goto parse_time;
1312 }
1313 break;
1314
Ben Lindstromade03f62001-12-06 18:22:17 +00001315 case sGatewayPorts:
Damien Miller7acefbb2014-07-18 14:11:24 +10001316 intptr = &options->fwd_opts.gateway_ports;
Damien Miller33322122011-06-20 14:43:11 +10001317 multistate_ptr = multistate_gatewayports;
1318 goto parse_multistate;
Ben Lindstromade03f62001-12-06 18:22:17 +00001319
Damien Miller3a961dc2003-06-03 10:25:48 +10001320 case sUseDNS:
1321 intptr = &options->use_dns;
Ben Lindstromade03f62001-12-06 18:22:17 +00001322 goto parse_flag;
1323
1324 case sLogFacility:
Darren Tucker1e44c5d2008-01-01 20:32:26 +11001325 log_facility_ptr = &options->log_facility;
Ben Lindstromade03f62001-12-06 18:22:17 +00001326 arg = strdelim(&cp);
1327 value = log_facility_number(arg);
Damien Millerfcd93202002-02-05 12:26:34 +11001328 if (value == SYSLOG_FACILITY_NOT_SET)
Ben Lindstromade03f62001-12-06 18:22:17 +00001329 fatal("%.200s line %d: unsupported log facility '%s'",
1330 filename, linenum, arg ? arg : "<NONE>");
Darren Tucker1e44c5d2008-01-01 20:32:26 +11001331 if (*log_facility_ptr == -1)
1332 *log_facility_ptr = (SyslogFacility) value;
Ben Lindstromade03f62001-12-06 18:22:17 +00001333 break;
1334
1335 case sLogLevel:
Darren Tucker1e44c5d2008-01-01 20:32:26 +11001336 log_level_ptr = &options->log_level;
Ben Lindstromade03f62001-12-06 18:22:17 +00001337 arg = strdelim(&cp);
1338 value = log_level_number(arg);
Damien Millerfcd93202002-02-05 12:26:34 +11001339 if (value == SYSLOG_LEVEL_NOT_SET)
Ben Lindstromade03f62001-12-06 18:22:17 +00001340 fatal("%.200s line %d: unsupported log level '%s'",
1341 filename, linenum, arg ? arg : "<NONE>");
Darren Tucker1e44c5d2008-01-01 20:32:26 +11001342 if (*log_level_ptr == -1)
1343 *log_level_ptr = (LogLevel) value;
Ben Lindstromade03f62001-12-06 18:22:17 +00001344 break;
1345
1346 case sAllowTcpForwarding:
1347 intptr = &options->allow_tcp_forwarding;
Damien Milleraa5b3f82012-12-03 09:50:54 +11001348 multistate_ptr = multistate_tcpfwd;
1349 goto parse_multistate;
Ben Lindstromade03f62001-12-06 18:22:17 +00001350
Damien Miller7acefbb2014-07-18 14:11:24 +10001351 case sAllowStreamLocalForwarding:
1352 intptr = &options->allow_streamlocal_forwarding;
1353 multistate_ptr = multistate_tcpfwd;
1354 goto parse_multistate;
1355
Damien Miller4f755cd2008-05-19 14:57:41 +10001356 case sAllowAgentForwarding:
1357 intptr = &options->allow_agent_forwarding;
1358 goto parse_flag;
1359
Ben Lindstrom7a2073c2002-03-22 02:30:41 +00001360 case sUsePrivilegeSeparation:
1361 intptr = &use_privsep;
Damien Miller69ff1df2011-06-23 08:30:03 +10001362 multistate_ptr = multistate_privsep;
1363 goto parse_multistate;
Ben Lindstrom7a2073c2002-03-22 02:30:41 +00001364
Ben Lindstromade03f62001-12-06 18:22:17 +00001365 case sAllowUsers:
1366 while ((arg = strdelim(&cp)) && *arg != '\0') {
1367 if (options->num_allow_users >= MAX_ALLOW_USERS)
1368 fatal("%s line %d: too many allow users.",
1369 filename, linenum);
Damien Millerc24da772012-06-20 21:53:58 +10001370 if (!*activep)
1371 continue;
Ben Lindstrome1353632002-06-23 21:29:23 +00001372 options->allow_users[options->num_allow_users++] =
1373 xstrdup(arg);
Ben Lindstromade03f62001-12-06 18:22:17 +00001374 }
1375 break;
1376
1377 case sDenyUsers:
1378 while ((arg = strdelim(&cp)) && *arg != '\0') {
1379 if (options->num_deny_users >= MAX_DENY_USERS)
Damien Miller4dec5d72006-08-05 11:38:40 +10001380 fatal("%s line %d: too many deny users.",
Ben Lindstromade03f62001-12-06 18:22:17 +00001381 filename, linenum);
Damien Millerc24da772012-06-20 21:53:58 +10001382 if (!*activep)
1383 continue;
Ben Lindstrome1353632002-06-23 21:29:23 +00001384 options->deny_users[options->num_deny_users++] =
1385 xstrdup(arg);
Ben Lindstromade03f62001-12-06 18:22:17 +00001386 }
1387 break;
1388
1389 case sAllowGroups:
1390 while ((arg = strdelim(&cp)) && *arg != '\0') {
1391 if (options->num_allow_groups >= MAX_ALLOW_GROUPS)
1392 fatal("%s line %d: too many allow groups.",
1393 filename, linenum);
Damien Millerc24da772012-06-20 21:53:58 +10001394 if (!*activep)
1395 continue;
Ben Lindstrome1353632002-06-23 21:29:23 +00001396 options->allow_groups[options->num_allow_groups++] =
1397 xstrdup(arg);
Ben Lindstromade03f62001-12-06 18:22:17 +00001398 }
1399 break;
1400
1401 case sDenyGroups:
1402 while ((arg = strdelim(&cp)) && *arg != '\0') {
1403 if (options->num_deny_groups >= MAX_DENY_GROUPS)
1404 fatal("%s line %d: too many deny groups.",
1405 filename, linenum);
Damien Millerc24da772012-06-20 21:53:58 +10001406 if (!*activep)
1407 continue;
1408 options->deny_groups[options->num_deny_groups++] =
1409 xstrdup(arg);
Ben Lindstromade03f62001-12-06 18:22:17 +00001410 }
1411 break;
1412
1413 case sCiphers:
1414 arg = strdelim(&cp);
1415 if (!arg || *arg == '\0')
1416 fatal("%s line %d: Missing argument.", filename, linenum);
1417 if (!ciphers_valid(arg))
1418 fatal("%s line %d: Bad SSH2 cipher spec '%s'.",
1419 filename, linenum, arg ? arg : "<NONE>");
1420 if (options->ciphers == NULL)
1421 options->ciphers = xstrdup(arg);
1422 break;
1423
1424 case sMacs:
1425 arg = strdelim(&cp);
1426 if (!arg || *arg == '\0')
1427 fatal("%s line %d: Missing argument.", filename, linenum);
1428 if (!mac_valid(arg))
1429 fatal("%s line %d: Bad SSH2 mac spec '%s'.",
1430 filename, linenum, arg ? arg : "<NONE>");
1431 if (options->macs == NULL)
1432 options->macs = xstrdup(arg);
1433 break;
1434
Damien Millerd5f62bf2010-09-24 22:11:14 +10001435 case sKexAlgorithms:
1436 arg = strdelim(&cp);
1437 if (!arg || *arg == '\0')
1438 fatal("%s line %d: Missing argument.",
1439 filename, linenum);
1440 if (!kex_names_valid(arg))
1441 fatal("%s line %d: Bad SSH2 KexAlgorithms '%s'.",
1442 filename, linenum, arg ? arg : "<NONE>");
1443 if (options->kex_algorithms == NULL)
1444 options->kex_algorithms = xstrdup(arg);
1445 break;
1446
Ben Lindstromade03f62001-12-06 18:22:17 +00001447 case sProtocol:
1448 intptr = &options->protocol;
1449 arg = strdelim(&cp);
1450 if (!arg || *arg == '\0')
1451 fatal("%s line %d: Missing argument.", filename, linenum);
1452 value = proto_spec(arg);
1453 if (value == SSH_PROTO_UNKNOWN)
1454 fatal("%s line %d: Bad protocol spec '%s'.",
Damien Miller9f0f5c62001-12-21 14:45:46 +11001455 filename, linenum, arg ? arg : "<NONE>");
Ben Lindstromade03f62001-12-06 18:22:17 +00001456 if (*intptr == SSH_PROTO_UNKNOWN)
1457 *intptr = value;
1458 break;
1459
1460 case sSubsystem:
1461 if (options->num_subsystems >= MAX_SUBSYSTEMS) {
1462 fatal("%s line %d: too many subsystems defined.",
Damien Miller9f0f5c62001-12-21 14:45:46 +11001463 filename, linenum);
Ben Lindstromade03f62001-12-06 18:22:17 +00001464 }
1465 arg = strdelim(&cp);
1466 if (!arg || *arg == '\0')
1467 fatal("%s line %d: Missing subsystem name.",
Damien Miller9f0f5c62001-12-21 14:45:46 +11001468 filename, linenum);
Darren Tucker45150472006-07-12 22:34:17 +10001469 if (!*activep) {
1470 arg = strdelim(&cp);
1471 break;
1472 }
Ben Lindstromade03f62001-12-06 18:22:17 +00001473 for (i = 0; i < options->num_subsystems; i++)
1474 if (strcmp(arg, options->subsystem_name[i]) == 0)
1475 fatal("%s line %d: Subsystem '%s' already defined.",
Damien Miller9f0f5c62001-12-21 14:45:46 +11001476 filename, linenum, arg);
Ben Lindstromade03f62001-12-06 18:22:17 +00001477 options->subsystem_name[options->num_subsystems] = xstrdup(arg);
1478 arg = strdelim(&cp);
1479 if (!arg || *arg == '\0')
1480 fatal("%s line %d: Missing subsystem command.",
Damien Miller9f0f5c62001-12-21 14:45:46 +11001481 filename, linenum);
Ben Lindstromade03f62001-12-06 18:22:17 +00001482 options->subsystem_command[options->num_subsystems] = xstrdup(arg);
Damien Miller917f9b62006-07-10 20:36:47 +10001483
1484 /* Collect arguments (separate to executable) */
1485 p = xstrdup(arg);
1486 len = strlen(p) + 1;
1487 while ((arg = strdelim(&cp)) != NULL && *arg != '\0') {
1488 len += 1 + strlen(arg);
deraadt@openbsd.org657a5fb2015-04-24 01:36:00 +00001489 p = xreallocarray(p, 1, len);
Damien Miller917f9b62006-07-10 20:36:47 +10001490 strlcat(p, " ", len);
1491 strlcat(p, arg, len);
1492 }
1493 options->subsystem_args[options->num_subsystems] = p;
Ben Lindstromade03f62001-12-06 18:22:17 +00001494 options->num_subsystems++;
1495 break;
1496
1497 case sMaxStartups:
1498 arg = strdelim(&cp);
1499 if (!arg || *arg == '\0')
1500 fatal("%s line %d: Missing MaxStartups spec.",
Damien Miller9f0f5c62001-12-21 14:45:46 +11001501 filename, linenum);
Ben Lindstromade03f62001-12-06 18:22:17 +00001502 if ((n = sscanf(arg, "%d:%d:%d",
1503 &options->max_startups_begin,
1504 &options->max_startups_rate,
1505 &options->max_startups)) == 3) {
1506 if (options->max_startups_begin >
1507 options->max_startups ||
1508 options->max_startups_rate > 100 ||
1509 options->max_startups_rate < 1)
1510 fatal("%s line %d: Illegal MaxStartups spec.",
1511 filename, linenum);
1512 } else if (n != 1)
1513 fatal("%s line %d: Illegal MaxStartups spec.",
1514 filename, linenum);
1515 else
1516 options->max_startups = options->max_startups_begin;
1517 break;
1518
Darren Tucker89413db2004-05-24 10:36:23 +10001519 case sMaxAuthTries:
1520 intptr = &options->max_authtries;
1521 goto parse_int;
1522
Damien Miller7207f642008-05-19 15:34:50 +10001523 case sMaxSessions:
1524 intptr = &options->max_sessions;
1525 goto parse_int;
1526
Ben Lindstromade03f62001-12-06 18:22:17 +00001527 case sBanner:
1528 charptr = &options->banner;
1529 goto parse_filename;
Damien Millerd8cb1f12008-02-10 22:40:12 +11001530
Ben Lindstromade03f62001-12-06 18:22:17 +00001531 /*
1532 * These options can contain %X options expanded at
1533 * connect time, so that you can specify paths like:
1534 *
1535 * AuthorizedKeysFile /etc/ssh_keys/%u
1536 */
1537 case sAuthorizedKeysFile:
Damien Millerd8478b62011-05-29 21:39:36 +10001538 if (*activep && options->num_authkeys_files == 0) {
1539 while ((arg = strdelim(&cp)) && *arg != '\0') {
1540 if (options->num_authkeys_files >=
1541 MAX_AUTHKEYS_FILES)
1542 fatal("%s line %d: "
1543 "too many authorized keys files.",
1544 filename, linenum);
1545 options->authorized_keys_files[
1546 options->num_authkeys_files++] =
1547 tilde_expand_filename(arg, getuid());
1548 }
1549 }
1550 return 0;
1551
Damien Miller30da3442010-05-10 11:58:03 +10001552 case sAuthorizedPrincipalsFile:
1553 charptr = &options->authorized_principals_file;
Damien Millerc4cb47b2010-03-22 05:52:26 +11001554 arg = strdelim(&cp);
1555 if (!arg || *arg == '\0')
1556 fatal("%s line %d: missing file name.",
1557 filename, linenum);
1558 if (*activep && *charptr == NULL) {
Damien Miller4a5f0d32010-03-22 05:53:04 +11001559 *charptr = tilde_expand_filename(arg, getuid());
Damien Millerc4cb47b2010-03-22 05:52:26 +11001560 /* increase optional counter */
1561 if (intptr != NULL)
1562 *intptr = *intptr + 1;
1563 }
1564 break;
Ben Lindstromade03f62001-12-06 18:22:17 +00001565
1566 case sClientAliveInterval:
1567 intptr = &options->client_alive_interval;
1568 goto parse_time;
1569
1570 case sClientAliveCountMax:
1571 intptr = &options->client_alive_count_max;
1572 goto parse_int;
1573
Darren Tucker46bc0752004-05-02 22:11:30 +10001574 case sAcceptEnv:
1575 while ((arg = strdelim(&cp)) && *arg != '\0') {
1576 if (strchr(arg, '=') != NULL)
1577 fatal("%s line %d: Invalid environment name.",
1578 filename, linenum);
1579 if (options->num_accept_env >= MAX_ACCEPT_ENV)
1580 fatal("%s line %d: too many allow env.",
1581 filename, linenum);
Darren Tucker45150472006-07-12 22:34:17 +10001582 if (!*activep)
Damien Millerc24da772012-06-20 21:53:58 +10001583 continue;
Darren Tucker46bc0752004-05-02 22:11:30 +10001584 options->accept_env[options->num_accept_env++] =
1585 xstrdup(arg);
1586 }
1587 break;
1588
Damien Millerd27b9472005-12-13 19:29:02 +11001589 case sPermitTunnel:
1590 intptr = &options->permit_tun;
Damien Miller7b58e802005-12-13 19:33:19 +11001591 arg = strdelim(&cp);
1592 if (!arg || *arg == '\0')
1593 fatal("%s line %d: Missing yes/point-to-point/"
1594 "ethernet/no argument.", filename, linenum);
Darren Tuckere7140f22008-06-10 23:01:51 +10001595 value = -1;
1596 for (i = 0; tunmode_desc[i].val != -1; i++)
1597 if (strcmp(tunmode_desc[i].text, arg) == 0) {
1598 value = tunmode_desc[i].val;
1599 break;
1600 }
1601 if (value == -1)
Damien Miller7b58e802005-12-13 19:33:19 +11001602 fatal("%s line %d: Bad yes/point-to-point/ethernet/"
1603 "no argument: %s", filename, linenum, arg);
djm@openbsd.org9559d7d2015-05-01 07:08:08 +00001604 if (*activep && *intptr == -1)
Damien Miller7b58e802005-12-13 19:33:19 +11001605 *intptr = value;
1606 break;
Damien Millerd27b9472005-12-13 19:29:02 +11001607
Darren Tucker45150472006-07-12 22:34:17 +10001608 case sMatch:
1609 if (cmdline)
1610 fatal("Match directive not supported as a command-line "
1611 "option");
Darren Tuckerfbcf8272012-05-19 19:37:01 +10001612 value = match_cfg_line(&cp, linenum, connectinfo);
Darren Tucker45150472006-07-12 22:34:17 +10001613 if (value < 0)
1614 fatal("%s line %d: Bad Match condition", filename,
1615 linenum);
1616 *activep = value;
1617 break;
1618
Damien Miller9b439df2006-07-24 14:04:00 +10001619 case sPermitOpen:
1620 arg = strdelim(&cp);
1621 if (!arg || *arg == '\0')
1622 fatal("%s line %d: missing PermitOpen specification",
1623 filename, linenum);
Damien Miller9fc6a562007-01-05 16:29:02 +11001624 n = options->num_permitted_opens; /* modified later */
Damien Miller9b439df2006-07-24 14:04:00 +10001625 if (strcmp(arg, "any") == 0) {
Damien Miller9fc6a562007-01-05 16:29:02 +11001626 if (*activep && n == -1) {
Damien Miller9b439df2006-07-24 14:04:00 +10001627 channel_clear_adm_permitted_opens();
Damien Millera765cf42006-07-24 14:08:13 +10001628 options->num_permitted_opens = 0;
1629 }
Damien Miller9b439df2006-07-24 14:04:00 +10001630 break;
1631 }
Damien Millerc6081482012-04-22 11:18:53 +10001632 if (strcmp(arg, "none") == 0) {
1633 if (*activep && n == -1) {
Damien Millerc6081482012-04-22 11:18:53 +10001634 options->num_permitted_opens = 1;
1635 channel_disable_adm_local_opens();
1636 }
1637 break;
1638 }
Damien Millera29b95e2007-01-05 16:28:36 +11001639 if (*activep && n == -1)
1640 channel_clear_adm_permitted_opens();
Damien Millera765cf42006-07-24 14:08:13 +10001641 for (; arg != NULL && *arg != '\0'; arg = strdelim(&cp)) {
1642 p = hpdelim(&arg);
1643 if (p == NULL)
1644 fatal("%s line %d: missing host in PermitOpen",
1645 filename, linenum);
1646 p = cleanhostname(p);
Darren Tucker1338b9e2011-10-02 18:57:35 +11001647 if (arg == NULL || ((port = permitopen_port(arg)) < 0))
Damien Millera765cf42006-07-24 14:08:13 +10001648 fatal("%s line %d: bad port number in "
1649 "PermitOpen", filename, linenum);
Damien Millera29b95e2007-01-05 16:28:36 +11001650 if (*activep && n == -1)
Damien Millera765cf42006-07-24 14:08:13 +10001651 options->num_permitted_opens =
1652 channel_add_adm_permitted_opens(p, port);
Damien Millera765cf42006-07-24 14:08:13 +10001653 }
Damien Miller9b439df2006-07-24 14:04:00 +10001654 break;
1655
Damien Millere2754432006-07-24 14:06:47 +10001656 case sForceCommand:
dtucker@openbsd.orgbd902b82015-04-23 04:53:53 +00001657 if (cp == NULL || *cp == '\0')
Damien Millere2754432006-07-24 14:06:47 +10001658 fatal("%.200s line %d: Missing argument.", filename,
1659 linenum);
1660 len = strspn(cp, WHITESPACE);
1661 if (*activep && options->adm_forced_command == NULL)
1662 options->adm_forced_command = xstrdup(cp + len);
1663 return 0;
1664
Damien Millerd8cb1f12008-02-10 22:40:12 +11001665 case sChrootDirectory:
1666 charptr = &options->chroot_directory;
Damien Miller54e37732008-02-10 22:48:55 +11001667
1668 arg = strdelim(&cp);
1669 if (!arg || *arg == '\0')
1670 fatal("%s line %d: missing file name.",
1671 filename, linenum);
1672 if (*activep && *charptr == NULL)
1673 *charptr = xstrdup(arg);
1674 break;
Damien Millerd8cb1f12008-02-10 22:40:12 +11001675
Damien Miller1aed65e2010-03-04 21:53:35 +11001676 case sTrustedUserCAKeys:
1677 charptr = &options->trusted_user_ca_keys;
1678 goto parse_filename;
1679
1680 case sRevokedKeys:
1681 charptr = &options->revoked_keys_file;
1682 goto parse_filename;
1683
Damien Miller0dac6fb2010-11-20 15:19:38 +11001684 case sIPQoS:
1685 arg = strdelim(&cp);
1686 if ((value = parse_ipqos(arg)) == -1)
1687 fatal("%s line %d: Bad IPQoS value: %s",
1688 filename, linenum, arg);
1689 arg = strdelim(&cp);
1690 if (arg == NULL)
1691 value2 = value;
1692 else if ((value2 = parse_ipqos(arg)) == -1)
1693 fatal("%s line %d: Bad IPQoS value: %s",
1694 filename, linenum, arg);
1695 if (*activep) {
1696 options->ip_qos_interactive = value;
1697 options->ip_qos_bulk = value2;
1698 }
1699 break;
1700
Damien Miller23528812012-04-22 11:24:43 +10001701 case sVersionAddendum:
dtucker@openbsd.orgbd902b82015-04-23 04:53:53 +00001702 if (cp == NULL || *cp == '\0')
Damien Miller23528812012-04-22 11:24:43 +10001703 fatal("%.200s line %d: Missing argument.", filename,
1704 linenum);
1705 len = strspn(cp, WHITESPACE);
1706 if (*activep && options->version_addendum == NULL) {
1707 if (strcasecmp(cp + len, "none") == 0)
1708 options->version_addendum = xstrdup("");
1709 else if (strchr(cp + len, '\r') != NULL)
1710 fatal("%.200s line %d: Invalid argument",
1711 filename, linenum);
1712 else
1713 options->version_addendum = xstrdup(cp + len);
1714 }
1715 return 0;
1716
Damien Miller09d3e122012-10-31 08:58:58 +11001717 case sAuthorizedKeysCommand:
jsg@openbsd.org72bba3d2014-11-24 03:39:22 +00001718 if (cp == NULL)
1719 fatal("%.200s line %d: Missing argument.", filename,
1720 linenum);
Damien Miller09d3e122012-10-31 08:58:58 +11001721 len = strspn(cp, WHITESPACE);
1722 if (*activep && options->authorized_keys_command == NULL) {
1723 if (cp[len] != '/' && strcasecmp(cp + len, "none") != 0)
1724 fatal("%.200s line %d: AuthorizedKeysCommand "
1725 "must be an absolute path",
1726 filename, linenum);
1727 options->authorized_keys_command = xstrdup(cp + len);
1728 }
1729 return 0;
1730
1731 case sAuthorizedKeysCommandUser:
1732 charptr = &options->authorized_keys_command_user;
1733
1734 arg = strdelim(&cp);
jsg@openbsd.org72bba3d2014-11-24 03:39:22 +00001735 if (!arg || *arg == '\0')
1736 fatal("%s line %d: missing AuthorizedKeysCommandUser "
1737 "argument.", filename, linenum);
Damien Miller09d3e122012-10-31 08:58:58 +11001738 if (*activep && *charptr == NULL)
1739 *charptr = xstrdup(arg);
1740 break;
1741
djm@openbsd.orgbcc50d82015-05-21 06:43:30 +00001742 case sAuthorizedPrincipalsCommand:
1743 if (cp == NULL)
1744 fatal("%.200s line %d: Missing argument.", filename,
1745 linenum);
1746 len = strspn(cp, WHITESPACE);
1747 if (*activep &&
1748 options->authorized_principals_command == NULL) {
1749 if (cp[len] != '/' && strcasecmp(cp + len, "none") != 0)
1750 fatal("%.200s line %d: "
1751 "AuthorizedPrincipalsCommand must be "
1752 "an absolute path", filename, linenum);
1753 options->authorized_principals_command =
1754 xstrdup(cp + len);
1755 }
1756 return 0;
1757
1758 case sAuthorizedPrincipalsCommandUser:
1759 charptr = &options->authorized_principals_command_user;
1760
1761 arg = strdelim(&cp);
1762 if (!arg || *arg == '\0')
1763 fatal("%s line %d: missing "
1764 "AuthorizedPrincipalsCommandUser argument.",
1765 filename, linenum);
1766 if (*activep && *charptr == NULL)
1767 *charptr = xstrdup(arg);
1768 break;
1769
Damien Millera6e3f012012-11-04 23:21:40 +11001770 case sAuthenticationMethods:
djm@openbsd.org9559d7d2015-05-01 07:08:08 +00001771 if (options->num_auth_methods == 0) {
Damien Millera6e3f012012-11-04 23:21:40 +11001772 while ((arg = strdelim(&cp)) && *arg != '\0') {
1773 if (options->num_auth_methods >=
1774 MAX_AUTH_METHODS)
1775 fatal("%s line %d: "
1776 "too many authentication methods.",
1777 filename, linenum);
1778 if (auth2_methods_valid(arg, 0) != 0)
1779 fatal("%s line %d: invalid "
1780 "authentication method list.",
1781 filename, linenum);
djm@openbsd.org9559d7d2015-05-01 07:08:08 +00001782 if (!*activep)
1783 continue;
Damien Millera6e3f012012-11-04 23:21:40 +11001784 options->auth_methods[
1785 options->num_auth_methods++] = xstrdup(arg);
1786 }
1787 }
1788 return 0;
1789
Damien Miller7acefbb2014-07-18 14:11:24 +10001790 case sStreamLocalBindMask:
1791 arg = strdelim(&cp);
1792 if (!arg || *arg == '\0')
djm@openbsd.org9559d7d2015-05-01 07:08:08 +00001793 fatal("%s line %d: missing StreamLocalBindMask "
1794 "argument.", filename, linenum);
Damien Miller7acefbb2014-07-18 14:11:24 +10001795 /* Parse mode in octal format */
1796 value = strtol(arg, &p, 8);
1797 if (arg == p || value < 0 || value > 0777)
1798 fatal("%s line %d: Bad mask.", filename, linenum);
djm@openbsd.org9559d7d2015-05-01 07:08:08 +00001799 if (*activep)
1800 options->fwd_opts.streamlocal_bind_mask = (mode_t)value;
Damien Miller7acefbb2014-07-18 14:11:24 +10001801 break;
1802
1803 case sStreamLocalBindUnlink:
1804 intptr = &options->fwd_opts.streamlocal_bind_unlink;
1805 goto parse_flag;
1806
djm@openbsd.org56d1c832014-12-21 22:27:55 +00001807 case sFingerprintHash:
1808 arg = strdelim(&cp);
1809 if (!arg || *arg == '\0')
1810 fatal("%.200s line %d: Missing argument.",
1811 filename, linenum);
1812 if ((value = ssh_digest_alg_by_name(arg)) == -1)
1813 fatal("%.200s line %d: Invalid hash algorithm \"%s\".",
1814 filename, linenum, arg);
1815 if (*activep)
1816 options->fingerprint_hash = value;
1817 break;
1818
Ben Lindstromade03f62001-12-06 18:22:17 +00001819 case sDeprecated:
Damien Miller996acd22003-04-09 20:59:48 +10001820 logit("%s line %d: Deprecated option %s",
Ben Lindstromade03f62001-12-06 18:22:17 +00001821 filename, linenum, arg);
1822 while (arg)
1823 arg = strdelim(&cp);
1824 break;
1825
Damien Millerf9b3feb2003-05-16 11:38:32 +10001826 case sUnsupported:
1827 logit("%s line %d: Unsupported option %s",
1828 filename, linenum, arg);
1829 while (arg)
1830 arg = strdelim(&cp);
1831 break;
1832
Ben Lindstromade03f62001-12-06 18:22:17 +00001833 default:
1834 fatal("%s line %d: Missing handler for opcode %s (%d)",
1835 filename, linenum, arg, opcode);
1836 }
1837 if ((arg = strdelim(&cp)) != NULL && *arg != '\0')
1838 fatal("%s line %d: garbage at end of line; \"%.200s\".",
1839 filename, linenum, arg);
1840 return 0;
1841}
1842
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001843/* Reads the server configuration file. */
1844
Damien Miller4af51302000-04-16 11:18:38 +10001845void
Darren Tucker645ab752004-06-25 13:33:20 +10001846load_server_config(const char *filename, Buffer *conf)
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001847{
Damien Miller46cb75a2012-07-31 12:22:37 +10001848 char line[4096], *cp;
Ben Lindstrome1353632002-06-23 21:29:23 +00001849 FILE *f;
Damien Miller46cb75a2012-07-31 12:22:37 +10001850 int lineno = 0;
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001851
Darren Tucker645ab752004-06-25 13:33:20 +10001852 debug2("%s: filename %s", __func__, filename);
1853 if ((f = fopen(filename, "r")) == NULL) {
Damien Miller95def091999-11-25 00:26:21 +11001854 perror(filename);
Damien Millerd4a8b7e1999-10-27 13:42:43 +10001855 exit(1);
Damien Miller95def091999-11-25 00:26:21 +11001856 }
Darren Tucker645ab752004-06-25 13:33:20 +10001857 buffer_clear(conf);
Damien Miller95def091999-11-25 00:26:21 +11001858 while (fgets(line, sizeof(line), f)) {
Damien Miller46cb75a2012-07-31 12:22:37 +10001859 lineno++;
1860 if (strlen(line) == sizeof(line) - 1)
1861 fatal("%s line %d too long", filename, lineno);
Darren Tucker645ab752004-06-25 13:33:20 +10001862 /*
1863 * Trim out comments and strip whitespace
Darren Tuckerfc959702004-07-17 16:12:08 +10001864 * NB - preserve newlines, they are needed to reproduce
Darren Tucker645ab752004-06-25 13:33:20 +10001865 * line numbers later for error messages
1866 */
1867 if ((cp = strchr(line, '#')) != NULL)
1868 memcpy(cp, "\n", 2);
1869 cp = line + strspn(line, " \t\r");
1870
1871 buffer_append(conf, cp, strlen(cp));
1872 }
1873 buffer_append(conf, "\0", 1);
1874 fclose(f);
1875 debug2("%s: done config len = %d", __func__, buffer_len(conf));
1876}
1877
1878void
Darren Tuckerfbcf8272012-05-19 19:37:01 +10001879parse_server_match_config(ServerOptions *options,
1880 struct connection_info *connectinfo)
Darren Tucker645ab752004-06-25 13:33:20 +10001881{
Darren Tucker45150472006-07-12 22:34:17 +10001882 ServerOptions mo;
1883
1884 initialize_server_options(&mo);
Darren Tuckerfbcf8272012-05-19 19:37:01 +10001885 parse_server_config(&mo, "reprocess config", &cfg, connectinfo);
Darren Tucker1629c072007-02-19 22:25:37 +11001886 copy_set_server_options(options, &mo, 0);
Darren Tucker45150472006-07-12 22:34:17 +10001887}
1888
Darren Tuckerfbcf8272012-05-19 19:37:01 +10001889int parse_server_match_testspec(struct connection_info *ci, char *spec)
1890{
1891 char *p;
1892
1893 while ((p = strsep(&spec, ",")) && *p != '\0') {
1894 if (strncmp(p, "addr=", 5) == 0) {
1895 ci->address = xstrdup(p + 5);
1896 } else if (strncmp(p, "host=", 5) == 0) {
1897 ci->host = xstrdup(p + 5);
1898 } else if (strncmp(p, "user=", 5) == 0) {
1899 ci->user = xstrdup(p + 5);
1900 } else if (strncmp(p, "laddr=", 6) == 0) {
1901 ci->laddress = xstrdup(p + 6);
1902 } else if (strncmp(p, "lport=", 6) == 0) {
1903 ci->lport = a2port(p + 6);
1904 if (ci->lport == -1) {
1905 fprintf(stderr, "Invalid port '%s' in test mode"
1906 " specification %s\n", p+6, p);
1907 return -1;
1908 }
1909 } else {
1910 fprintf(stderr, "Invalid test mode specification %s\n",
1911 p);
1912 return -1;
1913 }
1914 }
1915 return 0;
1916}
1917
1918/*
1919 * returns 1 for a complete spec, 0 for partial spec and -1 for an
1920 * empty spec.
1921 */
1922int server_match_spec_complete(struct connection_info *ci)
1923{
1924 if (ci->user && ci->host && ci->address)
1925 return 1; /* complete */
1926 if (!ci->user && !ci->host && !ci->address)
1927 return -1; /* empty */
1928 return 0; /* partial */
1929}
1930
Darren Tucker1629c072007-02-19 22:25:37 +11001931/*
1932 * Copy any supported values that are set.
1933 *
Darren Tucker3b59dfa2009-06-21 17:54:47 +10001934 * If the preauth flag is set, we do not bother copying the string or
Darren Tucker1629c072007-02-19 22:25:37 +11001935 * array values that are not used pre-authentication, because any that we
1936 * do use must be explictly sent in mm_getpwnamallow().
1937 */
Darren Tucker45150472006-07-12 22:34:17 +10001938void
Darren Tucker1629c072007-02-19 22:25:37 +11001939copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth)
Darren Tucker45150472006-07-12 22:34:17 +10001940{
Damien Miller534b2cc2013-12-05 14:07:27 +11001941#define M_CP_INTOPT(n) do {\
1942 if (src->n != -1) \
1943 dst->n = src->n; \
1944} while (0)
1945
Darren Tucker1629c072007-02-19 22:25:37 +11001946 M_CP_INTOPT(password_authentication);
1947 M_CP_INTOPT(gss_authentication);
1948 M_CP_INTOPT(rsa_authentication);
1949 M_CP_INTOPT(pubkey_authentication);
1950 M_CP_INTOPT(kerberos_authentication);
1951 M_CP_INTOPT(hostbased_authentication);
Damien Millerab6de352010-06-26 09:38:45 +10001952 M_CP_INTOPT(hostbased_uses_name_from_packet_only);
Darren Tucker1629c072007-02-19 22:25:37 +11001953 M_CP_INTOPT(kbd_interactive_authentication);
Darren Tucker15f94272008-01-01 20:36:56 +11001954 M_CP_INTOPT(permit_root_login);
Damien Miller51bde602008-11-03 19:23:10 +11001955 M_CP_INTOPT(permit_empty_passwd);
Darren Tucker1629c072007-02-19 22:25:37 +11001956
1957 M_CP_INTOPT(allow_tcp_forwarding);
Damien Miller7acefbb2014-07-18 14:11:24 +10001958 M_CP_INTOPT(allow_streamlocal_forwarding);
Damien Miller4f755cd2008-05-19 14:57:41 +10001959 M_CP_INTOPT(allow_agent_forwarding);
Damien Millerab6de352010-06-26 09:38:45 +10001960 M_CP_INTOPT(permit_tun);
Damien Miller7acefbb2014-07-18 14:11:24 +10001961 M_CP_INTOPT(fwd_opts.gateway_ports);
Darren Tucker1629c072007-02-19 22:25:37 +11001962 M_CP_INTOPT(x11_display_offset);
1963 M_CP_INTOPT(x11_forwarding);
1964 M_CP_INTOPT(x11_use_localhost);
Damien Miller5ff30c62013-10-30 22:21:50 +11001965 M_CP_INTOPT(permit_tty);
Damien Miller72e6b5c2014-07-04 09:00:04 +10001966 M_CP_INTOPT(permit_user_rc);
Damien Miller7207f642008-05-19 15:34:50 +10001967 M_CP_INTOPT(max_sessions);
Damien Miller307c1d12008-06-16 07:56:20 +10001968 M_CP_INTOPT(max_authtries);
Damien Miller0dac6fb2010-11-20 15:19:38 +11001969 M_CP_INTOPT(ip_qos_interactive);
1970 M_CP_INTOPT(ip_qos_bulk);
Darren Tucker5f96f3b2013-05-16 20:29:28 +10001971 M_CP_INTOPT(rekey_limit);
1972 M_CP_INTOPT(rekey_interval);
Darren Tucker1629c072007-02-19 22:25:37 +11001973
Damien Miller534b2cc2013-12-05 14:07:27 +11001974 /* M_CP_STROPT and M_CP_STRARRAYOPT should not appear before here */
1975#define M_CP_STROPT(n) do {\
1976 if (src->n != NULL && dst->n != src->n) { \
1977 free(dst->n); \
1978 dst->n = src->n; \
1979 } \
1980} while(0)
1981#define M_CP_STRARRAYOPT(n, num_n) do {\
1982 if (src->num_n != 0) { \
1983 for (dst->num_n = 0; dst->num_n < src->num_n; dst->num_n++) \
1984 dst->n[dst->num_n] = xstrdup(src->n[dst->num_n]); \
1985 } \
1986} while(0)
1987
Damien Millerf2e407e2011-05-20 19:04:14 +10001988 /* See comment in servconf.h */
1989 COPY_MATCH_STRING_OPTS();
Damien Miller5d74e582011-05-20 19:03:31 +10001990
Damien Millerc2411902011-05-20 19:03:49 +10001991 /*
1992 * The only things that should be below this point are string options
1993 * which are only used after authentication.
1994 */
Damien Miller5d74e582011-05-20 19:03:31 +10001995 if (preauth)
1996 return;
Damien Millerd8478b62011-05-29 21:39:36 +10001997
Damien Miller5d74e582011-05-20 19:03:31 +10001998 M_CP_STROPT(adm_forced_command);
1999 M_CP_STROPT(chroot_directory);
Darren Tucker45150472006-07-12 22:34:17 +10002000}
2001
Darren Tucker1629c072007-02-19 22:25:37 +11002002#undef M_CP_INTOPT
2003#undef M_CP_STROPT
Damien Millerd8478b62011-05-29 21:39:36 +10002004#undef M_CP_STRARRAYOPT
Darren Tucker1629c072007-02-19 22:25:37 +11002005
Darren Tucker45150472006-07-12 22:34:17 +10002006void
2007parse_server_config(ServerOptions *options, const char *filename, Buffer *conf,
Darren Tuckerfbcf8272012-05-19 19:37:01 +10002008 struct connection_info *connectinfo)
Darren Tucker45150472006-07-12 22:34:17 +10002009{
2010 int active, linenum, bad_options = 0;
Darren Tucker9fbac712004-08-12 22:41:44 +10002011 char *cp, *obuf, *cbuf;
Darren Tucker645ab752004-06-25 13:33:20 +10002012
2013 debug2("%s: config %s len %d", __func__, filename, buffer_len(conf));
2014
Darren Tucker9fbac712004-08-12 22:41:44 +10002015 obuf = cbuf = xstrdup(buffer_ptr(conf));
Darren Tuckerfbcf8272012-05-19 19:37:01 +10002016 active = connectinfo ? 0 : 1;
Darren Tucker137e9c92004-08-13 21:30:24 +10002017 linenum = 1;
Darren Tucker47eede72005-03-14 23:08:12 +11002018 while ((cp = strsep(&cbuf, "\n")) != NULL) {
Darren Tucker645ab752004-06-25 13:33:20 +10002019 if (process_server_config_line(options, cp, filename,
Darren Tuckerfbcf8272012-05-19 19:37:01 +10002020 linenum++, &active, connectinfo) != 0)
Damien Miller95def091999-11-25 00:26:21 +11002021 bad_options++;
Damien Millerd4a8b7e1999-10-27 13:42:43 +10002022 }
Darren Tuckera627d422013-06-02 07:31:17 +10002023 free(obuf);
Ben Lindstromb5cdc662001-04-16 02:13:26 +00002024 if (bad_options > 0)
2025 fatal("%s: terminating, %d bad configuration options",
2026 filename, bad_options);
dtucker@openbsd.org531a57a2015-04-29 03:48:56 +00002027 process_queued_listen_addrs(options);
Damien Millerd4a8b7e1999-10-27 13:42:43 +10002028}
Darren Tuckere7140f22008-06-10 23:01:51 +10002029
2030static const char *
Damien Miller82c55872011-06-23 08:20:30 +10002031fmt_multistate_int(int val, const struct multistate *m)
2032{
2033 u_int i;
2034
2035 for (i = 0; m[i].key != NULL; i++) {
2036 if (m[i].value == val)
2037 return m[i].key;
2038 }
2039 return "UNKNOWN";
2040}
2041
2042static const char *
Darren Tuckere7140f22008-06-10 23:01:51 +10002043fmt_intarg(ServerOpCodes code, int val)
2044{
Damien Miller82c55872011-06-23 08:20:30 +10002045 if (val == -1)
2046 return "unset";
2047 switch (code) {
2048 case sAddressFamily:
2049 return fmt_multistate_int(val, multistate_addressfamily);
2050 case sPermitRootLogin:
2051 return fmt_multistate_int(val, multistate_permitrootlogin);
2052 case sGatewayPorts:
2053 return fmt_multistate_int(val, multistate_gatewayports);
2054 case sCompression:
2055 return fmt_multistate_int(val, multistate_compression);
Damien Miller69ff1df2011-06-23 08:30:03 +10002056 case sUsePrivilegeSeparation:
2057 return fmt_multistate_int(val, multistate_privsep);
Damien Milleraa5b3f82012-12-03 09:50:54 +11002058 case sAllowTcpForwarding:
2059 return fmt_multistate_int(val, multistate_tcpfwd);
Damien Miller7acefbb2014-07-18 14:11:24 +10002060 case sAllowStreamLocalForwarding:
2061 return fmt_multistate_int(val, multistate_tcpfwd);
djm@openbsd.org56d1c832014-12-21 22:27:55 +00002062 case sFingerprintHash:
2063 return ssh_digest_alg_name(val);
Damien Miller82c55872011-06-23 08:20:30 +10002064 case sProtocol:
Darren Tuckere7140f22008-06-10 23:01:51 +10002065 switch (val) {
2066 case SSH_PROTO_1:
2067 return "1";
2068 case SSH_PROTO_2:
2069 return "2";
2070 case (SSH_PROTO_1|SSH_PROTO_2):
2071 return "2,1";
2072 default:
2073 return "UNKNOWN";
2074 }
Damien Miller82c55872011-06-23 08:20:30 +10002075 default:
2076 switch (val) {
2077 case 0:
2078 return "no";
2079 case 1:
2080 return "yes";
2081 default:
2082 return "UNKNOWN";
2083 }
Darren Tuckere7140f22008-06-10 23:01:51 +10002084 }
Darren Tuckere7140f22008-06-10 23:01:51 +10002085}
2086
2087static const char *
2088lookup_opcode_name(ServerOpCodes code)
2089{
2090 u_int i;
2091
2092 for (i = 0; keywords[i].name != NULL; i++)
2093 if (keywords[i].opcode == code)
2094 return(keywords[i].name);
2095 return "UNKNOWN";
2096}
2097
2098static void
2099dump_cfg_int(ServerOpCodes code, int val)
2100{
2101 printf("%s %d\n", lookup_opcode_name(code), val);
2102}
2103
2104static void
dtucker@openbsd.org1108ae22015-04-23 04:59:10 +00002105dump_cfg_oct(ServerOpCodes code, int val)
2106{
2107 printf("%s 0%o\n", lookup_opcode_name(code), val);
2108}
2109
2110static void
Darren Tuckere7140f22008-06-10 23:01:51 +10002111dump_cfg_fmtint(ServerOpCodes code, int val)
2112{
2113 printf("%s %s\n", lookup_opcode_name(code), fmt_intarg(code, val));
2114}
2115
2116static void
2117dump_cfg_string(ServerOpCodes code, const char *val)
2118{
2119 if (val == NULL)
2120 return;
djm@openbsd.org161cf412014-12-22 07:55:51 +00002121 printf("%s %s\n", lookup_opcode_name(code),
2122 val == NULL ? "none" : val);
Darren Tuckere7140f22008-06-10 23:01:51 +10002123}
2124
2125static void
2126dump_cfg_strarray(ServerOpCodes code, u_int count, char **vals)
2127{
2128 u_int i;
2129
2130 for (i = 0; i < count; i++)
Damien Millerd8478b62011-05-29 21:39:36 +10002131 printf("%s %s\n", lookup_opcode_name(code), vals[i]);
2132}
2133
2134static void
2135dump_cfg_strarray_oneline(ServerOpCodes code, u_int count, char **vals)
2136{
2137 u_int i;
2138
dtucker@openbsd.org40132ff2015-04-17 04:12:35 +00002139 if (count <= 0)
2140 return;
Damien Millerd8478b62011-05-29 21:39:36 +10002141 printf("%s", lookup_opcode_name(code));
2142 for (i = 0; i < count; i++)
2143 printf(" %s", vals[i]);
2144 printf("\n");
Darren Tuckere7140f22008-06-10 23:01:51 +10002145}
2146
2147void
2148dump_config(ServerOptions *o)
2149{
2150 u_int i;
2151 int ret;
2152 struct addrinfo *ai;
2153 char addr[NI_MAXHOST], port[NI_MAXSERV], *s = NULL;
dtucker@openbsd.org1108ae22015-04-23 04:59:10 +00002154 char *laddr1 = xstrdup(""), *laddr2 = NULL;
Darren Tuckere7140f22008-06-10 23:01:51 +10002155
2156 /* these are usually at the top of the config */
2157 for (i = 0; i < o->num_ports; i++)
2158 printf("port %d\n", o->ports[i]);
2159 dump_cfg_fmtint(sProtocol, o->protocol);
2160 dump_cfg_fmtint(sAddressFamily, o->address_family);
2161
dtucker@openbsd.org1108ae22015-04-23 04:59:10 +00002162 /*
2163 * ListenAddress must be after Port. add_one_listen_addr pushes
2164 * addresses onto a stack, so to maintain ordering we need to
2165 * print these in reverse order.
2166 */
Darren Tuckere7140f22008-06-10 23:01:51 +10002167 for (ai = o->listen_addrs; ai; ai = ai->ai_next) {
2168 if ((ret = getnameinfo(ai->ai_addr, ai->ai_addrlen, addr,
2169 sizeof(addr), port, sizeof(port),
2170 NI_NUMERICHOST|NI_NUMERICSERV)) != 0) {
2171 error("getnameinfo failed: %.100s",
2172 (ret != EAI_SYSTEM) ? gai_strerror(ret) :
2173 strerror(errno));
2174 } else {
dtucker@openbsd.org1108ae22015-04-23 04:59:10 +00002175 laddr2 = laddr1;
Darren Tuckere7140f22008-06-10 23:01:51 +10002176 if (ai->ai_family == AF_INET6)
dtucker@openbsd.org1108ae22015-04-23 04:59:10 +00002177 xasprintf(&laddr1, "listenaddress [%s]:%s\n%s",
2178 addr, port, laddr2);
Darren Tuckere7140f22008-06-10 23:01:51 +10002179 else
dtucker@openbsd.org1108ae22015-04-23 04:59:10 +00002180 xasprintf(&laddr1, "listenaddress %s:%s\n%s",
2181 addr, port, laddr2);
2182 free(laddr2);
Darren Tuckere7140f22008-06-10 23:01:51 +10002183 }
2184 }
dtucker@openbsd.org1108ae22015-04-23 04:59:10 +00002185 printf("%s", laddr1);
2186 free(laddr1);
Darren Tuckere7140f22008-06-10 23:01:51 +10002187
2188 /* integer arguments */
Damien Miller212f0b02008-07-23 17:42:29 +10002189#ifdef USE_PAM
Darren Tucker70860b62015-04-17 10:56:13 +10002190 dump_cfg_fmtint(sUsePAM, o->use_pam);
Damien Miller212f0b02008-07-23 17:42:29 +10002191#endif
Darren Tuckere7140f22008-06-10 23:01:51 +10002192 dump_cfg_int(sServerKeyBits, o->server_key_bits);
2193 dump_cfg_int(sLoginGraceTime, o->login_grace_time);
2194 dump_cfg_int(sKeyRegenerationTime, o->key_regeneration_time);
2195 dump_cfg_int(sX11DisplayOffset, o->x11_display_offset);
2196 dump_cfg_int(sMaxAuthTries, o->max_authtries);
Damien Miller7fc5c0f2008-11-05 16:12:11 +11002197 dump_cfg_int(sMaxSessions, o->max_sessions);
Darren Tuckere7140f22008-06-10 23:01:51 +10002198 dump_cfg_int(sClientAliveInterval, o->client_alive_interval);
2199 dump_cfg_int(sClientAliveCountMax, o->client_alive_count_max);
dtucker@openbsd.org1108ae22015-04-23 04:59:10 +00002200 dump_cfg_oct(sStreamLocalBindMask, o->fwd_opts.streamlocal_bind_mask);
Darren Tuckere7140f22008-06-10 23:01:51 +10002201
2202 /* formatted integer arguments */
2203 dump_cfg_fmtint(sPermitRootLogin, o->permit_root_login);
2204 dump_cfg_fmtint(sIgnoreRhosts, o->ignore_rhosts);
2205 dump_cfg_fmtint(sIgnoreUserKnownHosts, o->ignore_user_known_hosts);
2206 dump_cfg_fmtint(sRhostsRSAAuthentication, o->rhosts_rsa_authentication);
2207 dump_cfg_fmtint(sHostbasedAuthentication, o->hostbased_authentication);
2208 dump_cfg_fmtint(sHostbasedUsesNameFromPacketOnly,
2209 o->hostbased_uses_name_from_packet_only);
2210 dump_cfg_fmtint(sRSAAuthentication, o->rsa_authentication);
2211 dump_cfg_fmtint(sPubkeyAuthentication, o->pubkey_authentication);
Damien Miller6ef430d2008-07-23 17:40:04 +10002212#ifdef KRB5
Darren Tuckere7140f22008-06-10 23:01:51 +10002213 dump_cfg_fmtint(sKerberosAuthentication, o->kerberos_authentication);
2214 dump_cfg_fmtint(sKerberosOrLocalPasswd, o->kerberos_or_local_passwd);
2215 dump_cfg_fmtint(sKerberosTicketCleanup, o->kerberos_ticket_cleanup);
Damien Miller6ef430d2008-07-23 17:40:04 +10002216# ifdef USE_AFS
Darren Tuckere7140f22008-06-10 23:01:51 +10002217 dump_cfg_fmtint(sKerberosGetAFSToken, o->kerberos_get_afs_token);
Damien Miller6ef430d2008-07-23 17:40:04 +10002218# endif
2219#endif
2220#ifdef GSSAPI
Darren Tuckere7140f22008-06-10 23:01:51 +10002221 dump_cfg_fmtint(sGssAuthentication, o->gss_authentication);
2222 dump_cfg_fmtint(sGssCleanupCreds, o->gss_cleanup_creds);
Damien Miller6ef430d2008-07-23 17:40:04 +10002223#endif
Darren Tuckere7140f22008-06-10 23:01:51 +10002224 dump_cfg_fmtint(sPasswordAuthentication, o->password_authentication);
2225 dump_cfg_fmtint(sKbdInteractiveAuthentication,
2226 o->kbd_interactive_authentication);
2227 dump_cfg_fmtint(sChallengeResponseAuthentication,
2228 o->challenge_response_authentication);
2229 dump_cfg_fmtint(sPrintMotd, o->print_motd);
2230 dump_cfg_fmtint(sPrintLastLog, o->print_lastlog);
2231 dump_cfg_fmtint(sX11Forwarding, o->x11_forwarding);
2232 dump_cfg_fmtint(sX11UseLocalhost, o->x11_use_localhost);
Damien Miller5ff30c62013-10-30 22:21:50 +11002233 dump_cfg_fmtint(sPermitTTY, o->permit_tty);
Damien Miller72e6b5c2014-07-04 09:00:04 +10002234 dump_cfg_fmtint(sPermitUserRC, o->permit_user_rc);
Darren Tuckere7140f22008-06-10 23:01:51 +10002235 dump_cfg_fmtint(sStrictModes, o->strict_modes);
2236 dump_cfg_fmtint(sTCPKeepAlive, o->tcp_keep_alive);
2237 dump_cfg_fmtint(sEmptyPasswd, o->permit_empty_passwd);
2238 dump_cfg_fmtint(sPermitUserEnvironment, o->permit_user_env);
2239 dump_cfg_fmtint(sUseLogin, o->use_login);
2240 dump_cfg_fmtint(sCompression, o->compression);
Damien Miller7acefbb2014-07-18 14:11:24 +10002241 dump_cfg_fmtint(sGatewayPorts, o->fwd_opts.gateway_ports);
Darren Tuckere7140f22008-06-10 23:01:51 +10002242 dump_cfg_fmtint(sUseDNS, o->use_dns);
2243 dump_cfg_fmtint(sAllowTcpForwarding, o->allow_tcp_forwarding);
dtucker@openbsd.org40132ff2015-04-17 04:12:35 +00002244 dump_cfg_fmtint(sAllowAgentForwarding, o->allow_agent_forwarding);
Damien Miller7acefbb2014-07-18 14:11:24 +10002245 dump_cfg_fmtint(sAllowStreamLocalForwarding, o->allow_streamlocal_forwarding);
Darren Tuckere7140f22008-06-10 23:01:51 +10002246 dump_cfg_fmtint(sUsePrivilegeSeparation, use_privsep);
djm@openbsd.org56d1c832014-12-21 22:27:55 +00002247 dump_cfg_fmtint(sFingerprintHash, o->fingerprint_hash);
Darren Tuckere7140f22008-06-10 23:01:51 +10002248
2249 /* string arguments */
2250 dump_cfg_string(sPidFile, o->pid_file);
2251 dump_cfg_string(sXAuthLocation, o->xauth_location);
djm@openbsd.org57d378e2014-08-19 23:58:28 +00002252 dump_cfg_string(sCiphers, o->ciphers ? o->ciphers : KEX_SERVER_ENCRYPT);
2253 dump_cfg_string(sMacs, o->macs ? o->macs : KEX_SERVER_MAC);
Darren Tuckere7140f22008-06-10 23:01:51 +10002254 dump_cfg_string(sBanner, o->banner);
Darren Tuckere7140f22008-06-10 23:01:51 +10002255 dump_cfg_string(sForceCommand, o->adm_forced_command);
Darren Tuckerd3300452010-01-10 19:26:43 +11002256 dump_cfg_string(sChrootDirectory, o->chroot_directory);
Damien Miller1aed65e2010-03-04 21:53:35 +11002257 dump_cfg_string(sTrustedUserCAKeys, o->trusted_user_ca_keys);
2258 dump_cfg_string(sRevokedKeys, o->revoked_keys_file);
Damien Miller30da3442010-05-10 11:58:03 +10002259 dump_cfg_string(sAuthorizedPrincipalsFile,
2260 o->authorized_principals_file);
dtucker@openbsd.org40132ff2015-04-17 04:12:35 +00002261 dump_cfg_string(sVersionAddendum, *o->version_addendum == '\0'
2262 ? "none" : o->version_addendum);
Damien Miller09d3e122012-10-31 08:58:58 +11002263 dump_cfg_string(sAuthorizedKeysCommand, o->authorized_keys_command);
2264 dump_cfg_string(sAuthorizedKeysCommandUser, o->authorized_keys_command_user);
djm@openbsd.orgbcc50d82015-05-21 06:43:30 +00002265 dump_cfg_string(sAuthorizedPrincipalsCommand, o->authorized_principals_command);
2266 dump_cfg_string(sAuthorizedPrincipalsCommandUser, o->authorized_principals_command_user);
Damien Miller85b45e02013-07-20 13:21:52 +10002267 dump_cfg_string(sHostKeyAgent, o->host_key_agent);
djm@openbsd.org57d378e2014-08-19 23:58:28 +00002268 dump_cfg_string(sKexAlgorithms,
djm@openbsd.org259a02e2014-10-13 00:38:35 +00002269 o->kex_algorithms ? o->kex_algorithms : KEX_SERVER_KEX);
djm@openbsd.org1f729f02015-01-13 07:39:19 +00002270 dump_cfg_string(sHostbasedAcceptedKeyTypes, o->hostbased_key_types ?
2271 o->hostbased_key_types : KEX_DEFAULT_PK_ALG);
2272 dump_cfg_string(sPubkeyAcceptedKeyTypes, o->pubkey_key_types ?
2273 o->pubkey_key_types : KEX_DEFAULT_PK_ALG);
Darren Tuckere7140f22008-06-10 23:01:51 +10002274
2275 /* string arguments requiring a lookup */
2276 dump_cfg_string(sLogLevel, log_level_name(o->log_level));
2277 dump_cfg_string(sLogFacility, log_facility_name(o->log_facility));
2278
2279 /* string array arguments */
Damien Millerd8478b62011-05-29 21:39:36 +10002280 dump_cfg_strarray_oneline(sAuthorizedKeysFile, o->num_authkeys_files,
2281 o->authorized_keys_files);
Darren Tuckere7140f22008-06-10 23:01:51 +10002282 dump_cfg_strarray(sHostKeyFile, o->num_host_key_files,
2283 o->host_key_files);
dtucker@openbsd.org40132ff2015-04-17 04:12:35 +00002284 dump_cfg_strarray(sHostCertificate, o->num_host_cert_files,
Damien Miller0a80ca12010-02-27 07:55:05 +11002285 o->host_cert_files);
Darren Tuckere7140f22008-06-10 23:01:51 +10002286 dump_cfg_strarray(sAllowUsers, o->num_allow_users, o->allow_users);
2287 dump_cfg_strarray(sDenyUsers, o->num_deny_users, o->deny_users);
2288 dump_cfg_strarray(sAllowGroups, o->num_allow_groups, o->allow_groups);
2289 dump_cfg_strarray(sDenyGroups, o->num_deny_groups, o->deny_groups);
2290 dump_cfg_strarray(sAcceptEnv, o->num_accept_env, o->accept_env);
Damien Millera6e3f012012-11-04 23:21:40 +11002291 dump_cfg_strarray_oneline(sAuthenticationMethods,
2292 o->num_auth_methods, o->auth_methods);
Darren Tuckere7140f22008-06-10 23:01:51 +10002293
2294 /* other arguments */
2295 for (i = 0; i < o->num_subsystems; i++)
2296 printf("subsystem %s %s\n", o->subsystem_name[i],
2297 o->subsystem_args[i]);
2298
2299 printf("maxstartups %d:%d:%d\n", o->max_startups_begin,
2300 o->max_startups_rate, o->max_startups);
2301
2302 for (i = 0; tunmode_desc[i].val != -1; i++)
2303 if (tunmode_desc[i].val == o->permit_tun) {
2304 s = tunmode_desc[i].text;
2305 break;
2306 }
2307 dump_cfg_string(sPermitTunnel, s);
2308
Damien Miller91475862011-05-05 14:14:34 +10002309 printf("ipqos %s ", iptos2str(o->ip_qos_interactive));
2310 printf("%s\n", iptos2str(o->ip_qos_bulk));
Damien Miller0dac6fb2010-11-20 15:19:38 +11002311
Damien Millera6d6c1f2013-08-21 02:40:01 +10002312 printf("rekeylimit %lld %d\n", (long long)o->rekey_limit,
2313 o->rekey_interval);
Darren Tucker5f96f3b2013-05-16 20:29:28 +10002314
Darren Tuckere7140f22008-06-10 23:01:51 +10002315 channel_print_adm_permitted_opens();
Darren Tuckere7140f22008-06-10 23:01:51 +10002316}