[BACK]Return to servconf.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Annotation of src/usr.bin/ssh/servconf.c, Revision 1.230

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