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

Annotation of src/usr.bin/ssh/readconf.c, Revision 1.127

1.1       deraadt     1: /*
1.18      deraadt     2:  * Author: Tatu Ylonen <ylo@cs.hut.fi>
                      3:  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
                      4:  *                    All rights reserved
                      5:  * Functions for reading the configuration files.
1.26      markus      6:  *
1.46      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.18      deraadt    12:  */
1.1       deraadt    13:
                     14: #include "includes.h"
1.127   ! markus     15: RCSID("$OpenBSD: readconf.c,v 1.126 2003/12/09 21:53:36 markus Exp $");
1.1       deraadt    16:
                     17: #include "ssh.h"
                     18: #include "xmalloc.h"
1.25      markus     19: #include "compat.h"
1.58      markus     20: #include "cipher.h"
1.55      markus     21: #include "pathnames.h"
1.58      markus     22: #include "log.h"
                     23: #include "readconf.h"
                     24: #include "match.h"
                     25: #include "misc.h"
1.62      markus     26: #include "kex.h"
                     27: #include "mac.h"
1.1       deraadt    28:
                     29: /* Format of the configuration file:
                     30:
                     31:    # Configuration data is parsed as follows:
                     32:    #  1. command line options
                     33:    #  2. user-specific file
                     34:    #  3. system-wide file
                     35:    # Any configuration value is only changed the first time it is set.
                     36:    # Thus, host-specific definitions should be at the beginning of the
                     37:    # configuration file, and defaults at the end.
                     38:
                     39:    # Host-specific declarations.  These may override anything above.  A single
                     40:    # host may match multiple declarations; these are processed in the order
                     41:    # that they are given in.
                     42:
                     43:    Host *.ngs.fi ngs.fi
1.96      markus     44:      User foo
1.1       deraadt    45:
                     46:    Host fake.com
                     47:      HostName another.host.name.real.org
                     48:      User blaah
                     49:      Port 34289
                     50:      ForwardX11 no
                     51:      ForwardAgent no
                     52:
                     53:    Host books.com
                     54:      RemoteForward 9999 shadows.cs.hut.fi:9999
                     55:      Cipher 3des
                     56:
                     57:    Host fascist.blob.com
                     58:      Port 23123
                     59:      User tylonen
                     60:      PasswordAuthentication no
                     61:
                     62:    Host puukko.hut.fi
                     63:      User t35124p
                     64:      ProxyCommand ssh-proxy %h %p
                     65:
                     66:    Host *.fr
1.96      markus     67:      PublicKeyAuthentication no
1.1       deraadt    68:
                     69:    Host *.su
                     70:      Cipher none
                     71:      PasswordAuthentication no
                     72:
                     73:    # Defaults for various options
                     74:    Host *
                     75:      ForwardAgent no
1.50      markus     76:      ForwardX11 no
1.1       deraadt    77:      PasswordAuthentication yes
                     78:      RSAAuthentication yes
                     79:      RhostsRSAAuthentication yes
                     80:      StrictHostKeyChecking yes
1.126     markus     81:      TcpKeepAlive no
1.1       deraadt    82:      IdentityFile ~/.ssh/identity
                     83:      Port 22
                     84:      EscapeChar ~
                     85:
                     86: */
                     87:
                     88: /* Keyword tokens. */
                     89:
1.17      markus     90: typedef enum {
                     91:        oBadOption,
1.123     markus     92:        oForwardAgent, oForwardX11, oForwardX11Trusted, oGatewayPorts,
1.100     deraadt    93:        oPasswordAuthentication, oRSAAuthentication,
1.59      markus     94:        oChallengeResponseAuthentication, oXAuthLocation,
1.17      markus     95:        oIdentityFile, oHostName, oPort, oCipher, oRemoteForward, oLocalForward,
                     96:        oUser, oHost, oEscapeChar, oRhostsRSAAuthentication, oProxyCommand,
                     97:        oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts,
                     98:        oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression,
1.126     markus     99:        oCompressionLevel, oTCPKeepAlive, oNumberOfPasswordPrompts,
1.62      markus    100:        oUsePrivilegedPort, oLogLevel, oCiphers, oProtocol, oMacs,
1.50      markus    101:        oGlobalKnownHostsFile2, oUserKnownHostsFile2, oPubkeyAuthentication,
1.67      markus    102:        oKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias,
1.76      markus    103:        oDynamicForward, oPreferredAuthentications, oHostbasedAuthentication,
1.90      stevesk   104:        oHostKeyAlgorithms, oBindAddress, oSmartcardDevice,
1.96      markus    105:        oClearAllForwardings, oNoHostAuthenticationForLocalhost,
1.111     djm       106:        oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,
1.118     markus    107:        oAddressFamily, oGssAuthentication, oGssDelegateCreds,
1.127   ! markus    108:        oServerAliveInterval, oServerAliveCountMax,
1.110     jakob     109:        oDeprecated, oUnsupported
1.1       deraadt   110: } OpCodes;
                    111:
                    112: /* Textual representations of the tokens. */
                    113:
