summaryrefslogtreecommitdiff
path: root/readconf.c
diff options
context:
space:
mode:
Diffstat (limited to 'readconf.c')
-rw-r--r--readconf.c74
1 files changed, 71 insertions, 3 deletions
diff --git a/readconf.c b/readconf.c
index d2c5a77f7..7933c5289 100644
--- a/readconf.c
+++ b/readconf.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: readconf.c,v 1.143 2005/07/30 02:03:47 djm Exp $"); 15RCSID("$OpenBSD: readconf.c,v 1.145 2005/12/08 18:34:11 reyk Exp $");
16 16
17#include "ssh.h" 17#include "ssh.h"
18#include "xmalloc.h" 18#include "xmalloc.h"
@@ -70,6 +70,10 @@ RCSID("$OpenBSD: readconf.c,v 1.143 2005/07/30 02:03:47 djm Exp $");
70 Cipher none 70 Cipher none
71 PasswordAuthentication no 71 PasswordAuthentication no
72 72
73 Host vpn.fake.com
74 Tunnel yes
75 TunnelDevice 3
76
73 # Defaults for various options 77 # Defaults for various options
74 Host * 78 Host *
75 ForwardAgent no 79 ForwardAgent no
@@ -107,6 +111,7 @@ typedef enum {
107 oAddressFamily, oGssAuthentication, oGssDelegateCreds, 111 oAddressFamily, oGssAuthentication, oGssDelegateCreds,
108 oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly, 112 oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
109 oSendEnv, oControlPath, oControlMaster, oHashKnownHosts, 113 oSendEnv, oControlPath, oControlMaster, oHashKnownHosts,
114 oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand,
110 oProtocolKeepAlives, oSetupTimeOut, 115 oProtocolKeepAlives, oSetupTimeOut,
111 oDeprecated, oUnsupported 116 oDeprecated, oUnsupported
112} OpCodes; 117} OpCodes;
@@ -199,6 +204,10 @@ static struct {
199 { "controlpath", oControlPath }, 204 { "controlpath", oControlPath },
200 { "controlmaster", oControlMaster }, 205 { "controlmaster", oControlMaster },
201 { "hashknownhosts", oHashKnownHosts }, 206 { "hashknownhosts", oHashKnownHosts },
207 { "tunnel", oTunnel },
208 { "tunneldevice", oTunnelDevice },
209 { "localcommand", oLocalCommand },
210 { "permitlocalcommand", oPermitLocalCommand },
202 { "protocolkeepalives", oProtocolKeepAlives }, 211 { "protocolkeepalives", oProtocolKeepAlives },
203 { "setuptimeout", oSetupTimeOut }, 212 { "setuptimeout", oSetupTimeOut },
204 { NULL, oBadOption } 213 { NULL, oBadOption }
@@ -267,6 +276,7 @@ clear_forwardings(Options *options)
267 xfree(options->remote_forwards[i].connect_host); 276 xfree(options->remote_forwards[i].connect_host);
268 } 277 }
269 options->num_remote_forwards = 0; 278 options->num_remote_forwards = 0;
279 options->tun_open = SSH_TUNMODE_NO;
270} 280}
271 281
272/* 282/*
@@ -299,7 +309,7 @@ process_config_line(Options *options, const char *host,
299 int *activep) 309 int *activep)
300{ 310{
301 char *s, **charptr, *endofnumber, *keyword, *arg, *arg2, fwdarg[256]; 311 char *s, **charptr, *endofnumber, *keyword, *arg, *arg2, fwdarg[256];
302 int opcode, *intptr, value; 312 int opcode, *intptr, value, value2;
303 size_t len; 313 size_t len;
304 Forward fwd; 314 Forward fwd;
305 315
@@ -556,9 +566,10 @@ parse_string:
556 goto parse_string; 566 goto parse_string;
557 567
558 case oProxyCommand: 568 case oProxyCommand:
569 charptr = &options->proxy_command;
570parse_command:
559 if (s == NULL) 571 if (s == NULL)
560 fatal("%.200s line %d: Missing argument.", filename, linenum); 572 fatal("%.200s line %d: Missing argument.", filename, linenum);
561 charptr = &options->proxy_command;
562 len = strspn(s, WHITESPACE "="); 573 len = strspn(s, WHITESPACE "=");
563 if (*activep && *charptr == NULL) 574 if (*activep && *charptr == NULL)
564 *charptr = xstrdup(s + len); 575 *charptr = xstrdup(s + len);
@@ -826,6 +837,49 @@ parse_int:
826 intptr = &options->hash_known_hosts; 837 intptr = &options->hash_known_hosts;
827 goto parse_flag; 838 goto parse_flag;
828 839
840 case oTunnel:
841 intptr = &options->tun_open;
842 arg = strdelim(&s);
843 if (!arg || *arg == '\0')
844 fatal("%s line %d: Missing yes/point-to-point/"
845 "ethernet/no argument.", filename, linenum);
846 value = 0; /* silence compiler */
847 if (strcasecmp(arg, "ethernet") == 0)
848 value = SSH_TUNMODE_ETHERNET;
849 else if (strcasecmp(arg, "point-to-point") == 0)
850 value = SSH_TUNMODE_POINTOPOINT;
851 else if (strcasecmp(arg, "yes") == 0)
852 value = SSH_TUNMODE_DEFAULT;
853 else if (strcasecmp(arg, "no") == 0)
854 value = SSH_TUNMODE_NO;
855 else
856 fatal("%s line %d: Bad yes/point-to-point/ethernet/"
857 "no argument: %s", filename, linenum, arg);
858 if (*activep)
859 *intptr = value;
860 break;
861
862 case oTunnelDevice:
863 arg = strdelim(&s);
864 if (!arg || *arg == '\0')
865 fatal("%.200s line %d: Missing argument.", filename, linenum);
866 value = a2tun(arg, &value2);
867 if (value == SSH_TUNID_ERR)
868 fatal("%.200s line %d: Bad tun device.", filename, linenum);
869 if (*activep) {
870 options->tun_local = value;
871 options->tun_remote = value2;
872 }
873 break;
874
875 case oLocalCommand:
876 charptr = &options->local_command;
877 goto parse_command;
878
879 case oPermitLocalCommand:
880 intptr = &options->permit_local_command;
881 goto parse_flag;
882
829 case oSetupTimeOut: 883 case oSetupTimeOut:
830 intptr = &options->setuptimeout; 884 intptr = &options->setuptimeout;
831 goto parse_int; 885 goto parse_int;
@@ -994,6 +1048,11 @@ initialize_options(Options * options)
994 options->control_path = NULL; 1048 options->control_path = NULL;
995 options->control_master = -1; 1049 options->control_master = -1;
996 options->hash_known_hosts = -1; 1050 options->hash_known_hosts = -1;
1051 options->tun_open = -1;
1052 options->tun_local = -1;
1053 options->tun_remote = -1;
1054 options->local_command = NULL;
1055 options->permit_local_command = -1;
997} 1056}
998 1057
999/* 1058/*
@@ -1123,6 +1182,14 @@ fill_default_options(Options * options)
1123 options->control_master = 0; 1182 options->control_master = 0;
1124 if (options->hash_known_hosts == -1) 1183 if (options->hash_known_hosts == -1)
1125 options->hash_known_hosts = 0; 1184 options->hash_known_hosts = 0;
1185 if (options->tun_open == -1)
1186 options->tun_open = SSH_TUNMODE_NO;
1187 if (options->tun_local == -1)
1188 options->tun_local = SSH_TUNID_ANY;
1189 if (options->tun_remote == -1)
1190 options->tun_remote = SSH_TUNID_ANY;
1191 if (options->permit_local_command == -1)
1192 options->permit_local_command = 0;
1126 if (options->setuptimeout == -1) { 1193 if (options->setuptimeout == -1) {
1127 /* in batch mode, default is 5mins */ 1194 /* in batch mode, default is 5mins */
1128 if (options->batch_mode == 1) 1195 if (options->batch_mode == 1)
@@ -1130,6 +1197,7 @@ fill_default_options(Options * options)
1130 else 1197 else
1131 options->setuptimeout = 0; 1198 options->setuptimeout = 0;
1132 } 1199 }
1200 /* options->local_command should not be set by default */
1133 /* options->proxy_command should not be set by default */ 1201 /* options->proxy_command should not be set by default */
1134 /* options->user will be set in the main program if appropriate */ 1202 /* options->user will be set in the main program if appropriate */
1135 /* options->hostname will be set in the main program if appropriate */ 1203 /* options->hostname will be set in the main program if appropriate */