Merge branch 'vendor/OPENSSH'
[dragonfly.git] / crypto / openssh / readconf.c
index eb4a8b9..02aeae0 100644 (file)
@@ -44,6 +44,8 @@
 #include "buffer.h"
 #include "kex.h"
 #include "mac.h"
+#include "uidswap.h"
+#include "version.h"
 
 /* Format of the configuration file:
 
@@ -130,11 +132,14 @@ typedef enum {
        oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,
        oAddressFamily, oGssAuthentication, oGssDelegateCreds,
        oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
+       oVersionAddendum,
        oSendEnv, oControlPath, oControlMaster, oControlPersist,
        oHashKnownHosts,
        oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand,
        oVisualHostKey, oUseRoaming, oZeroKnowledgePasswordAuthentication,
        oKexAlgorithms, oIPQoS,
+       oNoneEnabled, oTcpRcvBufPoll, oTcpRcvBuf, oNoneSwitch, oHPNDisabled,
+       oHPNBufferSize,
        oDeprecated, oUnsupported
 } OpCodes;
 
@@ -226,6 +231,7 @@ static struct {
        { "addressfamily", oAddressFamily },
        { "serveraliveinterval", oServerAliveInterval },
        { "serveralivecountmax", oServerAliveCountMax },
+       { "versionaddendum", oVersionAddendum },
        { "sendenv", oSendEnv },
        { "controlpath", oControlPath },
        { "controlmaster", oControlMaster },
@@ -245,6 +251,12 @@ static struct {
 #endif
        { "kexalgorithms", oKexAlgorithms },
        { "ipqos", oIPQoS },
+       { "noneenabled", oNoneEnabled },
+       { "tcprcvbufpoll", oTcpRcvBufPoll },
+       { "tcprcvbuf", oTcpRcvBuf },
+       { "noneswitch", oNoneSwitch },
+       { "hpndisabled", oHPNDisabled },
+       { "hpnbuffersize", oHPNBufferSize },
 
        { NULL, oBadOption }
 };
@@ -491,6 +503,37 @@ parse_flag:
                intptr = &options->check_host_ip;
                goto parse_flag;
 
+       case oNoneEnabled:
+               intptr = &options->none_enabled;
+               goto parse_flag;
+
+       /* we check to see if the command comes from the */
+       /* command line or not. If it does then enable it */
+       /* otherwise fail. NONE should never be a default configuration */
+       case oNoneSwitch:
+               if(strcmp(filename,"command-line")==0)
+               {
+                   intptr = &options->none_switch;
+                   goto parse_flag;
+               } else {
+                   error("NoneSwitch is found in %.200s.\nYou may only use this configuration option from the command line", filename);
+                   error("Continuing...");
+                   debug("NoneSwitch directive found in %.200s.", filename);
+                   return 0;
+               }
+
+       case oHPNDisabled:
+               intptr = &options->hpn_disabled;
+               goto parse_flag;
+
+       case oHPNBufferSize:
+               intptr = &options->hpn_buffer_size;
+               goto parse_int;
+
+       case oTcpRcvBufPoll:
+               intptr = &options->tcp_rcv_buf_poll;
+               goto parse_flag;
+
        case oVerifyHostKeyDNS:
                intptr = &options->verify_host_key_dns;
                goto parse_yesnoask;
@@ -669,6 +712,10 @@ parse_int:
                intptr = &options->connection_attempts;
                goto parse_int;
 
+       case oTcpRcvBuf:
+               intptr = &options->tcp_rcv_buf;
+               goto parse_int;
+
        case oCipher:
                intptr = &options->cipher;
                arg = strdelim(&s);
@@ -858,6 +905,13 @@ parse_int:
                intptr = &options->server_alive_count_max;
                goto parse_int;
 
+       case oVersionAddendum:
+               ssh_version_set_addendum(strtok(s, "\n"));
+               do {
+                       arg = strdelim(&s);
+               } while (arg != NULL && *arg != '\0');
+               break;
+
        case oSendEnv:
                while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
                        if (strchr(arg, '=') != NULL)
@@ -1157,6 +1211,12 @@ initialize_options(Options * options)
        options->zero_knowledge_password_authentication = -1;
        options->ip_qos_interactive = -1;
        options->ip_qos_bulk = -1;
+       options->none_switch = -1;
+       options->none_enabled = -1;
+       options->hpn_disabled = -1;
+       options->hpn_buffer_size = -1;
+       options->tcp_rcv_buf_poll = -1;
+       options->tcp_rcv_buf = -1;
 }
 
 /*
@@ -1206,7 +1266,7 @@ fill_default_options(Options * options)
        if (options->batch_mode == -1)
                options->batch_mode = 0;
        if (options->check_host_ip == -1)
-               options->check_host_ip = 1;
+               options->check_host_ip = 0;
        if (options->strict_host_key_checking == -1)
                options->strict_host_key_checking = 2;  /* 2 is default */
        if (options->compression == -1)
@@ -1289,6 +1349,29 @@ fill_default_options(Options * options)
                options->server_alive_interval = 0;
        if (options->server_alive_count_max == -1)
                options->server_alive_count_max = 3;
+       if (options->none_switch == -1)
+               options->none_switch = 0;
+       if (options->hpn_disabled == -1)
+               options->hpn_disabled = 0;
+       if (options->hpn_buffer_size > -1)
+       {
+         /* if a user tries to set the size to 0 set it to 1KB */
+               if (options->hpn_buffer_size == 0)
+               options->hpn_buffer_size = 1024;
+               /*limit the buffer to 64MB*/
+               if (options->hpn_buffer_size > 65536)
+               {
+                       options->hpn_buffer_size = 65536*1024;
+                       debug("User requested buffer larger than 64MB. Request reverted to 64MB");
+               }
+               debug("hpn_buffer_size set to %d", options->hpn_buffer_size);
+       }
+       if (options->tcp_rcv_buf == 0)
+               options->tcp_rcv_buf = 1;
+       if (options->tcp_rcv_buf > -1)
+               options->tcp_rcv_buf *=1024;
+       if (options->tcp_rcv_buf_poll == -1)
+               options->tcp_rcv_buf_poll = 1;
        if (options->control_master == -1)
                options->control_master = 0;
        if (options->control_persist == -1) {