1.17      markus    114: static struct {
                    115:        const char *name;
                    116:        OpCodes opcode;
                    117: } keywords[] = {
                    118:        { "forwardagent", oForwardAgent },
                    119:        { "forwardx11", oForwardX11 },
1.123     markus    120:        { "forwardx11trusted", oForwardX11Trusted },
1.34      markus    121:        { "xauthlocation", oXAuthLocation },
1.17      markus    122:        { "gatewayports", oGatewayPorts },
                    123:        { "useprivilegedport", oUsePrivilegedPort },
1.116     markus    124:        { "rhostsauthentication", oDeprecated },
1.17      markus    125:        { "passwordauthentication", oPasswordAuthentication },
1.48      markus    126:        { "kbdinteractiveauthentication", oKbdInteractiveAuthentication },
                    127:        { "kbdinteractivedevices", oKbdInteractiveDevices },
1.17      markus    128:        { "rsaauthentication", oRSAAuthentication },
1.50      markus    129:        { "pubkeyauthentication", oPubkeyAuthentication },
1.59      markus    130:        { "dsaauthentication", oPubkeyAuthentication },             /* alias */
1.72      markus    131:        { "rhostsrsaauthentication", oRhostsRSAAuthentication },
1.73      markus    132:        { "hostbasedauthentication", oHostbasedAuthentication },
1.59      markus    133:        { "challengeresponseauthentication", oChallengeResponseAuthentication },
                    134:        { "skeyauthentication", oChallengeResponseAuthentication }, /* alias */
                    135:        { "tisauthentication", oChallengeResponseAuthentication },  /* alias */
1.110     jakob     136:        { "kerberosauthentication", oUnsupported },
                    137:        { "kerberostgtpassing", oUnsupported },
                    138:        { "afstokenpassing", oUnsupported },
1.118     markus    139: #if defined(GSSAPI)
                    140:        { "gssapiauthentication", oGssAuthentication },
                    141:        { "gssapidelegatecredentials", oGssDelegateCreds },
                    142: #else
                    143:        { "gssapiauthentication", oUnsupported },
                    144:        { "gssapidelegatecredentials", oUnsupported },
                    145: #endif
1.96      markus    146:        { "fallbacktorsh", oDeprecated },
                    147:        { "usersh", oDeprecated },
1.17      markus    148:        { "identityfile", oIdentityFile },
1.50      markus    149:        { "identityfile2", oIdentityFile },                     /* alias */
1.17      markus    150:        { "hostname", oHostName },
1.52      markus    151:        { "hostkeyalias", oHostKeyAlias },
1.17      markus    152:        { "proxycommand", oProxyCommand },
                    153:        { "port", oPort },
                    154:        { "cipher", oCipher },
1.25      markus    155:        { "ciphers", oCiphers },
1.62      markus    156:        { "macs", oMacs },
1.25      markus    157:        { "protocol", oProtocol },
1.17      markus    158:        { "remoteforward", oRemoteForward },
                    159:        { "localforward", oLocalForward },
                    160:        { "user", oUser },
                    161:        { "host", oHost },
                    162:        { "escapechar", oEscapeChar },
                    163:        { "globalknownhostsfile", oGlobalKnownHostsFile },
1.81      markus    164:        { "userknownhostsfile", oUserKnownHostsFile },          /* obsolete */
1.27      markus    165:        { "globalknownhostsfile2", oGlobalKnownHostsFile2 },
1.81      markus    166:        { "userknownhostsfile2", oUserKnownHostsFile2 },        /* obsolete */
1.17      markus    167:        { "connectionattempts", oConnectionAttempts },
                    168:        { "batchmode", oBatchMode },
                    169:        { "checkhostip", oCheckHostIP },
                    170:        { "stricthostkeychecking", oStrictHostKeyChecking },
                    171:        { "compression", oCompression },
                    172:        { "compressionlevel", oCompressionLevel },
1.126     markus    173:        { "tcpkeepalive", oTCPKeepAlive },
                    174:        { "keepalive", oTCPKeepAlive },                         /* obsolete */
1.17      markus    175:        { "numberofpasswordprompts", oNumberOfPasswordPrompts },
                    176:        { "loglevel", oLogLevel },
1.71      markus    177:        { "dynamicforward", oDynamicForward },
1.67      markus    178:        { "preferredauthentications", oPreferredAuthentications },
1.76      markus    179:        { "hostkeyalgorithms", oHostKeyAlgorithms },
1.77      markus    180:        { "bindaddress", oBindAddress },
1.110     jakob     181: #ifdef SMARTCARD
1.85      jakob     182:        { "smartcarddevice", oSmartcardDevice },
1.110     jakob     183: #else
                    184:        { "smartcarddevice", oUnsupported },
                    185: #endif
1.93      deraadt   186:        { "clearallforwardings", oClearAllForwardings },
1.101     markus    187:        { "enablesshkeysign", oEnableSSHKeysign },
1.107     jakob     188:        { "verifyhostkeydns", oVerifyHostKeyDNS },
1.93      deraadt   189:        { "nohostauthenticationforlocalhost", oNoHostAuthenticationForLocalhost },
1.105     markus    190:        { "rekeylimit", oRekeyLimit },
1.111     djm       191:        { "connecttimeout", oConnectTimeout },
1.112     djm       192:        { "addressfamily", oAddressFamily },
1.127   ! markus    193:        { "serveraliveinterval", oServerAliveInterval },
        !           194:        { "serveralivecountmax", oServerAliveCountMax },
1.92      stevesk   195:        { NULL, oBadOption }
1.13      markus    196: };
                    197:
1.19      markus    198: /*
                    199:  * Adds a local TCP/IP port forward to options.  Never returns if there is an
                    200:  * error.
                    201:  */
1.1       deraadt   202:
1.26      markus    203: void
1.22      markus    204: add_local_forward(Options *options, u_short port, const char *host,
                    205:                  u_short host_port)
1.1       deraadt   206: {
1.17      markus    207:        Forward *fwd;
                    208:        extern uid_t original_real_uid;
                    209:        if (port < IPPORT_RESERVED && original_real_uid != 0)
1.64      millert   210:                fatal("Privileged ports can only be forwarded by root.");
1.17      markus    211:        if (options->num_local_forwards >= SSH_MAX_FORWARDS_PER_DIRECTION)
                    212:                fatal("Too many local forwards (max %d).", SSH_MAX_FORWARDS_PER_DIRECTION);
                    213:        fwd = &options->local_forwards[options->num_local_forwards++];
                    214:        fwd->port = port;
                    215:        fwd->host = xstrdup(host);
                    216:        fwd->host_port = host_port;
1.1       deraadt   217: }
                    218:
1.19      markus    219: /*
                    220:  * Adds a remote TCP/IP port forward to options.  Never returns if there is
                    221:  * an error.
                    222:  */
1.1       deraadt   223:
1.26      markus    224: void
1.22      markus    225: add_remote_forward(Options *options, u_short port, const char *host,
                    226:                   u_short host_port)
1.1       deraadt   227: {
1.17      markus    228:        Forward *fwd;
                    229:        if (options->num_remote_forwards >= SSH_MAX_FORWARDS_PER_DIRECTION)
                    230:                fatal("Too many remote forwards (max %d).",
1.93      deraadt   231:                    SSH_MAX_FORWARDS_PER_DIRECTION);
1.17      markus    232:        fwd = &options->remote_forwards[options->num_remote_forwards++];
                    233:        fwd->port = port;
                    234:        fwd->host = xstrdup(host);
                    235:        fwd->host_port = host_port;
1.1       deraadt   236: }
                    237:
