Deleted Added
full compact
readconf.c (106130) readconf.c (113911)
1/*
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.
6 *
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".
12 */
13
14#include "includes.h"
1/*
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.
6 *
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".
12 */
13
14#include "includes.h"
15RCSID("$OpenBSD: readconf.c,v 1.100 2002/06/19 00:27:55 deraadt Exp $");
16RCSID("$FreeBSD: head/crypto/openssh/readconf.c 106130 2002-10-29 10:16:02Z des $");
15RCSID("$OpenBSD: readconf.c,v 1.104 2003/04/01 10:22:21 markus Exp $");
16RCSID("$FreeBSD: head/crypto/openssh/readconf.c 113911 2003-04-23 17:13:13Z des $");
17
18#include "ssh.h"
19#include "xmalloc.h"
20#include "compat.h"
21#include "cipher.h"
22#include "pathnames.h"
23#include "log.h"
24#include "readconf.h"

--- 85 unchanged lines hidden (view full) ---

110 oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression,
111 oCompressionLevel, oKeepAlives, oNumberOfPasswordPrompts,
112 oUsePrivilegedPort, oLogLevel, oCiphers, oProtocol, oMacs,
113 oGlobalKnownHostsFile2, oUserKnownHostsFile2, oPubkeyAuthentication,
114 oKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias,
115 oDynamicForward, oPreferredAuthentications, oHostbasedAuthentication,
116 oHostKeyAlgorithms, oBindAddress, oSmartcardDevice,
117 oClearAllForwardings, oNoHostAuthenticationForLocalhost,
17
18#include "ssh.h"
19#include "xmalloc.h"
20#include "compat.h"
21#include "cipher.h"
22#include "pathnames.h"
23#include "log.h"
24#include "readconf.h"

--- 85 unchanged lines hidden (view full) ---

