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