1.90      stevesk   238: static void
                    239: clear_forwardings(Options *options)
                    240: {
                    241:        int i;
                    242:
                    243:        for (i = 0; i < options->num_local_forwards; i++)
                    244:                xfree(options->local_forwards[i].host);
                    245:        options->num_local_forwards = 0;
                    246:        for (i = 0; i < options->num_remote_forwards; i++)
                    247:                xfree(options->remote_forwards[i].host);
                    248:        options->num_remote_forwards = 0;
                    249: }
                    250:
1.19      markus    251: /*
1.70      stevesk   252:  * Returns the number of the token pointed to by cp or oBadOption.
1.19      markus    253:  */
1.1       deraadt   254:
1.26      markus    255: static OpCodes
1.17      markus    256: parse_token(const char *cp, const char *filename, int linenum)
1.1       deraadt   257: {
1.51      markus    258:        u_int i;
1.1       deraadt   259:
1.17      markus    260:        for (i = 0; keywords[i].name; i++)
1.20      markus    261:                if (strcasecmp(cp, keywords[i].name) == 0)
1.17      markus    262:                        return keywords[i].opcode;
                    263:
1.75      stevesk   264:        error("%s: line %d: Bad configuration option: %s",
                    265:            filename, linenum, cp);
1.17      markus    266:        return oBadOption;
1.1       deraadt   267: }
                    268:
1.19      markus    269: /*
                    270:  * Processes a single option line as used in the configuration files. This
                    271:  * only sets those values that have not already been set.
                    272:  */
1.102     markus    273: #define WHITESPACE " \t\r\n"
1.1       deraadt   274:
1.14      markus    275: int
                    276: process_config_line(Options *options, const char *host,
1.17      markus    277:                    char *line, const char *filename, int linenum,
                    278:                    int *activep)
