summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c54
1 files changed, 43 insertions, 11 deletions
diff --git a/clientloop.c b/clientloop.c
index 18a85c56c..8f4b6e1b0 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: clientloop.c,v 1.236 2011/06/22 22:08:42 djm Exp $ */ 1/* $OpenBSD: clientloop.c,v 1.238 2012/01/18 21:46:43 dtucker 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
@@ -285,6 +285,23 @@ set_control_persist_exit_time(void)
285 /* else we are already counting down to the timeout */ 285 /* else we are already counting down to the timeout */
286} 286}
287 287
288#define SSH_X11_VALID_DISPLAY_CHARS ":/.-_"
289static int
290client_x11_display_valid(const char *display)
291{
292 size_t i, dlen;
293
294 dlen = strlen(display);
295 for (i = 0; i < dlen; i++) {
296 if (!isalnum(display[i]) &&
297 strchr(SSH_X11_VALID_DISPLAY_CHARS, display[i]) == NULL) {
298 debug("Invalid character '%c' in DISPLAY", display[i]);
299 return 0;
300 }
301 }
302 return 1;
303}
304
288#define SSH_X11_PROTO "MIT-MAGIC-COOKIE-1" 305#define SSH_X11_PROTO "MIT-MAGIC-COOKIE-1"
289void 306void
290client_x11_get_proto(const char *display, const char *xauth_path, 307client_x11_get_proto(const char *display, const char *xauth_path,
@@ -307,6 +324,9 @@ client_x11_get_proto(const char *display, const char *xauth_path,
307 324
308 if (xauth_path == NULL ||(stat(xauth_path, &st) == -1)) { 325 if (xauth_path == NULL ||(stat(xauth_path, &st) == -1)) {
309 debug("No xauth program."); 326 debug("No xauth program.");
327 } else if (!client_x11_display_valid(display)) {
328 logit("DISPLAY '%s' invalid, falling back to fake xauth data",
329 display);
310 } else { 330 } else {
311 if (display == NULL) { 331 if (display == NULL) {
312 debug("x11_get_proto: DISPLAY not set"); 332 debug("x11_get_proto: DISPLAY not set");
@@ -848,9 +868,8 @@ process_cmdline(void)
848{ 868{
849 void (*handler)(int); 869 void (*handler)(int);
850 char *s, *cmd, *cancel_host; 870 char *s, *cmd, *cancel_host;
851 int delete = 0; 871 int delete = 0, local = 0, remote = 0, dynamic = 0;
852 int local = 0, remote = 0, dynamic = 0; 872 int cancel_port, ok;
853 int cancel_port;
854 Forward fwd; 873 Forward fwd;
855 874
856 bzero(&fwd, sizeof(fwd)); 875 bzero(&fwd, sizeof(fwd));
@@ -876,8 +895,12 @@ process_cmdline(void)
876 "Request remote forward"); 895 "Request remote forward");
877 logit(" -D[bind_address:]port " 896 logit(" -D[bind_address:]port "
878 "Request dynamic forward"); 897 "Request dynamic forward");
898 logit(" -KL[bind_address:]port "
899 "Cancel local forward");
879 logit(" -KR[bind_address:]port " 900 logit(" -KR[bind_address:]port "
880 "Cancel remote forward"); 901 "Cancel remote forward");
902 logit(" -KD[bind_address:]port "
903 "Cancel dynamic forward");
881 if (!options.permit_local_command) 904 if (!options.permit_local_command)
882 goto out; 905 goto out;
883 logit(" !args " 906 logit(" !args "
@@ -906,11 +929,7 @@ process_cmdline(void)
906 goto out; 929 goto out;
907 } 930 }
908 931
909 if ((local || dynamic) && delete) { 932 if (delete && !compat20) {
910 logit("Not supported.");
911 goto out;
912 }
913 if (remote && delete && !compat20) {
914 logit("Not supported for SSH protocol version 1."); 933 logit("Not supported for SSH protocol version 1.");
915 goto out; 934 goto out;
916 } 935 }
@@ -933,7 +952,21 @@ process_cmdline(void)
933 logit("Bad forwarding close port"); 952 logit("Bad forwarding close port");
934 goto out; 953 goto out;
935 } 954 }
936 channel_request_rforward_cancel(cancel_host, cancel_port); 955 if (remote)
956 ok = channel_request_rforward_cancel(cancel_host,
957 cancel_port) == 0;
958 else if (dynamic)
959 ok = channel_cancel_lport_listener(cancel_host,
960 cancel_port, 0, options.gateway_ports) > 0;
961 else
962 ok = channel_cancel_lport_listener(cancel_host,
963 cancel_port, CHANNEL_CANCEL_PORT_STATIC,
964 options.gateway_ports) > 0;
965 if (!ok) {
966 logit("Unkown port forwarding.");
967 goto out;
968 }
969 logit("Canceled forwarding.");
937 } else { 970 } else {
938 if (!parse_forward(&fwd, s, dynamic, remote)) { 971 if (!parse_forward(&fwd, s, dynamic, remote)) {
939 logit("Bad forwarding specification."); 972 logit("Bad forwarding specification.");
@@ -954,7 +987,6 @@ process_cmdline(void)
954 goto out; 987 goto out;
955 } 988 }
956 } 989 }
957
958 logit("Forwarding port."); 990 logit("Forwarding port.");
959 } 991 }
960 992