110 oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression,
111 oCompressionLevel, oKeepAlives, oNumberOfPasswordPrompts,
112 oUsePrivilegedPort, oLogLevel, oCiphers, oProtocol, oMacs,
113 oGlobalKnownHostsFile2, oUserKnownHostsFile2, oPubkeyAuthentication,
114 oKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias,
115 oDynamicForward, oPreferredAuthentications, oHostbasedAuthentication,
116 oHostKeyAlgorithms, oBindAddress, oSmartcardDevice,
117 oClearAllForwardings, oNoHostAuthenticationForLocalhost,
118 oEnableSSHKeysign,
118 oVersionAddendum,
119 oDeprecated
120} OpCodes;
121
122/* Textual representations of the tokens. */
123
124static struct {
125 const char *name;

--- 56 unchanged lines hidden (view full) ---

182 { "numberofpasswordprompts", oNumberOfPasswordPrompts },
183 { "loglevel", oLogLevel },
184 { "dynamicforward", oDynamicForward },
185 { "preferredauthentications", oPreferredAuthentications },
186 { "hostkeyalgorithms", oHostKeyAlgorithms },
187 { "bindaddress", oBindAddress },
188 { "smartcarddevice", oSmartcardDevice },
189 { "clearallforwardings", oClearAllForwardings },
119 oVersionAddendum,
120 oDeprecated
121} OpCodes;
122
123/* Textual representations of the tokens. */
124
125static struct {
126 const char *name;

--- 56 unchanged lines hidden (view full) ---

183 { "numberofpasswordprompts", oNumberOfPasswordPrompts },
184 { "loglevel", oLogLevel },
185 { "dynamicforward", oDynamicForward },
186 { "preferredauthentications", oPreferredAuthentications },
187 { "hostkeyalgorithms", oHostKeyAlgorithms },
188 { "bindaddress", oBindAddress },
189 { "smartcarddevice", oSmartcardDevice },
190 { "clearallforwardings", oClearAllForwardings },
191 { "enablesshkeysign", oEnableSSHKeysign },
190 { "nohostauthenticationforlocalhost", oNoHostAuthenticationForLocalhost },
191 { "versionaddendum", oVersionAddendum },
192 { NULL, oBadOption }
193};
194
195/*
196 * Adds a local TCP/IP port forward to options. Never returns if there is an
197 * error.

--- 66 unchanged lines hidden (view full) ---

264 filename, linenum, cp);
265 return oBadOption;
266}
267
268/*
269 * Processes a single option line as used in the configuration files. This
270 * only sets those values that have not already been set.
271 */
192 { "nohostauthenticationforlocalhost", oNoHostAuthenticationForLocalhost },
193 { "versionaddendum", oVersionAddendum },
194 { NULL, oBadOption }
195};
196
197/*
198 * Adds a local TCP/IP port forward to options. Never returns if there is an
199 * error.

--- 66 unchanged lines hidden (view full) ---

266 filename, linenum, cp);
267 return oBadOption;
268}
269
270/*
271 * Processes a single option line as used in the configuration files. This
272 * only sets those values that have not already been set.
273 */
274#define WHITESPACE " \t\r\n"
272
273int
274process_config_line(Options *options, const char *host,
275 char *line, const char *filename, int linenum,
276 int *activep)
277{
275
276int
277process_config_line(Options *options, const char *host,
278 char *line, const char *filename, int linenum,
279 int *activep)
280{
278 char buf[256], *s, *string, **charptr, *endofnumber, *keyword, *arg;
281 char buf[256], *s, **charptr, *endofnumber, *keyword, *arg;
279 int opcode, *intptr, value;
282 int opcode, *intptr, value;
283 size_t len;
280 u_short fwd_port, fwd_host_port;
281 char sfwd_host_port[6];
282
283 s = line;
284 /* Get the keyword. (Each line is supposed to begin with a keyword). */
285 keyword = strdelim(&s);
286 /* Ignore leading whitespace. */
287 if (*keyword == '\0')

--- 196 unchanged lines hidden (view full) ---

484 goto parse_string;
485
486 case oSmartcardDevice:
487 charptr = &options->smartcard_device;
488 goto parse_string;
489
490 case oProxyCommand:
491 charptr = &options->proxy_command;
284 u_short fwd_port, fwd_host_port;
285 char sfwd_host_port[6];
286
287 s = line;
288 /* Get the keyword. (Each line is supposed to begin with a keyword). */
289 keyword = strdelim(&s);
290 /* Ignore leading whitespace. */
291 if (*keyword == '\0')

--- 196 unchanged lines hidden (view full) ---

488 goto parse_string;
489
490 case oSmartcardDevice:
491 charptr = &options->smartcard_device;
492 goto parse_string;
493
494 case oProxyCommand:
495 charptr = &options->proxy_command;
492 string = xstrdup("");
493 while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
494 string = xrealloc(string, strlen(string) + strlen(arg) + 2);
495 strcat(string, " ");
496 strcat(string, arg);
497 }
496 len = strspn(s, WHITESPACE "=");
498 if (*activep && *charptr == NULL)
497 if (*activep && *charptr == NULL)
499 *charptr = string;
500 else
501 xfree(string);
498 *charptr = xstrdup(s + len);
502 return 0;
503
504 case oPort:
505 intptr = &options->port;
506parse_int:
507 arg = strdelim(&s);
508 if (!arg || *arg == '\0')
509 fatal("%.200s line %d: Missing argument.", filename, linenum);

--- 157 unchanged lines hidden (view full) ---

667 filename, linenum);
668 /* NOTREACHED */
669 value = 0; /* Avoid compiler warning. */
670 }
671 if (*activep && *intptr == -1)
672 *intptr = value;
673 break;
674
499 return 0;
500
501 case oPort:
502 intptr = &options->port;
503parse_int:
504 arg = strdelim(&s);
505 if (!arg || *arg == '\0')
506 fatal("%.200s line %d: Missing argument.", filename, linenum);