1.1       deraadt   279: {
1.102     markus    280:        char buf[256], *s, **charptr, *endofnumber, *keyword, *arg;
1.22      markus    281:        int opcode, *intptr, value;
1.102     markus    282:        size_t len;
1.22      markus    283:        u_short fwd_port, fwd_host_port;
1.88      stevesk   284:        char sfwd_host_port[6];
1.106     djm       285:
                    286:        /* Strip trailing whitespace */
                    287:        for(len = strlen(line) - 1; len > 0; len--) {
                    288:                if (strchr(WHITESPACE, line[len]) == NULL)
                    289:                        break;
                    290:                line[len] = '\0';
                    291:        }
1.1       deraadt   292:
1.42      provos    293:        s = line;
                    294:        /* Get the keyword. (Each line is supposed to begin with a keyword). */
                    295:        keyword = strdelim(&s);
                    296:        /* Ignore leading whitespace. */
                    297:        if (*keyword == '\0')
1.43      markus    298:                keyword = strdelim(&s);
1.56      deraadt   299:        if (keyword == NULL || !*keyword || *keyword == '\n' || *keyword == '#')
1.17      markus    300:                return 0;
                    301:
1.38      provos    302:        opcode = parse_token(keyword, filename, linenum);
1.17      markus    303:
                    304:        switch (opcode) {
                    305:        case oBadOption:
1.19      markus    306:                /* don't panic, but count bad options */
                    307:                return -1;
1.17      markus    308:                /* NOTREACHED */
1.111     djm       309:        case oConnectTimeout:
                    310:                intptr = &options->connection_timeout;
1.127   ! markus    311: parse_time:
1.111     djm       312:                arg = strdelim(&s);
                    313:                if (!arg || *arg == '\0')
                    314:                        fatal("%s line %d: missing time value.",
                    315:                            filename, linenum);
                    316:                if ((value = convtime(arg)) == -1)
                    317:                        fatal("%s line %d: invalid time value.",
                    318:                            filename, linenum);
                    319:                if (*intptr == -1)
                    320:                        *intptr = value;
                    321:                break;
                    322:
1.17      markus    323:        case oForwardAgent:
                    324:                intptr = &options->forward_agent;
                    325: parse_flag:
1.42      provos    326:                arg = strdelim(&s);
1.40      ho        327:                if (!arg || *arg == '\0')
1.17      markus    328:                        fatal("%.200s line %d: Missing yes/no argument.", filename, linenum);
                    329:                value = 0;      /* To avoid compiler warning... */
1.38      provos    330:                if (strcmp(arg, "yes") == 0 || strcmp(arg, "true") == 0)
1.17      markus    331:                        value = 1;
1.38      provos    332:                else if (strcmp(arg, "no") == 0 || strcmp(arg, "false") == 0)
1.17      markus    333:                        value = 0;
                    334:                else
                    335:                        fatal("%.200s line %d: Bad yes/no argument.", filename, linenum);
                    336:                if (*activep && *intptr == -1)
                    337:                        *intptr = value;
                    338:                break;
                    339:
                    340:        case oForwardX11:
                    341:                intptr = &options->forward_x11;
                    342:                goto parse_flag;
                    343:
1.123     markus    344:        case oForwardX11Trusted:
                    345:                intptr = &options->forward_x11_trusted;
                    346:                goto parse_flag;
                    347:
1.17      markus    348:        case oGatewayPorts:
                    349:                intptr = &options->gateway_ports;
                    350:                goto parse_flag;
                    351:
                    352:        case oUsePrivilegedPort:
                    353:                intptr = &options->use_privileged_port;
                    354:                goto parse_flag;
                    355:
                    356:        case oPasswordAuthentication:
                    357:                intptr = &options->password_authentication;
                    358:                goto parse_flag;
                    359:
1.48      markus    360:        case oKbdInteractiveAuthentication:
                    361:                intptr = &options->kbd_interactive_authentication;
                    362:                goto parse_flag;
                    363:
                    364:        case oKbdInteractiveDevices:
                    365:                charptr = &options->kbd_interactive_devices;
                    366:                goto parse_string;
                    367:
1.50      markus    368:        case oPubkeyAuthentication:
                    369:                intptr = &options->pubkey_authentication;
1.30      markus    370:                goto parse_flag;
                    371:
1.17      markus    372:        case oRSAAuthentication:
                    373:                intptr = &options->rsa_authentication;
                    374:                goto parse_flag;
                    375:
                    376:        case oRhostsRSAAuthentication:
                    377:                intptr = &options->rhosts_rsa_authentication;
                    378:                goto parse_flag;
                    379:
1.72      markus    380:        case oHostbasedAuthentication:
                    381:                intptr = &options->hostbased_authentication;
                    382:                goto parse_flag;
                    383:
1.59      markus    384:        case oChallengeResponseAuthentication:
1.78      markus    385:                intptr = &options->challenge_response_authentication;
1.17      markus    386:                goto parse_flag;
1.108     jakob     387:
1.118     markus    388:        case oGssAuthentication:
                    389:                intptr = &options->gss_authentication;
                    390:                goto parse_flag;
                    391:
                    392:        case oGssDelegateCreds:
                    393:                intptr = &options->gss_deleg_creds;
                    394:                goto parse_flag;
                    395:
1.17      markus    396:        case oBatchMode:
                    397:                intptr = &options->batch_mode;
                    398:                goto parse_flag;
                    399:
                    400:        case oCheckHostIP:
                    401:                intptr = &options->check_host_ip;
                    402:                goto parse_flag;
                    403:
1.107     jakob     404:        case oVerifyHostKeyDNS:
                    405:                intptr = &options->verify_host_key_dns;
1.125     jakob     406:                goto parse_yesnoask;
1.107     jakob     407:
1.17      markus    408:        case oStrictHostKeyChecking:
                    409:                intptr = &options->strict_host_key_checking;
1.125     jakob     410: parse_yesnoask:
1.42      provos    411:                arg = strdelim(&s);
1.40      ho        412:                if (!arg || *arg == '\0')
1.60      stevesk   413:                        fatal("%.200s line %d: Missing yes/no/ask argument.",
1.93      deraadt   414:                            filename, linenum);
1.17      markus    415:                value = 0;      /* To avoid compiler warning... */
1.38      provos    416:                if (strcmp(arg, "yes") == 0 || strcmp(arg, "true") == 0)
1.17      markus    417:                        value = 1;
1.38      provos    418:                else if (strcmp(arg, "no") == 0 || strcmp(arg, "false") == 0)
1.17      markus    419:                        value = 0;
1.38      provos    420:                else if (strcmp(arg, "ask") == 0)
1.17      markus    421:                        value = 2;
                    422:                else
                    423:                        fatal("%.200s line %d: Bad yes/no/ask argument.", filename, linenum);
                    424:                if (*activep && *intptr == -1)
                    425:                        *intptr = value;
                    426:                break;
                    427:
                    428:        case oCompression:
                    429:                intptr = &options->compression;
                    430:                goto parse_flag;
                    431:
1.126     markus    432:        case oTCPKeepAlive:
                    433:                intptr = &options->tcp_keep_alive;
1.17      markus    434:                goto parse_flag;
                    435:
1.91      markus    436:        case oNoHostAuthenticationForLocalhost:
                    437:                intptr = &options->no_host_authentication_for_localhost;
                    438:                goto parse_flag;
                    439:
1.17      markus    440:        case oNumberOfPasswordPrompts:
                    441:                intptr = &options->number_of_password_prompts;
                    442:                goto parse_int;
                    443:
                    444:        case oCompressionLevel:
                    445:                intptr = &options->compression_level;
                    446:                goto parse_int;
                    447:
1.105     markus    448:        case oRekeyLimit:
                    449:                intptr = &options->rekey_limit;
                    450:                arg = strdelim(&s);
                    451:                if (!arg || *arg == '\0')
                    452:                        fatal("%.200s line %d: Missing argument.", filename, linenum);
                    453:                if (arg[0] < '0' || arg[0] > '9')
                    454:                        fatal("%.200s line %d: Bad number.", filename, linenum);
                    455:                value = strtol(arg, &endofnumber, 10);
                    456:                if (arg == endofnumber)
                    457:                        fatal("%.200s line %d: Bad number.", filename, linenum);
                    458:                switch (toupper(*endofnumber)) {
                    459:                case 'K':
                    460:                        value *= 1<<10;
                    461:                        break;
                    462:                case 'M':
                    463:                        value *= 1<<20;
                    464:                        break;
                    465:                case 'G':
                    466:                        value *= 1<<30;
                    467:                        break;
                    468:                }
                    469:                if (*activep && *intptr == -1)
                    470:                        *intptr = value;
                    471:                break;
                    472:
1.17      markus    473:        case oIdentityFile:
1.42      provos    474:                arg = strdelim(&s);
1.40      ho        475:                if (!arg || *arg == '\0')
1.17      markus    476:                        fatal("%.200s line %d: Missing argument.", filename, linenum);
                    477:                if (*activep) {
1.50      markus    478:                        intptr = &options->num_identity_files;
1.27      markus    479:                        if (*intptr >= SSH_MAX_IDENTITY_FILES)
1.17      markus    480:                                fatal("%.200s line %d: Too many identity files specified (max %d).",
1.93      deraadt   481:                                    filename, linenum, SSH_MAX_IDENTITY_FILES);
1.50      markus    482:                        charptr =  &options->identity_files[*intptr];
1.38      provos    483:                        *charptr = xstrdup(arg);
1.27      markus    484:                        *intptr = *intptr + 1;
1.17      markus    485:                }
                    486:                break;
                    487:
1.34      markus    488:        case oXAuthLocation:
                    489:                charptr=&options->xauth_location;
                    490:                goto parse_string;
                    491:
1.17      markus    492:        case oUser:
                    493:                charptr = &options->user;
                    494: parse_string:
1.42      provos    495:                arg = strdelim(&s);
1.40      ho        496:                if (!arg || *arg == '\0')
1.17      markus    497:                        fatal("%.200s line %d: Missing argument.", filename, linenum);
                    498:                if (*activep && *charptr == NULL)
1.38      provos    499:                        *charptr = xstrdup(arg);
1.17      markus    500:                break;
                    501:
                    502:        case oGlobalKnownHostsFile:
                    503:                charptr = &options->system_hostfile;
                    504:                goto parse_string;
                    505:
                    506:        case oUserKnownHostsFile:
                    507:                charptr = &options->user_hostfile;
                    508:                goto parse_string;
                    509:
1.27      markus    510:        case oGlobalKnownHostsFile2:
                    511:                charptr = &options->system_hostfile2;
                    512:                goto parse_string;
                    513:
                    514:        case oUserKnownHostsFile2:
                    515:                charptr = &options->user_hostfile2;
                    516:                goto parse_string;
                    517:
1.17      markus    518:        case oHostName:
                    519:                charptr = &options->hostname;
                    520:                goto parse_string;
                    521:
1.52      markus    522:        case oHostKeyAlias:
                    523:                charptr = &options->host_key_alias;
                    524:                goto parse_string;
                    525:
1.67      markus    526:        case oPreferredAuthentications:
                    527:                charptr = &options->preferred_authentications;
                    528:                goto parse_string;
                    529:
1.77      markus    530:        case oBindAddress:
                    531:                charptr = &options->bind_address;
                    532:                goto parse_string;
                    533:
1.85      jakob     534:        case oSmartcardDevice:
1.86      markus    535:                charptr = &options->smartcard_device;
                    536:                goto parse_string;
1.85      jakob     537:
1.17      markus    538:        case oProxyCommand:
1.113     markus    539:                if (s == NULL)
                    540:                        fatal("%.200s line %d: Missing argument.", filename, linenum);
1.17      markus    541:                charptr = &options->proxy_command;
1.102     markus    542:                len = strspn(s, WHITESPACE "=");
1.17      markus    543:                if (*activep && *charptr == NULL)
1.102     markus    544:                        *charptr = xstrdup(s + len);
1.17      markus    545:                return 0;
                    546:
                    547:        case oPort:
                    548:                intptr = &options->port;
                    549: parse_int:
1.42      provos    550:                arg = strdelim(&s);
1.40      ho        551:                if (!arg || *arg == '\0')
1.17      markus    552:                        fatal("%.200s line %d: Missing argument.", filename, linenum);
1.38      provos    553:                if (arg[0] < '0' || arg[0] > '9')
1.17      markus    554:                        fatal("%.200s line %d: Bad number.", filename, linenum);
1.21      markus    555:
                    556:                /* Octal, decimal, or hex format? */
1.38      provos    557:                value = strtol(arg, &endofnumber, 0);
                    558:                if (arg == endofnumber)
1.21      markus    559:                        fatal("%.200s line %d: Bad number.", filename, linenum);
1.17      markus    560:                if (*activep && *intptr == -1)
                    561:                        *intptr = value;
                    562:                break;
                    563:
                    564:        case oConnectionAttempts:
                    565:                intptr = &options->connection_attempts;
                    566:                goto parse_int;
                    567:
                    568:        case oCipher:
                    569:                intptr = &options->cipher;
1.42      provos    570:                arg = strdelim(&s);
1.40      ho        571:                if (!arg || *arg == '\0')
1.32      markus    572:                        fatal("%.200s line %d: Missing argument.", filename, linenum);
1.38      provos    573:                value = cipher_number(arg);
1.17      markus    574:                if (value == -1)
                    575:                        fatal("%.200s line %d: Bad cipher '%s'.",
1.93      deraadt   576:                            filename, linenum, arg ? arg : "<NONE>");
1.17      markus    577:                if (*activep && *intptr == -1)
                    578:                        *intptr = value;
                    579:                break;
                    580:
1.25      markus    581:        case oCiphers:
1.42      provos    582:                arg = strdelim(&s);
1.40      ho        583:                if (!arg || *arg == '\0')
1.32      markus    584:                        fatal("%.200s line %d: Missing argument.", filename, linenum);
1.38      provos    585:                if (!ciphers_valid(arg))
1.31      markus    586:                        fatal("%.200s line %d: Bad SSH2 cipher spec '%s'.",
1.93      deraadt   587:                            filename, linenum, arg ? arg : "<NONE>");
1.25      markus    588:                if (*activep && options->ciphers == NULL)
1.38      provos    589:                        options->ciphers = xstrdup(arg);
1.25      markus    590:                break;
                    591:
1.62      markus    592:        case oMacs:
                    593:                arg = strdelim(&s);
                    594:                if (!arg || *arg == '\0')
                    595:                        fatal("%.200s line %d: Missing argument.", filename, linenum);
                    596:                if (!mac_valid(arg))
                    597:                        fatal("%.200s line %d: Bad SSH2 Mac spec '%s'.",
1.93      deraadt   598:                            filename, linenum, arg ? arg : "<NONE>");
1.62      markus    599:                if (*activep && options->macs == NULL)
                    600:                        options->macs = xstrdup(arg);
                    601:                break;
                    602:
1.76      markus    603:        case oHostKeyAlgorithms:
                    604:                arg = strdelim(&s);
                    605:                if (!arg || *arg == '\0')
                    606:                        fatal("%.200s line %d: Missing argument.", filename, linenum);
                    607:                if (!key_names_valid2(arg))
                    608:                        fatal("%.200s line %d: Bad protocol 2 host key algorithms '%s'.",
1.93      deraadt   609:                            filename, linenum, arg ? arg : "<NONE>");
1.76      markus    610:                if (*activep && options->hostkeyalgorithms == NULL)
                    611:                        options->hostkeyalgorithms = xstrdup(arg);
                    612:                break;
                    613:
1.25      markus    614:        case oProtocol:
                    615:                intptr = &options->protocol;
1.42      provos    616:                arg = strdelim(&s);
1.40      ho        617:                if (!arg || *arg == '\0')
1.32      markus    618:                        fatal("%.200s line %d: Missing argument.", filename, linenum);
1.38      provos    619:                value = proto_spec(arg);
1.25      markus    620:                if (value == SSH_PROTO_UNKNOWN)
                    621:                        fatal("%.200s line %d: Bad protocol spec '%s'.",
1.93      deraadt   622:                            filename, linenum, arg ? arg : "<NONE>");
1.25      markus    623:                if (*activep && *intptr == SSH_PROTO_UNKNOWN)
                    624:                        *intptr = value;
                    625:                break;
                    626:
1.17      markus    627:        case oLogLevel:
                    628:                intptr = (int *) &options->log_level;
1.42      provos    629:                arg = strdelim(&s);
1.38      provos    630:                value = log_level_number(arg);
1.95      markus    631:                if (value == SYSLOG_LEVEL_NOT_SET)
1.64      millert   632:                        fatal("%.200s line %d: unsupported log level '%s'",
1.93      deraadt   633:                            filename, linenum, arg ? arg : "<NONE>");
1.95      markus    634:                if (*activep && (LogLevel) *intptr == SYSLOG_LEVEL_NOT_SET)
1.17      markus    635:                        *intptr = (LogLevel) value;
                    636:                break;
                    637:
1.88      stevesk   638:        case oLocalForward:
1.17      markus    639:        case oRemoteForward:
1.42      provos    640:                arg = strdelim(&s);
1.40      ho        641:                if (!arg || *arg == '\0')
1.88      stevesk   642:                        fatal("%.200s line %d: Missing port argument.",
                    643:                            filename, linenum);
                    644:                if ((fwd_port = a2port(arg)) == 0)
                    645:                        fatal("%.200s line %d: Bad listen port.",
                    646:                            filename, linenum);
1.42      provos    647:                arg = strdelim(&s);
1.40      ho        648:                if (!arg || *arg == '\0')
1.17      markus    649:                        fatal("%.200s line %d: Missing second argument.",
1.88      stevesk   650:                            filename, linenum);
                    651:                if (sscanf(arg, "%255[^:]:%5[0-9]", buf, sfwd_host_port) != 2 &&
                    652:                    sscanf(arg, "%255[^/]/%5[0-9]", buf, sfwd_host_port) != 2)
                    653:                        fatal("%.200s line %d: Bad forwarding specification.",
                    654:                            filename, linenum);
                    655:                if ((fwd_host_port = a2port(sfwd_host_port)) == 0)
                    656:                        fatal("%.200s line %d: Bad forwarding port.",
                    657:                            filename, linenum);
                    658:                if (*activep) {
                    659:                        if (opcode == oLocalForward)
                    660:                                add_local_forward(options, fwd_port, buf,
                    661:                                    fwd_host_port);
                    662:                        else if (opcode == oRemoteForward)
                    663:                                add_remote_forward(options, fwd_port, buf,
                    664:                                    fwd_host_port);
                    665:                }
1.17      markus    666:                break;
1.71      markus    667:
                    668:        case oDynamicForward:
                    669:                arg = strdelim(&s);
                    670:                if (!arg || *arg == '\0')
                    671:                        fatal("%.200s line %d: Missing port argument.",
                    672:                            filename, linenum);
1.74      stevesk   673:                fwd_port = a2port(arg);
                    674:                if (fwd_port == 0)
1.71      markus    675:                        fatal("%.200s line %d: Badly formatted port number.",
                    676:                            filename, linenum);
1.87      markus    677:                if (*activep)
1.117     markus    678:                        add_local_forward(options, fwd_port, "socks", 0);
1.72      markus    679:                break;
1.17      markus    680:
1.90      stevesk   681:        case oClearAllForwardings:
                    682:                intptr = &options->clear_forwardings;
                    683:                goto parse_flag;
                    684:
1.17      markus    685:        case oHost:
                    686:                *activep = 0;
1.42      provos    687:                while ((arg = strdelim(&s)) != NULL && *arg != '\0')
1.38      provos    688:                        if (match_pattern(host, arg)) {
                    689:                                debug("Applying options for %.100s", arg);
1.17      markus    690:                                *activep = 1;
                    691:                                break;
                    692:                        }
1.42      provos    693:                /* Avoid garbage check below, as strdelim is done. */
1.17      markus    694:                return 0;
                    695:
                    696:        case oEscapeChar:
                    697:                intptr = &options->escape_char;
1.42      provos    698:                arg = strdelim(&s);
1.40      ho        699:                if (!arg || *arg == '\0')
1.17      markus    700:                        fatal("%.200s line %d: Missing argument.", filename, linenum);
1.38      provos    701:                if (arg[0] == '^' && arg[2] == 0 &&
1.51      markus    702:                    (u_char) arg[1] >= 64 && (u_char) arg[1] < 128)
                    703:                        value = (u_char) arg[1] & 31;
1.38      provos    704:                else if (strlen(arg) == 1)
1.51      markus    705:                        value = (u_char) arg[0];
1.38      provos    706:                else if (strcmp(arg, "none") == 0)
1.79      stevesk   707:                        value = SSH_ESCAPECHAR_NONE;
1.17      markus    708:                else {
                    709:                        fatal("%.200s line %d: Bad escape character.",
1.93      deraadt   710:                            filename, linenum);
1.17      markus    711:                        /* NOTREACHED */
                    712:                        value = 0;      /* Avoid compiler warning. */
                    713:                }
                    714:                if (*activep && *intptr == -1)
                    715:                        *intptr = value;
1.112     djm       716:                break;
                    717:
                    718:        case oAddressFamily:
                    719:                arg = strdelim(&s);
1.114     djm       720:                intptr = &options->address_family;
1.112     djm       721:                if (strcasecmp(arg, "inet") == 0)
1.114     djm       722:                        value = AF_INET;
1.112     djm       723:                else if (strcasecmp(arg, "inet6") == 0)
1.114     djm       724:                        value = AF_INET6;
1.112     djm       725:                else if (strcasecmp(arg, "any") == 0)
1.114     djm       726:                        value = AF_UNSPEC;
1.112     djm       727:                else
                    728:                        fatal("Unsupported AddressFamily \"%s\"", arg);
1.114     djm       729:                if (*activep && *intptr == -1)
                    730:                        *intptr = value;
1.17      markus    731:                break;
                    732:
1.101     markus    733:        case oEnableSSHKeysign:
                    734:                intptr = &options->enable_ssh_keysign;
                    735:                goto parse_flag;
                    736:
1.127   ! markus    737:        case oServerAliveInterval:
        !           738:                intptr = &options->server_alive_interval;
        !           739:                goto parse_time;
        !           740:
        !           741:        case oServerAliveCountMax:
        !           742:                intptr = &options->server_alive_count_max;
        !           743:                goto parse_int;
        !           744:
1.96      markus    745:        case oDeprecated:
1.98      markus    746:                debug("%s line %d: Deprecated option \"%s\"",
1.96      markus    747:                    filename, linenum, keyword);
1.98      markus    748:                return 0;
1.96      markus    749:
1.110     jakob     750:        case oUnsupported:
                    751:                error("%s line %d: Unsupported option \"%s\"",
                    752:                    filename, linenum, keyword);
                    753:                return 0;
                    754:
1.17      markus    755:        default:
                    756:                fatal("process_config_line: Unimplemented opcode %d", opcode);
                    757:        }
                    758:
                    759:        /* Check that there is no garbage at end of line. */
1.57      djm       760:        if ((arg = strdelim(&s)) != NULL && *arg != '\0') {
1.39      ho        761:                fatal("%.200s line %d: garbage at end of line; \"%.200s\".",
1.93      deraadt   762:                     filename, linenum, arg);
1.39      ho        763:        }
1.17      markus    764:        return 0;
1.1       deraadt   765: }
                    766:
                    767:
