Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 1 | |
Damien Miller | 1f583df | 2013-02-12 11:02:08 +1100 | [diff] [blame] | 2 | /* $OpenBSD: servconf.c,v 1.234 2013/02/06 00:20:42 dtucker Exp $ */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 3 | /* |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
| 5 | * All rights reserved |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 6 | * |
Damien Miller | e4340be | 2000-09-16 13:29:08 +1100 | [diff] [blame] | 7 | * As far as I am concerned, the code I have written for this software |
| 8 | * can be used freely for any purpose. Any derived versions of this |
| 9 | * software must be clearly marked as such, and if the derived work is |
| 10 | * incompatible with the protocol description in the RFC file, it must be |
| 11 | * called by a name other than "ssh" or "Secure Shell". |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 12 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 13 | |
| 14 | #include "includes.h" |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 15 | |
Damien Miller | e3b60b5 | 2006-07-10 21:08:03 +1000 | [diff] [blame] | 16 | #include <sys/types.h> |
| 17 | #include <sys/socket.h> |
| 18 | |
Damien Miller | 0dac6fb | 2010-11-20 15:19:38 +1100 | [diff] [blame] | 19 | #include <netinet/in.h> |
| 20 | #include <netinet/in_systm.h> |
| 21 | #include <netinet/ip.h> |
| 22 | |
Damien Miller | b8fe89c | 2006-07-24 14:51:00 +1000 | [diff] [blame] | 23 | #include <netdb.h> |
Damien Miller | 565ca3f | 2006-08-19 00:23:15 +1000 | [diff] [blame] | 24 | #include <pwd.h> |
Damien Miller | a7a73ee | 2006-08-05 11:37:59 +1000 | [diff] [blame] | 25 | #include <stdio.h> |
Damien Miller | e7a1e5c | 2006-08-05 11:34:19 +1000 | [diff] [blame] | 26 | #include <stdlib.h> |
Damien Miller | e3476ed | 2006-07-24 14:13:33 +1000 | [diff] [blame] | 27 | #include <string.h> |
Damien Miller | d783435 | 2006-08-05 12:39:39 +1000 | [diff] [blame] | 28 | #include <signal.h> |
Damien Miller | e6b3b61 | 2006-07-24 14:01:23 +1000 | [diff] [blame] | 29 | #include <unistd.h> |
Damien Miller | d783435 | 2006-08-05 12:39:39 +1000 | [diff] [blame] | 30 | #include <stdarg.h> |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 31 | #include <errno.h> |
Damien Miller | be43ebf | 2006-07-24 13:51:51 +1000 | [diff] [blame] | 32 | |
Damien Miller | b84886b | 2008-05-19 15:05:07 +1000 | [diff] [blame] | 33 | #include "openbsd-compat/sys-queue.h" |
Damien Miller | d783435 | 2006-08-05 12:39:39 +1000 | [diff] [blame] | 34 | #include "xmalloc.h" |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 35 | #include "ssh.h" |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 36 | #include "log.h" |
Damien Miller | d783435 | 2006-08-05 12:39:39 +1000 | [diff] [blame] | 37 | #include "buffer.h" |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 38 | #include "servconf.h" |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 39 | #include "compat.h" |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 40 | #include "pathnames.h" |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 41 | #include "misc.h" |
| 42 | #include "cipher.h" |
Damien Miller | d783435 | 2006-08-05 12:39:39 +1000 | [diff] [blame] | 43 | #include "key.h" |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 44 | #include "kex.h" |
| 45 | #include "mac.h" |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 46 | #include "match.h" |
Damien Miller | 9b439df | 2006-07-24 14:04:00 +1000 | [diff] [blame] | 47 | #include "channels.h" |
Damien Miller | 565ca3f | 2006-08-19 00:23:15 +1000 | [diff] [blame] | 48 | #include "groupaccess.h" |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 49 | #include "canohost.h" |
| 50 | #include "packet.h" |
Damien Miller | a6e3f01 | 2012-11-04 23:21:40 +1100 | [diff] [blame] | 51 | #include "hostfile.h" |
| 52 | #include "auth.h" |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 53 | |
Damien Miller | 3dc71ad | 2009-01-28 16:31:22 +1100 | [diff] [blame] | 54 | static void add_listen_addr(ServerOptions *, char *, int); |
| 55 | static void add_one_listen_addr(ServerOptions *, char *, int); |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 56 | |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 57 | /* Use of privilege separation or not */ |
| 58 | extern int use_privsep; |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 59 | extern Buffer cfg; |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 60 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 61 | /* Initializes the server options to their default values. */ |
| 62 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 63 | void |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 64 | initialize_server_options(ServerOptions *options) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 65 | { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 66 | memset(options, 0, sizeof(*options)); |
Damien Miller | 726273e | 2001-11-12 11:40:11 +1100 | [diff] [blame] | 67 | |
| 68 | /* Portable-specific options */ |
Damien Miller | 4e448a3 | 2003-05-14 15:11:48 +1000 | [diff] [blame] | 69 | options->use_pam = -1; |
Damien Miller | 726273e | 2001-11-12 11:40:11 +1100 | [diff] [blame] | 70 | |
| 71 | /* Standard Options */ |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 72 | options->num_ports = 0; |
| 73 | options->ports_from_cmdline = 0; |
| 74 | options->listen_addrs = NULL; |
Darren Tucker | 0f38323 | 2005-01-20 10:57:56 +1100 | [diff] [blame] | 75 | options->address_family = -1; |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 76 | options->num_host_key_files = 0; |
Damien Miller | 0a80ca1 | 2010-02-27 07:55:05 +1100 | [diff] [blame] | 77 | options->num_host_cert_files = 0; |
Damien Miller | 6f83b8e | 2000-05-02 09:23:45 +1000 | [diff] [blame] | 78 | options->pid_file = NULL; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 79 | options->server_key_bits = -1; |
| 80 | options->login_grace_time = -1; |
| 81 | options->key_regeneration_time = -1; |
Ben Lindstrom | d8a9021 | 2001-02-15 03:08:27 +0000 | [diff] [blame] | 82 | options->permit_root_login = PERMIT_NOT_SET; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 83 | options->ignore_rhosts = -1; |
| 84 | options->ignore_user_known_hosts = -1; |
| 85 | options->print_motd = -1; |
Ben Lindstrom | 7bfff36 | 2001-03-26 05:45:53 +0000 | [diff] [blame] | 86 | options->print_lastlog = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 87 | options->x11_forwarding = -1; |
| 88 | options->x11_display_offset = -1; |
Damien Miller | 95c249f | 2002-02-05 12:11:34 +1100 | [diff] [blame] | 89 | options->x11_use_localhost = -1; |
Damien Miller | d3a1857 | 2000-06-07 19:55:44 +1000 | [diff] [blame] | 90 | options->xauth_location = NULL; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 91 | options->strict_modes = -1; |
Damien Miller | 12c150e | 2003-12-17 16:31:10 +1100 | [diff] [blame] | 92 | options->tcp_keep_alive = -1; |
Damien Miller | fcd9320 | 2002-02-05 12:26:34 +1100 | [diff] [blame] | 93 | options->log_facility = SYSLOG_FACILITY_NOT_SET; |
| 94 | options->log_level = SYSLOG_LEVEL_NOT_SET; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 95 | options->rhosts_rsa_authentication = -1; |
Ben Lindstrom | 5eabda3 | 2001-04-12 23:34:34 +0000 | [diff] [blame] | 96 | options->hostbased_authentication = -1; |
| 97 | options->hostbased_uses_name_from_packet_only = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 98 | options->rsa_authentication = -1; |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 99 | options->pubkey_authentication = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 100 | options->kerberos_authentication = -1; |
| 101 | options->kerberos_or_local_passwd = -1; |
| 102 | options->kerberos_ticket_cleanup = -1; |
Darren Tucker | 22ef508 | 2003-12-31 11:37:34 +1100 | [diff] [blame] | 103 | options->kerberos_get_afs_token = -1; |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 104 | options->gss_authentication=-1; |
| 105 | options->gss_cleanup_creds = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 106 | options->password_authentication = -1; |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 107 | options->kbd_interactive_authentication = -1; |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 108 | options->challenge_response_authentication = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 109 | options->permit_empty_passwd = -1; |
Ben Lindstrom | 5d860f0 | 2002-08-01 01:28:38 +0000 | [diff] [blame] | 110 | options->permit_user_env = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 111 | options->use_login = -1; |
Ben Lindstrom | 23e0f66 | 2002-06-21 01:09:47 +0000 | [diff] [blame] | 112 | options->compression = -1; |
Damien Miller | 50a41ed | 2000-10-16 12:14:42 +1100 | [diff] [blame] | 113 | options->allow_tcp_forwarding = -1; |
Damien Miller | 4f755cd | 2008-05-19 14:57:41 +1000 | [diff] [blame] | 114 | options->allow_agent_forwarding = -1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 115 | options->num_allow_users = 0; |
| 116 | options->num_deny_users = 0; |
| 117 | options->num_allow_groups = 0; |
| 118 | options->num_deny_groups = 0; |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 119 | options->ciphers = NULL; |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 120 | options->macs = NULL; |
Damien Miller | d5f62bf | 2010-09-24 22:11:14 +1000 | [diff] [blame] | 121 | options->kex_algorithms = NULL; |
Damien Miller | 7892879 | 2000-04-12 20:17:38 +1000 | [diff] [blame] | 122 | options->protocol = SSH_PROTO_UNKNOWN; |
Damien Miller | e247cc4 | 2000-05-07 12:03:14 +1000 | [diff] [blame] | 123 | options->gateway_ports = -1; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 124 | options->num_subsystems = 0; |
Damien Miller | 942da03 | 2000-08-18 13:59:06 +1000 | [diff] [blame] | 125 | options->max_startups_begin = -1; |
| 126 | options->max_startups_rate = -1; |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 127 | options->max_startups = -1; |
Darren Tucker | 89413db | 2004-05-24 10:36:23 +1000 | [diff] [blame] | 128 | options->max_authtries = -1; |
Damien Miller | 7207f64 | 2008-05-19 15:34:50 +1000 | [diff] [blame] | 129 | options->max_sessions = -1; |
Ben Lindstrom | 48bd7c1 | 2001-01-09 00:35:42 +0000 | [diff] [blame] | 130 | options->banner = NULL; |
Damien Miller | 3a961dc | 2003-06-03 10:25:48 +1000 | [diff] [blame] | 131 | options->use_dns = -1; |
Ben Lindstrom | 5744dc4 | 2001-04-13 23:28:01 +0000 | [diff] [blame] | 132 | options->client_alive_interval = -1; |
| 133 | options->client_alive_count_max = -1; |
Damien Miller | d8478b6 | 2011-05-29 21:39:36 +1000 | [diff] [blame] | 134 | options->num_authkeys_files = 0; |
Darren Tucker | 46bc075 | 2004-05-02 22:11:30 +1000 | [diff] [blame] | 135 | options->num_accept_env = 0; |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 136 | options->permit_tun = -1; |
Damien Miller | a765cf4 | 2006-07-24 14:08:13 +1000 | [diff] [blame] | 137 | options->num_permitted_opens = -1; |
Damien Miller | e275443 | 2006-07-24 14:06:47 +1000 | [diff] [blame] | 138 | options->adm_forced_command = NULL; |
Damien Miller | d8cb1f1 | 2008-02-10 22:40:12 +1100 | [diff] [blame] | 139 | options->chroot_directory = NULL; |
Damien Miller | 09d3e12 | 2012-10-31 08:58:58 +1100 | [diff] [blame] | 140 | options->authorized_keys_command = NULL; |
| 141 | options->authorized_keys_command_user = NULL; |
Damien Miller | 01ed227 | 2008-11-05 16:20:46 +1100 | [diff] [blame] | 142 | options->zero_knowledge_password_authentication = -1; |
Damien Miller | 1aed65e | 2010-03-04 21:53:35 +1100 | [diff] [blame] | 143 | options->revoked_keys_file = NULL; |
| 144 | options->trusted_user_ca_keys = NULL; |
Damien Miller | 30da344 | 2010-05-10 11:58:03 +1000 | [diff] [blame] | 145 | options->authorized_principals_file = NULL; |
Damien Miller | 0dac6fb | 2010-11-20 15:19:38 +1100 | [diff] [blame] | 146 | options->ip_qos_interactive = -1; |
| 147 | options->ip_qos_bulk = -1; |
Damien Miller | 2352881 | 2012-04-22 11:24:43 +1000 | [diff] [blame] | 148 | options->version_addendum = NULL; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 149 | } |
| 150 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 151 | void |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 152 | fill_default_server_options(ServerOptions *options) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 153 | { |
Damien Miller | 726273e | 2001-11-12 11:40:11 +1100 | [diff] [blame] | 154 | /* Portable-specific options */ |
Damien Miller | 4e448a3 | 2003-05-14 15:11:48 +1000 | [diff] [blame] | 155 | if (options->use_pam == -1) |
Damien Miller | 5c3a558 | 2003-09-23 22:12:38 +1000 | [diff] [blame] | 156 | options->use_pam = 0; |
Damien Miller | 726273e | 2001-11-12 11:40:11 +1100 | [diff] [blame] | 157 | |
| 158 | /* Standard Options */ |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 159 | if (options->protocol == SSH_PROTO_UNKNOWN) |
Darren Tucker | bad5076 | 2009-10-11 21:51:08 +1100 | [diff] [blame] | 160 | options->protocol = SSH_PROTO_2; |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 161 | if (options->num_host_key_files == 0) { |
| 162 | /* fill default hostkeys for protocols */ |
| 163 | if (options->protocol & SSH_PROTO_1) |
Damien Miller | 7fc2373 | 2002-01-22 23:19:11 +1100 | [diff] [blame] | 164 | options->host_key_files[options->num_host_key_files++] = |
| 165 | _PATH_HOST_KEY_FILE; |
| 166 | if (options->protocol & SSH_PROTO_2) { |
| 167 | options->host_key_files[options->num_host_key_files++] = |
| 168 | _PATH_HOST_RSA_KEY_FILE; |
| 169 | options->host_key_files[options->num_host_key_files++] = |
| 170 | _PATH_HOST_DSA_KEY_FILE; |
Damien Miller | dd190dd | 2010-11-11 14:17:02 +1100 | [diff] [blame] | 171 | #ifdef OPENSSL_HAS_ECC |
Damien Miller | e13cadf | 2010-09-10 11:15:33 +1000 | [diff] [blame] | 172 | options->host_key_files[options->num_host_key_files++] = |
| 173 | _PATH_HOST_ECDSA_KEY_FILE; |
Damien Miller | dd190dd | 2010-11-11 14:17:02 +1100 | [diff] [blame] | 174 | #endif |
Damien Miller | 7fc2373 | 2002-01-22 23:19:11 +1100 | [diff] [blame] | 175 | } |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 176 | } |
Damien Miller | 0a80ca1 | 2010-02-27 07:55:05 +1100 | [diff] [blame] | 177 | /* No certificates by default */ |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 178 | if (options->num_ports == 0) |
| 179 | options->ports[options->num_ports++] = SSH_DEFAULT_PORT; |
| 180 | if (options->listen_addrs == NULL) |
Ben Lindstrom | 19066a1 | 2001-04-12 23:39:26 +0000 | [diff] [blame] | 181 | add_listen_addr(options, NULL, 0); |
Damien Miller | 6f83b8e | 2000-05-02 09:23:45 +1000 | [diff] [blame] | 182 | if (options->pid_file == NULL) |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 183 | options->pid_file = _PATH_SSH_DAEMON_PID_FILE; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 184 | if (options->server_key_bits == -1) |
Darren Tucker | 7499b0c | 2008-07-02 22:35:43 +1000 | [diff] [blame] | 185 | options->server_key_bits = 1024; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 186 | if (options->login_grace_time == -1) |
Damien Miller | c134863 | 2002-09-05 14:35:14 +1000 | [diff] [blame] | 187 | options->login_grace_time = 120; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 188 | if (options->key_regeneration_time == -1) |
| 189 | options->key_regeneration_time = 3600; |
Ben Lindstrom | d8a9021 | 2001-02-15 03:08:27 +0000 | [diff] [blame] | 190 | if (options->permit_root_login == PERMIT_NOT_SET) |
| 191 | options->permit_root_login = PERMIT_YES; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 192 | if (options->ignore_rhosts == -1) |
Damien Miller | 98c7ad6 | 2000-03-09 21:27:49 +1100 | [diff] [blame] | 193 | options->ignore_rhosts = 1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 194 | if (options->ignore_user_known_hosts == -1) |
| 195 | options->ignore_user_known_hosts = 0; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 196 | if (options->print_motd == -1) |
| 197 | options->print_motd = 1; |
Ben Lindstrom | 7bfff36 | 2001-03-26 05:45:53 +0000 | [diff] [blame] | 198 | if (options->print_lastlog == -1) |
| 199 | options->print_lastlog = 1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 200 | if (options->x11_forwarding == -1) |
Damien Miller | 98c7ad6 | 2000-03-09 21:27:49 +1100 | [diff] [blame] | 201 | options->x11_forwarding = 0; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 202 | if (options->x11_display_offset == -1) |
Damien Miller | 98c7ad6 | 2000-03-09 21:27:49 +1100 | [diff] [blame] | 203 | options->x11_display_offset = 10; |
Damien Miller | 95c249f | 2002-02-05 12:11:34 +1100 | [diff] [blame] | 204 | if (options->x11_use_localhost == -1) |
| 205 | options->x11_use_localhost = 1; |
Damien Miller | d3a1857 | 2000-06-07 19:55:44 +1000 | [diff] [blame] | 206 | if (options->xauth_location == NULL) |
Ben Lindstrom | 1bf11f6 | 2001-06-09 01:48:01 +0000 | [diff] [blame] | 207 | options->xauth_location = _PATH_XAUTH; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 208 | if (options->strict_modes == -1) |
| 209 | options->strict_modes = 1; |
Damien Miller | 12c150e | 2003-12-17 16:31:10 +1100 | [diff] [blame] | 210 | if (options->tcp_keep_alive == -1) |
| 211 | options->tcp_keep_alive = 1; |
Damien Miller | fcd9320 | 2002-02-05 12:26:34 +1100 | [diff] [blame] | 212 | if (options->log_facility == SYSLOG_FACILITY_NOT_SET) |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 213 | options->log_facility = SYSLOG_FACILITY_AUTH; |
Damien Miller | fcd9320 | 2002-02-05 12:26:34 +1100 | [diff] [blame] | 214 | if (options->log_level == SYSLOG_LEVEL_NOT_SET) |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 215 | options->log_level = SYSLOG_LEVEL_INFO; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 216 | if (options->rhosts_rsa_authentication == -1) |
Damien Miller | 98c7ad6 | 2000-03-09 21:27:49 +1100 | [diff] [blame] | 217 | options->rhosts_rsa_authentication = 0; |
Ben Lindstrom | 5eabda3 | 2001-04-12 23:34:34 +0000 | [diff] [blame] | 218 | if (options->hostbased_authentication == -1) |
| 219 | options->hostbased_authentication = 0; |
| 220 | if (options->hostbased_uses_name_from_packet_only == -1) |
| 221 | options->hostbased_uses_name_from_packet_only = 0; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 222 | if (options->rsa_authentication == -1) |
| 223 | options->rsa_authentication = 1; |
Damien Miller | 0bc1bd8 | 2000-11-13 22:57:25 +1100 | [diff] [blame] | 224 | if (options->pubkey_authentication == -1) |
| 225 | options->pubkey_authentication = 1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 226 | if (options->kerberos_authentication == -1) |
Damien Miller | d7de14b | 2002-04-23 21:04:51 +1000 | [diff] [blame] | 227 | options->kerberos_authentication = 0; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 228 | if (options->kerberos_or_local_passwd == -1) |
| 229 | options->kerberos_or_local_passwd = 1; |
| 230 | if (options->kerberos_ticket_cleanup == -1) |
| 231 | options->kerberos_ticket_cleanup = 1; |
Darren Tucker | 22ef508 | 2003-12-31 11:37:34 +1100 | [diff] [blame] | 232 | if (options->kerberos_get_afs_token == -1) |
| 233 | options->kerberos_get_afs_token = 0; |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 234 | if (options->gss_authentication == -1) |
| 235 | options->gss_authentication = 0; |
| 236 | if (options->gss_cleanup_creds == -1) |
| 237 | options->gss_cleanup_creds = 1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 238 | if (options->password_authentication == -1) |
| 239 | options->password_authentication = 1; |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 240 | if (options->kbd_interactive_authentication == -1) |
| 241 | options->kbd_interactive_authentication = 0; |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 242 | if (options->challenge_response_authentication == -1) |
| 243 | options->challenge_response_authentication = 1; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 244 | if (options->permit_empty_passwd == -1) |
Damien Miller | 98c7ad6 | 2000-03-09 21:27:49 +1100 | [diff] [blame] | 245 | options->permit_empty_passwd = 0; |
Ben Lindstrom | 5d860f0 | 2002-08-01 01:28:38 +0000 | [diff] [blame] | 246 | if (options->permit_user_env == -1) |
| 247 | options->permit_user_env = 0; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 248 | if (options->use_login == -1) |
| 249 | options->use_login = 0; |
Ben Lindstrom | 23e0f66 | 2002-06-21 01:09:47 +0000 | [diff] [blame] | 250 | if (options->compression == -1) |
Damien Miller | 9786e6e | 2005-07-26 21:54:56 +1000 | [diff] [blame] | 251 | options->compression = COMP_DELAYED; |
Damien Miller | 50a41ed | 2000-10-16 12:14:42 +1100 | [diff] [blame] | 252 | if (options->allow_tcp_forwarding == -1) |
Damien Miller | aa5b3f8 | 2012-12-03 09:50:54 +1100 | [diff] [blame] | 253 | options->allow_tcp_forwarding = FORWARD_ALLOW; |
Damien Miller | 4f755cd | 2008-05-19 14:57:41 +1000 | [diff] [blame] | 254 | if (options->allow_agent_forwarding == -1) |
| 255 | options->allow_agent_forwarding = 1; |
Damien Miller | e247cc4 | 2000-05-07 12:03:14 +1000 | [diff] [blame] | 256 | if (options->gateway_ports == -1) |
| 257 | options->gateway_ports = 0; |
Damien Miller | 3702396 | 2000-07-11 17:31:38 +1000 | [diff] [blame] | 258 | if (options->max_startups == -1) |
Damien Miller | 1f583df | 2013-02-12 11:02:08 +1100 | [diff] [blame] | 259 | options->max_startups = 100; |
Damien Miller | 942da03 | 2000-08-18 13:59:06 +1000 | [diff] [blame] | 260 | if (options->max_startups_rate == -1) |
Damien Miller | 1f583df | 2013-02-12 11:02:08 +1100 | [diff] [blame] | 261 | options->max_startups_rate = 30; /* 30% */ |
Damien Miller | 942da03 | 2000-08-18 13:59:06 +1000 | [diff] [blame] | 262 | if (options->max_startups_begin == -1) |
Damien Miller | 1f583df | 2013-02-12 11:02:08 +1100 | [diff] [blame] | 263 | options->max_startups_begin = 10; |
Darren Tucker | 89413db | 2004-05-24 10:36:23 +1000 | [diff] [blame] | 264 | if (options->max_authtries == -1) |
| 265 | options->max_authtries = DEFAULT_AUTH_FAIL_MAX; |
Damien Miller | 7207f64 | 2008-05-19 15:34:50 +1000 | [diff] [blame] | 266 | if (options->max_sessions == -1) |
| 267 | options->max_sessions = DEFAULT_SESSIONS_MAX; |
Damien Miller | 3a961dc | 2003-06-03 10:25:48 +1000 | [diff] [blame] | 268 | if (options->use_dns == -1) |
| 269 | options->use_dns = 1; |
Ben Lindstrom | 5744dc4 | 2001-04-13 23:28:01 +0000 | [diff] [blame] | 270 | if (options->client_alive_interval == -1) |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 271 | options->client_alive_interval = 0; |
Ben Lindstrom | 5744dc4 | 2001-04-13 23:28:01 +0000 | [diff] [blame] | 272 | if (options->client_alive_count_max == -1) |
| 273 | options->client_alive_count_max = 3; |
Damien Miller | d8478b6 | 2011-05-29 21:39:36 +1000 | [diff] [blame] | 274 | if (options->num_authkeys_files == 0) { |
| 275 | options->authorized_keys_files[options->num_authkeys_files++] = |
| 276 | xstrdup(_PATH_SSH_USER_PERMITTED_KEYS); |
| 277 | options->authorized_keys_files[options->num_authkeys_files++] = |
| 278 | xstrdup(_PATH_SSH_USER_PERMITTED_KEYS2); |
| 279 | } |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 280 | if (options->permit_tun == -1) |
Damien Miller | 7b58e80 | 2005-12-13 19:33:19 +1100 | [diff] [blame] | 281 | options->permit_tun = SSH_TUNMODE_NO; |
Damien Miller | 01ed227 | 2008-11-05 16:20:46 +1100 | [diff] [blame] | 282 | if (options->zero_knowledge_password_authentication == -1) |
| 283 | options->zero_knowledge_password_authentication = 0; |
Damien Miller | 0dac6fb | 2010-11-20 15:19:38 +1100 | [diff] [blame] | 284 | if (options->ip_qos_interactive == -1) |
| 285 | options->ip_qos_interactive = IPTOS_LOWDELAY; |
| 286 | if (options->ip_qos_bulk == -1) |
| 287 | options->ip_qos_bulk = IPTOS_THROUGHPUT; |
Damien Miller | 2352881 | 2012-04-22 11:24:43 +1000 | [diff] [blame] | 288 | if (options->version_addendum == NULL) |
| 289 | options->version_addendum = xstrdup(""); |
Ben Lindstrom | fb62a69 | 2002-06-06 19:47:11 +0000 | [diff] [blame] | 290 | /* Turn privilege separation on by default */ |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 291 | if (use_privsep == -1) |
Damien Miller | 5a5c2b9 | 2012-07-31 12:21:34 +1000 | [diff] [blame] | 292 | use_privsep = PRIVSEP_NOSANDBOX; |
Damien Miller | 4903eb4 | 2002-06-21 16:20:44 +1000 | [diff] [blame] | 293 | |
Tim Rice | 40017b0 | 2002-07-14 13:36:49 -0700 | [diff] [blame] | 294 | #ifndef HAVE_MMAP |
Damien Miller | 4903eb4 | 2002-06-21 16:20:44 +1000 | [diff] [blame] | 295 | if (use_privsep && options->compression == 1) { |
| 296 | error("This platform does not support both privilege " |
| 297 | "separation and compression"); |
| 298 | error("Compression disabled"); |
| 299 | options->compression = 0; |
| 300 | } |
| 301 | #endif |
| 302 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 303 | } |
| 304 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 305 | /* Keyword tokens. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 306 | typedef enum { |
| 307 | sBadOption, /* == unknown option */ |
Damien Miller | 726273e | 2001-11-12 11:40:11 +1100 | [diff] [blame] | 308 | /* Portable-specific options */ |
Damien Miller | 4e448a3 | 2003-05-14 15:11:48 +1000 | [diff] [blame] | 309 | sUsePAM, |
Damien Miller | 726273e | 2001-11-12 11:40:11 +1100 | [diff] [blame] | 310 | /* Standard Options */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 311 | sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime, sKeyRegenerationTime, |
| 312 | sPermitRootLogin, sLogFacility, sLogLevel, |
Darren Tucker | ec960f2 | 2003-08-13 20:37:05 +1000 | [diff] [blame] | 313 | sRhostsRSAAuthentication, sRSAAuthentication, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 314 | sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup, |
Darren Tucker | 22ef508 | 2003-12-31 11:37:34 +1100 | [diff] [blame] | 315 | sKerberosGetAFSToken, |
Darren Tucker | 6aaa58c | 2003-08-02 22:24:49 +1000 | [diff] [blame] | 316 | sKerberosTgtPassing, sChallengeResponseAuthentication, |
Darren Tucker | 0f38323 | 2005-01-20 10:57:56 +1100 | [diff] [blame] | 317 | sPasswordAuthentication, sKbdInteractiveAuthentication, |
| 318 | sListenAddress, sAddressFamily, |
Ben Lindstrom | 7bfff36 | 2001-03-26 05:45:53 +0000 | [diff] [blame] | 319 | sPrintMotd, sPrintLastLog, sIgnoreRhosts, |
Damien Miller | 95c249f | 2002-02-05 12:11:34 +1100 | [diff] [blame] | 320 | sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost, |
Damien Miller | 12c150e | 2003-12-17 16:31:10 +1100 | [diff] [blame] | 321 | sStrictModes, sEmptyPasswd, sTCPKeepAlive, |
Ben Lindstrom | 5d860f0 | 2002-08-01 01:28:38 +0000 | [diff] [blame] | 322 | sPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression, |
Damien Miller | 50a41ed | 2000-10-16 12:14:42 +1100 | [diff] [blame] | 323 | sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups, |
Ben Lindstrom | 06b33aa | 2001-02-15 03:01:59 +0000 | [diff] [blame] | 324 | sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile, |
Darren Tucker | 89413db | 2004-05-24 10:36:23 +1000 | [diff] [blame] | 325 | sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, |
Damien Miller | 7207f64 | 2008-05-19 15:34:50 +1000 | [diff] [blame] | 326 | sMaxStartups, sMaxAuthTries, sMaxSessions, |
Damien Miller | 3a961dc | 2003-06-03 10:25:48 +1000 | [diff] [blame] | 327 | sBanner, sUseDNS, sHostbasedAuthentication, |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 328 | sHostbasedUsesNameFromPacketOnly, sClientAliveInterval, |
Damien Miller | ec2eaa3 | 2011-05-20 18:57:14 +1000 | [diff] [blame] | 329 | sClientAliveCountMax, sAuthorizedKeysFile, |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 330 | sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel, |
Damien Miller | d8cb1f1 | 2008-02-10 22:40:12 +1100 | [diff] [blame] | 331 | sMatch, sPermitOpen, sForceCommand, sChrootDirectory, |
Darren Tucker | 7bd98e7 | 2010-01-10 10:31:12 +1100 | [diff] [blame] | 332 | sUsePrivilegeSeparation, sAllowAgentForwarding, |
Damien Miller | 0a80ca1 | 2010-02-27 07:55:05 +1100 | [diff] [blame] | 333 | sZeroKnowledgePasswordAuthentication, sHostCertificate, |
Damien Miller | 30da344 | 2010-05-10 11:58:03 +1000 | [diff] [blame] | 334 | sRevokedKeys, sTrustedUserCAKeys, sAuthorizedPrincipalsFile, |
Damien Miller | 2352881 | 2012-04-22 11:24:43 +1000 | [diff] [blame] | 335 | sKexAlgorithms, sIPQoS, sVersionAddendum, |
Damien Miller | 09d3e12 | 2012-10-31 08:58:58 +1100 | [diff] [blame] | 336 | sAuthorizedKeysCommand, sAuthorizedKeysCommandUser, |
Damien Miller | a6e3f01 | 2012-11-04 23:21:40 +1100 | [diff] [blame] | 337 | sAuthenticationMethods, |
Damien Miller | f9b3feb | 2003-05-16 11:38:32 +1000 | [diff] [blame] | 338 | sDeprecated, sUnsupported |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 339 | } ServerOpCodes; |
| 340 | |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 341 | #define SSHCFG_GLOBAL 0x01 /* allowed in main section of sshd_config */ |
| 342 | #define SSHCFG_MATCH 0x02 /* allowed inside a Match section */ |
| 343 | #define SSHCFG_ALL (SSHCFG_GLOBAL|SSHCFG_MATCH) |
| 344 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 345 | /* Textual representation of the tokens. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 346 | static struct { |
| 347 | const char *name; |
| 348 | ServerOpCodes opcode; |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 349 | u_int flags; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 350 | } keywords[] = { |
Damien Miller | 726273e | 2001-11-12 11:40:11 +1100 | [diff] [blame] | 351 | /* Portable-specific options */ |
Damien Miller | 6ac2c48 | 2003-05-16 11:42:35 +1000 | [diff] [blame] | 352 | #ifdef USE_PAM |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 353 | { "usepam", sUsePAM, SSHCFG_GLOBAL }, |
Damien Miller | 6ac2c48 | 2003-05-16 11:42:35 +1000 | [diff] [blame] | 354 | #else |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 355 | { "usepam", sUnsupported, SSHCFG_GLOBAL }, |
Damien Miller | 6ac2c48 | 2003-05-16 11:42:35 +1000 | [diff] [blame] | 356 | #endif |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 357 | { "pamauthenticationviakbdint", sDeprecated, SSHCFG_GLOBAL }, |
Damien Miller | 726273e | 2001-11-12 11:40:11 +1100 | [diff] [blame] | 358 | /* Standard Options */ |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 359 | { "port", sPort, SSHCFG_GLOBAL }, |
| 360 | { "hostkey", sHostKeyFile, SSHCFG_GLOBAL }, |
| 361 | { "hostdsakey", sHostKeyFile, SSHCFG_GLOBAL }, /* alias */ |
| 362 | { "pidfile", sPidFile, SSHCFG_GLOBAL }, |
| 363 | { "serverkeybits", sServerKeyBits, SSHCFG_GLOBAL }, |
| 364 | { "logingracetime", sLoginGraceTime, SSHCFG_GLOBAL }, |
| 365 | { "keyregenerationinterval", sKeyRegenerationTime, SSHCFG_GLOBAL }, |
Darren Tucker | 15f9427 | 2008-01-01 20:36:56 +1100 | [diff] [blame] | 366 | { "permitrootlogin", sPermitRootLogin, SSHCFG_ALL }, |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 367 | { "syslogfacility", sLogFacility, SSHCFG_GLOBAL }, |
| 368 | { "loglevel", sLogLevel, SSHCFG_GLOBAL }, |
| 369 | { "rhostsauthentication", sDeprecated, SSHCFG_GLOBAL }, |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 370 | { "rhostsrsaauthentication", sRhostsRSAAuthentication, SSHCFG_ALL }, |
| 371 | { "hostbasedauthentication", sHostbasedAuthentication, SSHCFG_ALL }, |
Damien Miller | ab6de35 | 2010-06-26 09:38:45 +1000 | [diff] [blame] | 372 | { "hostbasedusesnamefrompacketonly", sHostbasedUsesNameFromPacketOnly, SSHCFG_ALL }, |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 373 | { "rsaauthentication", sRSAAuthentication, SSHCFG_ALL }, |
| 374 | { "pubkeyauthentication", sPubkeyAuthentication, SSHCFG_ALL }, |
Darren Tucker | 64cee36 | 2009-06-21 20:26:17 +1000 | [diff] [blame] | 375 | { "dsaauthentication", sPubkeyAuthentication, SSHCFG_GLOBAL }, /* alias */ |
Darren Tucker | 6aaa58c | 2003-08-02 22:24:49 +1000 | [diff] [blame] | 376 | #ifdef KRB5 |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 377 | { "kerberosauthentication", sKerberosAuthentication, SSHCFG_ALL }, |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 378 | { "kerberosorlocalpasswd", sKerberosOrLocalPasswd, SSHCFG_GLOBAL }, |
| 379 | { "kerberosticketcleanup", sKerberosTicketCleanup, SSHCFG_GLOBAL }, |
Darren Tucker | 3c78c5e | 2004-01-23 22:03:10 +1100 | [diff] [blame] | 380 | #ifdef USE_AFS |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 381 | { "kerberosgetafstoken", sKerberosGetAFSToken, SSHCFG_GLOBAL }, |
Damien Miller | f9b3feb | 2003-05-16 11:38:32 +1000 | [diff] [blame] | 382 | #else |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 383 | { "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL }, |
Darren Tucker | 409cb32 | 2004-01-05 22:36:51 +1100 | [diff] [blame] | 384 | #endif |
| 385 | #else |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 386 | { "kerberosauthentication", sUnsupported, SSHCFG_ALL }, |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 387 | { "kerberosorlocalpasswd", sUnsupported, SSHCFG_GLOBAL }, |
| 388 | { "kerberosticketcleanup", sUnsupported, SSHCFG_GLOBAL }, |
| 389 | { "kerberosgetafstoken", sUnsupported, SSHCFG_GLOBAL }, |
Damien Miller | f9b3feb | 2003-05-16 11:38:32 +1000 | [diff] [blame] | 390 | #endif |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 391 | { "kerberostgtpassing", sUnsupported, SSHCFG_GLOBAL }, |
| 392 | { "afstokenpassing", sUnsupported, SSHCFG_GLOBAL }, |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 393 | #ifdef GSSAPI |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 394 | { "gssapiauthentication", sGssAuthentication, SSHCFG_ALL }, |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 395 | { "gssapicleanupcredentials", sGssCleanupCreds, SSHCFG_GLOBAL }, |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 396 | #else |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 397 | { "gssapiauthentication", sUnsupported, SSHCFG_ALL }, |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 398 | { "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL }, |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 399 | #endif |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 400 | { "passwordauthentication", sPasswordAuthentication, SSHCFG_ALL }, |
| 401 | { "kbdinteractiveauthentication", sKbdInteractiveAuthentication, SSHCFG_ALL }, |
Darren Tucker | 1d75f22 | 2007-03-01 21:31:28 +1100 | [diff] [blame] | 402 | { "challengeresponseauthentication", sChallengeResponseAuthentication, SSHCFG_GLOBAL }, |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 403 | { "skeyauthentication", sChallengeResponseAuthentication, SSHCFG_GLOBAL }, /* alias */ |
Damien Miller | 01ed227 | 2008-11-05 16:20:46 +1100 | [diff] [blame] | 404 | #ifdef JPAKE |
| 405 | { "zeroknowledgepasswordauthentication", sZeroKnowledgePasswordAuthentication, SSHCFG_ALL }, |
| 406 | #else |
| 407 | { "zeroknowledgepasswordauthentication", sUnsupported, SSHCFG_ALL }, |
| 408 | #endif |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 409 | { "checkmail", sDeprecated, SSHCFG_GLOBAL }, |
| 410 | { "listenaddress", sListenAddress, SSHCFG_GLOBAL }, |
| 411 | { "addressfamily", sAddressFamily, SSHCFG_GLOBAL }, |
| 412 | { "printmotd", sPrintMotd, SSHCFG_GLOBAL }, |
| 413 | { "printlastlog", sPrintLastLog, SSHCFG_GLOBAL }, |
| 414 | { "ignorerhosts", sIgnoreRhosts, SSHCFG_GLOBAL }, |
| 415 | { "ignoreuserknownhosts", sIgnoreUserKnownHosts, SSHCFG_GLOBAL }, |
Damien Miller | d1de995 | 2006-07-24 14:05:48 +1000 | [diff] [blame] | 416 | { "x11forwarding", sX11Forwarding, SSHCFG_ALL }, |
| 417 | { "x11displayoffset", sX11DisplayOffset, SSHCFG_ALL }, |
| 418 | { "x11uselocalhost", sX11UseLocalhost, SSHCFG_ALL }, |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 419 | { "xauthlocation", sXAuthLocation, SSHCFG_GLOBAL }, |
| 420 | { "strictmodes", sStrictModes, SSHCFG_GLOBAL }, |
Damien Miller | 51bde60 | 2008-11-03 19:23:10 +1100 | [diff] [blame] | 421 | { "permitemptypasswords", sEmptyPasswd, SSHCFG_ALL }, |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 422 | { "permituserenvironment", sPermitUserEnvironment, SSHCFG_GLOBAL }, |
| 423 | { "uselogin", sUseLogin, SSHCFG_GLOBAL }, |
| 424 | { "compression", sCompression, SSHCFG_GLOBAL }, |
| 425 | { "tcpkeepalive", sTCPKeepAlive, SSHCFG_GLOBAL }, |
| 426 | { "keepalive", sTCPKeepAlive, SSHCFG_GLOBAL }, /* obsolete alias */ |
| 427 | { "allowtcpforwarding", sAllowTcpForwarding, SSHCFG_ALL }, |
Damien Miller | 4f755cd | 2008-05-19 14:57:41 +1000 | [diff] [blame] | 428 | { "allowagentforwarding", sAllowAgentForwarding, SSHCFG_ALL }, |
Damien Miller | c24da77 | 2012-06-20 21:53:58 +1000 | [diff] [blame] | 429 | { "allowusers", sAllowUsers, SSHCFG_ALL }, |
| 430 | { "denyusers", sDenyUsers, SSHCFG_ALL }, |
| 431 | { "allowgroups", sAllowGroups, SSHCFG_ALL }, |
| 432 | { "denygroups", sDenyGroups, SSHCFG_ALL }, |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 433 | { "ciphers", sCiphers, SSHCFG_GLOBAL }, |
| 434 | { "macs", sMacs, SSHCFG_GLOBAL }, |
| 435 | { "protocol", sProtocol, SSHCFG_GLOBAL }, |
| 436 | { "gatewayports", sGatewayPorts, SSHCFG_ALL }, |
| 437 | { "subsystem", sSubsystem, SSHCFG_GLOBAL }, |
| 438 | { "maxstartups", sMaxStartups, SSHCFG_GLOBAL }, |
Damien Miller | 307c1d1 | 2008-06-16 07:56:20 +1000 | [diff] [blame] | 439 | { "maxauthtries", sMaxAuthTries, SSHCFG_ALL }, |
Damien Miller | 7207f64 | 2008-05-19 15:34:50 +1000 | [diff] [blame] | 440 | { "maxsessions", sMaxSessions, SSHCFG_ALL }, |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 441 | { "banner", sBanner, SSHCFG_ALL }, |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 442 | { "usedns", sUseDNS, SSHCFG_GLOBAL }, |
| 443 | { "verifyreversemapping", sDeprecated, SSHCFG_GLOBAL }, |
| 444 | { "reversemappingcheck", sDeprecated, SSHCFG_GLOBAL }, |
| 445 | { "clientaliveinterval", sClientAliveInterval, SSHCFG_GLOBAL }, |
| 446 | { "clientalivecountmax", sClientAliveCountMax, SSHCFG_GLOBAL }, |
Damien Miller | ab6de35 | 2010-06-26 09:38:45 +1000 | [diff] [blame] | 447 | { "authorizedkeysfile", sAuthorizedKeysFile, SSHCFG_ALL }, |
Damien Miller | d8478b6 | 2011-05-29 21:39:36 +1000 | [diff] [blame] | 448 | { "authorizedkeysfile2", sDeprecated, SSHCFG_ALL }, |
Darren Tucker | 64cee36 | 2009-06-21 20:26:17 +1000 | [diff] [blame] | 449 | { "useprivilegeseparation", sUsePrivilegeSeparation, SSHCFG_GLOBAL}, |
Damien Miller | c24da77 | 2012-06-20 21:53:58 +1000 | [diff] [blame] | 450 | { "acceptenv", sAcceptEnv, SSHCFG_ALL }, |
Damien Miller | ab6de35 | 2010-06-26 09:38:45 +1000 | [diff] [blame] | 451 | { "permittunnel", sPermitTunnel, SSHCFG_ALL }, |
Darren Tucker | 64cee36 | 2009-06-21 20:26:17 +1000 | [diff] [blame] | 452 | { "match", sMatch, SSHCFG_ALL }, |
Damien Miller | 9b439df | 2006-07-24 14:04:00 +1000 | [diff] [blame] | 453 | { "permitopen", sPermitOpen, SSHCFG_ALL }, |
Damien Miller | e275443 | 2006-07-24 14:06:47 +1000 | [diff] [blame] | 454 | { "forcecommand", sForceCommand, SSHCFG_ALL }, |
Damien Miller | d8cb1f1 | 2008-02-10 22:40:12 +1100 | [diff] [blame] | 455 | { "chrootdirectory", sChrootDirectory, SSHCFG_ALL }, |
Damien Miller | 0a80ca1 | 2010-02-27 07:55:05 +1100 | [diff] [blame] | 456 | { "hostcertificate", sHostCertificate, SSHCFG_GLOBAL }, |
Damien Miller | 1aed65e | 2010-03-04 21:53:35 +1100 | [diff] [blame] | 457 | { "revokedkeys", sRevokedKeys, SSHCFG_ALL }, |
| 458 | { "trustedusercakeys", sTrustedUserCAKeys, SSHCFG_ALL }, |
Damien Miller | ab6de35 | 2010-06-26 09:38:45 +1000 | [diff] [blame] | 459 | { "authorizedprincipalsfile", sAuthorizedPrincipalsFile, SSHCFG_ALL }, |
Damien Miller | d5f62bf | 2010-09-24 22:11:14 +1000 | [diff] [blame] | 460 | { "kexalgorithms", sKexAlgorithms, SSHCFG_GLOBAL }, |
Damien Miller | 0dac6fb | 2010-11-20 15:19:38 +1100 | [diff] [blame] | 461 | { "ipqos", sIPQoS, SSHCFG_ALL }, |
Damien Miller | 09d3e12 | 2012-10-31 08:58:58 +1100 | [diff] [blame] | 462 | { "authorizedkeyscommand", sAuthorizedKeysCommand, SSHCFG_ALL }, |
| 463 | { "authorizedkeyscommanduser", sAuthorizedKeysCommandUser, SSHCFG_ALL }, |
Damien Miller | 2352881 | 2012-04-22 11:24:43 +1000 | [diff] [blame] | 464 | { "versionaddendum", sVersionAddendum, SSHCFG_GLOBAL }, |
Damien Miller | a6e3f01 | 2012-11-04 23:21:40 +1100 | [diff] [blame] | 465 | { "authenticationmethods", sAuthenticationMethods, SSHCFG_ALL }, |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 466 | { NULL, sBadOption, 0 } |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 467 | }; |
| 468 | |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 469 | static struct { |
| 470 | int val; |
| 471 | char *text; |
| 472 | } tunmode_desc[] = { |
| 473 | { SSH_TUNMODE_NO, "no" }, |
| 474 | { SSH_TUNMODE_POINTOPOINT, "point-to-point" }, |
| 475 | { SSH_TUNMODE_ETHERNET, "ethernet" }, |
| 476 | { SSH_TUNMODE_YES, "yes" }, |
| 477 | { -1, NULL } |
| 478 | }; |
| 479 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 480 | /* |
Ben Lindstrom | 3704c26 | 2001-04-02 18:20:03 +0000 | [diff] [blame] | 481 | * Returns the number of the token pointed to by cp or sBadOption. |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 482 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 483 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 484 | static ServerOpCodes |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 485 | parse_token(const char *cp, const char *filename, |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 486 | int linenum, u_int *flags) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 487 | { |
Ben Lindstrom | 46c1622 | 2000-12-22 01:43:59 +0000 | [diff] [blame] | 488 | u_int i; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 489 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 490 | for (i = 0; keywords[i].name; i++) |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 491 | if (strcasecmp(cp, keywords[i].name) == 0) { |
| 492 | *flags = keywords[i].flags; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 493 | return keywords[i].opcode; |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 494 | } |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 495 | |
Ben Lindstrom | b5cdc66 | 2001-04-16 02:13:26 +0000 | [diff] [blame] | 496 | error("%s: line %d: Bad configuration option: %s", |
| 497 | filename, linenum, cp); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 498 | return sBadOption; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 499 | } |
| 500 | |
Darren Tucker | 88b6fb2 | 2010-01-13 22:44:29 +1100 | [diff] [blame] | 501 | char * |
| 502 | derelativise_path(const char *path) |
| 503 | { |
Damien Miller | 44451d0 | 2010-03-26 10:40:04 +1100 | [diff] [blame] | 504 | char *expanded, *ret, cwd[MAXPATHLEN]; |
Darren Tucker | 88b6fb2 | 2010-01-13 22:44:29 +1100 | [diff] [blame] | 505 | |
| 506 | expanded = tilde_expand_filename(path, getuid()); |
| 507 | if (*expanded == '/') |
| 508 | return expanded; |
Damien Miller | 44451d0 | 2010-03-26 10:40:04 +1100 | [diff] [blame] | 509 | if (getcwd(cwd, sizeof(cwd)) == NULL) |
Darren Tucker | 88b6fb2 | 2010-01-13 22:44:29 +1100 | [diff] [blame] | 510 | fatal("%s: getcwd: %s", __func__, strerror(errno)); |
| 511 | xasprintf(&ret, "%s/%s", cwd, expanded); |
Darren Tucker | 88b6fb2 | 2010-01-13 22:44:29 +1100 | [diff] [blame] | 512 | xfree(expanded); |
| 513 | return ret; |
| 514 | } |
| 515 | |
Ben Lindstrom | bba8121 | 2001-06-25 05:01:22 +0000 | [diff] [blame] | 516 | static void |
Damien Miller | 3dc71ad | 2009-01-28 16:31:22 +1100 | [diff] [blame] | 517 | add_listen_addr(ServerOptions *options, char *addr, int port) |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 518 | { |
Damien Miller | eccb9de | 2005-06-17 12:59:34 +1000 | [diff] [blame] | 519 | u_int i; |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 520 | |
| 521 | if (options->num_ports == 0) |
| 522 | options->ports[options->num_ports++] = SSH_DEFAULT_PORT; |
Darren Tucker | 0f38323 | 2005-01-20 10:57:56 +1100 | [diff] [blame] | 523 | if (options->address_family == -1) |
| 524 | options->address_family = AF_UNSPEC; |
Ben Lindstrom | 19066a1 | 2001-04-12 23:39:26 +0000 | [diff] [blame] | 525 | if (port == 0) |
Ben Lindstrom | c510af4 | 2001-04-07 17:25:48 +0000 | [diff] [blame] | 526 | for (i = 0; i < options->num_ports; i++) |
| 527 | add_one_listen_addr(options, addr, options->ports[i]); |
| 528 | else |
Ben Lindstrom | 19066a1 | 2001-04-12 23:39:26 +0000 | [diff] [blame] | 529 | add_one_listen_addr(options, addr, port); |
Ben Lindstrom | c510af4 | 2001-04-07 17:25:48 +0000 | [diff] [blame] | 530 | } |
| 531 | |
Ben Lindstrom | bba8121 | 2001-06-25 05:01:22 +0000 | [diff] [blame] | 532 | static void |
Damien Miller | 3dc71ad | 2009-01-28 16:31:22 +1100 | [diff] [blame] | 533 | add_one_listen_addr(ServerOptions *options, char *addr, int port) |
Ben Lindstrom | c510af4 | 2001-04-07 17:25:48 +0000 | [diff] [blame] | 534 | { |
| 535 | struct addrinfo hints, *ai, *aitop; |
| 536 | char strport[NI_MAXSERV]; |
| 537 | int gaierr; |
| 538 | |
| 539 | memset(&hints, 0, sizeof(hints)); |
Darren Tucker | 0f38323 | 2005-01-20 10:57:56 +1100 | [diff] [blame] | 540 | hints.ai_family = options->address_family; |
Ben Lindstrom | c510af4 | 2001-04-07 17:25:48 +0000 | [diff] [blame] | 541 | hints.ai_socktype = SOCK_STREAM; |
| 542 | hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0; |
Damien Miller | 3dc71ad | 2009-01-28 16:31:22 +1100 | [diff] [blame] | 543 | snprintf(strport, sizeof strport, "%d", port); |
Ben Lindstrom | c510af4 | 2001-04-07 17:25:48 +0000 | [diff] [blame] | 544 | if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0) |
| 545 | fatal("bad addr or host: %s (%s)", |
| 546 | addr ? addr : "<NULL>", |
Darren Tucker | 4abde77 | 2007-12-29 02:43:51 +1100 | [diff] [blame] | 547 | ssh_gai_strerror(gaierr)); |
Ben Lindstrom | c510af4 | 2001-04-07 17:25:48 +0000 | [diff] [blame] | 548 | for (ai = aitop; ai->ai_next; ai = ai->ai_next) |
| 549 | ; |
| 550 | ai->ai_next = options->listen_addrs; |
| 551 | options->listen_addrs = aitop; |
Damien Miller | 34132e5 | 2000-01-14 15:45:46 +1100 | [diff] [blame] | 552 | } |
| 553 | |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 554 | struct connection_info * |
| 555 | get_connection_info(int populate, int use_dns) |
| 556 | { |
| 557 | static struct connection_info ci; |
| 558 | |
| 559 | if (!populate) |
| 560 | return &ci; |
| 561 | ci.host = get_canonical_hostname(use_dns); |
| 562 | ci.address = get_remote_ipaddr(); |
| 563 | ci.laddress = get_local_ipaddr(packet_get_connection_in()); |
| 564 | ci.lport = get_local_port(); |
| 565 | return &ci; |
| 566 | } |
| 567 | |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 568 | /* |
| 569 | * The strategy for the Match blocks is that the config file is parsed twice. |
| 570 | * |
| 571 | * The first time is at startup. activep is initialized to 1 and the |
| 572 | * directives in the global context are processed and acted on. Hitting a |
| 573 | * Match directive unsets activep and the directives inside the block are |
| 574 | * checked for syntax only. |
| 575 | * |
| 576 | * The second time is after a connection has been established but before |
| 577 | * authentication. activep is initialized to 2 and global config directives |
| 578 | * are ignored since they have already been processed. If the criteria in a |
| 579 | * Match block is met, activep is set and the subsequent directives |
| 580 | * processed and actioned until EOF or another Match block unsets it. Any |
| 581 | * options set are copied into the main server config. |
| 582 | * |
| 583 | * Potential additions/improvements: |
| 584 | * - Add Match support for pre-kex directives, eg Protocol, Ciphers. |
| 585 | * |
| 586 | * - Add a Tag directive (idea from David Leonard) ala pf, eg: |
| 587 | * Match Address 192.168.0.* |
| 588 | * Tag trusted |
| 589 | * Match Group wheel |
| 590 | * Tag trusted |
| 591 | * Match Tag trusted |
| 592 | * AllowTcpForwarding yes |
| 593 | * GatewayPorts clientspecified |
| 594 | * [...] |
| 595 | * |
| 596 | * - Add a PermittedChannelRequests directive |
| 597 | * Match Group shell |
| 598 | * PermittedChannelRequests session,forwarded-tcpip |
| 599 | */ |
| 600 | |
| 601 | static int |
Damien Miller | 565ca3f | 2006-08-19 00:23:15 +1000 | [diff] [blame] | 602 | match_cfg_line_group(const char *grps, int line, const char *user) |
| 603 | { |
| 604 | int result = 0; |
Damien Miller | 565ca3f | 2006-08-19 00:23:15 +1000 | [diff] [blame] | 605 | struct passwd *pw; |
| 606 | |
Damien Miller | 565ca3f | 2006-08-19 00:23:15 +1000 | [diff] [blame] | 607 | if (user == NULL) |
| 608 | goto out; |
| 609 | |
| 610 | if ((pw = getpwnam(user)) == NULL) { |
| 611 | debug("Can't match group at line %d because user %.100s does " |
| 612 | "not exist", line, user); |
| 613 | } else if (ga_init(pw->pw_name, pw->pw_gid) == 0) { |
| 614 | debug("Can't Match group because user %.100s not in any group " |
| 615 | "at line %d", user, line); |
Darren Tucker | b03fd02 | 2008-07-04 13:51:12 +1000 | [diff] [blame] | 616 | } else if (ga_match_pattern_list(grps) != 1) { |
| 617 | debug("user %.100s does not match group list %.100s at line %d", |
| 618 | user, grps, line); |
Damien Miller | 565ca3f | 2006-08-19 00:23:15 +1000 | [diff] [blame] | 619 | } else { |
Darren Tucker | b03fd02 | 2008-07-04 13:51:12 +1000 | [diff] [blame] | 620 | debug("user %.100s matched group list %.100s at line %d", user, |
| 621 | grps, line); |
Damien Miller | 565ca3f | 2006-08-19 00:23:15 +1000 | [diff] [blame] | 622 | result = 1; |
| 623 | } |
| 624 | out: |
| 625 | ga_free(); |
Damien Miller | 565ca3f | 2006-08-19 00:23:15 +1000 | [diff] [blame] | 626 | return result; |
| 627 | } |
| 628 | |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 629 | /* |
Darren Tucker | bb6cc07 | 2012-09-17 13:25:06 +1000 | [diff] [blame] | 630 | * All of the attributes on a single Match line are ANDed together, so we need |
| 631 | * to check every * attribute and set the result to zero if any attribute does |
| 632 | * not match. |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 633 | */ |
Damien Miller | 565ca3f | 2006-08-19 00:23:15 +1000 | [diff] [blame] | 634 | static int |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 635 | match_cfg_line(char **condition, int line, struct connection_info *ci) |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 636 | { |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 637 | int result = 1, port; |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 638 | char *arg, *attrib, *cp = *condition; |
| 639 | size_t len; |
| 640 | |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 641 | if (ci == NULL) |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 642 | debug3("checking syntax for 'Match %s'", cp); |
| 643 | else |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 644 | debug3("checking match for '%s' user %s host %s addr %s " |
| 645 | "laddr %s lport %d", cp, ci->user ? ci->user : "(null)", |
| 646 | ci->host ? ci->host : "(null)", |
| 647 | ci->address ? ci->address : "(null)", |
| 648 | ci->laddress ? ci->laddress : "(null)", ci->lport); |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 649 | |
| 650 | while ((attrib = strdelim(&cp)) && *attrib != '\0') { |
| 651 | if ((arg = strdelim(&cp)) == NULL || *arg == '\0') { |
| 652 | error("Missing Match criteria for %s", attrib); |
| 653 | return -1; |
| 654 | } |
| 655 | len = strlen(arg); |
| 656 | if (strcasecmp(attrib, "user") == 0) { |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 657 | if (ci == NULL || ci->user == NULL) { |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 658 | result = 0; |
| 659 | continue; |
| 660 | } |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 661 | if (match_pattern_list(ci->user, arg, len, 0) != 1) |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 662 | result = 0; |
| 663 | else |
| 664 | debug("user %.100s matched 'User %.100s' at " |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 665 | "line %d", ci->user, arg, line); |
Damien Miller | 565ca3f | 2006-08-19 00:23:15 +1000 | [diff] [blame] | 666 | } else if (strcasecmp(attrib, "group") == 0) { |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 667 | if (ci == NULL || ci->user == NULL) { |
| 668 | result = 0; |
| 669 | continue; |
| 670 | } |
| 671 | switch (match_cfg_line_group(arg, line, ci->user)) { |
Damien Miller | 565ca3f | 2006-08-19 00:23:15 +1000 | [diff] [blame] | 672 | case -1: |
| 673 | return -1; |
| 674 | case 0: |
| 675 | result = 0; |
| 676 | } |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 677 | } else if (strcasecmp(attrib, "host") == 0) { |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 678 | if (ci == NULL || ci->host == NULL) { |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 679 | result = 0; |
| 680 | continue; |
| 681 | } |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 682 | if (match_hostname(ci->host, arg, len) != 1) |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 683 | result = 0; |
| 684 | else |
| 685 | debug("connection from %.100s matched 'Host " |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 686 | "%.100s' at line %d", ci->host, arg, line); |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 687 | } else if (strcasecmp(attrib, "address") == 0) { |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 688 | if (ci == NULL || ci->address == NULL) { |
| 689 | result = 0; |
| 690 | continue; |
| 691 | } |
| 692 | switch (addr_match_list(ci->address, arg)) { |
Darren Tucker | 7a3935d | 2008-06-10 22:59:10 +1000 | [diff] [blame] | 693 | case 1: |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 694 | debug("connection from %.100s matched 'Address " |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 695 | "%.100s' at line %d", ci->address, arg, line); |
Darren Tucker | 7a3935d | 2008-06-10 22:59:10 +1000 | [diff] [blame] | 696 | break; |
| 697 | case 0: |
Darren Tucker | 896ad5a | 2008-06-11 09:34:46 +1000 | [diff] [blame] | 698 | case -1: |
Darren Tucker | 7a3935d | 2008-06-10 22:59:10 +1000 | [diff] [blame] | 699 | result = 0; |
| 700 | break; |
Darren Tucker | 896ad5a | 2008-06-11 09:34:46 +1000 | [diff] [blame] | 701 | case -2: |
Darren Tucker | 7a3935d | 2008-06-10 22:59:10 +1000 | [diff] [blame] | 702 | return -1; |
| 703 | } |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 704 | } else if (strcasecmp(attrib, "localaddress") == 0){ |
| 705 | if (ci == NULL || ci->laddress == NULL) { |
| 706 | result = 0; |
| 707 | continue; |
| 708 | } |
| 709 | switch (addr_match_list(ci->laddress, arg)) { |
| 710 | case 1: |
| 711 | debug("connection from %.100s matched " |
| 712 | "'LocalAddress %.100s' at line %d", |
| 713 | ci->laddress, arg, line); |
| 714 | break; |
| 715 | case 0: |
| 716 | case -1: |
| 717 | result = 0; |
| 718 | break; |
| 719 | case -2: |
| 720 | return -1; |
| 721 | } |
| 722 | } else if (strcasecmp(attrib, "localport") == 0) { |
| 723 | if ((port = a2port(arg)) == -1) { |
| 724 | error("Invalid LocalPort '%s' on Match line", |
| 725 | arg); |
| 726 | return -1; |
| 727 | } |
| 728 | if (ci == NULL || ci->lport == 0) { |
| 729 | result = 0; |
| 730 | continue; |
| 731 | } |
| 732 | /* TODO support port lists */ |
| 733 | if (port == ci->lport) |
| 734 | debug("connection from %.100s matched " |
| 735 | "'LocalPort %d' at line %d", |
| 736 | ci->laddress, port, line); |
| 737 | else |
| 738 | result = 0; |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 739 | } else { |
| 740 | error("Unsupported Match attribute %s", attrib); |
| 741 | return -1; |
| 742 | } |
| 743 | } |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 744 | if (ci != NULL) |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 745 | debug3("match %sfound", result ? "" : "not "); |
| 746 | *condition = cp; |
| 747 | return result; |
| 748 | } |
| 749 | |
Damien Miller | e275443 | 2006-07-24 14:06:47 +1000 | [diff] [blame] | 750 | #define WHITESPACE " \t\r\n" |
| 751 | |
Damien Miller | 3332212 | 2011-06-20 14:43:11 +1000 | [diff] [blame] | 752 | /* Multistate option parsing */ |
| 753 | struct multistate { |
| 754 | char *key; |
| 755 | int value; |
| 756 | }; |
| 757 | static const struct multistate multistate_addressfamily[] = { |
| 758 | { "inet", AF_INET }, |
| 759 | { "inet6", AF_INET6 }, |
| 760 | { "any", AF_UNSPEC }, |
| 761 | { NULL, -1 } |
| 762 | }; |
| 763 | static const struct multistate multistate_permitrootlogin[] = { |
| 764 | { "without-password", PERMIT_NO_PASSWD }, |
| 765 | { "forced-commands-only", PERMIT_FORCED_ONLY }, |
| 766 | { "yes", PERMIT_YES }, |
| 767 | { "no", PERMIT_NO }, |
| 768 | { NULL, -1 } |
| 769 | }; |
| 770 | static const struct multistate multistate_compression[] = { |
| 771 | { "delayed", COMP_DELAYED }, |
| 772 | { "yes", COMP_ZLIB }, |
| 773 | { "no", COMP_NONE }, |
| 774 | { NULL, -1 } |
| 775 | }; |
| 776 | static const struct multistate multistate_gatewayports[] = { |
| 777 | { "clientspecified", 2 }, |
| 778 | { "yes", 1 }, |
| 779 | { "no", 0 }, |
| 780 | { NULL, -1 } |
| 781 | }; |
Damien Miller | 69ff1df | 2011-06-23 08:30:03 +1000 | [diff] [blame] | 782 | static const struct multistate multistate_privsep[] = { |
Damien Miller | 5a5c2b9 | 2012-07-31 12:21:34 +1000 | [diff] [blame] | 783 | { "yes", PRIVSEP_NOSANDBOX }, |
| 784 | { "sandbox", PRIVSEP_ON }, |
| 785 | { "nosandbox", PRIVSEP_NOSANDBOX }, |
Damien Miller | 69ff1df | 2011-06-23 08:30:03 +1000 | [diff] [blame] | 786 | { "no", PRIVSEP_OFF }, |
| 787 | { NULL, -1 } |
| 788 | }; |
Damien Miller | aa5b3f8 | 2012-12-03 09:50:54 +1100 | [diff] [blame] | 789 | static const struct multistate multistate_tcpfwd[] = { |
| 790 | { "yes", FORWARD_ALLOW }, |
| 791 | { "all", FORWARD_ALLOW }, |
| 792 | { "no", FORWARD_DENY }, |
| 793 | { "remote", FORWARD_REMOTE }, |
| 794 | { "local", FORWARD_LOCAL }, |
| 795 | { NULL, -1 } |
| 796 | }; |
Damien Miller | 3332212 | 2011-06-20 14:43:11 +1000 | [diff] [blame] | 797 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 798 | int |
| 799 | process_server_config_line(ServerOptions *options, char *line, |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 800 | const char *filename, int linenum, int *activep, |
| 801 | struct connection_info *connectinfo) |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 802 | { |
| 803 | char *cp, **charptr, *arg, *p; |
Damien Miller | 0dac6fb | 2010-11-20 15:19:38 +1100 | [diff] [blame] | 804 | int cmdline = 0, *intptr, value, value2, n; |
Darren Tucker | 1e44c5d | 2008-01-01 20:32:26 +1100 | [diff] [blame] | 805 | SyslogFacility *log_facility_ptr; |
| 806 | LogLevel *log_level_ptr; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 807 | ServerOpCodes opcode; |
Damien Miller | 3dc71ad | 2009-01-28 16:31:22 +1100 | [diff] [blame] | 808 | int port; |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 809 | u_int i, flags = 0; |
Damien Miller | 917f9b6 | 2006-07-10 20:36:47 +1000 | [diff] [blame] | 810 | size_t len; |
Damien Miller | 3332212 | 2011-06-20 14:43:11 +1000 | [diff] [blame] | 811 | const struct multistate *multistate_ptr; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 812 | |
| 813 | cp = line; |
Damien Miller | 78f16cb | 2006-03-26 13:54:37 +1100 | [diff] [blame] | 814 | if ((arg = strdelim(&cp)) == NULL) |
Damien Miller | 928b236 | 2006-03-26 13:53:32 +1100 | [diff] [blame] | 815 | return 0; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 816 | /* Ignore leading whitespace */ |
| 817 | if (*arg == '\0') |
| 818 | arg = strdelim(&cp); |
| 819 | if (!arg || !*arg || *arg == '#') |
| 820 | return 0; |
| 821 | intptr = NULL; |
| 822 | charptr = NULL; |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 823 | opcode = parse_token(arg, filename, linenum, &flags); |
| 824 | |
| 825 | if (activep == NULL) { /* We are processing a command line directive */ |
| 826 | cmdline = 1; |
| 827 | activep = &cmdline; |
| 828 | } |
| 829 | if (*activep && opcode != sMatch) |
| 830 | debug3("%s:%d setting %s %s", filename, linenum, arg, cp); |
| 831 | if (*activep == 0 && !(flags & SSHCFG_MATCH)) { |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 832 | if (connectinfo == NULL) { |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 833 | fatal("%s line %d: Directive '%s' is not allowed " |
| 834 | "within a Match block", filename, linenum, arg); |
| 835 | } else { /* this is a directive we have already processed */ |
| 836 | while (arg) |
| 837 | arg = strdelim(&cp); |
| 838 | return 0; |
| 839 | } |
| 840 | } |
| 841 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 842 | switch (opcode) { |
| 843 | /* Portable-specific options */ |
Damien Miller | 4e448a3 | 2003-05-14 15:11:48 +1000 | [diff] [blame] | 844 | case sUsePAM: |
| 845 | intptr = &options->use_pam; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 846 | goto parse_flag; |
| 847 | |
| 848 | /* Standard Options */ |
| 849 | case sBadOption: |
| 850 | return -1; |
| 851 | case sPort: |
| 852 | /* ignore ports from configfile if cmdline specifies ports */ |
| 853 | if (options->ports_from_cmdline) |
| 854 | return 0; |
| 855 | if (options->listen_addrs != NULL) |
| 856 | fatal("%s line %d: ports must be specified before " |
Damien Miller | 4fbf08a | 2002-01-22 23:35:09 +1100 | [diff] [blame] | 857 | "ListenAddress.", filename, linenum); |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 858 | if (options->num_ports >= MAX_PORTS) |
| 859 | fatal("%s line %d: too many ports.", |
| 860 | filename, linenum); |
| 861 | arg = strdelim(&cp); |
| 862 | if (!arg || *arg == '\0') |
| 863 | fatal("%s line %d: missing port number.", |
| 864 | filename, linenum); |
| 865 | options->ports[options->num_ports++] = a2port(arg); |
Damien Miller | 3dc71ad | 2009-01-28 16:31:22 +1100 | [diff] [blame] | 866 | if (options->ports[options->num_ports-1] <= 0) |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 867 | fatal("%s line %d: Badly formatted port number.", |
| 868 | filename, linenum); |
| 869 | break; |
| 870 | |
| 871 | case sServerKeyBits: |
| 872 | intptr = &options->server_key_bits; |
Damien Miller | 7207f64 | 2008-05-19 15:34:50 +1000 | [diff] [blame] | 873 | parse_int: |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 874 | arg = strdelim(&cp); |
| 875 | if (!arg || *arg == '\0') |
| 876 | fatal("%s line %d: missing integer value.", |
| 877 | filename, linenum); |
| 878 | value = atoi(arg); |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 879 | if (*activep && *intptr == -1) |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 880 | *intptr = value; |
| 881 | break; |
| 882 | |
| 883 | case sLoginGraceTime: |
| 884 | intptr = &options->login_grace_time; |
Damien Miller | 7207f64 | 2008-05-19 15:34:50 +1000 | [diff] [blame] | 885 | parse_time: |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 886 | arg = strdelim(&cp); |
| 887 | if (!arg || *arg == '\0') |
| 888 | fatal("%s line %d: missing time value.", |
| 889 | filename, linenum); |
| 890 | if ((value = convtime(arg)) == -1) |
| 891 | fatal("%s line %d: invalid time value.", |
| 892 | filename, linenum); |
| 893 | if (*intptr == -1) |
| 894 | *intptr = value; |
| 895 | break; |
| 896 | |
| 897 | case sKeyRegenerationTime: |
| 898 | intptr = &options->key_regeneration_time; |
| 899 | goto parse_time; |
| 900 | |
| 901 | case sListenAddress: |
| 902 | arg = strdelim(&cp); |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 903 | if (arg == NULL || *arg == '\0') |
| 904 | fatal("%s line %d: missing address", |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 905 | filename, linenum); |
Damien Miller | 203c705 | 2005-08-12 22:11:37 +1000 | [diff] [blame] | 906 | /* check for bare IPv6 address: no "[]" and 2 or more ":" */ |
| 907 | if (strchr(arg, '[') == NULL && (p = strchr(arg, ':')) != NULL |
| 908 | && strchr(p+1, ':') != NULL) { |
| 909 | add_listen_addr(options, arg, 0); |
| 910 | break; |
| 911 | } |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 912 | p = hpdelim(&arg); |
| 913 | if (p == NULL) |
| 914 | fatal("%s line %d: bad address:port usage", |
| 915 | filename, linenum); |
| 916 | p = cleanhostname(p); |
| 917 | if (arg == NULL) |
| 918 | port = 0; |
Damien Miller | 3dc71ad | 2009-01-28 16:31:22 +1100 | [diff] [blame] | 919 | else if ((port = a2port(arg)) <= 0) |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 920 | fatal("%s line %d: bad port number", filename, linenum); |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 921 | |
Damien Miller | f91ee4c | 2005-03-01 21:24:33 +1100 | [diff] [blame] | 922 | add_listen_addr(options, p, port); |
| 923 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 924 | break; |
| 925 | |
Darren Tucker | 0f38323 | 2005-01-20 10:57:56 +1100 | [diff] [blame] | 926 | case sAddressFamily: |
Damien Miller | 3332212 | 2011-06-20 14:43:11 +1000 | [diff] [blame] | 927 | intptr = &options->address_family; |
| 928 | multistate_ptr = multistate_addressfamily; |
| 929 | if (options->listen_addrs != NULL) |
| 930 | fatal("%s line %d: address family must be specified " |
| 931 | "before ListenAddress.", filename, linenum); |
| 932 | parse_multistate: |
Darren Tucker | 0f38323 | 2005-01-20 10:57:56 +1100 | [diff] [blame] | 933 | arg = strdelim(&cp); |
Damien Miller | 17b23d8 | 2005-05-26 12:11:56 +1000 | [diff] [blame] | 934 | if (!arg || *arg == '\0') |
Damien Miller | 3332212 | 2011-06-20 14:43:11 +1000 | [diff] [blame] | 935 | fatal("%s line %d: missing argument.", |
Damien Miller | 17b23d8 | 2005-05-26 12:11:56 +1000 | [diff] [blame] | 936 | filename, linenum); |
Damien Miller | 3332212 | 2011-06-20 14:43:11 +1000 | [diff] [blame] | 937 | value = -1; |
| 938 | for (i = 0; multistate_ptr[i].key != NULL; i++) { |
| 939 | if (strcasecmp(arg, multistate_ptr[i].key) == 0) { |
| 940 | value = multistate_ptr[i].value; |
| 941 | break; |
| 942 | } |
| 943 | } |
| 944 | if (value == -1) |
| 945 | fatal("%s line %d: unsupported option \"%s\".", |
Darren Tucker | 0f38323 | 2005-01-20 10:57:56 +1100 | [diff] [blame] | 946 | filename, linenum, arg); |
Damien Miller | 3332212 | 2011-06-20 14:43:11 +1000 | [diff] [blame] | 947 | if (*activep && *intptr == -1) |
Darren Tucker | 0f38323 | 2005-01-20 10:57:56 +1100 | [diff] [blame] | 948 | *intptr = value; |
| 949 | break; |
| 950 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 951 | case sHostKeyFile: |
| 952 | intptr = &options->num_host_key_files; |
| 953 | if (*intptr >= MAX_HOSTKEYS) |
| 954 | fatal("%s line %d: too many host keys specified (max %d).", |
| 955 | filename, linenum, MAX_HOSTKEYS); |
| 956 | charptr = &options->host_key_files[*intptr]; |
Damien Miller | 7207f64 | 2008-05-19 15:34:50 +1000 | [diff] [blame] | 957 | parse_filename: |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 958 | arg = strdelim(&cp); |
| 959 | if (!arg || *arg == '\0') |
| 960 | fatal("%s line %d: missing file name.", |
| 961 | filename, linenum); |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 962 | if (*activep && *charptr == NULL) { |
Darren Tucker | 88b6fb2 | 2010-01-13 22:44:29 +1100 | [diff] [blame] | 963 | *charptr = derelativise_path(arg); |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 964 | /* increase optional counter */ |
| 965 | if (intptr != NULL) |
| 966 | *intptr = *intptr + 1; |
| 967 | } |
| 968 | break; |
| 969 | |
Damien Miller | 0a80ca1 | 2010-02-27 07:55:05 +1100 | [diff] [blame] | 970 | case sHostCertificate: |
| 971 | intptr = &options->num_host_cert_files; |
| 972 | if (*intptr >= MAX_HOSTKEYS) |
| 973 | fatal("%s line %d: too many host certificates " |
| 974 | "specified (max %d).", filename, linenum, |
| 975 | MAX_HOSTCERTS); |
| 976 | charptr = &options->host_cert_files[*intptr]; |
| 977 | goto parse_filename; |
| 978 | break; |
| 979 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 980 | case sPidFile: |
| 981 | charptr = &options->pid_file; |
| 982 | goto parse_filename; |
| 983 | |
| 984 | case sPermitRootLogin: |
| 985 | intptr = &options->permit_root_login; |
Damien Miller | 3332212 | 2011-06-20 14:43:11 +1000 | [diff] [blame] | 986 | multistate_ptr = multistate_permitrootlogin; |
| 987 | goto parse_multistate; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 988 | |
| 989 | case sIgnoreRhosts: |
| 990 | intptr = &options->ignore_rhosts; |
Damien Miller | 7207f64 | 2008-05-19 15:34:50 +1000 | [diff] [blame] | 991 | parse_flag: |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 992 | arg = strdelim(&cp); |
| 993 | if (!arg || *arg == '\0') |
| 994 | fatal("%s line %d: missing yes/no argument.", |
| 995 | filename, linenum); |
| 996 | value = 0; /* silence compiler */ |
| 997 | if (strcmp(arg, "yes") == 0) |
| 998 | value = 1; |
| 999 | else if (strcmp(arg, "no") == 0) |
| 1000 | value = 0; |
| 1001 | else |
| 1002 | fatal("%s line %d: Bad yes/no argument: %s", |
| 1003 | filename, linenum, arg); |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 1004 | if (*activep && *intptr == -1) |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1005 | *intptr = value; |
| 1006 | break; |
| 1007 | |
| 1008 | case sIgnoreUserKnownHosts: |
| 1009 | intptr = &options->ignore_user_known_hosts; |
| 1010 | goto parse_flag; |
| 1011 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1012 | case sRhostsRSAAuthentication: |
| 1013 | intptr = &options->rhosts_rsa_authentication; |
| 1014 | goto parse_flag; |
| 1015 | |
| 1016 | case sHostbasedAuthentication: |
| 1017 | intptr = &options->hostbased_authentication; |
| 1018 | goto parse_flag; |
| 1019 | |
| 1020 | case sHostbasedUsesNameFromPacketOnly: |
| 1021 | intptr = &options->hostbased_uses_name_from_packet_only; |
| 1022 | goto parse_flag; |
| 1023 | |
| 1024 | case sRSAAuthentication: |
| 1025 | intptr = &options->rsa_authentication; |
| 1026 | goto parse_flag; |
| 1027 | |
| 1028 | case sPubkeyAuthentication: |
| 1029 | intptr = &options->pubkey_authentication; |
| 1030 | goto parse_flag; |
Damien Miller | 2aa0ab4 | 2003-05-15 12:05:28 +1000 | [diff] [blame] | 1031 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1032 | case sKerberosAuthentication: |
| 1033 | intptr = &options->kerberos_authentication; |
| 1034 | goto parse_flag; |
| 1035 | |
| 1036 | case sKerberosOrLocalPasswd: |
| 1037 | intptr = &options->kerberos_or_local_passwd; |
| 1038 | goto parse_flag; |
| 1039 | |
| 1040 | case sKerberosTicketCleanup: |
| 1041 | intptr = &options->kerberos_ticket_cleanup; |
| 1042 | goto parse_flag; |
Damien Miller | 2aa0ab4 | 2003-05-15 12:05:28 +1000 | [diff] [blame] | 1043 | |
Darren Tucker | 22ef508 | 2003-12-31 11:37:34 +1100 | [diff] [blame] | 1044 | case sKerberosGetAFSToken: |
| 1045 | intptr = &options->kerberos_get_afs_token; |
| 1046 | goto parse_flag; |
| 1047 | |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 1048 | case sGssAuthentication: |
| 1049 | intptr = &options->gss_authentication; |
| 1050 | goto parse_flag; |
| 1051 | |
| 1052 | case sGssCleanupCreds: |
| 1053 | intptr = &options->gss_cleanup_creds; |
| 1054 | goto parse_flag; |
| 1055 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1056 | case sPasswordAuthentication: |
| 1057 | intptr = &options->password_authentication; |
| 1058 | goto parse_flag; |
| 1059 | |
Damien Miller | 01ed227 | 2008-11-05 16:20:46 +1100 | [diff] [blame] | 1060 | case sZeroKnowledgePasswordAuthentication: |
| 1061 | intptr = &options->zero_knowledge_password_authentication; |
| 1062 | goto parse_flag; |
| 1063 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1064 | case sKbdInteractiveAuthentication: |
| 1065 | intptr = &options->kbd_interactive_authentication; |
| 1066 | goto parse_flag; |
| 1067 | |
| 1068 | case sChallengeResponseAuthentication: |
| 1069 | intptr = &options->challenge_response_authentication; |
| 1070 | goto parse_flag; |
| 1071 | |
| 1072 | case sPrintMotd: |
| 1073 | intptr = &options->print_motd; |
| 1074 | goto parse_flag; |
| 1075 | |
| 1076 | case sPrintLastLog: |
| 1077 | intptr = &options->print_lastlog; |
| 1078 | goto parse_flag; |
| 1079 | |
| 1080 | case sX11Forwarding: |
| 1081 | intptr = &options->x11_forwarding; |
| 1082 | goto parse_flag; |
| 1083 | |
| 1084 | case sX11DisplayOffset: |
| 1085 | intptr = &options->x11_display_offset; |
| 1086 | goto parse_int; |
| 1087 | |
Damien Miller | 95c249f | 2002-02-05 12:11:34 +1100 | [diff] [blame] | 1088 | case sX11UseLocalhost: |
| 1089 | intptr = &options->x11_use_localhost; |
| 1090 | goto parse_flag; |
| 1091 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1092 | case sXAuthLocation: |
| 1093 | charptr = &options->xauth_location; |
| 1094 | goto parse_filename; |
| 1095 | |
| 1096 | case sStrictModes: |
| 1097 | intptr = &options->strict_modes; |
| 1098 | goto parse_flag; |
| 1099 | |
Damien Miller | 12c150e | 2003-12-17 16:31:10 +1100 | [diff] [blame] | 1100 | case sTCPKeepAlive: |
| 1101 | intptr = &options->tcp_keep_alive; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1102 | goto parse_flag; |
| 1103 | |
| 1104 | case sEmptyPasswd: |
| 1105 | intptr = &options->permit_empty_passwd; |
| 1106 | goto parse_flag; |
| 1107 | |
Ben Lindstrom | 5d860f0 | 2002-08-01 01:28:38 +0000 | [diff] [blame] | 1108 | case sPermitUserEnvironment: |
| 1109 | intptr = &options->permit_user_env; |
| 1110 | goto parse_flag; |
| 1111 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1112 | case sUseLogin: |
| 1113 | intptr = &options->use_login; |
| 1114 | goto parse_flag; |
| 1115 | |
Ben Lindstrom | 23e0f66 | 2002-06-21 01:09:47 +0000 | [diff] [blame] | 1116 | case sCompression: |
| 1117 | intptr = &options->compression; |
Damien Miller | 3332212 | 2011-06-20 14:43:11 +1000 | [diff] [blame] | 1118 | multistate_ptr = multistate_compression; |
| 1119 | goto parse_multistate; |
Ben Lindstrom | 23e0f66 | 2002-06-21 01:09:47 +0000 | [diff] [blame] | 1120 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1121 | case sGatewayPorts: |
| 1122 | intptr = &options->gateway_ports; |
Damien Miller | 3332212 | 2011-06-20 14:43:11 +1000 | [diff] [blame] | 1123 | multistate_ptr = multistate_gatewayports; |
| 1124 | goto parse_multistate; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1125 | |
Damien Miller | 3a961dc | 2003-06-03 10:25:48 +1000 | [diff] [blame] | 1126 | case sUseDNS: |
| 1127 | intptr = &options->use_dns; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1128 | goto parse_flag; |
| 1129 | |
| 1130 | case sLogFacility: |
Darren Tucker | 1e44c5d | 2008-01-01 20:32:26 +1100 | [diff] [blame] | 1131 | log_facility_ptr = &options->log_facility; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1132 | arg = strdelim(&cp); |
| 1133 | value = log_facility_number(arg); |
Damien Miller | fcd9320 | 2002-02-05 12:26:34 +1100 | [diff] [blame] | 1134 | if (value == SYSLOG_FACILITY_NOT_SET) |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1135 | fatal("%.200s line %d: unsupported log facility '%s'", |
| 1136 | filename, linenum, arg ? arg : "<NONE>"); |
Darren Tucker | 1e44c5d | 2008-01-01 20:32:26 +1100 | [diff] [blame] | 1137 | if (*log_facility_ptr == -1) |
| 1138 | *log_facility_ptr = (SyslogFacility) value; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1139 | break; |
| 1140 | |
| 1141 | case sLogLevel: |
Darren Tucker | 1e44c5d | 2008-01-01 20:32:26 +1100 | [diff] [blame] | 1142 | log_level_ptr = &options->log_level; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1143 | arg = strdelim(&cp); |
| 1144 | value = log_level_number(arg); |
Damien Miller | fcd9320 | 2002-02-05 12:26:34 +1100 | [diff] [blame] | 1145 | if (value == SYSLOG_LEVEL_NOT_SET) |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1146 | fatal("%.200s line %d: unsupported log level '%s'", |
| 1147 | filename, linenum, arg ? arg : "<NONE>"); |
Darren Tucker | 1e44c5d | 2008-01-01 20:32:26 +1100 | [diff] [blame] | 1148 | if (*log_level_ptr == -1) |
| 1149 | *log_level_ptr = (LogLevel) value; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1150 | break; |
| 1151 | |
| 1152 | case sAllowTcpForwarding: |
| 1153 | intptr = &options->allow_tcp_forwarding; |
Damien Miller | aa5b3f8 | 2012-12-03 09:50:54 +1100 | [diff] [blame] | 1154 | multistate_ptr = multistate_tcpfwd; |
| 1155 | goto parse_multistate; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1156 | |
Damien Miller | 4f755cd | 2008-05-19 14:57:41 +1000 | [diff] [blame] | 1157 | case sAllowAgentForwarding: |
| 1158 | intptr = &options->allow_agent_forwarding; |
| 1159 | goto parse_flag; |
| 1160 | |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 1161 | case sUsePrivilegeSeparation: |
| 1162 | intptr = &use_privsep; |
Damien Miller | 69ff1df | 2011-06-23 08:30:03 +1000 | [diff] [blame] | 1163 | multistate_ptr = multistate_privsep; |
| 1164 | goto parse_multistate; |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 1165 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1166 | case sAllowUsers: |
| 1167 | while ((arg = strdelim(&cp)) && *arg != '\0') { |
| 1168 | if (options->num_allow_users >= MAX_ALLOW_USERS) |
| 1169 | fatal("%s line %d: too many allow users.", |
| 1170 | filename, linenum); |
Damien Miller | c24da77 | 2012-06-20 21:53:58 +1000 | [diff] [blame] | 1171 | if (!*activep) |
| 1172 | continue; |
Ben Lindstrom | e135363 | 2002-06-23 21:29:23 +0000 | [diff] [blame] | 1173 | options->allow_users[options->num_allow_users++] = |
| 1174 | xstrdup(arg); |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1175 | } |
| 1176 | break; |
| 1177 | |
| 1178 | case sDenyUsers: |
| 1179 | while ((arg = strdelim(&cp)) && *arg != '\0') { |
| 1180 | if (options->num_deny_users >= MAX_DENY_USERS) |
Damien Miller | 4dec5d7 | 2006-08-05 11:38:40 +1000 | [diff] [blame] | 1181 | fatal("%s line %d: too many deny users.", |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1182 | filename, linenum); |
Damien Miller | c24da77 | 2012-06-20 21:53:58 +1000 | [diff] [blame] | 1183 | if (!*activep) |
| 1184 | continue; |
Ben Lindstrom | e135363 | 2002-06-23 21:29:23 +0000 | [diff] [blame] | 1185 | options->deny_users[options->num_deny_users++] = |
| 1186 | xstrdup(arg); |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1187 | } |
| 1188 | break; |
| 1189 | |
| 1190 | case sAllowGroups: |
| 1191 | while ((arg = strdelim(&cp)) && *arg != '\0') { |
| 1192 | if (options->num_allow_groups >= MAX_ALLOW_GROUPS) |
| 1193 | fatal("%s line %d: too many allow groups.", |
| 1194 | filename, linenum); |
Damien Miller | c24da77 | 2012-06-20 21:53:58 +1000 | [diff] [blame] | 1195 | if (!*activep) |
| 1196 | continue; |
Ben Lindstrom | e135363 | 2002-06-23 21:29:23 +0000 | [diff] [blame] | 1197 | options->allow_groups[options->num_allow_groups++] = |
| 1198 | xstrdup(arg); |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1199 | } |
| 1200 | break; |
| 1201 | |
| 1202 | case sDenyGroups: |
| 1203 | while ((arg = strdelim(&cp)) && *arg != '\0') { |
| 1204 | if (options->num_deny_groups >= MAX_DENY_GROUPS) |
| 1205 | fatal("%s line %d: too many deny groups.", |
| 1206 | filename, linenum); |
Damien Miller | c24da77 | 2012-06-20 21:53:58 +1000 | [diff] [blame] | 1207 | if (!*activep) |
| 1208 | continue; |
| 1209 | options->deny_groups[options->num_deny_groups++] = |
| 1210 | xstrdup(arg); |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1211 | } |
| 1212 | break; |
| 1213 | |
| 1214 | case sCiphers: |
| 1215 | arg = strdelim(&cp); |
| 1216 | if (!arg || *arg == '\0') |
| 1217 | fatal("%s line %d: Missing argument.", filename, linenum); |
| 1218 | if (!ciphers_valid(arg)) |
| 1219 | fatal("%s line %d: Bad SSH2 cipher spec '%s'.", |
| 1220 | filename, linenum, arg ? arg : "<NONE>"); |
| 1221 | if (options->ciphers == NULL) |
| 1222 | options->ciphers = xstrdup(arg); |
| 1223 | break; |
| 1224 | |
| 1225 | case sMacs: |
| 1226 | arg = strdelim(&cp); |
| 1227 | if (!arg || *arg == '\0') |
| 1228 | fatal("%s line %d: Missing argument.", filename, linenum); |
| 1229 | if (!mac_valid(arg)) |
| 1230 | fatal("%s line %d: Bad SSH2 mac spec '%s'.", |
| 1231 | filename, linenum, arg ? arg : "<NONE>"); |
| 1232 | if (options->macs == NULL) |
| 1233 | options->macs = xstrdup(arg); |
| 1234 | break; |
| 1235 | |
Damien Miller | d5f62bf | 2010-09-24 22:11:14 +1000 | [diff] [blame] | 1236 | case sKexAlgorithms: |
| 1237 | arg = strdelim(&cp); |
| 1238 | if (!arg || *arg == '\0') |
| 1239 | fatal("%s line %d: Missing argument.", |
| 1240 | filename, linenum); |
| 1241 | if (!kex_names_valid(arg)) |
| 1242 | fatal("%s line %d: Bad SSH2 KexAlgorithms '%s'.", |
| 1243 | filename, linenum, arg ? arg : "<NONE>"); |
| 1244 | if (options->kex_algorithms == NULL) |
| 1245 | options->kex_algorithms = xstrdup(arg); |
| 1246 | break; |
| 1247 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1248 | case sProtocol: |
| 1249 | intptr = &options->protocol; |
| 1250 | arg = strdelim(&cp); |
| 1251 | if (!arg || *arg == '\0') |
| 1252 | fatal("%s line %d: Missing argument.", filename, linenum); |
| 1253 | value = proto_spec(arg); |
| 1254 | if (value == SSH_PROTO_UNKNOWN) |
| 1255 | fatal("%s line %d: Bad protocol spec '%s'.", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 1256 | filename, linenum, arg ? arg : "<NONE>"); |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1257 | if (*intptr == SSH_PROTO_UNKNOWN) |
| 1258 | *intptr = value; |
| 1259 | break; |
| 1260 | |
| 1261 | case sSubsystem: |
| 1262 | if (options->num_subsystems >= MAX_SUBSYSTEMS) { |
| 1263 | fatal("%s line %d: too many subsystems defined.", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 1264 | filename, linenum); |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1265 | } |
| 1266 | arg = strdelim(&cp); |
| 1267 | if (!arg || *arg == '\0') |
| 1268 | fatal("%s line %d: Missing subsystem name.", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 1269 | filename, linenum); |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 1270 | if (!*activep) { |
| 1271 | arg = strdelim(&cp); |
| 1272 | break; |
| 1273 | } |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1274 | for (i = 0; i < options->num_subsystems; i++) |
| 1275 | if (strcmp(arg, options->subsystem_name[i]) == 0) |
| 1276 | fatal("%s line %d: Subsystem '%s' already defined.", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 1277 | filename, linenum, arg); |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1278 | options->subsystem_name[options->num_subsystems] = xstrdup(arg); |
| 1279 | arg = strdelim(&cp); |
| 1280 | if (!arg || *arg == '\0') |
| 1281 | fatal("%s line %d: Missing subsystem command.", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 1282 | filename, linenum); |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1283 | options->subsystem_command[options->num_subsystems] = xstrdup(arg); |
Damien Miller | 917f9b6 | 2006-07-10 20:36:47 +1000 | [diff] [blame] | 1284 | |
| 1285 | /* Collect arguments (separate to executable) */ |
| 1286 | p = xstrdup(arg); |
| 1287 | len = strlen(p) + 1; |
| 1288 | while ((arg = strdelim(&cp)) != NULL && *arg != '\0') { |
| 1289 | len += 1 + strlen(arg); |
| 1290 | p = xrealloc(p, 1, len); |
| 1291 | strlcat(p, " ", len); |
| 1292 | strlcat(p, arg, len); |
| 1293 | } |
| 1294 | options->subsystem_args[options->num_subsystems] = p; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1295 | options->num_subsystems++; |
| 1296 | break; |
| 1297 | |
| 1298 | case sMaxStartups: |
| 1299 | arg = strdelim(&cp); |
| 1300 | if (!arg || *arg == '\0') |
| 1301 | fatal("%s line %d: Missing MaxStartups spec.", |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 1302 | filename, linenum); |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1303 | if ((n = sscanf(arg, "%d:%d:%d", |
| 1304 | &options->max_startups_begin, |
| 1305 | &options->max_startups_rate, |
| 1306 | &options->max_startups)) == 3) { |
| 1307 | if (options->max_startups_begin > |
| 1308 | options->max_startups || |
| 1309 | options->max_startups_rate > 100 || |
| 1310 | options->max_startups_rate < 1) |
| 1311 | fatal("%s line %d: Illegal MaxStartups spec.", |
| 1312 | filename, linenum); |
| 1313 | } else if (n != 1) |
| 1314 | fatal("%s line %d: Illegal MaxStartups spec.", |
| 1315 | filename, linenum); |
| 1316 | else |
| 1317 | options->max_startups = options->max_startups_begin; |
| 1318 | break; |
| 1319 | |
Darren Tucker | 89413db | 2004-05-24 10:36:23 +1000 | [diff] [blame] | 1320 | case sMaxAuthTries: |
| 1321 | intptr = &options->max_authtries; |
| 1322 | goto parse_int; |
| 1323 | |
Damien Miller | 7207f64 | 2008-05-19 15:34:50 +1000 | [diff] [blame] | 1324 | case sMaxSessions: |
| 1325 | intptr = &options->max_sessions; |
| 1326 | goto parse_int; |
| 1327 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1328 | case sBanner: |
| 1329 | charptr = &options->banner; |
| 1330 | goto parse_filename; |
Damien Miller | d8cb1f1 | 2008-02-10 22:40:12 +1100 | [diff] [blame] | 1331 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1332 | /* |
| 1333 | * These options can contain %X options expanded at |
| 1334 | * connect time, so that you can specify paths like: |
| 1335 | * |
| 1336 | * AuthorizedKeysFile /etc/ssh_keys/%u |
| 1337 | */ |
| 1338 | case sAuthorizedKeysFile: |
Damien Miller | d8478b6 | 2011-05-29 21:39:36 +1000 | [diff] [blame] | 1339 | if (*activep && options->num_authkeys_files == 0) { |
| 1340 | while ((arg = strdelim(&cp)) && *arg != '\0') { |
| 1341 | if (options->num_authkeys_files >= |
| 1342 | MAX_AUTHKEYS_FILES) |
| 1343 | fatal("%s line %d: " |
| 1344 | "too many authorized keys files.", |
| 1345 | filename, linenum); |
| 1346 | options->authorized_keys_files[ |
| 1347 | options->num_authkeys_files++] = |
| 1348 | tilde_expand_filename(arg, getuid()); |
| 1349 | } |
| 1350 | } |
| 1351 | return 0; |
| 1352 | |
Damien Miller | 30da344 | 2010-05-10 11:58:03 +1000 | [diff] [blame] | 1353 | case sAuthorizedPrincipalsFile: |
| 1354 | charptr = &options->authorized_principals_file; |
Damien Miller | c4cb47b | 2010-03-22 05:52:26 +1100 | [diff] [blame] | 1355 | arg = strdelim(&cp); |
| 1356 | if (!arg || *arg == '\0') |
| 1357 | fatal("%s line %d: missing file name.", |
| 1358 | filename, linenum); |
| 1359 | if (*activep && *charptr == NULL) { |
Damien Miller | 4a5f0d3 | 2010-03-22 05:53:04 +1100 | [diff] [blame] | 1360 | *charptr = tilde_expand_filename(arg, getuid()); |
Damien Miller | c4cb47b | 2010-03-22 05:52:26 +1100 | [diff] [blame] | 1361 | /* increase optional counter */ |
| 1362 | if (intptr != NULL) |
| 1363 | *intptr = *intptr + 1; |
| 1364 | } |
| 1365 | break; |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1366 | |
| 1367 | case sClientAliveInterval: |
| 1368 | intptr = &options->client_alive_interval; |
| 1369 | goto parse_time; |
| 1370 | |
| 1371 | case sClientAliveCountMax: |
| 1372 | intptr = &options->client_alive_count_max; |
| 1373 | goto parse_int; |
| 1374 | |
Darren Tucker | 46bc075 | 2004-05-02 22:11:30 +1000 | [diff] [blame] | 1375 | case sAcceptEnv: |
| 1376 | while ((arg = strdelim(&cp)) && *arg != '\0') { |
| 1377 | if (strchr(arg, '=') != NULL) |
| 1378 | fatal("%s line %d: Invalid environment name.", |
| 1379 | filename, linenum); |
| 1380 | if (options->num_accept_env >= MAX_ACCEPT_ENV) |
| 1381 | fatal("%s line %d: too many allow env.", |
| 1382 | filename, linenum); |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 1383 | if (!*activep) |
Damien Miller | c24da77 | 2012-06-20 21:53:58 +1000 | [diff] [blame] | 1384 | continue; |
Darren Tucker | 46bc075 | 2004-05-02 22:11:30 +1000 | [diff] [blame] | 1385 | options->accept_env[options->num_accept_env++] = |
| 1386 | xstrdup(arg); |
| 1387 | } |
| 1388 | break; |
| 1389 | |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 1390 | case sPermitTunnel: |
| 1391 | intptr = &options->permit_tun; |
Damien Miller | 7b58e80 | 2005-12-13 19:33:19 +1100 | [diff] [blame] | 1392 | arg = strdelim(&cp); |
| 1393 | if (!arg || *arg == '\0') |
| 1394 | fatal("%s line %d: Missing yes/point-to-point/" |
| 1395 | "ethernet/no argument.", filename, linenum); |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1396 | value = -1; |
| 1397 | for (i = 0; tunmode_desc[i].val != -1; i++) |
| 1398 | if (strcmp(tunmode_desc[i].text, arg) == 0) { |
| 1399 | value = tunmode_desc[i].val; |
| 1400 | break; |
| 1401 | } |
| 1402 | if (value == -1) |
Damien Miller | 7b58e80 | 2005-12-13 19:33:19 +1100 | [diff] [blame] | 1403 | fatal("%s line %d: Bad yes/point-to-point/ethernet/" |
| 1404 | "no argument: %s", filename, linenum, arg); |
| 1405 | if (*intptr == -1) |
| 1406 | *intptr = value; |
| 1407 | break; |
Damien Miller | d27b947 | 2005-12-13 19:29:02 +1100 | [diff] [blame] | 1408 | |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 1409 | case sMatch: |
| 1410 | if (cmdline) |
| 1411 | fatal("Match directive not supported as a command-line " |
| 1412 | "option"); |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 1413 | value = match_cfg_line(&cp, linenum, connectinfo); |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 1414 | if (value < 0) |
| 1415 | fatal("%s line %d: Bad Match condition", filename, |
| 1416 | linenum); |
| 1417 | *activep = value; |
| 1418 | break; |
| 1419 | |
Damien Miller | 9b439df | 2006-07-24 14:04:00 +1000 | [diff] [blame] | 1420 | case sPermitOpen: |
| 1421 | arg = strdelim(&cp); |
| 1422 | if (!arg || *arg == '\0') |
| 1423 | fatal("%s line %d: missing PermitOpen specification", |
| 1424 | filename, linenum); |
Damien Miller | 9fc6a56 | 2007-01-05 16:29:02 +1100 | [diff] [blame] | 1425 | n = options->num_permitted_opens; /* modified later */ |
Damien Miller | 9b439df | 2006-07-24 14:04:00 +1000 | [diff] [blame] | 1426 | if (strcmp(arg, "any") == 0) { |
Damien Miller | 9fc6a56 | 2007-01-05 16:29:02 +1100 | [diff] [blame] | 1427 | if (*activep && n == -1) { |
Damien Miller | 9b439df | 2006-07-24 14:04:00 +1000 | [diff] [blame] | 1428 | channel_clear_adm_permitted_opens(); |
Damien Miller | a765cf4 | 2006-07-24 14:08:13 +1000 | [diff] [blame] | 1429 | options->num_permitted_opens = 0; |
| 1430 | } |
Damien Miller | 9b439df | 2006-07-24 14:04:00 +1000 | [diff] [blame] | 1431 | break; |
| 1432 | } |
Damien Miller | c608148 | 2012-04-22 11:18:53 +1000 | [diff] [blame] | 1433 | if (strcmp(arg, "none") == 0) { |
| 1434 | if (*activep && n == -1) { |
Damien Miller | c608148 | 2012-04-22 11:18:53 +1000 | [diff] [blame] | 1435 | options->num_permitted_opens = 1; |
| 1436 | channel_disable_adm_local_opens(); |
| 1437 | } |
| 1438 | break; |
| 1439 | } |
Damien Miller | a29b95e | 2007-01-05 16:28:36 +1100 | [diff] [blame] | 1440 | if (*activep && n == -1) |
| 1441 | channel_clear_adm_permitted_opens(); |
Damien Miller | a765cf4 | 2006-07-24 14:08:13 +1000 | [diff] [blame] | 1442 | for (; arg != NULL && *arg != '\0'; arg = strdelim(&cp)) { |
| 1443 | p = hpdelim(&arg); |
| 1444 | if (p == NULL) |
| 1445 | fatal("%s line %d: missing host in PermitOpen", |
| 1446 | filename, linenum); |
| 1447 | p = cleanhostname(p); |
Darren Tucker | 1338b9e | 2011-10-02 18:57:35 +1100 | [diff] [blame] | 1448 | if (arg == NULL || ((port = permitopen_port(arg)) < 0)) |
Damien Miller | a765cf4 | 2006-07-24 14:08:13 +1000 | [diff] [blame] | 1449 | fatal("%s line %d: bad port number in " |
| 1450 | "PermitOpen", filename, linenum); |
Damien Miller | a29b95e | 2007-01-05 16:28:36 +1100 | [diff] [blame] | 1451 | if (*activep && n == -1) |
Damien Miller | a765cf4 | 2006-07-24 14:08:13 +1000 | [diff] [blame] | 1452 | options->num_permitted_opens = |
| 1453 | channel_add_adm_permitted_opens(p, port); |
Damien Miller | a765cf4 | 2006-07-24 14:08:13 +1000 | [diff] [blame] | 1454 | } |
Damien Miller | 9b439df | 2006-07-24 14:04:00 +1000 | [diff] [blame] | 1455 | break; |
| 1456 | |
Damien Miller | e275443 | 2006-07-24 14:06:47 +1000 | [diff] [blame] | 1457 | case sForceCommand: |
| 1458 | if (cp == NULL) |
| 1459 | fatal("%.200s line %d: Missing argument.", filename, |
| 1460 | linenum); |
| 1461 | len = strspn(cp, WHITESPACE); |
| 1462 | if (*activep && options->adm_forced_command == NULL) |
| 1463 | options->adm_forced_command = xstrdup(cp + len); |
| 1464 | return 0; |
| 1465 | |
Damien Miller | d8cb1f1 | 2008-02-10 22:40:12 +1100 | [diff] [blame] | 1466 | case sChrootDirectory: |
| 1467 | charptr = &options->chroot_directory; |
Damien Miller | 54e3773 | 2008-02-10 22:48:55 +1100 | [diff] [blame] | 1468 | |
| 1469 | arg = strdelim(&cp); |
| 1470 | if (!arg || *arg == '\0') |
| 1471 | fatal("%s line %d: missing file name.", |
| 1472 | filename, linenum); |
| 1473 | if (*activep && *charptr == NULL) |
| 1474 | *charptr = xstrdup(arg); |
| 1475 | break; |
Damien Miller | d8cb1f1 | 2008-02-10 22:40:12 +1100 | [diff] [blame] | 1476 | |
Damien Miller | 1aed65e | 2010-03-04 21:53:35 +1100 | [diff] [blame] | 1477 | case sTrustedUserCAKeys: |
| 1478 | charptr = &options->trusted_user_ca_keys; |
| 1479 | goto parse_filename; |
| 1480 | |
| 1481 | case sRevokedKeys: |
| 1482 | charptr = &options->revoked_keys_file; |
| 1483 | goto parse_filename; |
| 1484 | |
Damien Miller | 0dac6fb | 2010-11-20 15:19:38 +1100 | [diff] [blame] | 1485 | case sIPQoS: |
| 1486 | arg = strdelim(&cp); |
| 1487 | if ((value = parse_ipqos(arg)) == -1) |
| 1488 | fatal("%s line %d: Bad IPQoS value: %s", |
| 1489 | filename, linenum, arg); |
| 1490 | arg = strdelim(&cp); |
| 1491 | if (arg == NULL) |
| 1492 | value2 = value; |
| 1493 | else if ((value2 = parse_ipqos(arg)) == -1) |
| 1494 | fatal("%s line %d: Bad IPQoS value: %s", |
| 1495 | filename, linenum, arg); |
| 1496 | if (*activep) { |
| 1497 | options->ip_qos_interactive = value; |
| 1498 | options->ip_qos_bulk = value2; |
| 1499 | } |
| 1500 | break; |
| 1501 | |
Damien Miller | 2352881 | 2012-04-22 11:24:43 +1000 | [diff] [blame] | 1502 | case sVersionAddendum: |
| 1503 | if (cp == NULL) |
| 1504 | fatal("%.200s line %d: Missing argument.", filename, |
| 1505 | linenum); |
| 1506 | len = strspn(cp, WHITESPACE); |
| 1507 | if (*activep && options->version_addendum == NULL) { |
| 1508 | if (strcasecmp(cp + len, "none") == 0) |
| 1509 | options->version_addendum = xstrdup(""); |
| 1510 | else if (strchr(cp + len, '\r') != NULL) |
| 1511 | fatal("%.200s line %d: Invalid argument", |
| 1512 | filename, linenum); |
| 1513 | else |
| 1514 | options->version_addendum = xstrdup(cp + len); |
| 1515 | } |
| 1516 | return 0; |
| 1517 | |
Damien Miller | 09d3e12 | 2012-10-31 08:58:58 +1100 | [diff] [blame] | 1518 | case sAuthorizedKeysCommand: |
| 1519 | len = strspn(cp, WHITESPACE); |
| 1520 | if (*activep && options->authorized_keys_command == NULL) { |
| 1521 | if (cp[len] != '/' && strcasecmp(cp + len, "none") != 0) |
| 1522 | fatal("%.200s line %d: AuthorizedKeysCommand " |
| 1523 | "must be an absolute path", |
| 1524 | filename, linenum); |
| 1525 | options->authorized_keys_command = xstrdup(cp + len); |
| 1526 | } |
| 1527 | return 0; |
| 1528 | |
| 1529 | case sAuthorizedKeysCommandUser: |
| 1530 | charptr = &options->authorized_keys_command_user; |
| 1531 | |
| 1532 | arg = strdelim(&cp); |
| 1533 | if (*activep && *charptr == NULL) |
| 1534 | *charptr = xstrdup(arg); |
| 1535 | break; |
| 1536 | |
Damien Miller | a6e3f01 | 2012-11-04 23:21:40 +1100 | [diff] [blame] | 1537 | case sAuthenticationMethods: |
| 1538 | if (*activep && options->num_auth_methods == 0) { |
| 1539 | while ((arg = strdelim(&cp)) && *arg != '\0') { |
| 1540 | if (options->num_auth_methods >= |
| 1541 | MAX_AUTH_METHODS) |
| 1542 | fatal("%s line %d: " |
| 1543 | "too many authentication methods.", |
| 1544 | filename, linenum); |
| 1545 | if (auth2_methods_valid(arg, 0) != 0) |
| 1546 | fatal("%s line %d: invalid " |
| 1547 | "authentication method list.", |
| 1548 | filename, linenum); |
| 1549 | options->auth_methods[ |
| 1550 | options->num_auth_methods++] = xstrdup(arg); |
| 1551 | } |
| 1552 | } |
| 1553 | return 0; |
| 1554 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1555 | case sDeprecated: |
Damien Miller | 996acd2 | 2003-04-09 20:59:48 +1000 | [diff] [blame] | 1556 | logit("%s line %d: Deprecated option %s", |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1557 | filename, linenum, arg); |
| 1558 | while (arg) |
| 1559 | arg = strdelim(&cp); |
| 1560 | break; |
| 1561 | |
Damien Miller | f9b3feb | 2003-05-16 11:38:32 +1000 | [diff] [blame] | 1562 | case sUnsupported: |
| 1563 | logit("%s line %d: Unsupported option %s", |
| 1564 | filename, linenum, arg); |
| 1565 | while (arg) |
| 1566 | arg = strdelim(&cp); |
| 1567 | break; |
| 1568 | |
Ben Lindstrom | ade03f6 | 2001-12-06 18:22:17 +0000 | [diff] [blame] | 1569 | default: |
| 1570 | fatal("%s line %d: Missing handler for opcode %s (%d)", |
| 1571 | filename, linenum, arg, opcode); |
| 1572 | } |
| 1573 | if ((arg = strdelim(&cp)) != NULL && *arg != '\0') |
| 1574 | fatal("%s line %d: garbage at end of line; \"%.200s\".", |
| 1575 | filename, linenum, arg); |
| 1576 | return 0; |
| 1577 | } |
| 1578 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1579 | /* Reads the server configuration file. */ |
| 1580 | |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 1581 | void |
Darren Tucker | 645ab75 | 2004-06-25 13:33:20 +1000 | [diff] [blame] | 1582 | load_server_config(const char *filename, Buffer *conf) |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1583 | { |
Damien Miller | 46cb75a | 2012-07-31 12:22:37 +1000 | [diff] [blame] | 1584 | char line[4096], *cp; |
Ben Lindstrom | e135363 | 2002-06-23 21:29:23 +0000 | [diff] [blame] | 1585 | FILE *f; |
Damien Miller | 46cb75a | 2012-07-31 12:22:37 +1000 | [diff] [blame] | 1586 | int lineno = 0; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1587 | |
Darren Tucker | 645ab75 | 2004-06-25 13:33:20 +1000 | [diff] [blame] | 1588 | debug2("%s: filename %s", __func__, filename); |
| 1589 | if ((f = fopen(filename, "r")) == NULL) { |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1590 | perror(filename); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1591 | exit(1); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1592 | } |
Darren Tucker | 645ab75 | 2004-06-25 13:33:20 +1000 | [diff] [blame] | 1593 | buffer_clear(conf); |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1594 | while (fgets(line, sizeof(line), f)) { |
Damien Miller | 46cb75a | 2012-07-31 12:22:37 +1000 | [diff] [blame] | 1595 | lineno++; |
| 1596 | if (strlen(line) == sizeof(line) - 1) |
| 1597 | fatal("%s line %d too long", filename, lineno); |
Darren Tucker | 645ab75 | 2004-06-25 13:33:20 +1000 | [diff] [blame] | 1598 | /* |
| 1599 | * Trim out comments and strip whitespace |
Darren Tucker | fc95970 | 2004-07-17 16:12:08 +1000 | [diff] [blame] | 1600 | * NB - preserve newlines, they are needed to reproduce |
Darren Tucker | 645ab75 | 2004-06-25 13:33:20 +1000 | [diff] [blame] | 1601 | * line numbers later for error messages |
| 1602 | */ |
| 1603 | if ((cp = strchr(line, '#')) != NULL) |
| 1604 | memcpy(cp, "\n", 2); |
| 1605 | cp = line + strspn(line, " \t\r"); |
| 1606 | |
| 1607 | buffer_append(conf, cp, strlen(cp)); |
| 1608 | } |
| 1609 | buffer_append(conf, "\0", 1); |
| 1610 | fclose(f); |
| 1611 | debug2("%s: done config len = %d", __func__, buffer_len(conf)); |
| 1612 | } |
| 1613 | |
| 1614 | void |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 1615 | parse_server_match_config(ServerOptions *options, |
| 1616 | struct connection_info *connectinfo) |
Darren Tucker | 645ab75 | 2004-06-25 13:33:20 +1000 | [diff] [blame] | 1617 | { |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 1618 | ServerOptions mo; |
| 1619 | |
| 1620 | initialize_server_options(&mo); |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 1621 | parse_server_config(&mo, "reprocess config", &cfg, connectinfo); |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 1622 | copy_set_server_options(options, &mo, 0); |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 1623 | } |
| 1624 | |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 1625 | int parse_server_match_testspec(struct connection_info *ci, char *spec) |
| 1626 | { |
| 1627 | char *p; |
| 1628 | |
| 1629 | while ((p = strsep(&spec, ",")) && *p != '\0') { |
| 1630 | if (strncmp(p, "addr=", 5) == 0) { |
| 1631 | ci->address = xstrdup(p + 5); |
| 1632 | } else if (strncmp(p, "host=", 5) == 0) { |
| 1633 | ci->host = xstrdup(p + 5); |
| 1634 | } else if (strncmp(p, "user=", 5) == 0) { |
| 1635 | ci->user = xstrdup(p + 5); |
| 1636 | } else if (strncmp(p, "laddr=", 6) == 0) { |
| 1637 | ci->laddress = xstrdup(p + 6); |
| 1638 | } else if (strncmp(p, "lport=", 6) == 0) { |
| 1639 | ci->lport = a2port(p + 6); |
| 1640 | if (ci->lport == -1) { |
| 1641 | fprintf(stderr, "Invalid port '%s' in test mode" |
| 1642 | " specification %s\n", p+6, p); |
| 1643 | return -1; |
| 1644 | } |
| 1645 | } else { |
| 1646 | fprintf(stderr, "Invalid test mode specification %s\n", |
| 1647 | p); |
| 1648 | return -1; |
| 1649 | } |
| 1650 | } |
| 1651 | return 0; |
| 1652 | } |
| 1653 | |
| 1654 | /* |
| 1655 | * returns 1 for a complete spec, 0 for partial spec and -1 for an |
| 1656 | * empty spec. |
| 1657 | */ |
| 1658 | int server_match_spec_complete(struct connection_info *ci) |
| 1659 | { |
| 1660 | if (ci->user && ci->host && ci->address) |
| 1661 | return 1; /* complete */ |
| 1662 | if (!ci->user && !ci->host && !ci->address) |
| 1663 | return -1; /* empty */ |
| 1664 | return 0; /* partial */ |
| 1665 | } |
| 1666 | |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 1667 | /* Helper macros */ |
| 1668 | #define M_CP_INTOPT(n) do {\ |
| 1669 | if (src->n != -1) \ |
| 1670 | dst->n = src->n; \ |
| 1671 | } while (0) |
| 1672 | #define M_CP_STROPT(n) do {\ |
| 1673 | if (src->n != NULL) { \ |
| 1674 | if (dst->n != NULL) \ |
| 1675 | xfree(dst->n); \ |
| 1676 | dst->n = src->n; \ |
| 1677 | } \ |
| 1678 | } while(0) |
Damien Miller | d8478b6 | 2011-05-29 21:39:36 +1000 | [diff] [blame] | 1679 | #define M_CP_STRARRAYOPT(n, num_n) do {\ |
| 1680 | if (src->num_n != 0) { \ |
| 1681 | for (dst->num_n = 0; dst->num_n < src->num_n; dst->num_n++) \ |
| 1682 | dst->n[dst->num_n] = xstrdup(src->n[dst->num_n]); \ |
| 1683 | } \ |
| 1684 | } while(0) |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 1685 | |
| 1686 | /* |
| 1687 | * Copy any supported values that are set. |
| 1688 | * |
Darren Tucker | 3b59dfa | 2009-06-21 17:54:47 +1000 | [diff] [blame] | 1689 | * If the preauth flag is set, we do not bother copying the string or |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 1690 | * array values that are not used pre-authentication, because any that we |
| 1691 | * do use must be explictly sent in mm_getpwnamallow(). |
| 1692 | */ |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 1693 | void |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 1694 | copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth) |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 1695 | { |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 1696 | M_CP_INTOPT(password_authentication); |
| 1697 | M_CP_INTOPT(gss_authentication); |
| 1698 | M_CP_INTOPT(rsa_authentication); |
| 1699 | M_CP_INTOPT(pubkey_authentication); |
| 1700 | M_CP_INTOPT(kerberos_authentication); |
| 1701 | M_CP_INTOPT(hostbased_authentication); |
Damien Miller | ab6de35 | 2010-06-26 09:38:45 +1000 | [diff] [blame] | 1702 | M_CP_INTOPT(hostbased_uses_name_from_packet_only); |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 1703 | M_CP_INTOPT(kbd_interactive_authentication); |
Damien Miller | 01ed227 | 2008-11-05 16:20:46 +1100 | [diff] [blame] | 1704 | M_CP_INTOPT(zero_knowledge_password_authentication); |
Damien Miller | 09d3e12 | 2012-10-31 08:58:58 +1100 | [diff] [blame] | 1705 | M_CP_STROPT(authorized_keys_command); |
| 1706 | M_CP_STROPT(authorized_keys_command_user); |
Darren Tucker | 15f9427 | 2008-01-01 20:36:56 +1100 | [diff] [blame] | 1707 | M_CP_INTOPT(permit_root_login); |
Damien Miller | 51bde60 | 2008-11-03 19:23:10 +1100 | [diff] [blame] | 1708 | M_CP_INTOPT(permit_empty_passwd); |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 1709 | |
| 1710 | M_CP_INTOPT(allow_tcp_forwarding); |
Damien Miller | 4f755cd | 2008-05-19 14:57:41 +1000 | [diff] [blame] | 1711 | M_CP_INTOPT(allow_agent_forwarding); |
Damien Miller | ab6de35 | 2010-06-26 09:38:45 +1000 | [diff] [blame] | 1712 | M_CP_INTOPT(permit_tun); |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 1713 | M_CP_INTOPT(gateway_ports); |
| 1714 | M_CP_INTOPT(x11_display_offset); |
| 1715 | M_CP_INTOPT(x11_forwarding); |
| 1716 | M_CP_INTOPT(x11_use_localhost); |
Damien Miller | 7207f64 | 2008-05-19 15:34:50 +1000 | [diff] [blame] | 1717 | M_CP_INTOPT(max_sessions); |
Damien Miller | 307c1d1 | 2008-06-16 07:56:20 +1000 | [diff] [blame] | 1718 | M_CP_INTOPT(max_authtries); |
Damien Miller | 0dac6fb | 2010-11-20 15:19:38 +1100 | [diff] [blame] | 1719 | M_CP_INTOPT(ip_qos_interactive); |
| 1720 | M_CP_INTOPT(ip_qos_bulk); |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 1721 | |
Damien Miller | f2e407e | 2011-05-20 19:04:14 +1000 | [diff] [blame] | 1722 | /* See comment in servconf.h */ |
| 1723 | COPY_MATCH_STRING_OPTS(); |
Damien Miller | 5d74e58 | 2011-05-20 19:03:31 +1000 | [diff] [blame] | 1724 | |
Damien Miller | c241190 | 2011-05-20 19:03:49 +1000 | [diff] [blame] | 1725 | /* |
| 1726 | * The only things that should be below this point are string options |
| 1727 | * which are only used after authentication. |
| 1728 | */ |
Damien Miller | 5d74e58 | 2011-05-20 19:03:31 +1000 | [diff] [blame] | 1729 | if (preauth) |
| 1730 | return; |
Damien Miller | d8478b6 | 2011-05-29 21:39:36 +1000 | [diff] [blame] | 1731 | |
Damien Miller | 5d74e58 | 2011-05-20 19:03:31 +1000 | [diff] [blame] | 1732 | M_CP_STROPT(adm_forced_command); |
| 1733 | M_CP_STROPT(chroot_directory); |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 1734 | } |
| 1735 | |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 1736 | #undef M_CP_INTOPT |
| 1737 | #undef M_CP_STROPT |
Damien Miller | d8478b6 | 2011-05-29 21:39:36 +1000 | [diff] [blame] | 1738 | #undef M_CP_STRARRAYOPT |
Darren Tucker | 1629c07 | 2007-02-19 22:25:37 +1100 | [diff] [blame] | 1739 | |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 1740 | void |
| 1741 | parse_server_config(ServerOptions *options, const char *filename, Buffer *conf, |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 1742 | struct connection_info *connectinfo) |
Darren Tucker | 4515047 | 2006-07-12 22:34:17 +1000 | [diff] [blame] | 1743 | { |
| 1744 | int active, linenum, bad_options = 0; |
Darren Tucker | 9fbac71 | 2004-08-12 22:41:44 +1000 | [diff] [blame] | 1745 | char *cp, *obuf, *cbuf; |
Darren Tucker | 645ab75 | 2004-06-25 13:33:20 +1000 | [diff] [blame] | 1746 | |
| 1747 | debug2("%s: config %s len %d", __func__, filename, buffer_len(conf)); |
| 1748 | |
Darren Tucker | 9fbac71 | 2004-08-12 22:41:44 +1000 | [diff] [blame] | 1749 | obuf = cbuf = xstrdup(buffer_ptr(conf)); |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 1750 | active = connectinfo ? 0 : 1; |
Darren Tucker | 137e9c9 | 2004-08-13 21:30:24 +1000 | [diff] [blame] | 1751 | linenum = 1; |
Darren Tucker | 47eede7 | 2005-03-14 23:08:12 +1100 | [diff] [blame] | 1752 | while ((cp = strsep(&cbuf, "\n")) != NULL) { |
Darren Tucker | 645ab75 | 2004-06-25 13:33:20 +1000 | [diff] [blame] | 1753 | if (process_server_config_line(options, cp, filename, |
Darren Tucker | fbcf827 | 2012-05-19 19:37:01 +1000 | [diff] [blame] | 1754 | linenum++, &active, connectinfo) != 0) |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 1755 | bad_options++; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1756 | } |
Darren Tucker | 9fbac71 | 2004-08-12 22:41:44 +1000 | [diff] [blame] | 1757 | xfree(obuf); |
Ben Lindstrom | b5cdc66 | 2001-04-16 02:13:26 +0000 | [diff] [blame] | 1758 | if (bad_options > 0) |
| 1759 | fatal("%s: terminating, %d bad configuration options", |
| 1760 | filename, bad_options); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1761 | } |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1762 | |
| 1763 | static const char * |
Damien Miller | 82c5587 | 2011-06-23 08:20:30 +1000 | [diff] [blame] | 1764 | fmt_multistate_int(int val, const struct multistate *m) |
| 1765 | { |
| 1766 | u_int i; |
| 1767 | |
| 1768 | for (i = 0; m[i].key != NULL; i++) { |
| 1769 | if (m[i].value == val) |
| 1770 | return m[i].key; |
| 1771 | } |
| 1772 | return "UNKNOWN"; |
| 1773 | } |
| 1774 | |
| 1775 | static const char * |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1776 | fmt_intarg(ServerOpCodes code, int val) |
| 1777 | { |
Damien Miller | 82c5587 | 2011-06-23 08:20:30 +1000 | [diff] [blame] | 1778 | if (val == -1) |
| 1779 | return "unset"; |
| 1780 | switch (code) { |
| 1781 | case sAddressFamily: |
| 1782 | return fmt_multistate_int(val, multistate_addressfamily); |
| 1783 | case sPermitRootLogin: |
| 1784 | return fmt_multistate_int(val, multistate_permitrootlogin); |
| 1785 | case sGatewayPorts: |
| 1786 | return fmt_multistate_int(val, multistate_gatewayports); |
| 1787 | case sCompression: |
| 1788 | return fmt_multistate_int(val, multistate_compression); |
Damien Miller | 69ff1df | 2011-06-23 08:30:03 +1000 | [diff] [blame] | 1789 | case sUsePrivilegeSeparation: |
| 1790 | return fmt_multistate_int(val, multistate_privsep); |
Damien Miller | aa5b3f8 | 2012-12-03 09:50:54 +1100 | [diff] [blame] | 1791 | case sAllowTcpForwarding: |
| 1792 | return fmt_multistate_int(val, multistate_tcpfwd); |
Damien Miller | 82c5587 | 2011-06-23 08:20:30 +1000 | [diff] [blame] | 1793 | case sProtocol: |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1794 | switch (val) { |
| 1795 | case SSH_PROTO_1: |
| 1796 | return "1"; |
| 1797 | case SSH_PROTO_2: |
| 1798 | return "2"; |
| 1799 | case (SSH_PROTO_1|SSH_PROTO_2): |
| 1800 | return "2,1"; |
| 1801 | default: |
| 1802 | return "UNKNOWN"; |
| 1803 | } |
Damien Miller | 82c5587 | 2011-06-23 08:20:30 +1000 | [diff] [blame] | 1804 | default: |
| 1805 | switch (val) { |
| 1806 | case 0: |
| 1807 | return "no"; |
| 1808 | case 1: |
| 1809 | return "yes"; |
| 1810 | default: |
| 1811 | return "UNKNOWN"; |
| 1812 | } |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1813 | } |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1814 | } |
| 1815 | |
| 1816 | static const char * |
| 1817 | lookup_opcode_name(ServerOpCodes code) |
| 1818 | { |
| 1819 | u_int i; |
| 1820 | |
| 1821 | for (i = 0; keywords[i].name != NULL; i++) |
| 1822 | if (keywords[i].opcode == code) |
| 1823 | return(keywords[i].name); |
| 1824 | return "UNKNOWN"; |
| 1825 | } |
| 1826 | |
| 1827 | static void |
| 1828 | dump_cfg_int(ServerOpCodes code, int val) |
| 1829 | { |
| 1830 | printf("%s %d\n", lookup_opcode_name(code), val); |
| 1831 | } |
| 1832 | |
| 1833 | static void |
| 1834 | dump_cfg_fmtint(ServerOpCodes code, int val) |
| 1835 | { |
| 1836 | printf("%s %s\n", lookup_opcode_name(code), fmt_intarg(code, val)); |
| 1837 | } |
| 1838 | |
| 1839 | static void |
| 1840 | dump_cfg_string(ServerOpCodes code, const char *val) |
| 1841 | { |
| 1842 | if (val == NULL) |
| 1843 | return; |
| 1844 | printf("%s %s\n", lookup_opcode_name(code), val); |
| 1845 | } |
| 1846 | |
| 1847 | static void |
| 1848 | dump_cfg_strarray(ServerOpCodes code, u_int count, char **vals) |
| 1849 | { |
| 1850 | u_int i; |
| 1851 | |
| 1852 | for (i = 0; i < count; i++) |
Damien Miller | d8478b6 | 2011-05-29 21:39:36 +1000 | [diff] [blame] | 1853 | printf("%s %s\n", lookup_opcode_name(code), vals[i]); |
| 1854 | } |
| 1855 | |
| 1856 | static void |
| 1857 | dump_cfg_strarray_oneline(ServerOpCodes code, u_int count, char **vals) |
| 1858 | { |
| 1859 | u_int i; |
| 1860 | |
| 1861 | printf("%s", lookup_opcode_name(code)); |
| 1862 | for (i = 0; i < count; i++) |
| 1863 | printf(" %s", vals[i]); |
| 1864 | printf("\n"); |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1865 | } |
| 1866 | |
| 1867 | void |
| 1868 | dump_config(ServerOptions *o) |
| 1869 | { |
| 1870 | u_int i; |
| 1871 | int ret; |
| 1872 | struct addrinfo *ai; |
| 1873 | char addr[NI_MAXHOST], port[NI_MAXSERV], *s = NULL; |
| 1874 | |
| 1875 | /* these are usually at the top of the config */ |
| 1876 | for (i = 0; i < o->num_ports; i++) |
| 1877 | printf("port %d\n", o->ports[i]); |
| 1878 | dump_cfg_fmtint(sProtocol, o->protocol); |
| 1879 | dump_cfg_fmtint(sAddressFamily, o->address_family); |
| 1880 | |
| 1881 | /* ListenAddress must be after Port */ |
| 1882 | for (ai = o->listen_addrs; ai; ai = ai->ai_next) { |
| 1883 | if ((ret = getnameinfo(ai->ai_addr, ai->ai_addrlen, addr, |
| 1884 | sizeof(addr), port, sizeof(port), |
| 1885 | NI_NUMERICHOST|NI_NUMERICSERV)) != 0) { |
| 1886 | error("getnameinfo failed: %.100s", |
| 1887 | (ret != EAI_SYSTEM) ? gai_strerror(ret) : |
| 1888 | strerror(errno)); |
| 1889 | } else { |
| 1890 | if (ai->ai_family == AF_INET6) |
| 1891 | printf("listenaddress [%s]:%s\n", addr, port); |
| 1892 | else |
| 1893 | printf("listenaddress %s:%s\n", addr, port); |
| 1894 | } |
| 1895 | } |
| 1896 | |
| 1897 | /* integer arguments */ |
Damien Miller | 212f0b0 | 2008-07-23 17:42:29 +1000 | [diff] [blame] | 1898 | #ifdef USE_PAM |
| 1899 | dump_cfg_int(sUsePAM, o->use_pam); |
| 1900 | #endif |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1901 | dump_cfg_int(sServerKeyBits, o->server_key_bits); |
| 1902 | dump_cfg_int(sLoginGraceTime, o->login_grace_time); |
| 1903 | dump_cfg_int(sKeyRegenerationTime, o->key_regeneration_time); |
| 1904 | dump_cfg_int(sX11DisplayOffset, o->x11_display_offset); |
| 1905 | dump_cfg_int(sMaxAuthTries, o->max_authtries); |
Damien Miller | 7fc5c0f | 2008-11-05 16:12:11 +1100 | [diff] [blame] | 1906 | dump_cfg_int(sMaxSessions, o->max_sessions); |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1907 | dump_cfg_int(sClientAliveInterval, o->client_alive_interval); |
| 1908 | dump_cfg_int(sClientAliveCountMax, o->client_alive_count_max); |
| 1909 | |
| 1910 | /* formatted integer arguments */ |
| 1911 | dump_cfg_fmtint(sPermitRootLogin, o->permit_root_login); |
| 1912 | dump_cfg_fmtint(sIgnoreRhosts, o->ignore_rhosts); |
| 1913 | dump_cfg_fmtint(sIgnoreUserKnownHosts, o->ignore_user_known_hosts); |
| 1914 | dump_cfg_fmtint(sRhostsRSAAuthentication, o->rhosts_rsa_authentication); |
| 1915 | dump_cfg_fmtint(sHostbasedAuthentication, o->hostbased_authentication); |
| 1916 | dump_cfg_fmtint(sHostbasedUsesNameFromPacketOnly, |
| 1917 | o->hostbased_uses_name_from_packet_only); |
| 1918 | dump_cfg_fmtint(sRSAAuthentication, o->rsa_authentication); |
| 1919 | dump_cfg_fmtint(sPubkeyAuthentication, o->pubkey_authentication); |
Damien Miller | 6ef430d | 2008-07-23 17:40:04 +1000 | [diff] [blame] | 1920 | #ifdef KRB5 |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1921 | dump_cfg_fmtint(sKerberosAuthentication, o->kerberos_authentication); |
| 1922 | dump_cfg_fmtint(sKerberosOrLocalPasswd, o->kerberos_or_local_passwd); |
| 1923 | dump_cfg_fmtint(sKerberosTicketCleanup, o->kerberos_ticket_cleanup); |
Damien Miller | 6ef430d | 2008-07-23 17:40:04 +1000 | [diff] [blame] | 1924 | # ifdef USE_AFS |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1925 | dump_cfg_fmtint(sKerberosGetAFSToken, o->kerberos_get_afs_token); |
Damien Miller | 6ef430d | 2008-07-23 17:40:04 +1000 | [diff] [blame] | 1926 | # endif |
| 1927 | #endif |
| 1928 | #ifdef GSSAPI |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1929 | dump_cfg_fmtint(sGssAuthentication, o->gss_authentication); |
| 1930 | dump_cfg_fmtint(sGssCleanupCreds, o->gss_cleanup_creds); |
Damien Miller | 6ef430d | 2008-07-23 17:40:04 +1000 | [diff] [blame] | 1931 | #endif |
Damien Miller | 01ed227 | 2008-11-05 16:20:46 +1100 | [diff] [blame] | 1932 | #ifdef JPAKE |
| 1933 | dump_cfg_fmtint(sZeroKnowledgePasswordAuthentication, |
| 1934 | o->zero_knowledge_password_authentication); |
| 1935 | #endif |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1936 | dump_cfg_fmtint(sPasswordAuthentication, o->password_authentication); |
| 1937 | dump_cfg_fmtint(sKbdInteractiveAuthentication, |
| 1938 | o->kbd_interactive_authentication); |
| 1939 | dump_cfg_fmtint(sChallengeResponseAuthentication, |
| 1940 | o->challenge_response_authentication); |
| 1941 | dump_cfg_fmtint(sPrintMotd, o->print_motd); |
| 1942 | dump_cfg_fmtint(sPrintLastLog, o->print_lastlog); |
| 1943 | dump_cfg_fmtint(sX11Forwarding, o->x11_forwarding); |
| 1944 | dump_cfg_fmtint(sX11UseLocalhost, o->x11_use_localhost); |
| 1945 | dump_cfg_fmtint(sStrictModes, o->strict_modes); |
| 1946 | dump_cfg_fmtint(sTCPKeepAlive, o->tcp_keep_alive); |
| 1947 | dump_cfg_fmtint(sEmptyPasswd, o->permit_empty_passwd); |
| 1948 | dump_cfg_fmtint(sPermitUserEnvironment, o->permit_user_env); |
| 1949 | dump_cfg_fmtint(sUseLogin, o->use_login); |
| 1950 | dump_cfg_fmtint(sCompression, o->compression); |
| 1951 | dump_cfg_fmtint(sGatewayPorts, o->gateway_ports); |
| 1952 | dump_cfg_fmtint(sUseDNS, o->use_dns); |
| 1953 | dump_cfg_fmtint(sAllowTcpForwarding, o->allow_tcp_forwarding); |
| 1954 | dump_cfg_fmtint(sUsePrivilegeSeparation, use_privsep); |
| 1955 | |
| 1956 | /* string arguments */ |
| 1957 | dump_cfg_string(sPidFile, o->pid_file); |
| 1958 | dump_cfg_string(sXAuthLocation, o->xauth_location); |
| 1959 | dump_cfg_string(sCiphers, o->ciphers); |
| 1960 | dump_cfg_string(sMacs, o->macs); |
| 1961 | dump_cfg_string(sBanner, o->banner); |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1962 | dump_cfg_string(sForceCommand, o->adm_forced_command); |
Darren Tucker | d330045 | 2010-01-10 19:26:43 +1100 | [diff] [blame] | 1963 | dump_cfg_string(sChrootDirectory, o->chroot_directory); |
Damien Miller | 1aed65e | 2010-03-04 21:53:35 +1100 | [diff] [blame] | 1964 | dump_cfg_string(sTrustedUserCAKeys, o->trusted_user_ca_keys); |
| 1965 | dump_cfg_string(sRevokedKeys, o->revoked_keys_file); |
Damien Miller | 30da344 | 2010-05-10 11:58:03 +1000 | [diff] [blame] | 1966 | dump_cfg_string(sAuthorizedPrincipalsFile, |
| 1967 | o->authorized_principals_file); |
Damien Miller | 2352881 | 2012-04-22 11:24:43 +1000 | [diff] [blame] | 1968 | dump_cfg_string(sVersionAddendum, o->version_addendum); |
Damien Miller | 09d3e12 | 2012-10-31 08:58:58 +1100 | [diff] [blame] | 1969 | dump_cfg_string(sAuthorizedKeysCommand, o->authorized_keys_command); |
| 1970 | dump_cfg_string(sAuthorizedKeysCommandUser, o->authorized_keys_command_user); |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1971 | |
| 1972 | /* string arguments requiring a lookup */ |
| 1973 | dump_cfg_string(sLogLevel, log_level_name(o->log_level)); |
| 1974 | dump_cfg_string(sLogFacility, log_facility_name(o->log_facility)); |
| 1975 | |
| 1976 | /* string array arguments */ |
Damien Miller | d8478b6 | 2011-05-29 21:39:36 +1000 | [diff] [blame] | 1977 | dump_cfg_strarray_oneline(sAuthorizedKeysFile, o->num_authkeys_files, |
| 1978 | o->authorized_keys_files); |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1979 | dump_cfg_strarray(sHostKeyFile, o->num_host_key_files, |
| 1980 | o->host_key_files); |
Damien Miller | 0a80ca1 | 2010-02-27 07:55:05 +1100 | [diff] [blame] | 1981 | dump_cfg_strarray(sHostKeyFile, o->num_host_cert_files, |
| 1982 | o->host_cert_files); |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1983 | dump_cfg_strarray(sAllowUsers, o->num_allow_users, o->allow_users); |
| 1984 | dump_cfg_strarray(sDenyUsers, o->num_deny_users, o->deny_users); |
| 1985 | dump_cfg_strarray(sAllowGroups, o->num_allow_groups, o->allow_groups); |
| 1986 | dump_cfg_strarray(sDenyGroups, o->num_deny_groups, o->deny_groups); |
| 1987 | dump_cfg_strarray(sAcceptEnv, o->num_accept_env, o->accept_env); |
Damien Miller | a6e3f01 | 2012-11-04 23:21:40 +1100 | [diff] [blame] | 1988 | dump_cfg_strarray_oneline(sAuthenticationMethods, |
| 1989 | o->num_auth_methods, o->auth_methods); |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 1990 | |
| 1991 | /* other arguments */ |
| 1992 | for (i = 0; i < o->num_subsystems; i++) |
| 1993 | printf("subsystem %s %s\n", o->subsystem_name[i], |
| 1994 | o->subsystem_args[i]); |
| 1995 | |
| 1996 | printf("maxstartups %d:%d:%d\n", o->max_startups_begin, |
| 1997 | o->max_startups_rate, o->max_startups); |
| 1998 | |
| 1999 | for (i = 0; tunmode_desc[i].val != -1; i++) |
| 2000 | if (tunmode_desc[i].val == o->permit_tun) { |
| 2001 | s = tunmode_desc[i].text; |
| 2002 | break; |
| 2003 | } |
| 2004 | dump_cfg_string(sPermitTunnel, s); |
| 2005 | |
Damien Miller | 9147586 | 2011-05-05 14:14:34 +1000 | [diff] [blame] | 2006 | printf("ipqos %s ", iptos2str(o->ip_qos_interactive)); |
| 2007 | printf("%s\n", iptos2str(o->ip_qos_bulk)); |
Damien Miller | 0dac6fb | 2010-11-20 15:19:38 +1100 | [diff] [blame] | 2008 | |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 2009 | channel_print_adm_permitted_opens(); |
Darren Tucker | e7140f2 | 2008-06-10 23:01:51 +1000 | [diff] [blame] | 2010 | } |