--- 157 unchanged lines hidden (view full) ---

664 filename, linenum);
665 /* NOTREACHED */
666 value = 0; /* Avoid compiler warning. */
667 }
668 if (*activep && *intptr == -1)
669 *intptr = value;
670 break;
671
672 case oEnableSSHKeysign:
673 intptr = &options->enable_ssh_keysign;
674 goto parse_flag;
675
675 case oVersionAddendum:
676 ssh_version_set_addendum(strtok(s, "\n"));
677 do {
678 arg = strdelim(&s);
679 } while (arg != NULL && *arg != '\0');
680 break;
681
682 case oDeprecated:

--- 114 unchanged lines hidden (view full) ---

797 options->user_hostfile2 = NULL;
798 options->num_local_forwards = 0;
799 options->num_remote_forwards = 0;
800 options->clear_forwardings = -1;
801 options->log_level = SYSLOG_LEVEL_NOT_SET;
802 options->preferred_authentications = NULL;
803 options->bind_address = NULL;
804 options->smartcard_device = NULL;
676 case oVersionAddendum:
677 ssh_version_set_addendum(strtok(s, "\n"));
678 do {
679 arg = strdelim(&s);
680 } while (arg != NULL && *arg != '\0');
681 break;
682
683 case oDeprecated:

--- 114 unchanged lines hidden (view full) ---

798 options->user_hostfile2 = NULL;
799 options->num_local_forwards = 0;
800 options->num_remote_forwards = 0;
801 options->clear_forwardings = -1;
802 options->log_level = SYSLOG_LEVEL_NOT_SET;
803 options->preferred_authentications = NULL;
804 options->bind_address = NULL;
805 options->smartcard_device = NULL;
806 options->enable_ssh_keysign = - 1;
805 options->no_host_authentication_for_localhost = - 1;
806}
807
808/*
809 * Called after processing other sources of option data, this fills those
810 * options for which no value has been specified with their default values.
811 */
812

--- 99 unchanged lines hidden (view full) ---

912 if (options->user_hostfile2 == NULL)
913 options->user_hostfile2 = _PATH_SSH_USER_HOSTFILE2;
914 if (options->log_level == SYSLOG_LEVEL_NOT_SET)
915 options->log_level = SYSLOG_LEVEL_INFO;
916 if (options->clear_forwardings == 1)
917 clear_forwardings(options);
918 if (options->no_host_authentication_for_localhost == - 1)
919 options->no_host_authentication_for_localhost = 0;
807 options->no_host_authentication_for_localhost = - 1;
808}
809
810/*
811 * Called after processing other sources of option data, this fills those
812 * options for which no value has been specified with their default values.
813 */
814

--- 99 unchanged lines hidden (view full) ---

914 if (options->user_hostfile2 == NULL)
915 options->user_hostfile2 = _PATH_SSH_USER_HOSTFILE2;
916 if (options->log_level == SYSLOG_LEVEL_NOT_SET)
917 options->log_level = SYSLOG_LEVEL_INFO;
918 if (options->clear_forwardings == 1)
919 clear_forwardings(options);
920 if (options->no_host_authentication_for_localhost == - 1)
921 options->no_host_authentication_for_localhost = 0;
922 if (options->enable_ssh_keysign == -1)
923 options->enable_ssh_keysign = 0;
920 /* options->proxy_command should not be set by default */
921 /* options->user will be set in the main program if appropriate */
922 /* options->hostname will be set in the main program if appropriate */
923 /* options->host_key_alias should not be set by default */
924 /* options->preferred_authentications will be set in ssh */
925}
924 /* options->proxy_command should not be set by default */
925 /* options->user will be set in the main program if appropriate */
926 /* options->hostname will be set in the main program if appropriate */
927 /* options->host_key_alias should not be set by default */
928 /* options->preferred_authentications will be set in ssh */
929}