1.19      markus    768: /*
                    769:  * Reads the config file and modifies the options accordingly.  Options
                    770:  * should already be initialized before this call.  This never returns if
1.89      stevesk   771:  * there is an error.  If the file does not exist, this returns 0.
1.19      markus    772:  */
1.1       deraadt   773:
1.89      stevesk   774: int
1.17      markus    775: read_config_file(const char *filename, const char *host, Options *options)
1.1       deraadt   776: {
1.17      markus    777:        FILE *f;
                    778:        char line[1024];
                    779:        int active, linenum;
                    780:        int bad_options = 0;
                    781:
                    782:        /* Open the file. */
                    783:        f = fopen(filename, "r");
                    784:        if (!f)
1.89      stevesk   785:                return 0;
1.17      markus    786:
                    787:        debug("Reading configuration data %.200s", filename);
                    788:
1.19      markus    789:        /*
                    790:         * Mark that we are now processing the options.  This flag is turned
                    791:         * on/off by Host specifications.
                    792:         */
1.17      markus    793:        active = 1;
                    794:        linenum = 0;
                    795:        while (fgets(line, sizeof(line), f)) {
                    796:                /* Update line number counter. */
                    797:                linenum++;
                    798:                if (process_config_line(options, host, line, filename, linenum, &active) != 0)
                    799:                        bad_options++;
                    800:        }
                    801:        fclose(f);
                    802:        if (bad_options > 0)
1.64      millert   803:                fatal("%s: terminating, %d bad configuration options",
1.93      deraadt   804:                    filename, bad_options);
1.89      stevesk   805:        return 1;
1.1       deraadt   806: }
                    807:
