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