summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2011-09-22 21:39:48 +1000
committerDamien Miller <djm@mindrot.org>2011-09-22 21:39:48 +1000
commitff773644e6892e6d3999b0e0c69f05b56705eabc (patch)
tree56f792434d92ef52dd0e05a00b9295ba52bcc64e /clientloop.c
parentf6dff7cd2ff5eba5cd63e3a9c7bf6ccf183cb056 (diff)
- markus@cvs.openbsd.org 2011/09/10 22:26:34
[channels.c channels.h clientloop.c ssh.1] support cancellation of local/dynamic forwardings from ~C commandline; ok & feedback djm@
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/clientloop.c b/clientloop.c
index c19b01f19..1339521f4 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.237 2011/09/10 22:26:34 markus 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
@@ -839,9 +839,8 @@ process_cmdline(void)
839{ 839{
840 void (*handler)(int); 840 void (*handler)(int);
841 char *s, *cmd, *cancel_host; 841 char *s, *cmd, *cancel_host;
842 int delete = 0; 842 int delete = 0, local = 0, remote = 0, dynamic = 0;
843 int local = 0, remote = 0, dynamic = 0; 843 int cancel_port, ok;
844 int cancel_port;
845 Forward fwd; 844 Forward fwd;
846 845
847 bzero(&fwd, sizeof(fwd)); 846 bzero(&fwd, sizeof(fwd));
@@ -867,8 +866,12 @@ process_cmdline(void)
867 "Request remote forward"); 866 "Request remote forward");
868 logit(" -D[bind_address:]port " 867 logit(" -D[bind_address:]port "
869 "Request dynamic forward"); 868 "Request dynamic forward");
869 logit(" -KL[bind_address:]port "
870 "Cancel local forward");
870 logit(" -KR[bind_address:]port " 871 logit(" -KR[bind_address:]port "
871 "Cancel remote forward"); 872 "Cancel remote forward");
873 logit(" -KD[bind_address:]port "
874 "Cancel dynamic forward");
872 if (!options.permit_local_command) 875 if (!options.permit_local_command)
873 goto out; 876 goto out;
874 logit(" !args " 877 logit(" !args "
@@ -897,11 +900,7 @@ process_cmdline(void)
897 goto out; 900 goto out;
898 } 901 }
899 902
900 if ((local || dynamic) && delete) { 903 if (delete && !compat20) {
901 logit("Not supported.");
902 goto out;
903 }
904 if (remote && delete && !compat20) {
905 logit("Not supported for SSH protocol version 1."); 904 logit("Not supported for SSH protocol version 1.");
906 goto out; 905 goto out;
907 } 906 }
@@ -924,7 +923,21 @@ process_cmdline(void)
924 logit("Bad forwarding close port"); 923 logit("Bad forwarding close port");
925 goto out; 924 goto out;
926 } 925 }
927 channel_request_rforward_cancel(cancel_host, cancel_port); 926 if (remote)
927 ok = channel_request_rforward_cancel(cancel_host,
928 cancel_port) == 0;
929 else if (dynamic)
930 ok = channel_cancel_lport_listener(cancel_host,
931 cancel_port, 0, options.gateway_ports) > 0;
932 else
933 ok = channel_cancel_lport_listener(cancel_host,
934 cancel_port, CHANNEL_CANCEL_PORT_STATIC,
935 options.gateway_ports) > 0;
936 if (!ok) {
937 logit("Unkown port forwarding.");
938 goto out;
939 }
940 logit("Canceled forwarding.");
928 } else { 941 } else {
929 if (!parse_forward(&fwd, s, dynamic, remote)) { 942 if (!parse_forward(&fwd, s, dynamic, remote)) {
930 logit("Bad forwarding specification."); 943 logit("Bad forwarding specification.");
@@ -945,7 +958,6 @@ process_cmdline(void)
945 goto out; 958 goto out;
946 } 959 }
947 } 960 }
948
949 logit("Forwarding port."); 961 logit("Forwarding port.");
950 } 962 }
951 963