1.19      markus    808: /*
                    809:  * Initializes options to special values that indicate that they have not yet
                    810:  * been set.  Read_config_file will only set options with this value. Options
                    811:  * are processed in the following order: command line, user config file,
                    812:  * system config file.  Last, fill_default_options is called.
                    813:  */
1.1       deraadt   814:
1.26      markus    815: void
1.17      markus    816: initialize_options(Options * options)
1.1       deraadt   817: {
1.17      markus    818:        memset(options, 'X', sizeof(*options));
                    819:        options->forward_agent = -1;
                    820:        options->forward_x11 = -1;
1.123     markus    821:        options->forward_x11_trusted = -1;
1.34      markus    822:        options->xauth_location = NULL;
1.17      markus    823:        options->gateway_ports = -1;
                    824:        options->use_privileged_port = -1;
                    825:        options->rsa_authentication = -1;
1.50      markus    826:        options->pubkey_authentication = -1;
1.78      markus    827:        options->challenge_response_authentication = -1;
1.118     markus    828:        options->gss_authentication = -1;
                    829:        options->gss_deleg_creds = -1;
1.17      markus    830:        options->password_authentication = -1;
1.48      markus    831:        options->kbd_interactive_authentication = -1;
                    832:        options->kbd_interactive_devices = NULL;
1.17      markus    833:        options->rhosts_rsa_authentication = -1;
1.72      markus    834:        options->hostbased_authentication = -1;
1.17      markus    835:        options->batch_mode = -1;
                    836:        options->check_host_ip = -1;
                    837:        options->strict_host_key_checking = -1;
                    838:        options->compression = -1;
1.126     markus    839:        options->tcp_keep_alive = -1;
1.17      markus    840:        options->compression_level = -1;
                    841:        options->port = -1;
1.114     djm       842:        options->address_family = -1;
1.17      markus    843:        options->connection_attempts = -1;
1.111     djm       844:        options->connection_timeout = -1;
1.17      markus    845:        options->number_of_password_prompts = -1;
                    846:        options->cipher = -1;
1.25      markus    847:        options->ciphers = NULL;
1.62      markus    848:        options->macs = NULL;
1.76      markus    849:        options->hostkeyalgorithms = NULL;
1.25      markus    850:        options->protocol = SSH_PROTO_UNKNOWN;
1.17      markus    851:        options->num_identity_files = 0;
                    852:        options->hostname = NULL;
1.52      markus    853:        options->host_key_alias = NULL;
1.17      markus    854:        options->proxy_command = NULL;
                    855:        options->user = NULL;
                    856:        options->escape_char = -1;
                    857:        options->system_hostfile = NULL;
                    858:        options->user_hostfile = NULL;
1.27      markus    859:        options->system_hostfile2 = NULL;
                    860:        options->user_hostfile2 = NULL;
1.17      markus    861:        options->num_local_forwards = 0;
                    862:        options->num_remote_forwards = 0;
1.90      stevesk   863:        options->clear_forwardings = -1;
1.95      markus    864:        options->log_level = SYSLOG_LEVEL_NOT_SET;
1.67      markus    865:        options->preferred_authentications = NULL;
1.77      markus    866:        options->bind_address = NULL;
1.86      markus    867:        options->smartcard_device = NULL;
1.101     markus    868:        options->enable_ssh_keysign = - 1;
1.91      markus    869:        options->no_host_authentication_for_localhost = - 1;
1.105     markus    870:        options->rekey_limit = - 1;
1.107     jakob     871:        options->verify_host_key_dns = -1;
1.127   ! markus    872:        options->server_alive_interval = -1;
        !           873:        options->server_alive_count_max = -1;
1.1       deraadt   874: }
                    875:
