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 345df9c25..355a41ccb 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
@@ -108,6 +112,7 @@ typedef enum {
108 oGssTrustDns, 112 oGssTrustDns,
109 oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly, 113 oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
110 oSendEnv, oControlPath, oControlMaster, oHashKnownHosts, 114 oSendEnv, oControlPath, oControlMaster, oHashKnownHosts,
115 oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand,
111 oDeprecated, oUnsupported 116 oDeprecated, oUnsupported
112} OpCodes; 117} OpCodes;
113 118
@@ -201,6 +206,10 @@ static struct {
201 { "controlpath", oControlPath }, 206 { "controlpath", oControlPath },
202 { "controlmaster", oControlMaster }, 207 { "controlmaster", oControlMaster },
203 { "hashknownhosts", oHashKnownHosts }, 208 { "hashknownhosts", oHashKnownHosts },
209 { "tunnel", oTunnel },
210 { "tunneldevice", oTunnelDevice },
211 { "localcommand", oLocalCommand },
212 { "permitlocalcommand", oPermitLocalCommand },
204 { NULL, oBadOption } 213 { NULL, oBadOption }
205}; 214};
206 215
@@ -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
@@ -560,9 +570,10 @@ parse_string:
560 goto parse_string; 570 goto parse_string;
561 571
562 case oProxyCommand: 572 case oProxyCommand:
573 charptr = &options->proxy_command;
574parse_command:
563 if (s == NULL) 575 if (s == NULL)
564 fatal("%.200s line %d: Missing argument.", filename, linenum); 576 fatal("%.200s line %d: Missing argument.", filename, linenum);
565 charptr = &options->proxy_command;
566 len = strspn(s, WHITESPACE "="); 577 len = strspn(s, WHITESPACE "=");
567 if (*activep && *charptr == NULL) 578 if (*activep && *charptr == NULL)
568 *charptr = xstrdup(s + len); 579 *charptr = xstrdup(s + len);
@@ -829,6 +840,49 @@ parse_int:
829 intptr = &options->hash_known_hosts; 840 intptr = &options->hash_known_hosts;
830 goto parse_flag; 841 goto parse_flag;
831 842
843 case oTunnel:
844 intptr = &options->tun_open;
845 arg = strdelim(&s);
846 if (!arg || *arg == '\0')
847 fatal("%s line %d: Missing yes/point-to-point/"
848 "ethernet/no argument.", filename, linenum);
849 value = 0; /* silence compiler */
850 if (strcasecmp(arg, "ethernet") == 0)
851 value = SSH_TUNMODE_ETHERNET;
852 else if (strcasecmp(arg, "point-to-point") == 0)
853 value = SSH_TUNMODE_POINTOPOINT;
854 else if (strcasecmp(arg, "yes") == 0)
855 value = SSH_TUNMODE_DEFAULT;
856 else if (strcasecmp(arg, "no") == 0)
857 value = SSH_TUNMODE_NO;
858 else
859 fatal("%s line %d: Bad yes/point-to-point/ethernet/"
860 "no argument: %s", filename, linenum, arg);
861 if (*activep)
862 *intptr = value;
863 break;
864
865 case oTunnelDevice:
866 arg = strdelim(&s);
867 if (!arg || *arg == '\0')
868 fatal("%.200s line %d: Missing argument.", filename, linenum);
869 value = a2tun(arg, &value2);
870 if (value == SSH_TUNID_ERR)
871 fatal("%.200s line %d: Bad tun device.", filename, linenum);
872 if (*activep) {
873 options->tun_local = value;
874 options->tun_remote = value2;
875 }
876 break;
877
878 case oLocalCommand:
879 charptr = &options->local_command;
880 goto parse_command;
881
882 case oPermitLocalCommand:
883 intptr = &options->permit_local_command;
884 goto parse_flag;
885
832 case oDeprecated: 886 case oDeprecated:
833 debug("%s line %d: Deprecated option \"%s\"", 887 debug("%s line %d: Deprecated option \"%s\"",
834 filename, linenum, keyword); 888 filename, linenum, keyword);
@@ -974,6 +1028,11 @@ initialize_options(Options * options)
974 options->control_path = NULL; 1028 options->control_path = NULL;
975 options->control_master = -1; 1029 options->control_master = -1;
976 options->hash_known_hosts = -1; 1030 options->hash_known_hosts = -1;
1031 options->tun_open = -1;
1032 options->tun_local = -1;
1033 options->tun_remote = -1;
1034 options->local_command = NULL;
1035 options->permit_local_command = -1;
977} 1036}
978 1037
979/* 1038/*
@@ -1100,6 +1159,15 @@ fill_default_options(Options * options)
1100 options->control_master = 0; 1159 options->control_master = 0;
1101 if (options->hash_known_hosts == -1) 1160 if (options->hash_known_hosts == -1)
1102 options->hash_known_hosts = 0; 1161 options->hash_known_hosts = 0;
1162 if (options->tun_open == -1)
1163 options->tun_open = SSH_TUNMODE_NO;
1164 if (options->tun_local == -1)
1165 options->tun_local = SSH_TUNID_ANY;
1166 if (options->tun_remote == -1)
1167 options->tun_remote = SSH_TUNID_ANY;
1168 if (options->permit_local_command == -1)
1169 options->permit_local_command = 0;
1170 /* options->local_command should not be set by default */
1103 /* options->proxy_command should not be set by default */ 1171 /* options->proxy_command should not be set by default */
1104 /* options->user will be set in the main program if appropriate */ 1172 /* options->user will be set in the main program if appropriate */
1105 /* options->hostname will be set in the main program if appropriate */ 1173 /* options->hostname will be set in the main program if appropriate */