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