Annotation of src/usr.bin/ssh/readconf.c, Revision 1.20
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.20 ! markus 17: RCSID("$Id: readconf.c,v 1.19 1999/11/24 19:53:49 markus 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++)
1.20 ! markus 214: if (strcasecmp(cp, keywords[i].name) == 0)
1.17 markus 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: opcode = parse_token(cp, filename, linenum);
243:
244: switch (opcode) {
245: case oBadOption:
1.19 markus 246: /* don't panic, but count bad options */
247: return -1;
1.17 markus 248: /* NOTREACHED */
249: case oForwardAgent:
250: intptr = &options->forward_agent;
251: parse_flag:
252: cp = strtok(NULL, WHITESPACE);
253: if (!cp)
254: fatal("%.200s line %d: Missing yes/no argument.", filename, linenum);
255: value = 0; /* To avoid compiler warning... */
256: if (strcmp(cp, "yes") == 0 || strcmp(cp, "true") == 0)
257: value = 1;
258: else if (strcmp(cp, "no") == 0 || strcmp(cp, "false") == 0)
259: value = 0;
260: else
261: fatal("%.200s line %d: Bad yes/no argument.", filename, linenum);
262: if (*activep && *intptr == -1)
263: *intptr = value;
264: break;
265:
266: case oForwardX11:
267: intptr = &options->forward_x11;
268: goto parse_flag;
269:
270: case oGatewayPorts:
271: intptr = &options->gateway_ports;
272: goto parse_flag;
273:
274: case oUsePrivilegedPort:
275: intptr = &options->use_privileged_port;
276: goto parse_flag;
277:
278: case oRhostsAuthentication:
279: intptr = &options->rhosts_authentication;
280: goto parse_flag;
281:
282: case oPasswordAuthentication:
283: intptr = &options->password_authentication;
284: goto parse_flag;
285:
286: case oRSAAuthentication:
287: intptr = &options->rsa_authentication;
288: goto parse_flag;
289:
290: case oRhostsRSAAuthentication:
291: intptr = &options->rhosts_rsa_authentication;
292: goto parse_flag;
293:
294: case oTISAuthentication:
295: /* fallthrough, there is no difference on the client side */
296: case oSkeyAuthentication:
297: intptr = &options->skey_authentication;
298: goto parse_flag;
1.16 markus 299:
1.1 deraadt 300: #ifdef KRB4
1.17 markus 301: case oKerberosAuthentication:
302: intptr = &options->kerberos_authentication;
303: goto parse_flag;
1.1 deraadt 304: #endif /* KRB4 */
305:
1.5 dugsong 306: #ifdef AFS
1.17 markus 307: case oKerberosTgtPassing:
308: intptr = &options->kerberos_tgt_passing;
309: goto parse_flag;
310:
311: case oAFSTokenPassing:
312: intptr = &options->afs_token_passing;
313: goto parse_flag;
1.1 deraadt 314: #endif
1.17 markus 315:
316: case oFallBackToRsh:
317: intptr = &options->fallback_to_rsh;
318: goto parse_flag;
319:
320: case oUseRsh:
321: intptr = &options->use_rsh;
322: goto parse_flag;
323:
324: case oBatchMode:
325: intptr = &options->batch_mode;
326: goto parse_flag;
327:
328: case oCheckHostIP:
329: intptr = &options->check_host_ip;
330: goto parse_flag;
331:
332: case oStrictHostKeyChecking:
333: intptr = &options->strict_host_key_checking;
334: cp = strtok(NULL, WHITESPACE);
335: if (!cp)
336: fatal("%.200s line %d: Missing yes/no argument.",
337: filename, linenum);
338: value = 0; /* To avoid compiler warning... */
339: if (strcmp(cp, "yes") == 0 || strcmp(cp, "true") == 0)
340: value = 1;
341: else if (strcmp(cp, "no") == 0 || strcmp(cp, "false") == 0)
342: value = 0;
343: else if (strcmp(cp, "ask") == 0)
344: value = 2;
345: else
346: fatal("%.200s line %d: Bad yes/no/ask argument.", filename, linenum);
347: if (*activep && *intptr == -1)
348: *intptr = value;
349: break;
350:
351: case oCompression:
352: intptr = &options->compression;
353: goto parse_flag;
354:
355: case oKeepAlives:
356: intptr = &options->keepalives;
357: goto parse_flag;
358:
359: case oNumberOfPasswordPrompts:
360: intptr = &options->number_of_password_prompts;
361: goto parse_int;
362:
363: case oCompressionLevel:
364: intptr = &options->compression_level;
365: goto parse_int;
366:
367: case oIdentityFile:
368: cp = strtok(NULL, WHITESPACE);
369: if (!cp)
370: fatal("%.200s line %d: Missing argument.", filename, linenum);
371: if (*activep) {
372: if (options->num_identity_files >= SSH_MAX_IDENTITY_FILES)
373: fatal("%.200s line %d: Too many identity files specified (max %d).",
374: filename, linenum, SSH_MAX_IDENTITY_FILES);
375: options->identity_files[options->num_identity_files++] = xstrdup(cp);
376: }
377: break;
378:
379: case oUser:
380: charptr = &options->user;
381: parse_string:
382: cp = strtok(NULL, WHITESPACE);
383: if (!cp)
384: fatal("%.200s line %d: Missing argument.", filename, linenum);
385: if (*activep && *charptr == NULL)
386: *charptr = xstrdup(cp);
387: break;
388:
389: case oGlobalKnownHostsFile:
390: charptr = &options->system_hostfile;
391: goto parse_string;
392:
393: case oUserKnownHostsFile:
394: charptr = &options->user_hostfile;
395: goto parse_string;
396:
397: case oHostName:
398: charptr = &options->hostname;
399: goto parse_string;
400:
401: case oProxyCommand:
402: charptr = &options->proxy_command;
403: string = xstrdup("");
404: while ((cp = strtok(NULL, WHITESPACE)) != NULL) {
405: string = xrealloc(string, strlen(string) + strlen(cp) + 2);
406: strcat(string, " ");
407: strcat(string, cp);
408: }
409: if (*activep && *charptr == NULL)
410: *charptr = string;
411: else
412: xfree(string);
413: return 0;
414:
415: case oPort:
416: intptr = &options->port;
417: parse_int:
418: cp = strtok(NULL, WHITESPACE);
419: if (!cp)
420: fatal("%.200s line %d: Missing argument.", filename, linenum);
421: if (cp[0] < '0' || cp[0] > '9')
422: fatal("%.200s line %d: Bad number.", filename, linenum);
1.1 deraadt 423: #if 0
1.17 markus 424: value = atoi(cp);
1.1 deraadt 425: #else
1.17 markus 426: {
427: char *ptr;
1.19 markus 428: /* Octal, decimal, or hex format? */
429: value = strtol(cp, &ptr, 0);
1.17 markus 430: if (cp == ptr)
431: fatal("%.200s line %d: Bad number.", filename, linenum);
432: }
1.1 deraadt 433: #endif
1.17 markus 434: if (*activep && *intptr == -1)
435: *intptr = value;
436: break;
437:
438: case oConnectionAttempts:
439: intptr = &options->connection_attempts;
440: goto parse_int;
441:
442: case oCipher:
443: intptr = &options->cipher;
444: cp = strtok(NULL, WHITESPACE);
445: value = cipher_number(cp);
446: if (value == -1)
447: fatal("%.200s line %d: Bad cipher '%s'.",
448: filename, linenum, cp ? cp : "<NONE>");
449: if (*activep && *intptr == -1)
450: *intptr = value;
451: break;
452:
453: case oLogLevel:
454: intptr = (int *) &options->log_level;
455: cp = strtok(NULL, WHITESPACE);
456: value = log_level_number(cp);
457: if (value == (LogLevel) - 1)
458: fatal("%.200s line %d: unsupported log level '%s'\n",
459: filename, linenum, cp ? cp : "<NONE>");
460: if (*activep && (LogLevel) * intptr == -1)
461: *intptr = (LogLevel) value;
462: break;
463:
464: case oRemoteForward:
465: cp = strtok(NULL, WHITESPACE);
466: if (!cp)
467: fatal("%.200s line %d: Missing argument.", filename, linenum);
468: if (cp[0] < '0' || cp[0] > '9')
469: fatal("%.200s line %d: Badly formatted port number.",
470: filename, linenum);
471: fwd_port = atoi(cp);
472: cp = strtok(NULL, WHITESPACE);
473: if (!cp)
474: fatal("%.200s line %d: Missing second argument.",
475: filename, linenum);
476: if (sscanf(cp, "%255[^:]:%d", buf, &fwd_host_port) != 2)
477: fatal("%.200s line %d: Badly formatted host:port.",
478: filename, linenum);
479: if (*activep)
480: add_remote_forward(options, fwd_port, buf, fwd_host_port);
481: break;
482:
483: case oLocalForward:
484: cp = strtok(NULL, WHITESPACE);
485: if (!cp)
486: fatal("%.200s line %d: Missing argument.", filename, linenum);
487: if (cp[0] < '0' || cp[0] > '9')
488: fatal("%.200s line %d: Badly formatted port number.",
489: filename, linenum);
490: fwd_port = atoi(cp);
491: cp = strtok(NULL, WHITESPACE);
492: if (!cp)
493: fatal("%.200s line %d: Missing second argument.",
494: filename, linenum);
495: if (sscanf(cp, "%255[^:]:%d", buf, &fwd_host_port) != 2)
496: fatal("%.200s line %d: Badly formatted host:port.",
497: filename, linenum);
498: if (*activep)
499: add_local_forward(options, fwd_port, buf, fwd_host_port);
500: break;
501:
502: case oHost:
503: *activep = 0;
504: while ((cp = strtok(NULL, WHITESPACE)) != NULL)
505: if (match_pattern(host, cp)) {
506: debug("Applying options for %.100s", cp);
507: *activep = 1;
508: break;
509: }
1.19 markus 510: /* Avoid garbage check below, as strtok already returned NULL. */
1.17 markus 511: return 0;
512:
513: case oEscapeChar:
514: intptr = &options->escape_char;
515: cp = strtok(NULL, WHITESPACE);
516: if (!cp)
517: fatal("%.200s line %d: Missing argument.", filename, linenum);
518: if (cp[0] == '^' && cp[2] == 0 &&
519: (unsigned char) cp[1] >= 64 && (unsigned char) cp[1] < 128)
520: value = (unsigned char) cp[1] & 31;
521: else if (strlen(cp) == 1)
522: value = (unsigned char) cp[0];
523: else if (strcmp(cp, "none") == 0)
524: value = -2;
525: else {
526: fatal("%.200s line %d: Bad escape character.",
527: filename, linenum);
528: /* NOTREACHED */
529: value = 0; /* Avoid compiler warning. */
530: }
531: if (*activep && *intptr == -1)
532: *intptr = value;
533: break;
534:
535: default:
536: fatal("process_config_line: Unimplemented opcode %d", opcode);
537: }
538:
539: /* Check that there is no garbage at end of line. */
540: if (strtok(NULL, WHITESPACE) != NULL)
541: fatal("%.200s line %d: garbage at end of line.",
542: filename, linenum);
543: return 0;
1.1 deraadt 544: }
545:
546:
1.19 markus 547: /*
548: * Reads the config file and modifies the options accordingly. Options
549: * should already be initialized before this call. This never returns if
550: * there is an error. If the file does not exist, this returns immediately.
551: */
1.1 deraadt 552:
1.17 markus 553: void
554: read_config_file(const char *filename, const char *host, Options *options)
1.1 deraadt 555: {
1.17 markus 556: FILE *f;
557: char line[1024];
558: int active, linenum;
559: int bad_options = 0;
560:
561: /* Open the file. */
562: f = fopen(filename, "r");
563: if (!f)
564: return;
565:
566: debug("Reading configuration data %.200s", filename);
567:
1.19 markus 568: /*
569: * Mark that we are now processing the options. This flag is turned
570: * on/off by Host specifications.
571: */
1.17 markus 572: active = 1;
573: linenum = 0;
574: while (fgets(line, sizeof(line), f)) {
575: /* Update line number counter. */
576: linenum++;
577: if (process_config_line(options, host, line, filename, linenum, &active) != 0)
578: bad_options++;
579: }
580: fclose(f);
581: if (bad_options > 0)
582: fatal("%s: terminating, %d bad configuration options\n",
583: filename, bad_options);
1.1 deraadt 584: }
585:
1.19 markus 586: /*
587: * Initializes options to special values that indicate that they have not yet
588: * been set. Read_config_file will only set options with this value. Options
589: * are processed in the following order: command line, user config file,
590: * system config file. Last, fill_default_options is called.
591: */
1.1 deraadt 592:
1.17 markus 593: void
594: initialize_options(Options * options)
1.1 deraadt 595: {
1.17 markus 596: memset(options, 'X', sizeof(*options));
597: options->forward_agent = -1;
598: options->forward_x11 = -1;
599: options->gateway_ports = -1;
600: options->use_privileged_port = -1;
601: options->rhosts_authentication = -1;
602: options->rsa_authentication = -1;
603: options->skey_authentication = -1;
1.1 deraadt 604: #ifdef KRB4
1.17 markus 605: options->kerberos_authentication = -1;
1.1 deraadt 606: #endif
1.5 dugsong 607: #ifdef AFS
1.17 markus 608: options->kerberos_tgt_passing = -1;
609: options->afs_token_passing = -1;
1.1 deraadt 610: #endif
1.17 markus 611: options->password_authentication = -1;
612: options->rhosts_rsa_authentication = -1;
613: options->fallback_to_rsh = -1;
614: options->use_rsh = -1;
615: options->batch_mode = -1;
616: options->check_host_ip = -1;
617: options->strict_host_key_checking = -1;
618: options->compression = -1;
619: options->keepalives = -1;
620: options->compression_level = -1;
621: options->port = -1;
622: options->connection_attempts = -1;
623: options->number_of_password_prompts = -1;
624: options->cipher = -1;
625: options->num_identity_files = 0;
626: options->hostname = NULL;
627: options->proxy_command = NULL;
628: options->user = NULL;
629: options->escape_char = -1;
630: options->system_hostfile = NULL;
631: options->user_hostfile = NULL;
632: options->num_local_forwards = 0;
633: options->num_remote_forwards = 0;
634: options->log_level = (LogLevel) - 1;
1.1 deraadt 635: }
636:
1.19 markus 637: /*
638: * Called after processing other sources of option data, this fills those
639: * options for which no value has been specified with their default values.
640: */
1.1 deraadt 641:
1.17 markus 642: void
643: fill_default_options(Options * options)
1.1 deraadt 644: {
1.17 markus 645: if (options->forward_agent == -1)
646: options->forward_agent = 1;
647: if (options->forward_x11 == -1)
648: options->forward_x11 = 1;
649: if (options->gateway_ports == -1)
650: options->gateway_ports = 0;
651: if (options->use_privileged_port == -1)
652: options->use_privileged_port = 1;
653: if (options->rhosts_authentication == -1)
654: options->rhosts_authentication = 1;
655: if (options->rsa_authentication == -1)
656: options->rsa_authentication = 1;
657: if (options->skey_authentication == -1)
658: options->skey_authentication = 0;
1.1 deraadt 659: #ifdef KRB4
1.17 markus 660: if (options->kerberos_authentication == -1)
661: options->kerberos_authentication = 1;
1.5 dugsong 662: #endif /* KRB4 */
663: #ifdef AFS
1.17 markus 664: if (options->kerberos_tgt_passing == -1)
665: options->kerberos_tgt_passing = 1;
666: if (options->afs_token_passing == -1)
667: options->afs_token_passing = 1;
1.5 dugsong 668: #endif /* AFS */
1.17 markus 669: if (options->password_authentication == -1)
670: options->password_authentication = 1;
671: if (options->rhosts_rsa_authentication == -1)
672: options->rhosts_rsa_authentication = 1;
673: if (options->fallback_to_rsh == -1)
674: options->fallback_to_rsh = 1;
675: if (options->use_rsh == -1)
676: options->use_rsh = 0;
677: if (options->batch_mode == -1)
678: options->batch_mode = 0;
679: if (options->check_host_ip == -1)
680: options->check_host_ip = 1;
681: if (options->strict_host_key_checking == -1)
682: options->strict_host_key_checking = 2; /* 2 is default */
683: if (options->compression == -1)
684: options->compression = 0;
685: if (options->keepalives == -1)
686: options->keepalives = 1;
687: if (options->compression_level == -1)
688: options->compression_level = 6;
689: if (options->port == -1)
690: options->port = 0; /* Filled in ssh_connect. */
691: if (options->connection_attempts == -1)
692: options->connection_attempts = 4;
693: if (options->number_of_password_prompts == -1)
694: options->number_of_password_prompts = 3;
695: /* Selected in ssh_login(). */
696: if (options->cipher == -1)
697: options->cipher = SSH_CIPHER_NOT_SET;
698: if (options->num_identity_files == 0) {
699: options->identity_files[0] =
700: xmalloc(2 + strlen(SSH_CLIENT_IDENTITY) + 1);
701: sprintf(options->identity_files[0], "~/%.100s", SSH_CLIENT_IDENTITY);
702: options->num_identity_files = 1;
703: }
704: if (options->escape_char == -1)
705: options->escape_char = '~';
706: if (options->system_hostfile == NULL)
707: options->system_hostfile = SSH_SYSTEM_HOSTFILE;
708: if (options->user_hostfile == NULL)
709: options->user_hostfile = SSH_USER_HOSTFILE;
710: if (options->log_level == (LogLevel) - 1)
711: options->log_level = SYSLOG_LEVEL_INFO;
712: /* options->proxy_command should not be set by default */
713: /* options->user will be set in the main program if appropriate */
714: /* options->hostname will be set in the main program if appropriate */
1.1 deraadt 715: }