1.19      markus    876: /*
                    877:  * Called after processing other sources of option data, this fills those
                    878:  * options for which no value has been specified with their default values.
                    879:  */
1.1       deraadt   880:
1.26      markus    881: void
1.17      markus    882: fill_default_options(Options * options)
1.1       deraadt   883: {
1.61      deraadt   884:        int len;
                    885:
1.17      markus    886:        if (options->forward_agent == -1)
1.33      markus    887:                options->forward_agent = 0;
1.17      markus    888:        if (options->forward_x11 == -1)
1.23      markus    889:                options->forward_x11 = 0;
1.123     markus    890:        if (options->forward_x11_trusted == -1)
                    891:                options->forward_x11_trusted = 0;
1.34      markus    892:        if (options->xauth_location == NULL)
1.80      markus    893:                options->xauth_location = _PATH_XAUTH;
1.17      markus    894:        if (options->gateway_ports == -1)
                    895:                options->gateway_ports = 0;
                    896:        if (options->use_privileged_port == -1)
1.65      markus    897:                options->use_privileged_port = 0;
1.17      markus    898:        if (options->rsa_authentication == -1)
                    899:                options->rsa_authentication = 1;
1.50      markus    900:        if (options->pubkey_authentication == -1)
                    901:                options->pubkey_authentication = 1;
1.78      markus    902:        if (options->challenge_response_authentication == -1)
1.83      markus    903:                options->challenge_response_authentication = 1;
1.118     markus    904:        if (options->gss_authentication == -1)
1.122     markus    905:                options->gss_authentication = 0;
1.118     markus    906:        if (options->gss_deleg_creds == -1)
                    907:                options->gss_deleg_creds = 0;
1.17      markus    908:        if (options->password_authentication == -1)
                    909:                options->password_authentication = 1;
1.48      markus    910:        if (options->kbd_interactive_authentication == -1)
1.59      markus    911:                options->kbd_interactive_authentication = 1;
1.17      markus    912:        if (options->rhosts_rsa_authentication == -1)
1.99      stevesk   913:                options->rhosts_rsa_authentication = 0;
1.72      markus    914:        if (options->hostbased_authentication == -1)
                    915:                options->hostbased_authentication = 0;
1.17      markus    916:        if (options->batch_mode == -1)
                    917:                options->batch_mode = 0;
                    918:        if (options->check_host_ip == -1)
                    919:                options->check_host_ip = 1;
                    920:        if (options->strict_host_key_checking == -1)
                    921:                options->strict_host_key_checking = 2;  /* 2 is default */
                    922:        if (options->compression == -1)
                    923:                options->compression = 0;
1.126     markus    924:        if (options->tcp_keep_alive == -1)
                    925:                options->tcp_keep_alive = 1;
1.17      markus    926:        if (options->compression_level == -1)
                    927:                options->compression_level = 6;
                    928:        if (options->port == -1)
                    929:                options->port = 0;      /* Filled in ssh_connect. */
1.114     djm       930:        if (options->address_family == -1)
                    931:                options->address_family = AF_UNSPEC;
1.17      markus    932:        if (options->connection_attempts == -1)
1.84      markus    933:                options->connection_attempts = 1;
1.17      markus    934:        if (options->number_of_password_prompts == -1)
                    935:                options->number_of_password_prompts = 3;
                    936:        /* Selected in ssh_login(). */
                    937:        if (options->cipher == -1)
                    938:                options->cipher = SSH_CIPHER_NOT_SET;
1.31      markus    939:        /* options->ciphers, default set in myproposals.h */
1.62      markus    940:        /* options->macs, default set in myproposals.h */
1.76      markus    941:        /* options->hostkeyalgorithms, default set in myproposals.h */
1.25      markus    942:        if (options->protocol == SSH_PROTO_UNKNOWN)
1.69      markus    943:                options->protocol = SSH_PROTO_1|SSH_PROTO_2;
1.17      markus    944:        if (options->num_identity_files == 0) {
1.50      markus    945:                if (options->protocol & SSH_PROTO_1) {
1.61      deraadt   946:                        len = 2 + strlen(_PATH_SSH_CLIENT_IDENTITY) + 1;
1.50      markus    947:                        options->identity_files[options->num_identity_files] =
1.61      deraadt   948:                            xmalloc(len);
                    949:                        snprintf(options->identity_files[options->num_identity_files++],
                    950:                            len, "~/%.100s", _PATH_SSH_CLIENT_IDENTITY);
1.50      markus    951:                }
                    952:                if (options->protocol & SSH_PROTO_2) {
1.63      deraadt   953:                        len = 2 + strlen(_PATH_SSH_CLIENT_ID_RSA) + 1;
                    954:                        options->identity_files[options->num_identity_files] =
                    955:                            xmalloc(len);
                    956:                        snprintf(options->identity_files[options->num_identity_files++],
                    957:                            len, "~/%.100s", _PATH_SSH_CLIENT_ID_RSA);
                    958:
1.61      deraadt   959:                        len = 2 + strlen(_PATH_SSH_CLIENT_ID_DSA) + 1;
1.50      markus    960:                        options->identity_files[options->num_identity_files] =
1.61      deraadt   961:                            xmalloc(len);
                    962:                        snprintf(options->identity_files[options->num_identity_files++],
                    963:                            len, "~/%.100s", _PATH_SSH_CLIENT_ID_DSA);
1.50      markus    964:                }
1.27      markus    965:        }
1.17      markus    966:        if (options->escape_char == -1)
                    967:                options->escape_char = '~';
                    968:        if (options->system_hostfile == NULL)
1.55      markus    969:                options->system_hostfile = _PATH_SSH_SYSTEM_HOSTFILE;
1.17      markus    970:        if (options->user_hostfile == NULL)
1.55      markus    971:                options->user_hostfile = _PATH_SSH_USER_HOSTFILE;
1.27      markus    972:        if (options->system_hostfile2 == NULL)
1.55      markus    973:                options->system_hostfile2 = _PATH_SSH_SYSTEM_HOSTFILE2;
1.27      markus    974:        if (options->user_hostfile2 == NULL)
1.55      markus    975:                options->user_hostfile2 = _PATH_SSH_USER_HOSTFILE2;
1.95      markus    976:        if (options->log_level == SYSLOG_LEVEL_NOT_SET)
1.54      markus    977:                options->log_level = SYSLOG_LEVEL_INFO;
1.90      stevesk   978:        if (options->clear_forwardings == 1)
                    979:                clear_forwardings(options);
1.91      markus    980:        if (options->no_host_authentication_for_localhost == - 1)
                    981:                options->no_host_authentication_for_localhost = 0;
1.101     markus    982:        if (options->enable_ssh_keysign == -1)
                    983:                options->enable_ssh_keysign = 0;
1.105     markus    984:        if (options->rekey_limit == -1)
                    985:                options->rekey_limit = 0;
1.107     jakob     986:        if (options->verify_host_key_dns == -1)
                    987:                options->verify_host_key_dns = 0;
1.127   ! markus    988:        if (options->server_alive_interval == -1)
        !           989:                options->server_alive_interval = 0;
        !           990:        if (options->server_alive_count_max == -1)
        !           991:                options->server_alive_count_max = 3;
1.17      markus    992:        /* options->proxy_command should not be set by default */
                    993:        /* options->user will be set in the main program if appropriate */
                    994:        /* options->hostname will be set in the main program if appropriate */
1.52      markus    995:        /* options->host_key_alias should not be set by default */
1.67      markus    996:        /* options->preferred_authentications will be set in ssh */
1.1       deraadt   997: }