diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | auth-options.c | 4 | ||||
-rw-r--r-- | channels.c | 12 | ||||
-rw-r--r-- | servconf.c | 18 | ||||
-rw-r--r-- | servconf.h | 10 | ||||
-rw-r--r-- | serverloop.c | 19 | ||||
-rw-r--r-- | session.c | 9 | ||||
-rw-r--r-- | sshd_config.5 | 16 |
8 files changed, 68 insertions, 26 deletions
@@ -12,6 +12,12 @@ | |||
12 | make deleting explicit keys "ssh-add -d" symmetric with adding keys - | 12 | make deleting explicit keys "ssh-add -d" symmetric with adding keys - |
13 | try to delete the corresponding certificate too and respect the -k option | 13 | try to delete the corresponding certificate too and respect the -k option |
14 | to allow deleting of the key only; feedback and ok markus@ | 14 | to allow deleting of the key only; feedback and ok markus@ |
15 | - djm@cvs.openbsd.org 2012/12/02 20:46:11 | ||
16 | [auth-options.c channels.c servconf.c servconf.h serverloop.c session.c] | ||
17 | [sshd_config.5] | ||
18 | make AllowTcpForwarding accept "local" and "remote" in addition to its | ||
19 | current "yes"/"no" to allow the server to specify whether just local or | ||
20 | remote TCP forwarding is enabled. ok markus@ | ||
15 | 21 | ||
16 | 20121114 | 22 | 20121114 |
17 | - (djm) OpenBSD CVS Sync | 23 | - (djm) OpenBSD CVS Sync |
diff --git a/auth-options.c b/auth-options.c index 0e67bd8c0..23d0423e1 100644 --- a/auth-options.c +++ b/auth-options.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: auth-options.c,v 1.56 2011/10/18 04:58:26 djm Exp $ */ | 1 | /* $OpenBSD: auth-options.c,v 1.57 2012/12/02 20:46:11 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -349,7 +349,7 @@ auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum) | |||
349 | xfree(patterns); | 349 | xfree(patterns); |
350 | goto bad_option; | 350 | goto bad_option; |
351 | } | 351 | } |
352 | if (options.allow_tcp_forwarding) | 352 | if ((options.allow_tcp_forwarding & FORWARD_LOCAL) != 0) |
353 | channel_add_permitted_opens(host, port); | 353 | channel_add_permitted_opens(host, port); |
354 | xfree(patterns); | 354 | xfree(patterns); |
355 | goto next_option; | 355 | goto next_option; |
diff --git a/channels.c b/channels.c index 7791febd7..9cf85a38d 100644 --- a/channels.c +++ b/channels.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: channels.c,v 1.318 2012/04/23 08:18:17 djm Exp $ */ | 1 | /* $OpenBSD: channels.c,v 1.319 2012/12/02 20:46:11 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -3165,12 +3165,10 @@ channel_add_adm_permitted_opens(char *host, int port) | |||
3165 | void | 3165 | void |
3166 | channel_disable_adm_local_opens(void) | 3166 | channel_disable_adm_local_opens(void) |
3167 | { | 3167 | { |
3168 | if (num_adm_permitted_opens == 0) { | 3168 | channel_clear_adm_permitted_opens(); |
3169 | permitted_adm_opens = xmalloc(sizeof(*permitted_adm_opens)); | 3169 | permitted_adm_opens = xmalloc(sizeof(*permitted_adm_opens)); |
3170 | permitted_adm_opens[num_adm_permitted_opens].host_to_connect | 3170 | permitted_adm_opens[num_adm_permitted_opens].host_to_connect = NULL; |
3171 | = NULL; | 3171 | num_adm_permitted_opens = 1; |
3172 | num_adm_permitted_opens = 1; | ||
3173 | } | ||
3174 | } | 3172 | } |
3175 | 3173 | ||
3176 | void | 3174 | void |
diff --git a/servconf.c b/servconf.c index b90dba63b..21b371c84 100644 --- a/servconf.c +++ b/servconf.c | |||
@@ -1,5 +1,5 @@ | |||
1 | 1 | ||
2 | /* $OpenBSD: servconf.c,v 1.232 2012/11/04 11:09:15 djm Exp $ */ | 2 | /* $OpenBSD: servconf.c,v 1.233 2012/12/02 20:46:11 djm Exp $ */ |
3 | /* | 3 | /* |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
5 | * All rights reserved | 5 | * All rights reserved |
@@ -250,7 +250,7 @@ fill_default_server_options(ServerOptions *options) | |||
250 | if (options->compression == -1) | 250 | if (options->compression == -1) |
251 | options->compression = COMP_DELAYED; | 251 | options->compression = COMP_DELAYED; |
252 | if (options->allow_tcp_forwarding == -1) | 252 | if (options->allow_tcp_forwarding == -1) |
253 | options->allow_tcp_forwarding = 1; | 253 | options->allow_tcp_forwarding = FORWARD_ALLOW; |
254 | if (options->allow_agent_forwarding == -1) | 254 | if (options->allow_agent_forwarding == -1) |
255 | options->allow_agent_forwarding = 1; | 255 | options->allow_agent_forwarding = 1; |
256 | if (options->gateway_ports == -1) | 256 | if (options->gateway_ports == -1) |
@@ -786,6 +786,14 @@ static const struct multistate multistate_privsep[] = { | |||
786 | { "no", PRIVSEP_OFF }, | 786 | { "no", PRIVSEP_OFF }, |
787 | { NULL, -1 } | 787 | { NULL, -1 } |
788 | }; | 788 | }; |
789 | static const struct multistate multistate_tcpfwd[] = { | ||
790 | { "yes", FORWARD_ALLOW }, | ||
791 | { "all", FORWARD_ALLOW }, | ||
792 | { "no", FORWARD_DENY }, | ||
793 | { "remote", FORWARD_REMOTE }, | ||
794 | { "local", FORWARD_LOCAL }, | ||
795 | { NULL, -1 } | ||
796 | }; | ||
789 | 797 | ||
790 | int | 798 | int |
791 | process_server_config_line(ServerOptions *options, char *line, | 799 | process_server_config_line(ServerOptions *options, char *line, |
@@ -1143,7 +1151,8 @@ process_server_config_line(ServerOptions *options, char *line, | |||
1143 | 1151 | ||
1144 | case sAllowTcpForwarding: | 1152 | case sAllowTcpForwarding: |
1145 | intptr = &options->allow_tcp_forwarding; | 1153 | intptr = &options->allow_tcp_forwarding; |
1146 | goto parse_flag; | 1154 | multistate_ptr = multistate_tcpfwd; |
1155 | goto parse_multistate; | ||
1147 | 1156 | ||
1148 | case sAllowAgentForwarding: | 1157 | case sAllowAgentForwarding: |
1149 | intptr = &options->allow_agent_forwarding; | 1158 | intptr = &options->allow_agent_forwarding; |
@@ -1423,7 +1432,6 @@ process_server_config_line(ServerOptions *options, char *line, | |||
1423 | } | 1432 | } |
1424 | if (strcmp(arg, "none") == 0) { | 1433 | if (strcmp(arg, "none") == 0) { |
1425 | if (*activep && n == -1) { | 1434 | if (*activep && n == -1) { |
1426 | channel_clear_adm_permitted_opens(); | ||
1427 | options->num_permitted_opens = 1; | 1435 | options->num_permitted_opens = 1; |
1428 | channel_disable_adm_local_opens(); | 1436 | channel_disable_adm_local_opens(); |
1429 | } | 1437 | } |
@@ -1780,6 +1788,8 @@ fmt_intarg(ServerOpCodes code, int val) | |||
1780 | return fmt_multistate_int(val, multistate_compression); | 1788 | return fmt_multistate_int(val, multistate_compression); |
1781 | case sUsePrivilegeSeparation: | 1789 | case sUsePrivilegeSeparation: |
1782 | return fmt_multistate_int(val, multistate_privsep); | 1790 | return fmt_multistate_int(val, multistate_privsep); |
1791 | case sAllowTcpForwarding: | ||
1792 | return fmt_multistate_int(val, multistate_tcpfwd); | ||
1783 | case sProtocol: | 1793 | case sProtocol: |
1784 | switch (val) { | 1794 | switch (val) { |
1785 | case SSH_PROTO_1: | 1795 | case SSH_PROTO_1: |
diff --git a/servconf.h b/servconf.h index 68fcdb764..a23ef7f3a 100644 --- a/servconf.h +++ b/servconf.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: servconf.h,v 1.105 2012/11/04 11:09:15 djm Exp $ */ | 1 | /* $OpenBSD: servconf.h,v 1.106 2012/12/02 20:46:11 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -42,6 +42,12 @@ | |||
42 | #define PRIVSEP_ON 1 | 42 | #define PRIVSEP_ON 1 |
43 | #define PRIVSEP_NOSANDBOX 2 | 43 | #define PRIVSEP_NOSANDBOX 2 |
44 | 44 | ||
45 | /* AllowTCPForwarding */ | ||
46 | #define FORWARD_DENY 0 | ||
47 | #define FORWARD_REMOTE (1) | ||
48 | #define FORWARD_LOCAL (1<<1) | ||
49 | #define FORWARD_ALLOW (FORWARD_REMOTE|FORWARD_LOCAL) | ||
50 | |||
45 | #define DEFAULT_AUTH_FAIL_MAX 6 /* Default for MaxAuthTries */ | 51 | #define DEFAULT_AUTH_FAIL_MAX 6 /* Default for MaxAuthTries */ |
46 | #define DEFAULT_SESSIONS_MAX 10 /* Default for MaxSessions */ | 52 | #define DEFAULT_SESSIONS_MAX 10 /* Default for MaxSessions */ |
47 | 53 | ||
@@ -116,7 +122,7 @@ typedef struct { | |||
116 | int permit_user_env; /* If true, read ~/.ssh/environment */ | 122 | int permit_user_env; /* If true, read ~/.ssh/environment */ |
117 | int use_login; /* If true, login(1) is used */ | 123 | int use_login; /* If true, login(1) is used */ |
118 | int compression; /* If true, compression is allowed */ | 124 | int compression; /* If true, compression is allowed */ |
119 | int allow_tcp_forwarding; | 125 | int allow_tcp_forwarding; /* One of FORWARD_* */ |
120 | int allow_agent_forwarding; | 126 | int allow_agent_forwarding; |
121 | u_int num_allow_users; | 127 | u_int num_allow_users; |
122 | char *allow_users[MAX_ALLOW_USERS]; | 128 | char *allow_users[MAX_ALLOW_USERS]; |
diff --git a/serverloop.c b/serverloop.c index 741c5befb..14e60c6dc 100644 --- a/serverloop.c +++ b/serverloop.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: serverloop.c,v 1.162 2012/06/20 04:42:58 djm Exp $ */ | 1 | /* $OpenBSD: serverloop.c,v 1.163 2012/12/02 20:46:11 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -950,7 +950,7 @@ server_input_window_size(int type, u_int32_t seq, void *ctxt) | |||
950 | static Channel * | 950 | static Channel * |
951 | server_request_direct_tcpip(void) | 951 | server_request_direct_tcpip(void) |
952 | { | 952 | { |
953 | Channel *c; | 953 | Channel *c = NULL; |
954 | char *target, *originator; | 954 | char *target, *originator; |
955 | u_short target_port, originator_port; | 955 | u_short target_port, originator_port; |
956 | 956 | ||
@@ -963,9 +963,16 @@ server_request_direct_tcpip(void) | |||
963 | debug("server_request_direct_tcpip: originator %s port %d, target %s " | 963 | debug("server_request_direct_tcpip: originator %s port %d, target %s " |
964 | "port %d", originator, originator_port, target, target_port); | 964 | "port %d", originator, originator_port, target, target_port); |
965 | 965 | ||
966 | /* XXX check permission */ | 966 | /* XXX fine grained permissions */ |
967 | c = channel_connect_to(target, target_port, | 967 | if ((options.allow_tcp_forwarding & FORWARD_LOCAL) != 0 && |
968 | "direct-tcpip", "direct-tcpip"); | 968 | !no_port_forwarding_flag) { |
969 | c = channel_connect_to(target, target_port, | ||
970 | "direct-tcpip", "direct-tcpip"); | ||
971 | } else { | ||
972 | logit("refused local port forward: " | ||
973 | "originator %s port %d, target %s port %d", | ||
974 | originator, originator_port, target, target_port); | ||
975 | } | ||
969 | 976 | ||
970 | xfree(originator); | 977 | xfree(originator); |
971 | xfree(target); | 978 | xfree(target); |
@@ -1126,7 +1133,7 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt) | |||
1126 | listen_address, listen_port); | 1133 | listen_address, listen_port); |
1127 | 1134 | ||
1128 | /* check permissions */ | 1135 | /* check permissions */ |
1129 | if (!options.allow_tcp_forwarding || | 1136 | if ((options.allow_tcp_forwarding & FORWARD_REMOTE) == 0 || |
1130 | no_port_forwarding_flag || | 1137 | no_port_forwarding_flag || |
1131 | (!want_reply && listen_port == 0) | 1138 | (!want_reply && listen_port == 0) |
1132 | #ifndef NO_IPPORT_RESERVED_CONCEPT | 1139 | #ifndef NO_IPPORT_RESERVED_CONCEPT |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: session.c,v 1.260 2012/03/15 03:10:27 guenther Exp $ */ | 1 | /* $OpenBSD: session.c,v 1.261 2012/12/02 20:46:11 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
4 | * All rights reserved | 4 | * All rights reserved |
@@ -273,7 +273,10 @@ do_authenticated(Authctxt *authctxt) | |||
273 | setproctitle("%s", authctxt->pw->pw_name); | 273 | setproctitle("%s", authctxt->pw->pw_name); |
274 | 274 | ||
275 | /* setup the channel layer */ | 275 | /* setup the channel layer */ |
276 | if (!no_port_forwarding_flag && options.allow_tcp_forwarding) | 276 | if (no_port_forwarding_flag || |
277 | (options.allow_tcp_forwarding & FORWARD_LOCAL) == 0) | ||
278 | channel_disable_adm_local_opens(); | ||
279 | else | ||
277 | channel_permit_all_opens(); | 280 | channel_permit_all_opens(); |
278 | 281 | ||
279 | auth_debug_send(); | 282 | auth_debug_send(); |
@@ -383,7 +386,7 @@ do_authenticated1(Authctxt *authctxt) | |||
383 | debug("Port forwarding not permitted for this authentication."); | 386 | debug("Port forwarding not permitted for this authentication."); |
384 | break; | 387 | break; |
385 | } | 388 | } |
386 | if (!options.allow_tcp_forwarding) { | 389 | if (!(options.allow_tcp_forwarding & FORWARD_REMOTE)) { |
387 | debug("Port forwarding not permitted."); | 390 | debug("Port forwarding not permitted."); |
388 | break; | 391 | break; |
389 | } | 392 | } |
diff --git a/sshd_config.5 b/sshd_config.5 index 05f3374fb..d2c4db55b 100644 --- a/sshd_config.5 +++ b/sshd_config.5 | |||
@@ -33,8 +33,8 @@ | |||
33 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 33 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
34 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 34 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
35 | .\" | 35 | .\" |
36 | .\" $OpenBSD: sshd_config.5,v 1.149 2012/11/04 11:09:15 djm Exp $ | 36 | .\" $OpenBSD: sshd_config.5,v 1.150 2012/12/02 20:46:11 djm Exp $ |
37 | .Dd $Mdocdate: November 4 2012 $ | 37 | .Dd $Mdocdate: December 2 2012 $ |
38 | .Dt SSHD_CONFIG 5 | 38 | .Dt SSHD_CONFIG 5 |
39 | .Os | 39 | .Os |
40 | .Sh NAME | 40 | .Sh NAME |
@@ -124,6 +124,18 @@ in | |||
124 | for more information on patterns. | 124 | for more information on patterns. |
125 | .It Cm AllowTcpForwarding | 125 | .It Cm AllowTcpForwarding |
126 | Specifies whether TCP forwarding is permitted. | 126 | Specifies whether TCP forwarding is permitted. |
127 | The available options are | ||
128 | .Dq yes | ||
129 | or | ||
130 | .Dq all | ||
131 | to allow TCP forwarding, | ||
132 | .Dq no | ||
133 | to prevent all TCP forwarding, | ||
134 | .Dq local | ||
135 | to allow local (from the perspective of | ||
136 | .Xr ssh 1 ) forwarding only or | ||
137 | .Dq remote | ||
138 | to allow remote forwarding only. | ||
127 | The default is | 139 | The default is |
128 | .Dq yes . | 140 | .Dq yes . |
129 | Note that disabling TCP forwarding does not improve security unless | 141 | Note that disabling TCP forwarding does not improve security unless |