Annotation of src/usr.bin/ssh/readconf.c, Revision 1.1
1.1 ! deraadt 1: /*
! 2:
! 3: readconf.c
! 4:
! 5: Author: Tatu Ylonen <ylo@cs.hut.fi>
! 6:
! 7: Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
! 8: All rights reserved
! 9:
! 10: Created: Sat Apr 22 00:03:10 1995 ylo
! 11:
! 12: Functions for reading the configuration files.
! 13:
! 14: */
! 15:
! 16: #include "includes.h"
! 17: RCSID("$Id: readconf.c,v 1.13 1999/06/14 10:20:32 bg Exp $");
! 18:
! 19: #include "ssh.h"
! 20: #include "cipher.h"
! 21: #include "readconf.h"
! 22: #include "xmalloc.h"
! 23:
! 24: /* Format of the configuration file:
! 25:
! 26: # Configuration data is parsed as follows:
! 27: # 1. command line options
! 28: # 2. user-specific file
! 29: # 3. system-wide file
! 30: # Any configuration value is only changed the first time it is set.
! 31: # Thus, host-specific definitions should be at the beginning of the
! 32: # configuration file, and defaults at the end.
! 33:
! 34: # Host-specific declarations. These may override anything above. A single
! 35: # host may match multiple declarations; these are processed in the order
! 36: # that they are given in.
! 37:
! 38: Host *.ngs.fi ngs.fi
! 39: FallBackToRsh no
! 40:
! 41: Host fake.com
! 42: HostName another.host.name.real.org
! 43: User blaah
! 44: Port 34289
! 45: ForwardX11 no
! 46: ForwardAgent no
! 47:
! 48: Host books.com
! 49: RemoteForward 9999 shadows.cs.hut.fi:9999
! 50: Cipher 3des
! 51:
! 52: Host fascist.blob.com
! 53: Port 23123
! 54: User tylonen
! 55: RhostsAuthentication no
! 56: PasswordAuthentication no
! 57:
! 58: Host puukko.hut.fi
! 59: User t35124p
! 60: ProxyCommand ssh-proxy %h %p
! 61:
! 62: Host *.fr
! 63: UseRsh yes
! 64:
! 65: Host *.su
! 66: Cipher none
! 67: PasswordAuthentication no
! 68:
! 69: # Defaults for various options
! 70: Host *
! 71: ForwardAgent no
! 72: ForwardX11 yes
! 73: RhostsAuthentication yes
! 74: PasswordAuthentication yes
! 75: RSAAuthentication yes
! 76: RhostsRSAAuthentication yes
! 77: FallBackToRsh no
! 78: UseRsh no
! 79: StrictHostKeyChecking yes
! 80: KeepAlives no
! 81: IdentityFile ~/.ssh/identity
! 82: Port 22
! 83: Cipher idea
! 84: EscapeChar ~
! 85:
! 86: */
! 87:
! 88: /* Keyword tokens. */
! 89:
! 90: typedef enum
! 91: {
! 92: oForwardAgent, oForwardX11, oRhostsAuthentication,
! 93: oPasswordAuthentication, oRSAAuthentication, oFallBackToRsh, oUseRsh,
! 94: #ifdef KRB4
! 95: oKerberosAuthentication,
! 96: #endif /* KRB4 */
! 97: #ifdef KERBEROS_TGT_PASSING
! 98: oKerberosTgtPassing,
! 99: #endif
! 100: #ifdef AFS
! 101: oAFSTokenPassing,
! 102: #endif
! 103: oIdentityFile, oHostName, oPort, oCipher, oRemoteForward, oLocalForward,
! 104: oUser, oHost, oEscapeChar, oRhostsRSAAuthentication, oProxyCommand,
! 105: oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts,
! 106: oBatchMode, oStrictHostKeyChecking, oCompression, oCompressionLevel,
! 107: oKeepAlives, oTISAuthentication
! 108: } OpCodes;
! 109:
! 110: /* Textual representations of the tokens. */
! 111:
! 112: static struct
! 113: {
! 114: const char *name;
! 115: OpCodes opcode;
! 116: } keywords[] =
! 117: {
! 118: { "forwardagent", oForwardAgent },
! 119: { "forwardx11", oForwardX11 },
! 120: { "rhostsauthentication", oRhostsAuthentication },
! 121: { "passwordauthentication", oPasswordAuthentication },
! 122: { "rsaauthentication", oRSAAuthentication },
! 123: #ifdef KRB4
! 124: { "kerberosauthentication", oKerberosAuthentication },
! 125: #endif /* KRB4 */
! 126: #ifdef KERBEROS_TGT_PASSING
! 127: { "kerberostgtpassing", oKerberosTgtPassing },
! 128: #endif
! 129: #ifdef AFS
! 130: { "afstokenpassing", oAFSTokenPassing },
! 131: #endif
! 132: { "fallbacktorsh", oFallBackToRsh },
! 133: { "usersh", oUseRsh },
! 134: { "identityfile", oIdentityFile },
! 135: { "hostname", oHostName },
! 136: { "proxycommand", oProxyCommand },
! 137: { "port", oPort },
! 138: { "cipher", oCipher },
! 139: { "remoteforward", oRemoteForward },
! 140: { "localforward", oLocalForward },
! 141: { "user", oUser },
! 142: { "host", oHost },
! 143: { "escapechar", oEscapeChar },
! 144: { "rhostsrsaauthentication", oRhostsRSAAuthentication },
! 145: { "globalknownhostsfile", oGlobalKnownHostsFile },
! 146: { "userknownhostsfile", oUserKnownHostsFile },
! 147: { "connectionattempts", oConnectionAttempts },
! 148: { "batchmode", oBatchMode },
! 149: { "stricthostkeychecking", oStrictHostKeyChecking },
! 150: { "compression", oCompression },
! 151: { "compressionlevel", oCompressionLevel },
! 152: { "keepalive", oKeepAlives },
! 153: { "tisauthentication", oTISAuthentication },
! 154: { NULL, 0 }
! 155: };
! 156:
! 157: /* Characters considered whitespace in strtok calls. */
! 158: #define WHITESPACE " \t\r\n"
! 159:
! 160:
! 161: /* Adds a local TCP/IP port forward to options. Never returns if there
! 162: is an error. */
! 163:
! 164: void add_local_forward(Options *options, int port, const char *host,
! 165: int host_port)
! 166: {
! 167: Forward *fwd;
! 168: if (options->num_local_forwards >= SSH_MAX_FORWARDS_PER_DIRECTION)
! 169: fatal("Too many local forwards (max %d).", SSH_MAX_FORWARDS_PER_DIRECTION);
! 170: fwd = &options->local_forwards[options->num_local_forwards++];
! 171: fwd->port = port;
! 172: fwd->host = xstrdup(host);
! 173: fwd->host_port = host_port;
! 174: }
! 175:
! 176: /* Adds a remote TCP/IP port forward to options. Never returns if there
! 177: is an error. */
! 178:
! 179: void add_remote_forward(Options *options, int port, const char *host,
! 180: int host_port)
! 181: {
! 182: Forward *fwd;
! 183: if (options->num_remote_forwards >= SSH_MAX_FORWARDS_PER_DIRECTION)
! 184: fatal("Too many remote forwards (max %d).",
! 185: SSH_MAX_FORWARDS_PER_DIRECTION);
! 186: fwd = &options->remote_forwards[options->num_remote_forwards++];
! 187: fwd->port = port;
! 188: fwd->host = xstrdup(host);
! 189: fwd->host_port = host_port;
! 190: }
! 191:
! 192: /* Returns the number of the token pointed to by cp of length len.
! 193: Never returns if the token is not known. */
! 194:
! 195: static OpCodes parse_token(const char *cp, const char *filename, int linenum)
! 196: {
! 197: unsigned int i;
! 198:
! 199: for (i = 0; keywords[i].name; i++)
! 200: if (strcmp(cp, keywords[i].name) == 0)
! 201: return keywords[i].opcode;
! 202:
! 203: fatal("%.200s line %d: Bad configuration option.",
! 204: filename, linenum);
! 205: /*NOTREACHED*/
! 206: return 0;
! 207: }
! 208:
! 209: /* Processes a single option line as used in the configuration files.
! 210: This only sets those values that have not already been set. */
! 211:
! 212: void process_config_line(Options *options, const char *host,
! 213: char *line, const char *filename, int linenum,
! 214: int *activep)
! 215: {
! 216: char buf[256], *cp, *string, **charptr;
! 217: int opcode, *intptr, value, fwd_port, fwd_host_port;
! 218:
! 219: /* Skip leading whitespace. */
! 220: cp = line + strspn(line, WHITESPACE);
! 221: if (!*cp || *cp == '\n' || *cp == '#')
! 222: return;
! 223:
! 224: /* Get the keyword. (Each line is supposed to begin with a keyword). */
! 225: cp = strtok(cp, WHITESPACE);
! 226: {
! 227: char *t = cp;
! 228: for (; *t != 0; t++)
! 229: if ('A' <= *t && *t <= 'Z')
! 230: *t = *t - 'A' + 'a'; /* tolower */
! 231:
! 232: }
! 233: opcode = parse_token(cp, filename, linenum);
! 234:
! 235: switch (opcode)
! 236: {
! 237:
! 238: case oForwardAgent:
! 239: intptr = &options->forward_agent;
! 240: parse_flag:
! 241: cp = strtok(NULL, WHITESPACE);
! 242: if (!cp)
! 243: fatal("%.200s line %d: Missing yes/no argument.", filename, linenum);
! 244: value = 0; /* To avoid compiler warning... */
! 245: if (strcmp(cp, "yes") == 0 || strcmp(cp, "true") == 0)
! 246: value = 1;
! 247: else if (strcmp(cp, "no") == 0 || strcmp(cp, "false") == 0)
! 248: value = 0;
! 249: else
! 250: fatal("%.200s line %d: Bad yes/no argument.", filename, linenum);
! 251: if (*activep && *intptr == -1)
! 252: *intptr = value;
! 253: break;
! 254:
! 255: case oForwardX11:
! 256: intptr = &options->forward_x11;
! 257: goto parse_flag;
! 258:
! 259: case oRhostsAuthentication:
! 260: intptr = &options->rhosts_authentication;
! 261: goto parse_flag;
! 262:
! 263: case oPasswordAuthentication:
! 264: intptr = &options->password_authentication;
! 265: goto parse_flag;
! 266:
! 267: case oRSAAuthentication:
! 268: intptr = &options->rsa_authentication;
! 269: goto parse_flag;
! 270:
! 271: case oRhostsRSAAuthentication:
! 272: intptr = &options->rhosts_rsa_authentication;
! 273: goto parse_flag;
! 274:
! 275: #ifdef KRB4
! 276: case oKerberosAuthentication:
! 277: intptr = &options->kerberos_authentication;
! 278: goto parse_flag;
! 279: #endif /* KRB4 */
! 280:
! 281: #ifdef KERBEROS_TGT_PASSING
! 282: case oKerberosTgtPassing:
! 283: intptr = &options->kerberos_tgt_passing;
! 284: goto parse_flag;
! 285: #endif
! 286:
! 287: #ifdef AFS
! 288: case oAFSTokenPassing:
! 289: intptr = &options->afs_token_passing;
! 290: goto parse_flag;
! 291: #endif
! 292:
! 293: case oFallBackToRsh:
! 294: intptr = &options->fallback_to_rsh;
! 295: goto parse_flag;
! 296:
! 297: case oUseRsh:
! 298: intptr = &options->use_rsh;
! 299: goto parse_flag;
! 300:
! 301: case oBatchMode:
! 302: intptr = &options->batch_mode;
! 303: goto parse_flag;
! 304:
! 305: case oStrictHostKeyChecking:
! 306: intptr = &options->strict_host_key_checking;
! 307: cp = strtok(NULL, WHITESPACE);
! 308: if (!cp)
! 309: fatal("%.200s line %d: Missing yes/no argument.",
! 310: filename, linenum);
! 311: value = 0; /* To avoid compiler warning... */
! 312: if (strcmp(cp, "yes") == 0 || strcmp(cp, "true") == 0)
! 313: value = 1;
! 314: else if (strcmp(cp, "no") == 0 || strcmp(cp, "false") == 0)
! 315: value = 0;
! 316: else if (strcmp(cp, "ask") == 0)
! 317: value = 2;
! 318: else
! 319: fatal("%.200s line %d: Bad yes/no/ask argument.", filename, linenum);
! 320: if (*activep && *intptr == -1)
! 321: *intptr = value;
! 322: break;
! 323:
! 324: #ifdef WITH_ZLIB
! 325: case oCompression:
! 326: intptr = &options->compression;
! 327: goto parse_flag;
! 328: #endif /* WITH_ZLIB */
! 329:
! 330: case oKeepAlives:
! 331: intptr = &options->keepalives;
! 332: goto parse_flag;
! 333:
! 334: case oTISAuthentication:
! 335: cp = strtok(NULL, WHITESPACE);
! 336: if (cp != 0 && (strcmp(cp, "yes") == 0 || strcmp(cp, "true") == 0))
! 337: fprintf(stderr,
! 338: "%.99s line %d: Warning, TIS is not supported.\n",
! 339: filename,
! 340: linenum);
! 341: break;
! 342:
! 343: #ifdef WITH_ZLIB
! 344: case oCompressionLevel:
! 345: intptr = &options->compression_level;
! 346: goto parse_int;
! 347: #endif /* WITH_ZLIB */
! 348:
! 349: case oIdentityFile:
! 350: cp = strtok(NULL, WHITESPACE);
! 351: if (!cp)
! 352: fatal("%.200s line %d: Missing argument.", filename, linenum);
! 353: if (*activep)
! 354: {
! 355: if (options->num_identity_files >= SSH_MAX_IDENTITY_FILES)
! 356: fatal("%.200s line %d: Too many identity files specified (max %d).",
! 357: filename, linenum, SSH_MAX_IDENTITY_FILES);
! 358: options->identity_files[options->num_identity_files++] = xstrdup(cp);
! 359: }
! 360: break;
! 361:
! 362: case oUser:
! 363: charptr = &options->user;
! 364: parse_string:
! 365: cp = strtok(NULL, WHITESPACE);
! 366: if (!cp)
! 367: fatal("%.200s line %d: Missing argument.", filename, linenum);
! 368: if (*activep && *charptr == NULL)
! 369: *charptr = xstrdup(cp);
! 370: break;
! 371:
! 372: case oGlobalKnownHostsFile:
! 373: charptr = &options->system_hostfile;
! 374: goto parse_string;
! 375:
! 376: case oUserKnownHostsFile:
! 377: charptr = &options->user_hostfile;
! 378: goto parse_string;
! 379:
! 380: case oHostName:
! 381: charptr = &options->hostname;
! 382: goto parse_string;
! 383:
! 384: case oProxyCommand:
! 385: charptr = &options->proxy_command;
! 386: string = xstrdup("");
! 387: while ((cp = strtok(NULL, WHITESPACE)) != NULL)
! 388: {
! 389: string = xrealloc(string, strlen(string) + strlen(cp) + 2);
! 390: strcat(string, " ");
! 391: strcat(string, cp);
! 392: }
! 393: if (*activep && *charptr == NULL)
! 394: *charptr = string;
! 395: else
! 396: xfree(string);
! 397: return;
! 398:
! 399: case oPort:
! 400: intptr = &options->port;
! 401: parse_int:
! 402: cp = strtok(NULL, WHITESPACE);
! 403: if (!cp)
! 404: fatal("%.200s line %d: Missing argument.", filename, linenum);
! 405: if (cp[0] < '0' || cp[0] > '9')
! 406: fatal("%.200s line %d: Bad number.", filename, linenum);
! 407: #if 0
! 408: value = atoi(cp);
! 409: #else
! 410: {
! 411: char *ptr;
! 412: value = strtol(cp, &ptr, 0); /* Octal, decimal, or hex format? */
! 413: if (cp == ptr)
! 414: fatal("%.200s line %d: Bad number.", filename, linenum);
! 415: }
! 416: #endif
! 417: if (*activep && *intptr == -1)
! 418: *intptr = value;
! 419: break;
! 420:
! 421: case oConnectionAttempts:
! 422: intptr = &options->connection_attempts;
! 423: goto parse_int;
! 424:
! 425: case oCipher:
! 426: intptr = &options->cipher;
! 427: cp = strtok(NULL, WHITESPACE);
! 428: value = cipher_number(cp);
! 429: if (value == -1)
! 430: fatal("%.200s line %d: Bad cipher.", filename, linenum);
! 431: if (*activep && *intptr == -1)
! 432: *intptr = value;
! 433: break;
! 434:
! 435: case oRemoteForward:
! 436: cp = strtok(NULL, WHITESPACE);
! 437: if (!cp)
! 438: fatal("%.200s line %d: Missing argument.", filename, linenum);
! 439: if (cp[0] < '0' || cp[0] > '9')
! 440: fatal("%.200s line %d: Badly formatted port number.",
! 441: filename, linenum);
! 442: fwd_port = atoi(cp);
! 443: cp = strtok(NULL, WHITESPACE);
! 444: if (!cp)
! 445: fatal("%.200s line %d: Missing second argument.",
! 446: filename, linenum);
! 447: if (sscanf(cp, "%255[^:]:%d", buf, &fwd_host_port) != 2)
! 448: fatal("%.200s line %d: Badly formatted host:port.",
! 449: filename, linenum);
! 450: if (*activep)
! 451: add_remote_forward(options, fwd_port, buf, fwd_host_port);
! 452: break;
! 453:
! 454: case oLocalForward:
! 455: cp = strtok(NULL, WHITESPACE);
! 456: if (!cp)
! 457: fatal("%.200s line %d: Missing argument.", filename, linenum);
! 458: if (cp[0] < '0' || cp[0] > '9')
! 459: fatal("%.200s line %d: Badly formatted port number.",
! 460: filename, linenum);
! 461: fwd_port = atoi(cp);
! 462: cp = strtok(NULL, WHITESPACE);
! 463: if (!cp)
! 464: fatal("%.200s line %d: Missing second argument.",
! 465: filename, linenum);
! 466: if (sscanf(cp, "%255[^:]:%d", buf, &fwd_host_port) != 2)
! 467: fatal("%.200s line %d: Badly formatted host:port.",
! 468: filename, linenum);
! 469: if (*activep)
! 470: add_local_forward(options, fwd_port, buf, fwd_host_port);
! 471: break;
! 472:
! 473: case oHost:
! 474: *activep = 0;
! 475: while ((cp = strtok(NULL, WHITESPACE)) != NULL)
! 476: if (match_pattern(host, cp))
! 477: {
! 478: debug("Applying options for %.100s", cp);
! 479: *activep = 1;
! 480: break;
! 481: }
! 482: /* Avoid garbage check below, as strtok already returned NULL. */
! 483: return;
! 484:
! 485: case oEscapeChar:
! 486: intptr = &options->escape_char;
! 487: cp = strtok(NULL, WHITESPACE);
! 488: if (!cp)
! 489: fatal("%.200s line %d: Missing argument.", filename, linenum);
! 490: if (cp[0] == '^' && cp[2] == 0 &&
! 491: (unsigned char)cp[1] >= 64 && (unsigned char)cp[1] < 128)
! 492: value = (unsigned char)cp[1] & 31;
! 493: else
! 494: if (strlen(cp) == 1)
! 495: value = (unsigned char)cp[0];
! 496: else
! 497: if (strcmp(cp, "none") == 0)
! 498: value = -2;
! 499: else
! 500: {
! 501: fatal("%.200s line %d: Bad escape character.",
! 502: filename, linenum);
! 503: /*NOTREACHED*/
! 504: value = 0; /* Avoid compiler warning. */
! 505: }
! 506: if (*activep && *intptr == -1)
! 507: *intptr = value;
! 508: break;
! 509:
! 510: default:
! 511: fatal("parse_config_file: Unimplemented opcode %d", opcode);
! 512: }
! 513:
! 514: /* Check that there is no garbage at end of line. */
! 515: if (strtok(NULL, WHITESPACE) != NULL)
! 516: fatal("%.200s line %d: garbage at end of line.",
! 517: filename, linenum);
! 518: }
! 519:
! 520:
! 521: /* Reads the config file and modifies the options accordingly. Options should
! 522: already be initialized before this call. This never returns if there
! 523: is an error. If the file does not exist, this returns immediately. */
! 524:
! 525: void read_config_file(const char *filename, const char *host, Options *options)
! 526: {
! 527: FILE *f;
! 528: char line[1024];
! 529: int active, linenum;
! 530:
! 531: /* Open the file. */
! 532: f = fopen(filename, "r");
! 533: if (!f)
! 534: return;
! 535:
! 536: debug("Reading configuration data %.200s", filename);
! 537:
! 538: /* Mark that we are now processing the options. This flag is turned on/off
! 539: by Host specifications. */
! 540: active = 1;
! 541: linenum = 0;
! 542: while (fgets(line, sizeof(line), f))
! 543: {
! 544: /* Update line number counter. */
! 545: linenum++;
! 546:
! 547: process_config_line(options, host, line, filename, linenum, &active);
! 548: }
! 549: fclose(f);
! 550: }
! 551:
! 552: /* Initializes options to special values that indicate that they have not
! 553: yet been set. Read_config_file will only set options with this value.
! 554: Options are processed in the following order: command line, user config
! 555: file, system config file. Last, fill_default_options is called. */
! 556:
! 557: void initialize_options(Options *options)
! 558: {
! 559: memset(options, 'X', sizeof(*options));
! 560: options->forward_agent = -1;
! 561: options->forward_x11 = -1;
! 562: options->rhosts_authentication = -1;
! 563: options->rsa_authentication = -1;
! 564: #ifdef KRB4
! 565: options->kerberos_authentication = -1;
! 566: #endif
! 567: #ifdef KERBEROS_TGT_PASSING
! 568: options->kerberos_tgt_passing = -1;
! 569: #endif
! 570: #ifdef AFS
! 571: options->afs_token_passing = -1;
! 572: #endif
! 573: options->password_authentication = -1;
! 574: options->rhosts_rsa_authentication = -1;
! 575: options->fallback_to_rsh = -1;
! 576: options->use_rsh = -1;
! 577: options->batch_mode = -1;
! 578: options->strict_host_key_checking = -1;
! 579: #ifdef WITH_ZLIB
! 580: options->compression = -1;
! 581: #endif /* WITH_ZLIB */
! 582: options->keepalives = -1;
! 583: #ifdef WITH_ZLIB
! 584: options->compression_level = -1;
! 585: #endif /* WITH_ZLIB */
! 586: options->port = -1;
! 587: options->connection_attempts = -1;
! 588: options->cipher = -1;
! 589: options->num_identity_files = 0;
! 590: options->hostname = NULL;
! 591: options->proxy_command = NULL;
! 592: options->user = NULL;
! 593: options->escape_char = -1;
! 594: options->system_hostfile = NULL;
! 595: options->user_hostfile = NULL;
! 596: options->num_local_forwards = 0;
! 597: options->num_remote_forwards = 0;
! 598: }
! 599:
! 600: /* Called after processing other sources of option data, this fills those
! 601: options for which no value has been specified with their default values. */
! 602:
! 603: void fill_default_options(Options *options)
! 604: {
! 605: if (options->forward_agent == -1)
! 606: options->forward_agent = 1;
! 607: if (options->forward_x11 == -1)
! 608: options->forward_x11 = 1;
! 609: if (options->rhosts_authentication == -1)
! 610: options->rhosts_authentication = 1;
! 611: if (options->rsa_authentication == -1)
! 612: options->rsa_authentication = 1;
! 613: #ifdef KRB4
! 614: if (options->kerberos_authentication == -1)
! 615: options->kerberos_authentication = 1;
! 616: #endif
! 617: #ifdef KERBEROS_TGT_PASSING
! 618: if (options->kerberos_tgt_passing == -1)
! 619: options->kerberos_tgt_passing = 1;
! 620: #endif
! 621: #ifdef AFS
! 622: if (options->afs_token_passing == -1)
! 623: options->afs_token_passing = 1;
! 624: #endif
! 625: if (options->password_authentication == -1)
! 626: options->password_authentication = 1;
! 627: if (options->rhosts_rsa_authentication == -1)
! 628: options->rhosts_rsa_authentication = 1;
! 629: if (options->fallback_to_rsh == -1)
! 630: options->fallback_to_rsh = 1;
! 631: if (options->use_rsh == -1)
! 632: options->use_rsh = 0;
! 633: if (options->batch_mode == -1)
! 634: options->batch_mode = 0;
! 635: if (options->strict_host_key_checking == -1)
! 636: options->strict_host_key_checking = 2; /* 2 is default */
! 637: #ifdef WITH_ZLIB
! 638: if (options->compression == -1)
! 639: options->compression = 0;
! 640: #endif /* WITH_ZLIB */
! 641: if (options->keepalives == -1)
! 642: options->keepalives = 1;
! 643: #ifdef WITH_ZLIB
! 644: if (options->compression_level == -1)
! 645: options->compression_level = 6;
! 646: #endif /* WITH_ZLIB */
! 647: if (options->port == -1)
! 648: options->port = 0; /* Filled in ssh_connect. */
! 649: if (options->connection_attempts == -1)
! 650: options->connection_attempts = 4;
! 651: if (options->cipher == -1)
! 652: options->cipher = SSH_CIPHER_NOT_SET; /* Selected in ssh_login(). */
! 653: if (options->num_identity_files == 0)
! 654: {
! 655: options->identity_files[0] =
! 656: xmalloc(2 + strlen(SSH_CLIENT_IDENTITY) + 1);
! 657: sprintf(options->identity_files[0], "~/%.100s", SSH_CLIENT_IDENTITY);
! 658: options->num_identity_files = 1;
! 659: }
! 660: if (options->escape_char == -1)
! 661: options->escape_char = '~';
! 662: if (options->system_hostfile == NULL)
! 663: options->system_hostfile = SSH_SYSTEM_HOSTFILE;
! 664: if (options->user_hostfile == NULL)
! 665: options->user_hostfile = SSH_USER_HOSTFILE;
! 666: /* options->proxy_command should not be set by default */
! 667: /* options->user will be set in the main program if appropriate */
! 668: /* options->hostname will be set in the main program if appropriate */
! 669: }
! 670: