10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 30Sstevel@tonic-gate * All rights reserved 40Sstevel@tonic-gate * 50Sstevel@tonic-gate * As far as I am concerned, the code I have written for this software 60Sstevel@tonic-gate * can be used freely for any purpose. Any derived versions of this 70Sstevel@tonic-gate * software must be clearly marked as such, and if the derived work is 80Sstevel@tonic-gate * incompatible with the protocol description in the RFC file, it must be 90Sstevel@tonic-gate * called by a name other than "ssh" or "Secure Shell". 100Sstevel@tonic-gate */ 110Sstevel@tonic-gate /* 12*9139SJan.Pechanec@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 130Sstevel@tonic-gate * Use is subject to license terms. 140Sstevel@tonic-gate */ 150Sstevel@tonic-gate 160Sstevel@tonic-gate #include "includes.h" 170Sstevel@tonic-gate RCSID("$OpenBSD: servconf.c,v 1.115 2002/09/04 18:52:42 stevesk Exp $"); 180Sstevel@tonic-gate 190Sstevel@tonic-gate #ifdef HAVE_DEFOPEN 200Sstevel@tonic-gate #include <deflt.h> 210Sstevel@tonic-gate #endif /* HAVE_DEFOPEN */ 220Sstevel@tonic-gate 230Sstevel@tonic-gate #if defined(KRB4) 240Sstevel@tonic-gate #include <krb.h> 250Sstevel@tonic-gate #endif 260Sstevel@tonic-gate #if defined(KRB5) 270Sstevel@tonic-gate #ifdef HEIMDAL 280Sstevel@tonic-gate #include <krb.h> 290Sstevel@tonic-gate #else 300Sstevel@tonic-gate /* Bodge - but then, so is using the kerberos IV KEYFILE to get a Kerberos V 310Sstevel@tonic-gate * keytab */ 320Sstevel@tonic-gate #define KEYFILE "/etc/krb5.keytab" 330Sstevel@tonic-gate #endif 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate #ifdef AFS 360Sstevel@tonic-gate #include <kafs.h> 370Sstevel@tonic-gate #endif 380Sstevel@tonic-gate 390Sstevel@tonic-gate #include "ssh.h" 400Sstevel@tonic-gate #include "log.h" 410Sstevel@tonic-gate #include "servconf.h" 420Sstevel@tonic-gate #include "xmalloc.h" 430Sstevel@tonic-gate #include "compat.h" 440Sstevel@tonic-gate #include "pathnames.h" 450Sstevel@tonic-gate #include "tildexpand.h" 460Sstevel@tonic-gate #include "misc.h" 470Sstevel@tonic-gate #include "cipher.h" 480Sstevel@tonic-gate #include "kex.h" 490Sstevel@tonic-gate #include "mac.h" 500Sstevel@tonic-gate #include "auth.h" 510Sstevel@tonic-gate 520Sstevel@tonic-gate static void add_listen_addr(ServerOptions *, char *, u_short); 530Sstevel@tonic-gate static void add_one_listen_addr(ServerOptions *, char *, u_short); 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* AF_UNSPEC or AF_INET or AF_INET6 */ 560Sstevel@tonic-gate extern int IPv4or6; 570Sstevel@tonic-gate 58*9139SJan.Pechanec@Sun.COM /* 59*9139SJan.Pechanec@Sun.COM * Initializes the server options to their initial (unset) values. Some of those 60*9139SJan.Pechanec@Sun.COM * that stay unset after the command line options and configuration files are 61*9139SJan.Pechanec@Sun.COM * read are set to their default values in fill_default_server_options(). 62*9139SJan.Pechanec@Sun.COM */ 630Sstevel@tonic-gate void 640Sstevel@tonic-gate initialize_server_options(ServerOptions *options) 650Sstevel@tonic-gate { 660Sstevel@tonic-gate (void) memset(options, 0, sizeof(*options)); 670Sstevel@tonic-gate 680Sstevel@tonic-gate /* Portable-specific options */ 690Sstevel@tonic-gate options->pam_authentication_via_kbd_int = -1; 700Sstevel@tonic-gate 710Sstevel@tonic-gate /* Standard Options */ 720Sstevel@tonic-gate options->num_ports = 0; 730Sstevel@tonic-gate options->ports_from_cmdline = 0; 740Sstevel@tonic-gate options->listen_addrs = NULL; 750Sstevel@tonic-gate options->num_host_key_files = 0; 760Sstevel@tonic-gate options->pid_file = NULL; 770Sstevel@tonic-gate options->server_key_bits = -1; 780Sstevel@tonic-gate options->login_grace_time = -1; 790Sstevel@tonic-gate options->key_regeneration_time = -1; 800Sstevel@tonic-gate options->permit_root_login = PERMIT_NOT_SET; 810Sstevel@tonic-gate options->ignore_rhosts = -1; 820Sstevel@tonic-gate options->ignore_user_known_hosts = -1; 830Sstevel@tonic-gate options->print_motd = -1; 840Sstevel@tonic-gate options->print_lastlog = -1; 850Sstevel@tonic-gate options->x11_forwarding = -1; 860Sstevel@tonic-gate options->x11_display_offset = -1; 870Sstevel@tonic-gate options->x11_use_localhost = -1; 880Sstevel@tonic-gate options->xauth_location = NULL; 890Sstevel@tonic-gate options->strict_modes = -1; 900Sstevel@tonic-gate options->keepalives = -1; 910Sstevel@tonic-gate options->log_facility = SYSLOG_FACILITY_NOT_SET; 920Sstevel@tonic-gate options->log_level = SYSLOG_LEVEL_NOT_SET; 930Sstevel@tonic-gate options->rhosts_authentication = -1; 940Sstevel@tonic-gate options->rhosts_rsa_authentication = -1; 950Sstevel@tonic-gate options->hostbased_authentication = -1; 960Sstevel@tonic-gate options->hostbased_uses_name_from_packet_only = -1; 970Sstevel@tonic-gate options->rsa_authentication = -1; 980Sstevel@tonic-gate options->pubkey_authentication = -1; 990Sstevel@tonic-gate #ifdef GSSAPI 1000Sstevel@tonic-gate options->gss_authentication = -1; 1010Sstevel@tonic-gate options->gss_keyex = -1; 1020Sstevel@tonic-gate options->gss_store_creds = -1; 1030Sstevel@tonic-gate options->gss_use_session_ccache = -1; 1040Sstevel@tonic-gate options->gss_cleanup_creds = -1; 1050Sstevel@tonic-gate #endif 1060Sstevel@tonic-gate #if defined(KRB4) || defined(KRB5) 1070Sstevel@tonic-gate options->kerberos_authentication = -1; 1080Sstevel@tonic-gate options->kerberos_or_local_passwd = -1; 1090Sstevel@tonic-gate options->kerberos_ticket_cleanup = -1; 1100Sstevel@tonic-gate #endif 1110Sstevel@tonic-gate #if defined(AFS) || defined(KRB5) 1120Sstevel@tonic-gate options->kerberos_tgt_passing = -1; 1130Sstevel@tonic-gate #endif 1140Sstevel@tonic-gate #ifdef AFS 1150Sstevel@tonic-gate options->afs_token_passing = -1; 1160Sstevel@tonic-gate #endif 1170Sstevel@tonic-gate options->password_authentication = -1; 1180Sstevel@tonic-gate options->kbd_interactive_authentication = -1; 1190Sstevel@tonic-gate options->challenge_response_authentication = -1; 1200Sstevel@tonic-gate options->permit_empty_passwd = -1; 1210Sstevel@tonic-gate options->permit_user_env = -1; 1220Sstevel@tonic-gate options->use_login = -1; 1230Sstevel@tonic-gate options->compression = -1; 1240Sstevel@tonic-gate options->allow_tcp_forwarding = -1; 1250Sstevel@tonic-gate options->num_allow_users = 0; 1260Sstevel@tonic-gate options->num_deny_users = 0; 1270Sstevel@tonic-gate options->num_allow_groups = 0; 1280Sstevel@tonic-gate options->num_deny_groups = 0; 1290Sstevel@tonic-gate options->ciphers = NULL; 1300Sstevel@tonic-gate options->macs = NULL; 1310Sstevel@tonic-gate options->protocol = SSH_PROTO_UNKNOWN; 1320Sstevel@tonic-gate options->gateway_ports = -1; 1330Sstevel@tonic-gate options->num_subsystems = 0; 1340Sstevel@tonic-gate options->max_startups_begin = -1; 1350Sstevel@tonic-gate options->max_startups_rate = -1; 1360Sstevel@tonic-gate options->max_startups = -1; 1370Sstevel@tonic-gate options->banner = NULL; 1380Sstevel@tonic-gate options->verify_reverse_mapping = -1; 1390Sstevel@tonic-gate options->client_alive_interval = -1; 1400Sstevel@tonic-gate options->client_alive_count_max = -1; 1410Sstevel@tonic-gate options->authorized_keys_file = NULL; 1420Sstevel@tonic-gate options->authorized_keys_file2 = NULL; 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate options->max_auth_tries = -1; 1450Sstevel@tonic-gate options->max_auth_tries_log = -1; 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate options->max_init_auth_tries = -1; 1480Sstevel@tonic-gate options->max_init_auth_tries_log = -1; 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate options->lookup_client_hostnames = -1; 1517574SJan.Pechanec@Sun.COM options->use_openssl_engine = -1; 152*9139SJan.Pechanec@Sun.COM options->chroot_directory = NULL; 1530Sstevel@tonic-gate } 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate #ifdef HAVE_DEFOPEN 1560Sstevel@tonic-gate /* 1570Sstevel@tonic-gate * Reads /etc/default/login and defaults several ServerOptions: 1580Sstevel@tonic-gate * 1590Sstevel@tonic-gate * PermitRootLogin 1600Sstevel@tonic-gate * PermitEmptyPasswords 1610Sstevel@tonic-gate * LoginGraceTime 1620Sstevel@tonic-gate * 1630Sstevel@tonic-gate * CONSOLE=* -> PermitRootLogin=without-password 1640Sstevel@tonic-gate * #CONSOLE=* -> PermitRootLogin=yes 1650Sstevel@tonic-gate * 1660Sstevel@tonic-gate * PASSREQ=YES -> PermitEmptyPasswords=no 1670Sstevel@tonic-gate * PASSREQ=NO -> PermitEmptyPasswords=yes 1680Sstevel@tonic-gate * #PASSREQ=* -> PermitEmptyPasswords=no 1690Sstevel@tonic-gate * 1700Sstevel@tonic-gate * TIMEOUT=<secs> -> LoginGraceTime=<secs> 1710Sstevel@tonic-gate * #TIMEOUT=<secs> -> LoginGraceTime=300 1720Sstevel@tonic-gate */ 1730Sstevel@tonic-gate static 1740Sstevel@tonic-gate void 1750Sstevel@tonic-gate deflt_fill_default_server_options(ServerOptions *options) 1760Sstevel@tonic-gate { 1770Sstevel@tonic-gate int flags; 1780Sstevel@tonic-gate char *ptr; 1790Sstevel@tonic-gate 1800Sstevel@tonic-gate if (defopen(_PATH_DEFAULT_LOGIN)) 1810Sstevel@tonic-gate return; 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate /* Ignore case */ 1840Sstevel@tonic-gate flags = defcntl(DC_GETFLAGS, 0); 1850Sstevel@tonic-gate TURNOFF(flags, DC_CASE); 1860Sstevel@tonic-gate (void) defcntl(DC_SETFLAGS, flags); 1870Sstevel@tonic-gate 1880Sstevel@tonic-gate if (options->permit_root_login == PERMIT_NOT_SET && 1890Sstevel@tonic-gate (ptr = defread("CONSOLE=")) != NULL) 1900Sstevel@tonic-gate options->permit_root_login = PERMIT_NO_PASSWD; 1910Sstevel@tonic-gate 1920Sstevel@tonic-gate if (options->permit_empty_passwd == -1 && 1930Sstevel@tonic-gate (ptr = defread("PASSREQ=")) != NULL) { 1940Sstevel@tonic-gate if (strcasecmp("YES", ptr) == 0) 1950Sstevel@tonic-gate options->permit_empty_passwd = 0; 1960Sstevel@tonic-gate else if (strcasecmp("NO", ptr) == 0) 1970Sstevel@tonic-gate options->permit_empty_passwd = 1; 1980Sstevel@tonic-gate } 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate if (options->max_init_auth_tries == -1 && 2010Sstevel@tonic-gate (ptr = defread("RETRIES=")) != NULL) { 2020Sstevel@tonic-gate options->max_init_auth_tries = atoi(ptr); 2030Sstevel@tonic-gate } 2040Sstevel@tonic-gate 2050Sstevel@tonic-gate if (options->max_init_auth_tries_log == -1 && 2060Sstevel@tonic-gate (ptr = defread("SYSLOG_FAILED_LOGINS=")) != NULL) { 2070Sstevel@tonic-gate options->max_init_auth_tries_log = atoi(ptr); 2080Sstevel@tonic-gate } 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate if (options->login_grace_time == -1) { 2110Sstevel@tonic-gate if ((ptr = defread("TIMEOUT=")) != NULL) 2120Sstevel@tonic-gate options->login_grace_time = (unsigned)atoi(ptr); 2130Sstevel@tonic-gate else 2140Sstevel@tonic-gate options->login_grace_time = 300; 2150Sstevel@tonic-gate } 2160Sstevel@tonic-gate 2170Sstevel@tonic-gate (void) defopen((char *)NULL); 2180Sstevel@tonic-gate } 2190Sstevel@tonic-gate #endif /* HAVE_DEFOPEN */ 2200Sstevel@tonic-gate 2210Sstevel@tonic-gate void 2220Sstevel@tonic-gate fill_default_server_options(ServerOptions *options) 2230Sstevel@tonic-gate { 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate #ifdef HAVE_DEFOPEN 2260Sstevel@tonic-gate deflt_fill_default_server_options(options); 2270Sstevel@tonic-gate #endif /* HAVE_DEFOPEN */ 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate /* Portable-specific options */ 2300Sstevel@tonic-gate if (options->pam_authentication_via_kbd_int == -1) 2310Sstevel@tonic-gate options->pam_authentication_via_kbd_int = 0; 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate /* Standard Options */ 2340Sstevel@tonic-gate if (options->protocol == SSH_PROTO_UNKNOWN) 2350Sstevel@tonic-gate options->protocol = SSH_PROTO_1|SSH_PROTO_2; 2360Sstevel@tonic-gate if (options->num_host_key_files == 0) { 2370Sstevel@tonic-gate /* fill default hostkeys for protocols */ 2380Sstevel@tonic-gate if (options->protocol & SSH_PROTO_1) 2390Sstevel@tonic-gate options->host_key_files[options->num_host_key_files++] = 2400Sstevel@tonic-gate _PATH_HOST_KEY_FILE; 2410Sstevel@tonic-gate #ifndef GSSAPI 2420Sstevel@tonic-gate /* With GSS keyex we can run v2 w/ no host keys */ 2430Sstevel@tonic-gate if (options->protocol & SSH_PROTO_2) { 2440Sstevel@tonic-gate options->host_key_files[options->num_host_key_files++] = 2450Sstevel@tonic-gate _PATH_HOST_RSA_KEY_FILE; 2460Sstevel@tonic-gate options->host_key_files[options->num_host_key_files++] = 2470Sstevel@tonic-gate _PATH_HOST_DSA_KEY_FILE; 2480Sstevel@tonic-gate } 2490Sstevel@tonic-gate #endif /* GSSAPI */ 2500Sstevel@tonic-gate } 2510Sstevel@tonic-gate if (options->num_ports == 0) 2520Sstevel@tonic-gate options->ports[options->num_ports++] = SSH_DEFAULT_PORT; 2530Sstevel@tonic-gate if (options->listen_addrs == NULL) 2540Sstevel@tonic-gate add_listen_addr(options, NULL, 0); 2550Sstevel@tonic-gate if (options->pid_file == NULL) 2560Sstevel@tonic-gate options->pid_file = _PATH_SSH_DAEMON_PID_FILE; 2570Sstevel@tonic-gate if (options->server_key_bits == -1) 2580Sstevel@tonic-gate options->server_key_bits = 768; 2590Sstevel@tonic-gate if (options->login_grace_time == -1) 2600Sstevel@tonic-gate options->login_grace_time = 120; 2610Sstevel@tonic-gate if (options->key_regeneration_time == -1) 2620Sstevel@tonic-gate options->key_regeneration_time = 3600; 2630Sstevel@tonic-gate if (options->permit_root_login == PERMIT_NOT_SET) 2640Sstevel@tonic-gate options->permit_root_login = PERMIT_YES; 2650Sstevel@tonic-gate if (options->ignore_rhosts == -1) 2660Sstevel@tonic-gate options->ignore_rhosts = 1; 2670Sstevel@tonic-gate if (options->ignore_user_known_hosts == -1) 2680Sstevel@tonic-gate options->ignore_user_known_hosts = 0; 2690Sstevel@tonic-gate if (options->print_motd == -1) 2700Sstevel@tonic-gate options->print_motd = 1; 2710Sstevel@tonic-gate if (options->print_lastlog == -1) 2720Sstevel@tonic-gate options->print_lastlog = 1; 2730Sstevel@tonic-gate if (options->x11_forwarding == -1) 2740Sstevel@tonic-gate options->x11_forwarding = 1; 2750Sstevel@tonic-gate if (options->x11_display_offset == -1) 2760Sstevel@tonic-gate options->x11_display_offset = 10; 2770Sstevel@tonic-gate if (options->x11_use_localhost == -1) 2780Sstevel@tonic-gate options->x11_use_localhost = 1; 2790Sstevel@tonic-gate if (options->xauth_location == NULL) 2800Sstevel@tonic-gate options->xauth_location = _PATH_XAUTH; 2810Sstevel@tonic-gate if (options->strict_modes == -1) 2820Sstevel@tonic-gate options->strict_modes = 1; 2830Sstevel@tonic-gate if (options->keepalives == -1) 2840Sstevel@tonic-gate options->keepalives = 1; 2850Sstevel@tonic-gate if (options->log_facility == SYSLOG_FACILITY_NOT_SET) 2860Sstevel@tonic-gate options->log_facility = SYSLOG_FACILITY_AUTH; 2870Sstevel@tonic-gate if (options->log_level == SYSLOG_LEVEL_NOT_SET) 2880Sstevel@tonic-gate options->log_level = SYSLOG_LEVEL_INFO; 2890Sstevel@tonic-gate if (options->rhosts_authentication == -1) 2900Sstevel@tonic-gate options->rhosts_authentication = 0; 2910Sstevel@tonic-gate if (options->rhosts_rsa_authentication == -1) 2920Sstevel@tonic-gate options->rhosts_rsa_authentication = 0; 2930Sstevel@tonic-gate if (options->hostbased_authentication == -1) 2940Sstevel@tonic-gate options->hostbased_authentication = 0; 2950Sstevel@tonic-gate if (options->hostbased_uses_name_from_packet_only == -1) 2960Sstevel@tonic-gate options->hostbased_uses_name_from_packet_only = 0; 2970Sstevel@tonic-gate if (options->rsa_authentication == -1) 2980Sstevel@tonic-gate options->rsa_authentication = 1; 2990Sstevel@tonic-gate if (options->pubkey_authentication == -1) 3000Sstevel@tonic-gate options->pubkey_authentication = 1; 3010Sstevel@tonic-gate #ifdef GSSAPI 3020Sstevel@tonic-gate if (options->gss_authentication == -1) 3030Sstevel@tonic-gate options->gss_authentication = 1; 3040Sstevel@tonic-gate if (options->gss_keyex == -1) 3050Sstevel@tonic-gate options->gss_keyex = 1; 3060Sstevel@tonic-gate if (options->gss_store_creds == -1) 3070Sstevel@tonic-gate options->gss_store_creds = 1; 3080Sstevel@tonic-gate if (options->gss_use_session_ccache == -1) 3090Sstevel@tonic-gate options->gss_use_session_ccache = 1; 3100Sstevel@tonic-gate if (options->gss_cleanup_creds == -1) 3110Sstevel@tonic-gate options->gss_cleanup_creds = 1; 3120Sstevel@tonic-gate #endif 3130Sstevel@tonic-gate #if defined(KRB4) || defined(KRB5) 3140Sstevel@tonic-gate if (options->kerberos_authentication == -1) 3150Sstevel@tonic-gate options->kerberos_authentication = 0; 3160Sstevel@tonic-gate if (options->kerberos_or_local_passwd == -1) 3170Sstevel@tonic-gate options->kerberos_or_local_passwd = 1; 3180Sstevel@tonic-gate if (options->kerberos_ticket_cleanup == -1) 3190Sstevel@tonic-gate options->kerberos_ticket_cleanup = 1; 3200Sstevel@tonic-gate #endif 3210Sstevel@tonic-gate #if defined(AFS) || defined(KRB5) 3220Sstevel@tonic-gate if (options->kerberos_tgt_passing == -1) 3230Sstevel@tonic-gate options->kerberos_tgt_passing = 0; 3240Sstevel@tonic-gate #endif 3250Sstevel@tonic-gate #ifdef AFS 3260Sstevel@tonic-gate if (options->afs_token_passing == -1) 3270Sstevel@tonic-gate options->afs_token_passing = 0; 3280Sstevel@tonic-gate #endif 3290Sstevel@tonic-gate if (options->password_authentication == -1) 3300Sstevel@tonic-gate options->password_authentication = 1; 3310Sstevel@tonic-gate if (options->kbd_interactive_authentication == -1) 3320Sstevel@tonic-gate options->kbd_interactive_authentication = 0; 3330Sstevel@tonic-gate if (options->challenge_response_authentication == -1) 3340Sstevel@tonic-gate options->challenge_response_authentication = 1; 3350Sstevel@tonic-gate if (options->permit_empty_passwd == -1) 3360Sstevel@tonic-gate options->permit_empty_passwd = 0; 3370Sstevel@tonic-gate if (options->permit_user_env == -1) 3380Sstevel@tonic-gate options->permit_user_env = 0; 3390Sstevel@tonic-gate if (options->use_login == -1) 3400Sstevel@tonic-gate options->use_login = 0; 3410Sstevel@tonic-gate if (options->compression == -1) 3420Sstevel@tonic-gate options->compression = 1; 3430Sstevel@tonic-gate if (options->allow_tcp_forwarding == -1) 3440Sstevel@tonic-gate options->allow_tcp_forwarding = 1; 3450Sstevel@tonic-gate if (options->gateway_ports == -1) 3460Sstevel@tonic-gate options->gateway_ports = 0; 3470Sstevel@tonic-gate if (options->max_startups == -1) 3480Sstevel@tonic-gate options->max_startups = 10; 3490Sstevel@tonic-gate if (options->max_startups_rate == -1) 3500Sstevel@tonic-gate options->max_startups_rate = 100; /* 100% */ 3510Sstevel@tonic-gate if (options->max_startups_begin == -1) 3520Sstevel@tonic-gate options->max_startups_begin = options->max_startups; 3530Sstevel@tonic-gate if (options->verify_reverse_mapping == -1) 3540Sstevel@tonic-gate options->verify_reverse_mapping = 0; 3550Sstevel@tonic-gate if (options->client_alive_interval == -1) 3560Sstevel@tonic-gate options->client_alive_interval = 0; 3570Sstevel@tonic-gate if (options->client_alive_count_max == -1) 3580Sstevel@tonic-gate options->client_alive_count_max = 3; 3590Sstevel@tonic-gate if (options->authorized_keys_file2 == NULL) { 3600Sstevel@tonic-gate /* authorized_keys_file2 falls back to authorized_keys_file */ 3610Sstevel@tonic-gate if (options->authorized_keys_file != NULL) 3620Sstevel@tonic-gate options->authorized_keys_file2 = options->authorized_keys_file; 3630Sstevel@tonic-gate else 3640Sstevel@tonic-gate options->authorized_keys_file2 = _PATH_SSH_USER_PERMITTED_KEYS2; 3650Sstevel@tonic-gate } 3660Sstevel@tonic-gate if (options->authorized_keys_file == NULL) 3670Sstevel@tonic-gate options->authorized_keys_file = _PATH_SSH_USER_PERMITTED_KEYS; 3680Sstevel@tonic-gate 3690Sstevel@tonic-gate if (options->max_auth_tries == -1) 3700Sstevel@tonic-gate options->max_auth_tries = AUTH_FAIL_MAX; 3710Sstevel@tonic-gate if (options->max_auth_tries_log == -1) 3720Sstevel@tonic-gate options->max_auth_tries_log = options->max_auth_tries / 2; 3730Sstevel@tonic-gate 3740Sstevel@tonic-gate if (options->max_init_auth_tries == -1) 3750Sstevel@tonic-gate options->max_init_auth_tries = AUTH_FAIL_MAX; 3760Sstevel@tonic-gate if (options->max_init_auth_tries_log == -1) 3770Sstevel@tonic-gate options->max_init_auth_tries_log = options->max_init_auth_tries / 2; 3780Sstevel@tonic-gate 3790Sstevel@tonic-gate if (options->lookup_client_hostnames == -1) 3800Sstevel@tonic-gate options->lookup_client_hostnames = 1; 3817574SJan.Pechanec@Sun.COM if (options->use_openssl_engine == -1) 3827574SJan.Pechanec@Sun.COM options->use_openssl_engine = 1; 3830Sstevel@tonic-gate } 3840Sstevel@tonic-gate 3850Sstevel@tonic-gate /* Keyword tokens. */ 3860Sstevel@tonic-gate typedef enum { 3870Sstevel@tonic-gate sBadOption, /* == unknown option */ 3880Sstevel@tonic-gate /* Portable-specific options */ 3890Sstevel@tonic-gate sPAMAuthenticationViaKbdInt, 3900Sstevel@tonic-gate /* Standard Options */ 3910Sstevel@tonic-gate sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime, sKeyRegenerationTime, 3920Sstevel@tonic-gate sPermitRootLogin, sLogFacility, sLogLevel, 3930Sstevel@tonic-gate sRhostsAuthentication, sRhostsRSAAuthentication, sRSAAuthentication, 3940Sstevel@tonic-gate #ifdef GSSAPI 3950Sstevel@tonic-gate sGssAuthentication, sGssKeyEx, sGssStoreDelegCreds, 3960Sstevel@tonic-gate sGssUseSessionCredCache, sGssCleanupCreds, 3970Sstevel@tonic-gate #endif /* GSSAPI */ 3980Sstevel@tonic-gate #if defined(KRB4) || defined(KRB5) 3990Sstevel@tonic-gate sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup, 4000Sstevel@tonic-gate #endif 4010Sstevel@tonic-gate #if defined(AFS) || defined(KRB5) 4020Sstevel@tonic-gate sKerberosTgtPassing, 4030Sstevel@tonic-gate #endif 4040Sstevel@tonic-gate #ifdef AFS 4050Sstevel@tonic-gate sAFSTokenPassing, 4060Sstevel@tonic-gate #endif 4070Sstevel@tonic-gate sChallengeResponseAuthentication, 4080Sstevel@tonic-gate sPasswordAuthentication, sKbdInteractiveAuthentication, sListenAddress, 4090Sstevel@tonic-gate sPrintMotd, sPrintLastLog, sIgnoreRhosts, 4100Sstevel@tonic-gate sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost, 4110Sstevel@tonic-gate sStrictModes, sEmptyPasswd, sKeepAlives, 4120Sstevel@tonic-gate sPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression, 4130Sstevel@tonic-gate sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups, 4140Sstevel@tonic-gate sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile, 4150Sstevel@tonic-gate sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, sMaxStartups, 4160Sstevel@tonic-gate sBanner, sVerifyReverseMapping, sHostbasedAuthentication, 4170Sstevel@tonic-gate sHostbasedUsesNameFromPacketOnly, sClientAliveInterval, 4180Sstevel@tonic-gate sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2, 4190Sstevel@tonic-gate sMaxAuthTries, sMaxAuthTriesLog, sUsePrivilegeSeparation, 420*9139SJan.Pechanec@Sun.COM sLookupClientHostnames, sUseOpenSSLEngine, sChrootDirectory, 4210Sstevel@tonic-gate sDeprecated 4220Sstevel@tonic-gate } ServerOpCodes; 4230Sstevel@tonic-gate 4240Sstevel@tonic-gate /* Textual representation of the tokens. */ 4250Sstevel@tonic-gate static struct { 4260Sstevel@tonic-gate const char *name; 4270Sstevel@tonic-gate ServerOpCodes opcode; 4280Sstevel@tonic-gate } keywords[] = { 4290Sstevel@tonic-gate /* Portable-specific options */ 4300Sstevel@tonic-gate { "PAMAuthenticationViaKbdInt", sPAMAuthenticationViaKbdInt }, 4310Sstevel@tonic-gate /* Standard Options */ 4320Sstevel@tonic-gate { "port", sPort }, 4330Sstevel@tonic-gate { "hostkey", sHostKeyFile }, 4340Sstevel@tonic-gate { "hostdsakey", sHostKeyFile }, /* alias */ 4350Sstevel@tonic-gate { "pidfile", sPidFile }, 4360Sstevel@tonic-gate { "serverkeybits", sServerKeyBits }, 4370Sstevel@tonic-gate { "logingracetime", sLoginGraceTime }, 4380Sstevel@tonic-gate { "keyregenerationinterval", sKeyRegenerationTime }, 4390Sstevel@tonic-gate { "permitrootlogin", sPermitRootLogin }, 4400Sstevel@tonic-gate { "syslogfacility", sLogFacility }, 4410Sstevel@tonic-gate { "loglevel", sLogLevel }, 4420Sstevel@tonic-gate { "rhostsauthentication", sRhostsAuthentication }, 4430Sstevel@tonic-gate { "rhostsrsaauthentication", sRhostsRSAAuthentication }, 4440Sstevel@tonic-gate { "hostbasedauthentication", sHostbasedAuthentication }, 4450Sstevel@tonic-gate { "hostbasedusesnamefrompacketonly", sHostbasedUsesNameFromPacketOnly }, 4460Sstevel@tonic-gate { "rsaauthentication", sRSAAuthentication }, 4470Sstevel@tonic-gate { "pubkeyauthentication", sPubkeyAuthentication }, 4480Sstevel@tonic-gate { "dsaauthentication", sPubkeyAuthentication }, /* alias */ 4490Sstevel@tonic-gate #ifdef GSSAPI 4500Sstevel@tonic-gate { "gssapiauthentication", sGssAuthentication }, 4510Sstevel@tonic-gate { "gssapikeyexchange", sGssKeyEx }, 4520Sstevel@tonic-gate { "gssapistoredelegatedcredentials", sGssStoreDelegCreds }, 4530Sstevel@tonic-gate { "gssauthentication", sGssAuthentication }, /* alias */ 4540Sstevel@tonic-gate { "gsskeyex", sGssKeyEx }, /* alias */ 4550Sstevel@tonic-gate { "gssstoredelegcreds", sGssStoreDelegCreds }, /* alias */ 4560Sstevel@tonic-gate #ifndef SUNW_GSSAPI 4570Sstevel@tonic-gate { "gssusesessionccache", sGssUseSessionCredCache }, 4580Sstevel@tonic-gate { "gssusesessioncredcache", sGssUseSessionCredCache }, 4590Sstevel@tonic-gate { "gsscleanupcreds", sGssCleanupCreds }, 4600Sstevel@tonic-gate #endif /* SUNW_GSSAPI */ 4610Sstevel@tonic-gate #endif 4620Sstevel@tonic-gate #if defined(KRB4) || defined(KRB5) 4630Sstevel@tonic-gate { "kerberosauthentication", sKerberosAuthentication }, 4640Sstevel@tonic-gate { "kerberosorlocalpasswd", sKerberosOrLocalPasswd }, 4650Sstevel@tonic-gate { "kerberosticketcleanup", sKerberosTicketCleanup }, 4660Sstevel@tonic-gate #endif 4670Sstevel@tonic-gate #if defined(AFS) || defined(KRB5) 4680Sstevel@tonic-gate { "kerberostgtpassing", sKerberosTgtPassing }, 4690Sstevel@tonic-gate #endif 4700Sstevel@tonic-gate #ifdef AFS 4710Sstevel@tonic-gate { "afstokenpassing", sAFSTokenPassing }, 4720Sstevel@tonic-gate #endif 4730Sstevel@tonic-gate { "passwordauthentication", sPasswordAuthentication }, 4740Sstevel@tonic-gate { "kbdinteractiveauthentication", sKbdInteractiveAuthentication }, 4750Sstevel@tonic-gate { "challengeresponseauthentication", sChallengeResponseAuthentication }, 4760Sstevel@tonic-gate { "skeyauthentication", sChallengeResponseAuthentication }, /* alias */ 4770Sstevel@tonic-gate { "checkmail", sDeprecated }, 4780Sstevel@tonic-gate { "listenaddress", sListenAddress }, 4790Sstevel@tonic-gate { "printmotd", sPrintMotd }, 4800Sstevel@tonic-gate { "printlastlog", sPrintLastLog }, 4810Sstevel@tonic-gate { "ignorerhosts", sIgnoreRhosts }, 4820Sstevel@tonic-gate { "ignoreuserknownhosts", sIgnoreUserKnownHosts }, 4830Sstevel@tonic-gate { "x11forwarding", sX11Forwarding }, 4840Sstevel@tonic-gate { "x11displayoffset", sX11DisplayOffset }, 4850Sstevel@tonic-gate { "x11uselocalhost", sX11UseLocalhost }, 4860Sstevel@tonic-gate { "xauthlocation", sXAuthLocation }, 4870Sstevel@tonic-gate { "strictmodes", sStrictModes }, 4880Sstevel@tonic-gate { "permitemptypasswords", sEmptyPasswd }, 4890Sstevel@tonic-gate { "permituserenvironment", sPermitUserEnvironment }, 4900Sstevel@tonic-gate { "uselogin", sUseLogin }, 4910Sstevel@tonic-gate { "compression", sCompression }, 4920Sstevel@tonic-gate { "keepalive", sKeepAlives }, 4930Sstevel@tonic-gate { "allowtcpforwarding", sAllowTcpForwarding }, 4940Sstevel@tonic-gate { "allowusers", sAllowUsers }, 4950Sstevel@tonic-gate { "denyusers", sDenyUsers }, 4960Sstevel@tonic-gate { "allowgroups", sAllowGroups }, 4970Sstevel@tonic-gate { "denygroups", sDenyGroups }, 4980Sstevel@tonic-gate { "ciphers", sCiphers }, 4990Sstevel@tonic-gate { "macs", sMacs }, 5000Sstevel@tonic-gate { "protocol", sProtocol }, 5010Sstevel@tonic-gate { "gatewayports", sGatewayPorts }, 5020Sstevel@tonic-gate { "subsystem", sSubsystem }, 5030Sstevel@tonic-gate { "maxstartups", sMaxStartups }, 5040Sstevel@tonic-gate { "banner", sBanner }, 5050Sstevel@tonic-gate { "verifyreversemapping", sVerifyReverseMapping }, 5060Sstevel@tonic-gate { "reversemappingcheck", sVerifyReverseMapping }, 5070Sstevel@tonic-gate { "clientaliveinterval", sClientAliveInterval }, 5080Sstevel@tonic-gate { "clientalivecountmax", sClientAliveCountMax }, 5090Sstevel@tonic-gate { "authorizedkeysfile", sAuthorizedKeysFile }, 5100Sstevel@tonic-gate { "authorizedkeysfile2", sAuthorizedKeysFile2 }, 5110Sstevel@tonic-gate { "maxauthtries", sMaxAuthTries }, 5120Sstevel@tonic-gate { "maxauthtrieslog", sMaxAuthTriesLog }, 5130Sstevel@tonic-gate { "useprivilegeseparation", sUsePrivilegeSeparation}, 5140Sstevel@tonic-gate { "lookupclienthostnames", sLookupClientHostnames}, 5157574SJan.Pechanec@Sun.COM { "useopensslengine", sUseOpenSSLEngine}, 516*9139SJan.Pechanec@Sun.COM { "chrootdirectory", sChrootDirectory}, 5170Sstevel@tonic-gate { NULL, sBadOption } 5180Sstevel@tonic-gate }; 5190Sstevel@tonic-gate 5200Sstevel@tonic-gate /* 5210Sstevel@tonic-gate * Returns the number of the token pointed to by cp or sBadOption. 5220Sstevel@tonic-gate */ 5230Sstevel@tonic-gate 5240Sstevel@tonic-gate static ServerOpCodes 5250Sstevel@tonic-gate parse_token(const char *cp, const char *filename, 5260Sstevel@tonic-gate int linenum) 5270Sstevel@tonic-gate { 5280Sstevel@tonic-gate u_int i; 5290Sstevel@tonic-gate 5300Sstevel@tonic-gate for (i = 0; keywords[i].name; i++) 5310Sstevel@tonic-gate if (strcasecmp(cp, keywords[i].name) == 0) 5320Sstevel@tonic-gate return keywords[i].opcode; 5330Sstevel@tonic-gate 5340Sstevel@tonic-gate error("%s: line %d: Bad configuration option: %s", 5350Sstevel@tonic-gate filename, linenum, cp); 5360Sstevel@tonic-gate return sBadOption; 5370Sstevel@tonic-gate } 5380Sstevel@tonic-gate 5390Sstevel@tonic-gate static void 5400Sstevel@tonic-gate add_listen_addr(ServerOptions *options, char *addr, u_short port) 5410Sstevel@tonic-gate { 5420Sstevel@tonic-gate int i; 5430Sstevel@tonic-gate 5440Sstevel@tonic-gate if (options->num_ports == 0) 5450Sstevel@tonic-gate options->ports[options->num_ports++] = SSH_DEFAULT_PORT; 5460Sstevel@tonic-gate if (port == 0) 5470Sstevel@tonic-gate for (i = 0; i < options->num_ports; i++) 5480Sstevel@tonic-gate add_one_listen_addr(options, addr, options->ports[i]); 5490Sstevel@tonic-gate else 5500Sstevel@tonic-gate add_one_listen_addr(options, addr, port); 5510Sstevel@tonic-gate } 5520Sstevel@tonic-gate 5530Sstevel@tonic-gate static void 5540Sstevel@tonic-gate add_one_listen_addr(ServerOptions *options, char *addr, u_short port) 5550Sstevel@tonic-gate { 5560Sstevel@tonic-gate struct addrinfo hints, *ai, *aitop; 5570Sstevel@tonic-gate char strport[NI_MAXSERV]; 5580Sstevel@tonic-gate int gaierr; 5590Sstevel@tonic-gate 5600Sstevel@tonic-gate (void) memset(&hints, 0, sizeof(hints)); 5610Sstevel@tonic-gate hints.ai_family = IPv4or6; 5620Sstevel@tonic-gate hints.ai_socktype = SOCK_STREAM; 5630Sstevel@tonic-gate hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0; 5640Sstevel@tonic-gate (void) snprintf(strport, sizeof strport, "%u", port); 5650Sstevel@tonic-gate if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0) 5660Sstevel@tonic-gate fatal("bad addr or host: %s (%s)", 5670Sstevel@tonic-gate addr ? addr : "<NULL>", 5680Sstevel@tonic-gate gai_strerror(gaierr)); 5690Sstevel@tonic-gate for (ai = aitop; ai->ai_next; ai = ai->ai_next) 5700Sstevel@tonic-gate ; 5710Sstevel@tonic-gate ai->ai_next = options->listen_addrs; 5720Sstevel@tonic-gate options->listen_addrs = aitop; 5730Sstevel@tonic-gate } 5740Sstevel@tonic-gate 5750Sstevel@tonic-gate int 5760Sstevel@tonic-gate process_server_config_line(ServerOptions *options, char *line, 5770Sstevel@tonic-gate const char *filename, int linenum) 5780Sstevel@tonic-gate { 5790Sstevel@tonic-gate char *cp, **charptr, *arg, *p; 5800Sstevel@tonic-gate int *intptr, value, i, n; 5810Sstevel@tonic-gate ServerOpCodes opcode; 582*9139SJan.Pechanec@Sun.COM size_t len; 5830Sstevel@tonic-gate 5840Sstevel@tonic-gate cp = line; 5850Sstevel@tonic-gate arg = strdelim(&cp); 5860Sstevel@tonic-gate /* Ignore leading whitespace */ 5870Sstevel@tonic-gate if (*arg == '\0') 5880Sstevel@tonic-gate arg = strdelim(&cp); 5890Sstevel@tonic-gate if (!arg || !*arg || *arg == '#') 5900Sstevel@tonic-gate return 0; 5910Sstevel@tonic-gate intptr = NULL; 5920Sstevel@tonic-gate charptr = NULL; 5930Sstevel@tonic-gate opcode = parse_token(arg, filename, linenum); 5940Sstevel@tonic-gate switch (opcode) { 5950Sstevel@tonic-gate /* Portable-specific options */ 5960Sstevel@tonic-gate case sPAMAuthenticationViaKbdInt: 5970Sstevel@tonic-gate intptr = &options->pam_authentication_via_kbd_int; 5980Sstevel@tonic-gate goto parse_flag; 5990Sstevel@tonic-gate 6000Sstevel@tonic-gate /* Standard Options */ 6010Sstevel@tonic-gate case sBadOption: 6020Sstevel@tonic-gate return -1; 6030Sstevel@tonic-gate case sPort: 6040Sstevel@tonic-gate /* ignore ports from configfile if cmdline specifies ports */ 6050Sstevel@tonic-gate if (options->ports_from_cmdline) 6060Sstevel@tonic-gate return 0; 6070Sstevel@tonic-gate if (options->listen_addrs != NULL) 6080Sstevel@tonic-gate fatal("%s line %d: ports must be specified before " 6090Sstevel@tonic-gate "ListenAddress.", filename, linenum); 6100Sstevel@tonic-gate if (options->num_ports >= MAX_PORTS) 6110Sstevel@tonic-gate fatal("%s line %d: too many ports.", 6120Sstevel@tonic-gate filename, linenum); 6130Sstevel@tonic-gate arg = strdelim(&cp); 6140Sstevel@tonic-gate if (!arg || *arg == '\0') 6150Sstevel@tonic-gate fatal("%s line %d: missing port number.", 6160Sstevel@tonic-gate filename, linenum); 6170Sstevel@tonic-gate options->ports[options->num_ports++] = a2port(arg); 6180Sstevel@tonic-gate if (options->ports[options->num_ports-1] == 0) 6190Sstevel@tonic-gate fatal("%s line %d: Badly formatted port number.", 6200Sstevel@tonic-gate filename, linenum); 6210Sstevel@tonic-gate break; 6220Sstevel@tonic-gate 6230Sstevel@tonic-gate case sServerKeyBits: 6240Sstevel@tonic-gate intptr = &options->server_key_bits; 6250Sstevel@tonic-gate parse_int: 6260Sstevel@tonic-gate arg = strdelim(&cp); 6270Sstevel@tonic-gate if (!arg || *arg == '\0') 6280Sstevel@tonic-gate fatal("%s line %d: missing integer value.", 6290Sstevel@tonic-gate filename, linenum); 6300Sstevel@tonic-gate value = atoi(arg); 6310Sstevel@tonic-gate if (*intptr == -1) 6320Sstevel@tonic-gate *intptr = value; 6330Sstevel@tonic-gate break; 6340Sstevel@tonic-gate 6350Sstevel@tonic-gate case sLoginGraceTime: 6360Sstevel@tonic-gate intptr = &options->login_grace_time; 6370Sstevel@tonic-gate parse_time: 6380Sstevel@tonic-gate arg = strdelim(&cp); 6390Sstevel@tonic-gate if (!arg || *arg == '\0') 6400Sstevel@tonic-gate fatal("%s line %d: missing time value.", 6410Sstevel@tonic-gate filename, linenum); 6420Sstevel@tonic-gate if ((value = convtime(arg)) == -1) 6430Sstevel@tonic-gate fatal("%s line %d: invalid time value.", 6440Sstevel@tonic-gate filename, linenum); 6450Sstevel@tonic-gate if (*intptr == -1) 6460Sstevel@tonic-gate *intptr = value; 6470Sstevel@tonic-gate break; 6480Sstevel@tonic-gate 6490Sstevel@tonic-gate case sKeyRegenerationTime: 6500Sstevel@tonic-gate intptr = &options->key_regeneration_time; 6510Sstevel@tonic-gate goto parse_time; 6520Sstevel@tonic-gate 6530Sstevel@tonic-gate case sListenAddress: 6540Sstevel@tonic-gate arg = strdelim(&cp); 6550Sstevel@tonic-gate if (!arg || *arg == '\0' || strncmp(arg, "[]", 2) == 0) 6560Sstevel@tonic-gate fatal("%s line %d: missing inet addr.", 6570Sstevel@tonic-gate filename, linenum); 6580Sstevel@tonic-gate if (*arg == '[') { 6590Sstevel@tonic-gate if ((p = strchr(arg, ']')) == NULL) 6600Sstevel@tonic-gate fatal("%s line %d: bad ipv6 inet addr usage.", 6610Sstevel@tonic-gate filename, linenum); 6620Sstevel@tonic-gate arg++; 6630Sstevel@tonic-gate (void) memmove(p, p+1, strlen(p+1)+1); 6640Sstevel@tonic-gate } else if (((p = strchr(arg, ':')) == NULL) || 6650Sstevel@tonic-gate (strchr(p+1, ':') != NULL)) { 6660Sstevel@tonic-gate add_listen_addr(options, arg, 0); 6670Sstevel@tonic-gate break; 6680Sstevel@tonic-gate } 6690Sstevel@tonic-gate if (*p == ':') { 6700Sstevel@tonic-gate u_short port; 6710Sstevel@tonic-gate 6720Sstevel@tonic-gate p++; 6730Sstevel@tonic-gate if (*p == '\0') 6740Sstevel@tonic-gate fatal("%s line %d: bad inet addr:port usage.", 6750Sstevel@tonic-gate filename, linenum); 6760Sstevel@tonic-gate else { 6770Sstevel@tonic-gate *(p-1) = '\0'; 6780Sstevel@tonic-gate if ((port = a2port(p)) == 0) 6790Sstevel@tonic-gate fatal("%s line %d: bad port number.", 6800Sstevel@tonic-gate filename, linenum); 6810Sstevel@tonic-gate add_listen_addr(options, arg, port); 6820Sstevel@tonic-gate } 6830Sstevel@tonic-gate } else if (*p == '\0') 6840Sstevel@tonic-gate add_listen_addr(options, arg, 0); 6850Sstevel@tonic-gate else 6860Sstevel@tonic-gate fatal("%s line %d: bad inet addr usage.", 6870Sstevel@tonic-gate filename, linenum); 6880Sstevel@tonic-gate break; 6890Sstevel@tonic-gate 6900Sstevel@tonic-gate case sHostKeyFile: 6910Sstevel@tonic-gate intptr = &options->num_host_key_files; 6920Sstevel@tonic-gate if (*intptr >= MAX_HOSTKEYS) 6930Sstevel@tonic-gate fatal("%s line %d: too many host keys specified (max %d).", 6940Sstevel@tonic-gate filename, linenum, MAX_HOSTKEYS); 6950Sstevel@tonic-gate charptr = &options->host_key_files[*intptr]; 6960Sstevel@tonic-gate parse_filename: 6970Sstevel@tonic-gate arg = strdelim(&cp); 6980Sstevel@tonic-gate if (!arg || *arg == '\0') 6990Sstevel@tonic-gate fatal("%s line %d: missing file name.", 7000Sstevel@tonic-gate filename, linenum); 7010Sstevel@tonic-gate if (*charptr == NULL) { 7020Sstevel@tonic-gate *charptr = tilde_expand_filename(arg, getuid()); 7030Sstevel@tonic-gate /* increase optional counter */ 7040Sstevel@tonic-gate if (intptr != NULL) 7050Sstevel@tonic-gate *intptr = *intptr + 1; 7060Sstevel@tonic-gate } 7070Sstevel@tonic-gate break; 7080Sstevel@tonic-gate 7090Sstevel@tonic-gate case sPidFile: 7100Sstevel@tonic-gate charptr = &options->pid_file; 7110Sstevel@tonic-gate goto parse_filename; 7120Sstevel@tonic-gate 7130Sstevel@tonic-gate case sPermitRootLogin: 7140Sstevel@tonic-gate intptr = &options->permit_root_login; 7150Sstevel@tonic-gate arg = strdelim(&cp); 7160Sstevel@tonic-gate if (!arg || *arg == '\0') 7170Sstevel@tonic-gate fatal("%s line %d: missing yes/" 7180Sstevel@tonic-gate "without-password/forced-commands-only/no " 7190Sstevel@tonic-gate "argument.", filename, linenum); 7200Sstevel@tonic-gate value = 0; /* silence compiler */ 7210Sstevel@tonic-gate if (strcmp(arg, "without-password") == 0) 7220Sstevel@tonic-gate value = PERMIT_NO_PASSWD; 7230Sstevel@tonic-gate else if (strcmp(arg, "forced-commands-only") == 0) 7240Sstevel@tonic-gate value = PERMIT_FORCED_ONLY; 7250Sstevel@tonic-gate else if (strcmp(arg, "yes") == 0) 7260Sstevel@tonic-gate value = PERMIT_YES; 7270Sstevel@tonic-gate else if (strcmp(arg, "no") == 0) 7280Sstevel@tonic-gate value = PERMIT_NO; 7290Sstevel@tonic-gate else 7300Sstevel@tonic-gate fatal("%s line %d: Bad yes/" 7310Sstevel@tonic-gate "without-password/forced-commands-only/no " 7320Sstevel@tonic-gate "argument: %s", filename, linenum, arg); 7330Sstevel@tonic-gate if (*intptr == -1) 7340Sstevel@tonic-gate *intptr = value; 7350Sstevel@tonic-gate break; 7360Sstevel@tonic-gate 7370Sstevel@tonic-gate case sIgnoreRhosts: 7380Sstevel@tonic-gate intptr = &options->ignore_rhosts; 7390Sstevel@tonic-gate parse_flag: 7400Sstevel@tonic-gate arg = strdelim(&cp); 7410Sstevel@tonic-gate if (!arg || *arg == '\0') 7420Sstevel@tonic-gate fatal("%s line %d: missing yes/no argument.", 7430Sstevel@tonic-gate filename, linenum); 7440Sstevel@tonic-gate value = 0; /* silence compiler */ 7450Sstevel@tonic-gate if (strcmp(arg, "yes") == 0) 7460Sstevel@tonic-gate value = 1; 7470Sstevel@tonic-gate else if (strcmp(arg, "no") == 0) 7480Sstevel@tonic-gate value = 0; 7490Sstevel@tonic-gate else 7500Sstevel@tonic-gate fatal("%s line %d: Bad yes/no argument: %s", 7510Sstevel@tonic-gate filename, linenum, arg); 7520Sstevel@tonic-gate if (*intptr == -1) 7530Sstevel@tonic-gate *intptr = value; 7540Sstevel@tonic-gate break; 7550Sstevel@tonic-gate 7560Sstevel@tonic-gate case sIgnoreUserKnownHosts: 7570Sstevel@tonic-gate intptr = &options->ignore_user_known_hosts; 7580Sstevel@tonic-gate goto parse_flag; 7590Sstevel@tonic-gate 7600Sstevel@tonic-gate case sRhostsAuthentication: 7610Sstevel@tonic-gate intptr = &options->rhosts_authentication; 7620Sstevel@tonic-gate goto parse_flag; 7630Sstevel@tonic-gate 7640Sstevel@tonic-gate case sRhostsRSAAuthentication: 7650Sstevel@tonic-gate intptr = &options->rhosts_rsa_authentication; 7660Sstevel@tonic-gate goto parse_flag; 7670Sstevel@tonic-gate 7680Sstevel@tonic-gate case sHostbasedAuthentication: 7690Sstevel@tonic-gate intptr = &options->hostbased_authentication; 7700Sstevel@tonic-gate goto parse_flag; 7710Sstevel@tonic-gate 7720Sstevel@tonic-gate case sHostbasedUsesNameFromPacketOnly: 7730Sstevel@tonic-gate intptr = &options->hostbased_uses_name_from_packet_only; 7740Sstevel@tonic-gate goto parse_flag; 7750Sstevel@tonic-gate 7760Sstevel@tonic-gate case sRSAAuthentication: 7770Sstevel@tonic-gate intptr = &options->rsa_authentication; 7780Sstevel@tonic-gate goto parse_flag; 7790Sstevel@tonic-gate 7800Sstevel@tonic-gate case sPubkeyAuthentication: 7810Sstevel@tonic-gate intptr = &options->pubkey_authentication; 7820Sstevel@tonic-gate goto parse_flag; 7830Sstevel@tonic-gate #ifdef GSSAPI 7840Sstevel@tonic-gate case sGssAuthentication: 7850Sstevel@tonic-gate intptr = &options->gss_authentication; 7860Sstevel@tonic-gate goto parse_flag; 7870Sstevel@tonic-gate case sGssKeyEx: 7880Sstevel@tonic-gate intptr = &options->gss_keyex; 7890Sstevel@tonic-gate goto parse_flag; 7900Sstevel@tonic-gate case sGssStoreDelegCreds: 7910Sstevel@tonic-gate intptr = &options->gss_keyex; 7920Sstevel@tonic-gate goto parse_flag; 7930Sstevel@tonic-gate #ifndef SUNW_GSSAPI 7940Sstevel@tonic-gate case sGssUseSessionCredCache: 7950Sstevel@tonic-gate intptr = &options->gss_use_session_ccache; 7960Sstevel@tonic-gate goto parse_flag; 7970Sstevel@tonic-gate case sGssCleanupCreds: 7980Sstevel@tonic-gate intptr = &options->gss_cleanup_creds; 7990Sstevel@tonic-gate goto parse_flag; 8000Sstevel@tonic-gate #endif /* SUNW_GSSAPI */ 8010Sstevel@tonic-gate #endif /* GSSAPI */ 8020Sstevel@tonic-gate #if defined(KRB4) || defined(KRB5) 8030Sstevel@tonic-gate case sKerberosAuthentication: 8040Sstevel@tonic-gate intptr = &options->kerberos_authentication; 8050Sstevel@tonic-gate goto parse_flag; 8060Sstevel@tonic-gate 8070Sstevel@tonic-gate case sKerberosOrLocalPasswd: 8080Sstevel@tonic-gate intptr = &options->kerberos_or_local_passwd; 8090Sstevel@tonic-gate goto parse_flag; 8100Sstevel@tonic-gate 8110Sstevel@tonic-gate case sKerberosTicketCleanup: 8120Sstevel@tonic-gate intptr = &options->kerberos_ticket_cleanup; 8130Sstevel@tonic-gate goto parse_flag; 8140Sstevel@tonic-gate #endif 8150Sstevel@tonic-gate #if defined(AFS) || defined(KRB5) 8160Sstevel@tonic-gate case sKerberosTgtPassing: 8170Sstevel@tonic-gate intptr = &options->kerberos_tgt_passing; 8180Sstevel@tonic-gate goto parse_flag; 8190Sstevel@tonic-gate #endif 8200Sstevel@tonic-gate #ifdef AFS 8210Sstevel@tonic-gate case sAFSTokenPassing: 8220Sstevel@tonic-gate intptr = &options->afs_token_passing; 8230Sstevel@tonic-gate goto parse_flag; 8240Sstevel@tonic-gate #endif 8250Sstevel@tonic-gate 8260Sstevel@tonic-gate case sPasswordAuthentication: 8270Sstevel@tonic-gate intptr = &options->password_authentication; 8280Sstevel@tonic-gate goto parse_flag; 8290Sstevel@tonic-gate 8300Sstevel@tonic-gate case sKbdInteractiveAuthentication: 8310Sstevel@tonic-gate intptr = &options->kbd_interactive_authentication; 8320Sstevel@tonic-gate goto parse_flag; 8330Sstevel@tonic-gate 8340Sstevel@tonic-gate case sChallengeResponseAuthentication: 8350Sstevel@tonic-gate intptr = &options->challenge_response_authentication; 8360Sstevel@tonic-gate goto parse_flag; 8370Sstevel@tonic-gate 8380Sstevel@tonic-gate case sPrintMotd: 8390Sstevel@tonic-gate intptr = &options->print_motd; 8400Sstevel@tonic-gate goto parse_flag; 8410Sstevel@tonic-gate 8420Sstevel@tonic-gate case sPrintLastLog: 8430Sstevel@tonic-gate intptr = &options->print_lastlog; 8440Sstevel@tonic-gate goto parse_flag; 8450Sstevel@tonic-gate 8460Sstevel@tonic-gate case sX11Forwarding: 8470Sstevel@tonic-gate intptr = &options->x11_forwarding; 8480Sstevel@tonic-gate goto parse_flag; 8490Sstevel@tonic-gate 8500Sstevel@tonic-gate case sX11DisplayOffset: 8510Sstevel@tonic-gate intptr = &options->x11_display_offset; 8520Sstevel@tonic-gate goto parse_int; 8530Sstevel@tonic-gate 8540Sstevel@tonic-gate case sX11UseLocalhost: 8550Sstevel@tonic-gate intptr = &options->x11_use_localhost; 8560Sstevel@tonic-gate goto parse_flag; 8570Sstevel@tonic-gate 8580Sstevel@tonic-gate case sXAuthLocation: 8590Sstevel@tonic-gate charptr = &options->xauth_location; 8600Sstevel@tonic-gate goto parse_filename; 8610Sstevel@tonic-gate 8620Sstevel@tonic-gate case sStrictModes: 8630Sstevel@tonic-gate intptr = &options->strict_modes; 8640Sstevel@tonic-gate goto parse_flag; 8650Sstevel@tonic-gate 8660Sstevel@tonic-gate case sKeepAlives: 8670Sstevel@tonic-gate intptr = &options->keepalives; 8680Sstevel@tonic-gate goto parse_flag; 8690Sstevel@tonic-gate 8700Sstevel@tonic-gate case sEmptyPasswd: 8710Sstevel@tonic-gate intptr = &options->permit_empty_passwd; 8720Sstevel@tonic-gate goto parse_flag; 8730Sstevel@tonic-gate 8740Sstevel@tonic-gate case sPermitUserEnvironment: 8750Sstevel@tonic-gate intptr = &options->permit_user_env; 8760Sstevel@tonic-gate goto parse_flag; 8770Sstevel@tonic-gate 8780Sstevel@tonic-gate case sUseLogin: 8790Sstevel@tonic-gate intptr = &options->use_login; 8800Sstevel@tonic-gate goto parse_flag; 8810Sstevel@tonic-gate 8820Sstevel@tonic-gate case sCompression: 8830Sstevel@tonic-gate intptr = &options->compression; 8840Sstevel@tonic-gate goto parse_flag; 8850Sstevel@tonic-gate 8860Sstevel@tonic-gate case sGatewayPorts: 8875334Sjp161948 arg = strdelim(&cp); 8885334Sjp161948 if (get_yes_no_flag(&options->gateway_ports, arg, filename, 8895334Sjp161948 linenum, 1) == 1) 8905334Sjp161948 break; 8915334Sjp161948 8925334Sjp161948 if (strcmp(arg, "clientspecified") == 0) 8935334Sjp161948 options->gateway_ports = 2; 8945334Sjp161948 else 8955334Sjp161948 fatal("%.200s line %d: Bad yes/no/clientspecified " 8965334Sjp161948 "argument.", filename, linenum); 8975334Sjp161948 break; 8980Sstevel@tonic-gate 8990Sstevel@tonic-gate case sVerifyReverseMapping: 9000Sstevel@tonic-gate intptr = &options->verify_reverse_mapping; 9010Sstevel@tonic-gate goto parse_flag; 9020Sstevel@tonic-gate 9030Sstevel@tonic-gate case sLogFacility: 9040Sstevel@tonic-gate intptr = (int *) &options->log_facility; 9050Sstevel@tonic-gate arg = strdelim(&cp); 9060Sstevel@tonic-gate value = log_facility_number(arg); 9070Sstevel@tonic-gate if (value == SYSLOG_FACILITY_NOT_SET) 9080Sstevel@tonic-gate fatal("%.200s line %d: unsupported log facility '%s'", 9090Sstevel@tonic-gate filename, linenum, arg ? arg : "<NONE>"); 9100Sstevel@tonic-gate if (*intptr == -1) 9110Sstevel@tonic-gate *intptr = (SyslogFacility) value; 9120Sstevel@tonic-gate break; 9130Sstevel@tonic-gate 9140Sstevel@tonic-gate case sLogLevel: 9150Sstevel@tonic-gate intptr = (int *) &options->log_level; 9160Sstevel@tonic-gate arg = strdelim(&cp); 9170Sstevel@tonic-gate value = log_level_number(arg); 9180Sstevel@tonic-gate if (value == SYSLOG_LEVEL_NOT_SET) 9190Sstevel@tonic-gate fatal("%.200s line %d: unsupported log level '%s'", 9200Sstevel@tonic-gate filename, linenum, arg ? arg : "<NONE>"); 9210Sstevel@tonic-gate if (*intptr == -1) 9220Sstevel@tonic-gate *intptr = (LogLevel) value; 9230Sstevel@tonic-gate break; 9240Sstevel@tonic-gate 9250Sstevel@tonic-gate case sAllowTcpForwarding: 9260Sstevel@tonic-gate intptr = &options->allow_tcp_forwarding; 9270Sstevel@tonic-gate goto parse_flag; 9280Sstevel@tonic-gate 9290Sstevel@tonic-gate case sUsePrivilegeSeparation: 9305562Sjp161948 log("%s line %d: ignoring UsePrivilegeSeparation option value." 9315562Sjp161948 " This option is always on.", filename, linenum); 9325562Sjp161948 while (arg) 9335562Sjp161948 arg = strdelim(&cp); 9345562Sjp161948 break; 9350Sstevel@tonic-gate 9360Sstevel@tonic-gate case sAllowUsers: 9370Sstevel@tonic-gate while (((arg = strdelim(&cp)) != NULL) && *arg != '\0') { 9380Sstevel@tonic-gate if (options->num_allow_users >= MAX_ALLOW_USERS) 9390Sstevel@tonic-gate fatal("%s line %d: too many allow users.", 9400Sstevel@tonic-gate filename, linenum); 9410Sstevel@tonic-gate options->allow_users[options->num_allow_users++] = 9420Sstevel@tonic-gate xstrdup(arg); 9430Sstevel@tonic-gate } 9440Sstevel@tonic-gate break; 9450Sstevel@tonic-gate 9460Sstevel@tonic-gate case sDenyUsers: 9470Sstevel@tonic-gate while (((arg = strdelim(&cp)) != NULL) && *arg != '\0') { 9480Sstevel@tonic-gate if (options->num_deny_users >= MAX_DENY_USERS) 9490Sstevel@tonic-gate fatal( "%s line %d: too many deny users.", 9500Sstevel@tonic-gate filename, linenum); 9510Sstevel@tonic-gate options->deny_users[options->num_deny_users++] = 9520Sstevel@tonic-gate xstrdup(arg); 9530Sstevel@tonic-gate } 9540Sstevel@tonic-gate break; 9550Sstevel@tonic-gate 9560Sstevel@tonic-gate case sAllowGroups: 9570Sstevel@tonic-gate while (((arg = strdelim(&cp)) != NULL) && *arg != '\0') { 9580Sstevel@tonic-gate if (options->num_allow_groups >= MAX_ALLOW_GROUPS) 9590Sstevel@tonic-gate fatal("%s line %d: too many allow groups.", 9600Sstevel@tonic-gate filename, linenum); 9610Sstevel@tonic-gate options->allow_groups[options->num_allow_groups++] = 9620Sstevel@tonic-gate xstrdup(arg); 9630Sstevel@tonic-gate } 9640Sstevel@tonic-gate break; 9650Sstevel@tonic-gate 9660Sstevel@tonic-gate case sDenyGroups: 9670Sstevel@tonic-gate while (((arg = strdelim(&cp)) != NULL) && *arg != '\0') { 9680Sstevel@tonic-gate if (options->num_deny_groups >= MAX_DENY_GROUPS) 9690Sstevel@tonic-gate fatal("%s line %d: too many deny groups.", 9700Sstevel@tonic-gate filename, linenum); 9710Sstevel@tonic-gate options->deny_groups[options->num_deny_groups++] = xstrdup(arg); 9720Sstevel@tonic-gate } 9730Sstevel@tonic-gate break; 9740Sstevel@tonic-gate 9750Sstevel@tonic-gate case sCiphers: 9760Sstevel@tonic-gate arg = strdelim(&cp); 9770Sstevel@tonic-gate if (!arg || *arg == '\0') 9780Sstevel@tonic-gate fatal("%s line %d: Missing argument.", filename, linenum); 9790Sstevel@tonic-gate if (!ciphers_valid(arg)) 9800Sstevel@tonic-gate fatal("%s line %d: Bad SSH2 cipher spec '%s'.", 9810Sstevel@tonic-gate filename, linenum, arg ? arg : "<NONE>"); 9820Sstevel@tonic-gate if (options->ciphers == NULL) 9830Sstevel@tonic-gate options->ciphers = xstrdup(arg); 9840Sstevel@tonic-gate break; 9850Sstevel@tonic-gate 9860Sstevel@tonic-gate case sMacs: 9870Sstevel@tonic-gate arg = strdelim(&cp); 9880Sstevel@tonic-gate if (!arg || *arg == '\0') 9890Sstevel@tonic-gate fatal("%s line %d: Missing argument.", filename, linenum); 9900Sstevel@tonic-gate if (!mac_valid(arg)) 9910Sstevel@tonic-gate fatal("%s line %d: Bad SSH2 mac spec '%s'.", 9920Sstevel@tonic-gate filename, linenum, arg ? arg : "<NONE>"); 9930Sstevel@tonic-gate if (options->macs == NULL) 9940Sstevel@tonic-gate options->macs = xstrdup(arg); 9950Sstevel@tonic-gate break; 9960Sstevel@tonic-gate 9970Sstevel@tonic-gate case sProtocol: 9980Sstevel@tonic-gate intptr = &options->protocol; 9990Sstevel@tonic-gate arg = strdelim(&cp); 10000Sstevel@tonic-gate if (!arg || *arg == '\0') 10010Sstevel@tonic-gate fatal("%s line %d: Missing argument.", filename, linenum); 10020Sstevel@tonic-gate value = proto_spec(arg); 10030Sstevel@tonic-gate if (value == SSH_PROTO_UNKNOWN) 10040Sstevel@tonic-gate fatal("%s line %d: Bad protocol spec '%s'.", 10050Sstevel@tonic-gate filename, linenum, arg ? arg : "<NONE>"); 10060Sstevel@tonic-gate if (*intptr == SSH_PROTO_UNKNOWN) 10070Sstevel@tonic-gate *intptr = value; 10080Sstevel@tonic-gate break; 10090Sstevel@tonic-gate 10100Sstevel@tonic-gate case sSubsystem: 10110Sstevel@tonic-gate if (options->num_subsystems >= MAX_SUBSYSTEMS) { 10120Sstevel@tonic-gate fatal("%s line %d: too many subsystems defined.", 10130Sstevel@tonic-gate filename, linenum); 10140Sstevel@tonic-gate } 10150Sstevel@tonic-gate arg = strdelim(&cp); 10160Sstevel@tonic-gate if (!arg || *arg == '\0') 10170Sstevel@tonic-gate fatal("%s line %d: Missing subsystem name.", 10180Sstevel@tonic-gate filename, linenum); 10190Sstevel@tonic-gate for (i = 0; i < options->num_subsystems; i++) 10200Sstevel@tonic-gate if (strcmp(arg, options->subsystem_name[i]) == 0) 10210Sstevel@tonic-gate fatal("%s line %d: Subsystem '%s' already defined.", 10220Sstevel@tonic-gate filename, linenum, arg); 10230Sstevel@tonic-gate options->subsystem_name[options->num_subsystems] = xstrdup(arg); 10240Sstevel@tonic-gate arg = strdelim(&cp); 10250Sstevel@tonic-gate if (!arg || *arg == '\0') 10260Sstevel@tonic-gate fatal("%s line %d: Missing subsystem command.", 10270Sstevel@tonic-gate filename, linenum); 10280Sstevel@tonic-gate options->subsystem_command[options->num_subsystems] = xstrdup(arg); 1029*9139SJan.Pechanec@Sun.COM 1030*9139SJan.Pechanec@Sun.COM /* 1031*9139SJan.Pechanec@Sun.COM * Collect arguments (separate to executable), including the 1032*9139SJan.Pechanec@Sun.COM * name of the executable, in a way that is easier to parse 1033*9139SJan.Pechanec@Sun.COM * later. 1034*9139SJan.Pechanec@Sun.COM */ 1035*9139SJan.Pechanec@Sun.COM p = xstrdup(arg); 1036*9139SJan.Pechanec@Sun.COM len = strlen(p) + 1; 1037*9139SJan.Pechanec@Sun.COM while ((arg = strdelim(&cp)) != NULL && *arg != '\0') { 1038*9139SJan.Pechanec@Sun.COM len += 1 + strlen(arg); 1039*9139SJan.Pechanec@Sun.COM p = xrealloc(p, len); 1040*9139SJan.Pechanec@Sun.COM strlcat(p, " ", len); 1041*9139SJan.Pechanec@Sun.COM strlcat(p, arg, len); 1042*9139SJan.Pechanec@Sun.COM } 1043*9139SJan.Pechanec@Sun.COM options->subsystem_args[options->num_subsystems] = p; 10440Sstevel@tonic-gate options->num_subsystems++; 10450Sstevel@tonic-gate break; 10460Sstevel@tonic-gate 10470Sstevel@tonic-gate case sMaxStartups: 10480Sstevel@tonic-gate arg = strdelim(&cp); 10490Sstevel@tonic-gate if (!arg || *arg == '\0') 10500Sstevel@tonic-gate fatal("%s line %d: Missing MaxStartups spec.", 10510Sstevel@tonic-gate filename, linenum); 10520Sstevel@tonic-gate if ((n = sscanf(arg, "%d:%d:%d", 10530Sstevel@tonic-gate &options->max_startups_begin, 10540Sstevel@tonic-gate &options->max_startups_rate, 10550Sstevel@tonic-gate &options->max_startups)) == 3) { 10560Sstevel@tonic-gate if (options->max_startups_begin > 10570Sstevel@tonic-gate options->max_startups || 10580Sstevel@tonic-gate options->max_startups_rate > 100 || 10590Sstevel@tonic-gate options->max_startups_rate < 1) 10600Sstevel@tonic-gate fatal("%s line %d: Illegal MaxStartups spec.", 10610Sstevel@tonic-gate filename, linenum); 10620Sstevel@tonic-gate } else if (n != 1) 10630Sstevel@tonic-gate fatal("%s line %d: Illegal MaxStartups spec.", 10640Sstevel@tonic-gate filename, linenum); 10650Sstevel@tonic-gate else 10660Sstevel@tonic-gate options->max_startups = options->max_startups_begin; 10670Sstevel@tonic-gate break; 10680Sstevel@tonic-gate 10690Sstevel@tonic-gate case sBanner: 10700Sstevel@tonic-gate charptr = &options->banner; 10710Sstevel@tonic-gate goto parse_filename; 10720Sstevel@tonic-gate /* 10730Sstevel@tonic-gate * These options can contain %X options expanded at 10740Sstevel@tonic-gate * connect time, so that you can specify paths like: 10750Sstevel@tonic-gate * 10760Sstevel@tonic-gate * AuthorizedKeysFile /etc/ssh_keys/%u 10770Sstevel@tonic-gate */ 10780Sstevel@tonic-gate case sAuthorizedKeysFile: 10790Sstevel@tonic-gate case sAuthorizedKeysFile2: 1080*9139SJan.Pechanec@Sun.COM charptr = (opcode == sAuthorizedKeysFile) ? 10810Sstevel@tonic-gate &options->authorized_keys_file : 10820Sstevel@tonic-gate &options->authorized_keys_file2; 10830Sstevel@tonic-gate goto parse_filename; 10840Sstevel@tonic-gate 10850Sstevel@tonic-gate case sClientAliveInterval: 10860Sstevel@tonic-gate intptr = &options->client_alive_interval; 10870Sstevel@tonic-gate goto parse_time; 10880Sstevel@tonic-gate 10890Sstevel@tonic-gate case sClientAliveCountMax: 10900Sstevel@tonic-gate intptr = &options->client_alive_count_max; 10910Sstevel@tonic-gate goto parse_int; 10920Sstevel@tonic-gate 10930Sstevel@tonic-gate case sMaxAuthTries: 10940Sstevel@tonic-gate intptr = &options->max_auth_tries; 10950Sstevel@tonic-gate goto parse_int; 10960Sstevel@tonic-gate 10970Sstevel@tonic-gate case sMaxAuthTriesLog: 10980Sstevel@tonic-gate intptr = &options->max_auth_tries_log; 10990Sstevel@tonic-gate goto parse_int; 11000Sstevel@tonic-gate 11010Sstevel@tonic-gate case sLookupClientHostnames: 11020Sstevel@tonic-gate intptr = &options->lookup_client_hostnames; 11030Sstevel@tonic-gate goto parse_flag; 1104*9139SJan.Pechanec@Sun.COM 11057574SJan.Pechanec@Sun.COM case sUseOpenSSLEngine: 11067574SJan.Pechanec@Sun.COM intptr = &options->use_openssl_engine; 11077574SJan.Pechanec@Sun.COM goto parse_flag; 11080Sstevel@tonic-gate 1109*9139SJan.Pechanec@Sun.COM case sChrootDirectory: 1110*9139SJan.Pechanec@Sun.COM charptr = &options->chroot_directory; 1111*9139SJan.Pechanec@Sun.COM 1112*9139SJan.Pechanec@Sun.COM arg = strdelim(&cp); 1113*9139SJan.Pechanec@Sun.COM if (arg == NULL || *arg == '\0') 1114*9139SJan.Pechanec@Sun.COM fatal("%s line %d: missing directory name for " 1115*9139SJan.Pechanec@Sun.COM "ChrootDirectory.", filename, linenum); 1116*9139SJan.Pechanec@Sun.COM if (*charptr == NULL) 1117*9139SJan.Pechanec@Sun.COM *charptr = xstrdup(arg); 1118*9139SJan.Pechanec@Sun.COM break; 1119*9139SJan.Pechanec@Sun.COM 11200Sstevel@tonic-gate case sDeprecated: 11210Sstevel@tonic-gate log("%s line %d: Deprecated option %s", 11220Sstevel@tonic-gate filename, linenum, arg); 11230Sstevel@tonic-gate while (arg) 11240Sstevel@tonic-gate arg = strdelim(&cp); 11250Sstevel@tonic-gate break; 11260Sstevel@tonic-gate 11270Sstevel@tonic-gate default: 11280Sstevel@tonic-gate fatal("%s line %d: Missing handler for opcode %s (%d)", 11290Sstevel@tonic-gate filename, linenum, arg, opcode); 11300Sstevel@tonic-gate } 11310Sstevel@tonic-gate if ((arg = strdelim(&cp)) != NULL && *arg != '\0') 11320Sstevel@tonic-gate fatal("%s line %d: garbage at end of line; \"%.200s\".", 11330Sstevel@tonic-gate filename, linenum, arg); 11340Sstevel@tonic-gate return 0; 11350Sstevel@tonic-gate } 11360Sstevel@tonic-gate 11370Sstevel@tonic-gate /* Reads the server configuration file. */ 11380Sstevel@tonic-gate 11390Sstevel@tonic-gate void 11400Sstevel@tonic-gate read_server_config(ServerOptions *options, const char *filename) 11410Sstevel@tonic-gate { 11420Sstevel@tonic-gate int linenum, bad_options = 0; 11430Sstevel@tonic-gate char line[1024]; 11440Sstevel@tonic-gate FILE *f; 11450Sstevel@tonic-gate 11460Sstevel@tonic-gate f = fopen(filename, "r"); 11470Sstevel@tonic-gate if (!f) { 11480Sstevel@tonic-gate perror(filename); 11490Sstevel@tonic-gate exit(1); 11500Sstevel@tonic-gate } 11510Sstevel@tonic-gate linenum = 0; 11520Sstevel@tonic-gate while (fgets(line, sizeof(line), f)) { 11530Sstevel@tonic-gate /* Update line number counter. */ 11540Sstevel@tonic-gate linenum++; 11550Sstevel@tonic-gate if (process_server_config_line(options, line, filename, linenum) != 0) 11560Sstevel@tonic-gate bad_options++; 11570Sstevel@tonic-gate } 11580Sstevel@tonic-gate (void) fclose(f); 11590Sstevel@tonic-gate if (bad_options > 0) 11600Sstevel@tonic-gate fatal("%s: terminating, %d bad configuration options", 11610Sstevel@tonic-gate filename, bad_options); 11620Sstevel@tonic-gate } 1163*9139SJan.Pechanec@Sun.COM 1164*9139SJan.Pechanec@Sun.COM /* 1165*9139SJan.Pechanec@Sun.COM * Note that "none" is a special path having the same affect on sshd 1166*9139SJan.Pechanec@Sun.COM * configuration as not specifying ChrootDirectory at all. 1167*9139SJan.Pechanec@Sun.COM */ 1168*9139SJan.Pechanec@Sun.COM int 1169*9139SJan.Pechanec@Sun.COM chroot_requested(char *chroot_directory) 1170*9139SJan.Pechanec@Sun.COM { 1171*9139SJan.Pechanec@Sun.COM return (chroot_directory != NULL && 1172*9139SJan.Pechanec@Sun.COM strcasecmp(chroot_directory, "none") != 0); 1173*9139SJan.Pechanec@Sun.COM } 1174