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