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