Annotation of src/usr.bin/ssh/readconf.c, Revision 1.19
1.1 deraadt 1: /*
1.18 deraadt 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: */
1.1 deraadt 15:
16: #include "includes.h"
1.19 ! markus 17: RCSID("$Id: readconf.c,v 1.18 1999/11/24 00:26:02 deraadt Exp $");
1.1 deraadt 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: EscapeChar ~
84:
85: */
86:
87: /* Keyword tokens. */
88:
1.17 markus 89: typedef enum {
90: oBadOption,
91: oForwardAgent, oForwardX11, oGatewayPorts, oRhostsAuthentication,
92: oPasswordAuthentication, oRSAAuthentication, oFallBackToRsh, oUseRsh,
93: oSkeyAuthentication,
1.1 deraadt 94: #ifdef KRB4
1.17 markus 95: oKerberosAuthentication,
1.1 deraadt 96: #endif /* KRB4 */
97: #ifdef AFS
1.17 markus 98: oKerberosTgtPassing, oAFSTokenPassing,
1.1 deraadt 99: #endif
1.17 markus 100: oIdentityFile, oHostName, oPort, oCipher, oRemoteForward, oLocalForward,
101: oUser, oHost, oEscapeChar, oRhostsRSAAuthentication, oProxyCommand,
102: oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts,
103: oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression,
104: oCompressionLevel, oKeepAlives, oNumberOfPasswordPrompts, oTISAuthentication,
105: oUsePrivilegedPort, oLogLevel
1.1 deraadt 106: } OpCodes;
107:
108: /* Textual representations of the tokens. */
109:
1.17 markus 110: static struct {
111: const char *name;
112: OpCodes opcode;
113: } keywords[] = {
114: { "forwardagent", oForwardAgent },
115: { "forwardx11", oForwardX11 },
116: { "gatewayports", oGatewayPorts },
117: { "useprivilegedport", oUsePrivilegedPort },
118: { "rhostsauthentication", oRhostsAuthentication },
119: { "passwordauthentication", oPasswordAuthentication },
120: { "rsaauthentication", oRSAAuthentication },
121: { "skeyauthentication", oSkeyAuthentication },
1.1 deraadt 122: #ifdef KRB4
1.17 markus 123: { "kerberosauthentication", oKerberosAuthentication },
1.1 deraadt 124: #endif /* KRB4 */
1.5 dugsong 125: #ifdef AFS
1.17 markus 126: { "kerberostgtpassing", oKerberosTgtPassing },
127: { "afstokenpassing", oAFSTokenPassing },
1.1 deraadt 128: #endif
1.17 markus 129: { "fallbacktorsh", oFallBackToRsh },
130: { "usersh", oUseRsh },
131: { "identityfile", oIdentityFile },
132: { "hostname", oHostName },
133: { "proxycommand", oProxyCommand },
134: { "port", oPort },
135: { "cipher", oCipher },
136: { "remoteforward", oRemoteForward },
137: { "localforward", oLocalForward },
138: { "user", oUser },
139: { "host", oHost },
140: { "escapechar", oEscapeChar },
141: { "rhostsrsaauthentication", oRhostsRSAAuthentication },
142: { "globalknownhostsfile", oGlobalKnownHostsFile },
143: { "userknownhostsfile", oUserKnownHostsFile },
144: { "connectionattempts", oConnectionAttempts },
145: { "batchmode", oBatchMode },
146: { "checkhostip", oCheckHostIP },
147: { "stricthostkeychecking", oStrictHostKeyChecking },
148: { "compression", oCompression },
149: { "compressionlevel", oCompressionLevel },
150: { "keepalive", oKeepAlives },
151: { "numberofpasswordprompts", oNumberOfPasswordPrompts },
152: { "tisauthentication", oTISAuthentication },
153: { "loglevel", oLogLevel },
154: { NULL, 0 }
1.13 markus 155: };
156:
1.1 deraadt 157: /* Characters considered whitespace in strtok calls. */
158: #define WHITESPACE " \t\r\n"
159:
160:
1.19 ! markus 161: /*
! 162: * Adds a local TCP/IP port forward to options. Never returns if there is an
! 163: * error.
! 164: */
1.1 deraadt 165:
1.17 markus 166: void
167: add_local_forward(Options *options, int port, const char *host,
168: int host_port)
1.1 deraadt 169: {
1.17 markus 170: Forward *fwd;
171: extern uid_t original_real_uid;
172: if ((port & 0xffff) != port)
173: fatal("Requested forwarding of nonexistent port %d.", port);
174: if (port < IPPORT_RESERVED && original_real_uid != 0)
175: fatal("Privileged ports can only be forwarded by root.\n");
176: if (options->num_local_forwards >= SSH_MAX_FORWARDS_PER_DIRECTION)
177: fatal("Too many local forwards (max %d).", SSH_MAX_FORWARDS_PER_DIRECTION);
178: fwd = &options->local_forwards[options->num_local_forwards++];
179: fwd->port = port;
180: fwd->host = xstrdup(host);
181: fwd->host_port = host_port;
1.1 deraadt 182: }
183:
1.19 ! markus 184: /*
! 185: * Adds a remote TCP/IP port forward to options. Never returns if there is
! 186: * an error.
! 187: */
1.1 deraadt 188:
1.17 markus 189: void
190: add_remote_forward(Options *options, int port, const char *host,
191: int host_port)
1.1 deraadt 192: {
1.17 markus 193: Forward *fwd;
194: if (options->num_remote_forwards >= SSH_MAX_FORWARDS_PER_DIRECTION)
195: fatal("Too many remote forwards (max %d).",
196: SSH_MAX_FORWARDS_PER_DIRECTION);
197: fwd = &options->remote_forwards[options->num_remote_forwards++];
198: fwd->port = port;
199: fwd->host = xstrdup(host);
200: fwd->host_port = host_port;
1.1 deraadt 201: }
202:
1.19 ! markus 203: /*
! 204: * Returns the number of the token pointed to by cp of length len. Never
! 205: * returns if the token is not known.
! 206: */
1.1 deraadt 207:
1.17 markus 208: static OpCodes
209: parse_token(const char *cp, const char *filename, int linenum)
1.1 deraadt 210: {
1.17 markus 211: unsigned int i;
1.1 deraadt 212:
1.17 markus 213: for (i = 0; keywords[i].name; i++)
214: if (strcmp(cp, keywords[i].name) == 0)
215: return keywords[i].opcode;
216:
217: fprintf(stderr, "%s: line %d: Bad configuration option: %s\n",
218: filename, linenum, cp);
219: return oBadOption;
1.1 deraadt 220: }
221:
1.19 ! markus 222: /*
! 223: * Processes a single option line as used in the configuration files. This
! 224: * only sets those values that have not already been set.
! 225: */
1.1 deraadt 226:
1.14 markus 227: int
228: process_config_line(Options *options, const char *host,
1.17 markus 229: char *line, const char *filename, int linenum,
230: int *activep)
1.1 deraadt 231: {
1.17 markus 232: char buf[256], *cp, *string, **charptr;
233: int opcode, *intptr, value, fwd_port, fwd_host_port;
1.1 deraadt 234:
1.17 markus 235: /* Skip leading whitespace. */
236: cp = line + strspn(line, WHITESPACE);
237: if (!*cp || *cp == '\n' || *cp == '#')
238: return 0;
239:
1.19 ! markus 240: /* Get the keyword. (Each line is supposed to begin with a keyword). */
1.17 markus 241: cp = strtok(cp, WHITESPACE);
242: {
243: char *t = cp;
244: for (; *t != 0; t++)
245: if ('A' <= *t && *t <= 'Z')
246: *t = *t - 'A' + 'a'; /* tolower */
247:
248: }
249: opcode = parse_token(cp, filename, linenum);
250:
251: switch (opcode) {
252: case oBadOption:
1.19 ! markus 253: /* don't panic, but count bad options */
! 254: return -1;
1.17 markus 255: /* NOTREACHED */
256: case oForwardAgent:
257: intptr = &options->forward_agent;
258: parse_flag:
259: cp = strtok(NULL, WHITESPACE);
260: if (!cp)
261: fatal("%.200s line %d: Missing yes/no argument.", filename, linenum);
262: value = 0; /* To avoid compiler warning... */
263: if (strcmp(cp, "yes") == 0 || strcmp(cp, "true") == 0)
264: value = 1;
265: else if (strcmp(cp, "no") == 0 || strcmp(cp, "false") == 0)
266: value = 0;
267: else
268: fatal("%.200s line %d: Bad yes/no argument.", filename, linenum);
269: if (*activep && *intptr == -1)
270: *intptr = value;
271: break;
272:
273: case oForwardX11:
274: intptr = &options->forward_x11;
275: goto parse_flag;
276:
277: case oGatewayPorts:
278: intptr = &options->gateway_ports;
279: goto parse_flag;
280:
281: case oUsePrivilegedPort:
282: intptr = &options->use_privileged_port;
283: goto parse_flag;
284:
285: case oRhostsAuthentication:
286: intptr = &options->rhosts_authentication;
287: goto parse_flag;
288:
289: case oPasswordAuthentication:
290: intptr = &options->password_authentication;
291: goto parse_flag;
292:
293: case oRSAAuthentication:
294: intptr = &options->rsa_authentication;
295: goto parse_flag;
296:
297: case oRhostsRSAAuthentication:
298: intptr = &options->rhosts_rsa_authentication;
299: goto parse_flag;
300:
301: case oTISAuthentication:
302: /* fallthrough, there is no difference on the client side */
303: case oSkeyAuthentication:
304: intptr = &options->skey_authentication;
305: goto parse_flag;
1.16 markus 306:
1.1 deraadt 307: #ifdef KRB4
1.17 markus 308: case oKerberosAuthentication:
309: intptr = &options->kerberos_authentication;
310: goto parse_flag;
1.1 deraadt 311: #endif /* KRB4 */
312:
1.5 dugsong 313: #ifdef AFS
1.17 markus 314: case oKerberosTgtPassing:
315: intptr = &options->kerberos_tgt_passing;
316: goto parse_flag;
317:
318: case oAFSTokenPassing:
319: intptr = &options->afs_token_passing;
320: goto parse_flag;
1.1 deraadt 321: #endif
1.17 markus 322:
323: case oFallBackToRsh:
324: intptr = &options->fallback_to_rsh;
325: goto parse_flag;
326:
327: case oUseRsh:
328: intptr = &options->use_rsh;
329: goto parse_flag;
330:
331: case oBatchMode:
332: intptr = &options->batch_mode;
333: goto parse_flag;
334:
335: case oCheckHostIP:
336: intptr = &options->check_host_ip;
337: goto parse_flag;
338:
339: case oStrictHostKeyChecking:
340: intptr = &options->strict_host_key_checking;
341: cp = strtok(NULL, WHITESPACE);
342: if (!cp)
343: fatal("%.200s line %d: Missing yes/no argument.",
344: filename, linenum);
345: value = 0; /* To avoid compiler warning... */
346: if (strcmp(cp, "yes") == 0 || strcmp(cp, "true") == 0)
347: value = 1;
348: else if (strcmp(cp, "no") == 0 || strcmp(cp, "false") == 0)
349: value = 0;
350: else if (strcmp(cp, "ask") == 0)
351: value = 2;
352: else
353: fatal("%.200s line %d: Bad yes/no/ask argument.", filename, linenum);
354: if (*activep && *intptr == -1)
355: *intptr = value;
356: break;
357:
358: case oCompression:
359: intptr = &options->compression;
360: goto parse_flag;
361:
362: case oKeepAlives:
363: intptr = &options->keepalives;
364: goto parse_flag;
365:
366: case oNumberOfPasswordPrompts:
367: intptr = &options->number_of_password_prompts;
368: goto parse_int;
369:
370: case oCompressionLevel:
371: intptr = &options->compression_level;
372: goto parse_int;
373:
374: case oIdentityFile:
375: cp = strtok(NULL, WHITESPACE);
376: if (!cp)
377: fatal("%.200s line %d: Missing argument.", filename, linenum);
378: if (*activep) {
379: if (options->num_identity_files >= SSH_MAX_IDENTITY_FILES)
380: fatal("%.200s line %d: Too many identity files specified (max %d).",
381: filename, linenum, SSH_MAX_IDENTITY_FILES);
382: options->identity_files[options->num_identity_files++] = xstrdup(cp);
383: }
384: break;
385:
386: case oUser:
387: charptr = &options->user;
388: parse_string:
389: cp = strtok(NULL, WHITESPACE);
390: if (!cp)
391: fatal("%.200s line %d: Missing argument.", filename, linenum);
392: if (*activep && *charptr == NULL)
393: *charptr = xstrdup(cp);
394: break;
395:
396: case oGlobalKnownHostsFile:
397: charptr = &options->system_hostfile;
398: goto parse_string;
399:
400: case oUserKnownHostsFile:
401: charptr = &options->user_hostfile;
402: goto parse_string;
403:
404: case oHostName:
405: charptr = &options->hostname;
406: goto parse_string;
407:
408: case oProxyCommand:
409: charptr = &options->proxy_command;
410: string = xstrdup("");
411: while ((cp = strtok(NULL, WHITESPACE)) != NULL) {
412: string = xrealloc(string, strlen(string) + strlen(cp) + 2);
413: strcat(string, " ");
414: strcat(string, cp);
415: }
416: if (*activep && *charptr == NULL)
417: *charptr = string;
418: else
419: xfree(string);
420: return 0;
421:
422: case oPort:
423: intptr = &options->port;
424: parse_int:
425: cp = strtok(NULL, WHITESPACE);
426: if (!cp)
427: fatal("%.200s line %d: Missing argument.", filename, linenum);
428: if (cp[0] < '0' || cp[0] > '9')
429: fatal("%.200s line %d: Bad number.", filename, linenum);
1.1 deraadt 430: #if 0
1.17 markus 431: value = atoi(cp);
1.1 deraadt 432: #else
1.17 markus 433: {
434: char *ptr;
1.19 ! markus 435: /* Octal, decimal, or hex format? */
! 436: value = strtol(cp, &ptr, 0);
1.17 markus 437: if (cp == ptr)
438: fatal("%.200s line %d: Bad number.", filename, linenum);
439: }
1.1 deraadt 440: #endif
1.17 markus 441: if (*activep && *intptr == -1)
442: *intptr = value;
443: break;
444:
445: case oConnectionAttempts:
446: intptr = &options->connection_attempts;
447: goto parse_int;
448:
449: case oCipher:
450: intptr = &options->cipher;
451: cp = strtok(NULL, WHITESPACE);
452: value = cipher_number(cp);
453: if (value == -1)
454: fatal("%.200s line %d: Bad cipher '%s'.",
455: filename, linenum, cp ? cp : "<NONE>");
456: if (*activep && *intptr == -1)
457: *intptr = value;
458: break;
459:
460: case oLogLevel:
461: intptr = (int *) &options->log_level;
462: cp = strtok(NULL, WHITESPACE);
463: value = log_level_number(cp);
464: if (value == (LogLevel) - 1)
465: fatal("%.200s line %d: unsupported log level '%s'\n",
466: filename, linenum, cp ? cp : "<NONE>");
467: if (*activep && (LogLevel) * intptr == -1)
468: *intptr = (LogLevel) value;
469: break;
470:
471: case oRemoteForward:
472: cp = strtok(NULL, WHITESPACE);
473: if (!cp)
474: fatal("%.200s line %d: Missing argument.", filename, linenum);
475: if (cp[0] < '0' || cp[0] > '9')
476: fatal("%.200s line %d: Badly formatted port number.",
477: filename, linenum);
478: fwd_port = atoi(cp);
479: cp = strtok(NULL, WHITESPACE);
480: if (!cp)
481: fatal("%.200s line %d: Missing second argument.",
482: filename, linenum);
483: if (sscanf(cp, "%255[^:]:%d", buf, &fwd_host_port) != 2)
484: fatal("%.200s line %d: Badly formatted host:port.",
485: filename, linenum);
486: if (*activep)
487: add_remote_forward(options, fwd_port, buf, fwd_host_port);
488: break;
489:
490: case oLocalForward:
491: cp = strtok(NULL, WHITESPACE);
492: if (!cp)
493: fatal("%.200s line %d: Missing argument.", filename, linenum);
494: if (cp[0] < '0' || cp[0] > '9')
495: fatal("%.200s line %d: Badly formatted port number.",
496: filename, linenum);
497: fwd_port = atoi(cp);
498: cp = strtok(NULL, WHITESPACE);
499: if (!cp)
500: fatal("%.200s line %d: Missing second argument.",
501: filename, linenum);
502: if (sscanf(cp, "%255[^:]:%d", buf, &fwd_host_port) != 2)
503: fatal("%.200s line %d: Badly formatted host:port.",
504: filename, linenum);
505: if (*activep)
506: add_local_forward(options, fwd_port, buf, fwd_host_port);
507: break;
508:
509: case oHost:
510: *activep = 0;
511: while ((cp = strtok(NULL, WHITESPACE)) != NULL)
512: if (match_pattern(host, cp)) {
513: debug("Applying options for %.100s", cp);
514: *activep = 1;
515: break;
516: }
1.19 ! markus 517: /* Avoid garbage check below, as strtok already returned NULL. */
1.17 markus 518: return 0;
519:
520: case oEscapeChar:
521: intptr = &options->escape_char;
522: cp = strtok(NULL, WHITESPACE);
523: if (!cp)
524: fatal("%.200s line %d: Missing argument.", filename, linenum);
525: if (cp[0] == '^' && cp[2] == 0 &&
526: (unsigned char) cp[1] >= 64 && (unsigned char) cp[1] < 128)
527: value = (unsigned char) cp[1] & 31;
528: else if (strlen(cp) == 1)
529: value = (unsigned char) cp[0];
530: else if (strcmp(cp, "none") == 0)
531: value = -2;
532: else {
533: fatal("%.200s line %d: Bad escape character.",
534: filename, linenum);
535: /* NOTREACHED */
536: value = 0; /* Avoid compiler warning. */
537: }
538: if (*activep && *intptr == -1)
539: *intptr = value;
540: break;
541:
542: default:
543: fatal("process_config_line: Unimplemented opcode %d", opcode);
544: }
545:
546: /* Check that there is no garbage at end of line. */
547: if (strtok(NULL, WHITESPACE) != NULL)
548: fatal("%.200s line %d: garbage at end of line.",
549: filename, linenum);
550: return 0;
1.1 deraadt 551: }
552:
553:
1.19 ! markus 554: /*
! 555: * Reads the config file and modifies the options accordingly. Options
! 556: * should already be initialized before this call. This never returns if
! 557: * there is an error. If the file does not exist, this returns immediately.
! 558: */
1.1 deraadt 559:
1.17 markus 560: void
561: read_config_file(const char *filename, const char *host, Options *options)
1.1 deraadt 562: {
1.17 markus 563: FILE *f;
564: char line[1024];
565: int active, linenum;
566: int bad_options = 0;
567:
568: /* Open the file. */
569: f = fopen(filename, "r");
570: if (!f)
571: return;
572:
573: debug("Reading configuration data %.200s", filename);
574:
1.19 ! markus 575: /*
! 576: * Mark that we are now processing the options. This flag is turned
! 577: * on/off by Host specifications.
! 578: */
1.17 markus 579: active = 1;
580: linenum = 0;
581: while (fgets(line, sizeof(line), f)) {
582: /* Update line number counter. */
583: linenum++;
584: if (process_config_line(options, host, line, filename, linenum, &active) != 0)
585: bad_options++;
586: }
587: fclose(f);
588: if (bad_options > 0)
589: fatal("%s: terminating, %d bad configuration options\n",
590: filename, bad_options);
1.1 deraadt 591: }
592:
1.19 ! markus 593: /*
! 594: * Initializes options to special values that indicate that they have not yet
! 595: * been set. Read_config_file will only set options with this value. Options
! 596: * are processed in the following order: command line, user config file,
! 597: * system config file. Last, fill_default_options is called.
! 598: */
1.1 deraadt 599:
1.17 markus 600: void
601: initialize_options(Options * options)
1.1 deraadt 602: {
1.17 markus 603: memset(options, 'X', sizeof(*options));
604: options->forward_agent = -1;
605: options->forward_x11 = -1;
606: options->gateway_ports = -1;
607: options->use_privileged_port = -1;
608: options->rhosts_authentication = -1;
609: options->rsa_authentication = -1;
610: options->skey_authentication = -1;
1.1 deraadt 611: #ifdef KRB4
1.17 markus 612: options->kerberos_authentication = -1;
1.1 deraadt 613: #endif
1.5 dugsong 614: #ifdef AFS
1.17 markus 615: options->kerberos_tgt_passing = -1;
616: options->afs_token_passing = -1;
1.1 deraadt 617: #endif
1.17 markus 618: options->password_authentication = -1;
619: options->rhosts_rsa_authentication = -1;
620: options->fallback_to_rsh = -1;
621: options->use_rsh = -1;
622: options->batch_mode = -1;
623: options->check_host_ip = -1;
624: options->strict_host_key_checking = -1;
625: options->compression = -1;
626: options->keepalives = -1;
627: options->compression_level = -1;
628: options->port = -1;
629: options->connection_attempts = -1;
630: options->number_of_password_prompts = -1;
631: options->cipher = -1;
632: options->num_identity_files = 0;
633: options->hostname = NULL;
634: options->proxy_command = NULL;
635: options->user = NULL;
636: options->escape_char = -1;
637: options->system_hostfile = NULL;
638: options->user_hostfile = NULL;
639: options->num_local_forwards = 0;
640: options->num_remote_forwards = 0;
641: options->log_level = (LogLevel) - 1;
1.1 deraadt 642: }
643:
1.19 ! markus 644: /*
! 645: * Called after processing other sources of option data, this fills those
! 646: * options for which no value has been specified with their default values.
! 647: */
1.1 deraadt 648:
1.17 markus 649: void
650: fill_default_options(Options * options)
1.1 deraadt 651: {
1.17 markus 652: if (options->forward_agent == -1)
653: options->forward_agent = 1;
654: if (options->forward_x11 == -1)
655: options->forward_x11 = 1;
656: if (options->gateway_ports == -1)
657: options->gateway_ports = 0;
658: if (options->use_privileged_port == -1)
659: options->use_privileged_port = 1;
660: if (options->rhosts_authentication == -1)
661: options->rhosts_authentication = 1;
662: if (options->rsa_authentication == -1)
663: options->rsa_authentication = 1;
664: if (options->skey_authentication == -1)
665: options->skey_authentication = 0;
1.1 deraadt 666: #ifdef KRB4
1.17 markus 667: if (options->kerberos_authentication == -1)
668: options->kerberos_authentication = 1;
1.5 dugsong 669: #endif /* KRB4 */
670: #ifdef AFS
1.17 markus 671: if (options->kerberos_tgt_passing == -1)
672: options->kerberos_tgt_passing = 1;
673: if (options->afs_token_passing == -1)
674: options->afs_token_passing = 1;
1.5 dugsong 675: #endif /* AFS */
1.17 markus 676: if (options->password_authentication == -1)
677: options->password_authentication = 1;
678: if (options->rhosts_rsa_authentication == -1)
679: options->rhosts_rsa_authentication = 1;
680: if (options->fallback_to_rsh == -1)
681: options->fallback_to_rsh = 1;
682: if (options->use_rsh == -1)
683: options->use_rsh = 0;
684: if (options->batch_mode == -1)
685: options->batch_mode = 0;
686: if (options->check_host_ip == -1)
687: options->check_host_ip = 1;
688: if (options->strict_host_key_checking == -1)
689: options->strict_host_key_checking = 2; /* 2 is default */
690: if (options->compression == -1)
691: options->compression = 0;
692: if (options->keepalives == -1)
693: options->keepalives = 1;
694: if (options->compression_level == -1)
695: options->compression_level = 6;
696: if (options->port == -1)
697: options->port = 0; /* Filled in ssh_connect. */
698: if (options->connection_attempts == -1)
699: options->connection_attempts = 4;
700: if (options->number_of_password_prompts == -1)
701: options->number_of_password_prompts = 3;
702: /* Selected in ssh_login(). */
703: if (options->cipher == -1)
704: options->cipher = SSH_CIPHER_NOT_SET;
705: if (options->num_identity_files == 0) {
706: options->identity_files[0] =
707: xmalloc(2 + strlen(SSH_CLIENT_IDENTITY) + 1);
708: sprintf(options->identity_files[0], "~/%.100s", SSH_CLIENT_IDENTITY);
709: options->num_identity_files = 1;
710: }
711: if (options->escape_char == -1)
712: options->escape_char = '~';
713: if (options->system_hostfile == NULL)
714: options->system_hostfile = SSH_SYSTEM_HOSTFILE;
715: if (options->user_hostfile == NULL)
716: options->user_hostfile = SSH_USER_HOSTFILE;
717: if (options->log_level == (LogLevel) - 1)
718: options->log_level = SYSLOG_LEVEL_INFO;
719: /* options->proxy_command should not be set by default */
720: /* options->user will be set in the main program if appropriate */
721: /* options->hostname will be set in the main program if appropriate */
1.1 deraadt 722: }