]> andersk Git - openssh.git/blobdiff - readconf.c
- djm@cvs.openbsd.org 2001/03/13 22:42:54
[openssh.git] / readconf.c
index e3a1dd742267843ce6f0b98fae7a0cd25fe4ef03..33d40e8c3b854754182e4126423d9610a3108c5e 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: readconf.c,v 1.60 2001/01/28 20:36:16 stevesk Exp $");
+RCSID("$OpenBSD: readconf.c,v 1.67 2001/03/10 17:51:04 markus Exp $");
 
 #include "ssh.h"
 #include "xmalloc.h"
@@ -23,6 +23,8 @@ RCSID("$OpenBSD: readconf.c,v 1.60 2001/01/28 20:36:16 stevesk Exp $");
 #include "readconf.h"
 #include "match.h"
 #include "misc.h"
+#include "kex.h"
+#include "mac.h"
 
 /* Format of the configuration file:
 
@@ -105,9 +107,10 @@ typedef enum {
        oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts,
        oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression,
        oCompressionLevel, oKeepAlives, oNumberOfPasswordPrompts,
-       oUsePrivilegedPort, oLogLevel, oCiphers, oProtocol,
+       oUsePrivilegedPort, oLogLevel, oCiphers, oProtocol, oMacs,
        oGlobalKnownHostsFile2, oUserKnownHostsFile2, oPubkeyAuthentication,
-       oKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias
+       oKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias,
+       oPreferredAuthentications
 } OpCodes;
 
 /* Textual representations of the tokens. */
@@ -148,6 +151,7 @@ static struct {
        { "port", oPort },
        { "cipher", oCipher },
        { "ciphers", oCiphers },
+       { "macs", oMacs },
        { "protocol", oProtocol },
        { "remoteforward", oRemoteForward },
        { "localforward", oLocalForward },
@@ -168,6 +172,7 @@ static struct {
        { "keepalive", oKeepAlives },
        { "numberofpasswordprompts", oNumberOfPasswordPrompts },
        { "loglevel", oLogLevel },
+       { "preferredauthentications", oPreferredAuthentications },
        { NULL, 0 }
 };
 
@@ -184,7 +189,7 @@ add_local_forward(Options *options, u_short port, const char *host,
 #ifndef HAVE_CYGWIN
        extern uid_t original_real_uid;
        if (port < IPPORT_RESERVED && original_real_uid != 0)
-               fatal("Privileged ports can only be forwarded by root.\n");
+               fatal("Privileged ports can only be forwarded by root.");
 #endif
        if (options->num_local_forwards >= SSH_MAX_FORWARDS_PER_DIRECTION)
                fatal("Too many local forwards (max %d).", SSH_MAX_FORWARDS_PER_DIRECTION);
@@ -443,6 +448,10 @@ parse_string:
                charptr = &options->host_key_alias;
                goto parse_string;
 
+       case oPreferredAuthentications:
+               charptr = &options->preferred_authentications;
+               goto parse_string;
+
        case oProxyCommand:
                charptr = &options->proxy_command;
                string = xstrdup("");
@@ -502,6 +511,17 @@ parse_int:
                        options->ciphers = xstrdup(arg);
                break;
 
+       case oMacs:
+               arg = strdelim(&s);
+               if (!arg || *arg == '\0')
+                       fatal("%.200s line %d: Missing argument.", filename, linenum);
+               if (!mac_valid(arg))
+                       fatal("%.200s line %d: Bad SSH2 Mac spec '%s'.",
+                             filename, linenum, arg ? arg : "<NONE>");
+               if (*activep && options->macs == NULL)
+                       options->macs = xstrdup(arg);
+               break;
+
        case oProtocol:
                intptr = &options->protocol;
                arg = strdelim(&s);
@@ -520,7 +540,7 @@ parse_int:
                arg = strdelim(&s);
                value = log_level_number(arg);
                if (value == (LogLevel) - 1)
-                       fatal("%.200s line %d: unsupported log level '%s'\n",
+                       fatal("%.200s line %d: unsupported log level '%s'",
                              filename, linenum, arg ? arg : "<NONE>");
                if (*activep && (LogLevel) * intptr == -1)
                        *intptr = (LogLevel) value;
@@ -645,7 +665,7 @@ read_config_file(const char *filename, const char *host, Options *options)
        }
        fclose(f);
        if (bad_options > 0)
-               fatal("%s: terminating, %d bad configuration options\n",
+               fatal("%s: terminating, %d bad configuration options",
                      filename, bad_options);
 }
 
@@ -693,6 +713,7 @@ initialize_options(Options * options)
        options->number_of_password_prompts = -1;
        options->cipher = -1;
        options->ciphers = NULL;
+       options->macs = NULL;
        options->protocol = SSH_PROTO_UNKNOWN;
        options->num_identity_files = 0;
        options->hostname = NULL;
@@ -707,6 +728,7 @@ initialize_options(Options * options)
        options->num_local_forwards = 0;
        options->num_remote_forwards = 0;
        options->log_level = (LogLevel) - 1;
+       options->preferred_authentications = NULL;
 }
 
 /*
@@ -717,6 +739,8 @@ initialize_options(Options * options)
 void
 fill_default_options(Options * options)
 {
+       int len;
+
        if (options->forward_agent == -1)
                options->forward_agent = 0;
        if (options->forward_x11 == -1)
@@ -728,7 +752,7 @@ fill_default_options(Options * options)
        if (options->gateway_ports == -1)
                options->gateway_ports = 0;
        if (options->use_privileged_port == -1)
-               options->use_privileged_port = 1;
+               options->use_privileged_port = 0;
        if (options->rhosts_authentication == -1)
                options->rhosts_authentication = 1;
        if (options->rsa_authentication == -1)
@@ -779,20 +803,29 @@ fill_default_options(Options * options)
        if (options->cipher == -1)
                options->cipher = SSH_CIPHER_NOT_SET;
        /* options->ciphers, default set in myproposals.h */
+       /* options->macs, default set in myproposals.h */
        if (options->protocol == SSH_PROTO_UNKNOWN)
-               options->protocol = SSH_PROTO_1|SSH_PROTO_2|SSH_PROTO_1_PREFERRED;
+               options->protocol = SSH_PROTO_1|SSH_PROTO_2;
        if (options->num_identity_files == 0) {
                if (options->protocol & SSH_PROTO_1) {
+                       len = 2 + strlen(_PATH_SSH_CLIENT_IDENTITY) + 1;
                        options->identity_files[options->num_identity_files] =
-                           xmalloc(2 + strlen(_PATH_SSH_CLIENT_IDENTITY) + 1);
-                       sprintf(options->identity_files[options->num_identity_files++],
-                           "~/%.100s", _PATH_SSH_CLIENT_IDENTITY);
+                           xmalloc(len);
+                       snprintf(options->identity_files[options->num_identity_files++],
+                           len, "~/%.100s", _PATH_SSH_CLIENT_IDENTITY);
                }
                if (options->protocol & SSH_PROTO_2) {
+                       len = 2 + strlen(_PATH_SSH_CLIENT_ID_RSA) + 1;
+                       options->identity_files[options->num_identity_files] =
+                           xmalloc(len);
+                       snprintf(options->identity_files[options->num_identity_files++],
+                           len, "~/%.100s", _PATH_SSH_CLIENT_ID_RSA);
+
+                       len = 2 + strlen(_PATH_SSH_CLIENT_ID_DSA) + 1;
                        options->identity_files[options->num_identity_files] =
-                           xmalloc(2 + strlen(_PATH_SSH_CLIENT_ID_DSA) + 1);
-                       sprintf(options->identity_files[options->num_identity_files++],
-                           "~/%.100s", _PATH_SSH_CLIENT_ID_DSA);
+                           xmalloc(len);
+                       snprintf(options->identity_files[options->num_identity_files++],
+                           len, "~/%.100s", _PATH_SSH_CLIENT_ID_DSA);
                }
        }
        if (options->escape_char == -1)
@@ -811,4 +844,5 @@ fill_default_options(Options * options)
        /* options->user will be set in the main program if appropriate */
        /* options->hostname will be set in the main program if appropriate */
        /* options->host_key_alias should not be set by default */
+       /* options->preferred_authentications will be set in ssh */
 }
This page took 0.042021 seconds and 4 git commands to generate.