summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--clientloop.c77
-rw-r--r--ssh.18
3 files changed, 88 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 307e20e14..b2e46a68c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -111,6 +111,10 @@
111 [ssh-add.c] 111 [ssh-add.c]
112 ignore errors for nonexisting default keys in ssh-add, 112 ignore errors for nonexisting default keys in ssh-add,
113 fixes http://bugzilla.mindrot.org/show_bug.cgi?id=158 113 fixes http://bugzilla.mindrot.org/show_bug.cgi?id=158
114 - jakob@cvs.openbsd.org 2002/03/21 15:17:26
115 [clientloop.c ssh.1]
116 add built-in command line for adding new port forwardings on the fly.
117 based on a patch from brian wellington. ok markus@.
114 118
11520020317 11920020317
116 - (tim) [configure.ac] Assume path given with --with-pid-dir=PATH is wanted, 120 - (tim) [configure.ac] Assume path given with --with-pid-dir=PATH is wanted,
@@ -7957,4 +7961,4 @@
7957 - Wrote replacements for strlcpy and mkdtemp 7961 - Wrote replacements for strlcpy and mkdtemp
7958 - Released 1.0pre1 7962 - Released 1.0pre1
7959 7963
7960$Id: ChangeLog,v 1.1956 2002/03/22 03:21:16 mouring Exp $ 7964$Id: ChangeLog,v 1.1957 2002/03/22 03:24:32 mouring Exp $
diff --git a/clientloop.c b/clientloop.c
index 65a6682a6..7259959ee 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
59 */ 59 */
60 60
61#include "includes.h" 61#include "includes.h"
62RCSID("$OpenBSD: clientloop.c,v 1.96 2002/02/06 14:55:15 markus Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.97 2002/03/21 15:17:26 jakob Exp $");
63 63
64#include "ssh.h" 64#include "ssh.h"
65#include "ssh1.h" 65#include "ssh1.h"
@@ -81,6 +81,7 @@ RCSID("$OpenBSD: clientloop.c,v 1.96 2002/02/06 14:55:15 markus Exp $");
81#include "atomicio.h" 81#include "atomicio.h"
82#include "sshtty.h" 82#include "sshtty.h"
83#include "misc.h" 83#include "misc.h"
84#include "readpass.h"
84 85
85/* import options */ 86/* import options */
86extern Options options; 87extern Options options;
@@ -470,6 +471,75 @@ client_process_net_input(fd_set * readset)
470 } 471 }
471} 472}
472 473
474static void
475process_cmdline(Buffer *bin, Buffer *bout, Buffer *berr)
476{
477 char string[1024];
478 void (*handler)(int);
479 char *s, *cmd;
480 u_short fwd_port, fwd_host_port;
481 char buf[1024], sfwd_port[6], sfwd_host_port[6];
482 int local = 0;
483 int n;
484
485 leave_raw_mode();
486 handler = signal(SIGINT, SIG_IGN);
487 s = read_passphrase("\r\nssh> ", RP_ECHO);
488 if (s == NULL)
489 goto out;
490 cmd = s;
491
492 while (*s && isspace(*s))
493 s++;
494
495 if (*s == 0)
496 goto out;
497
498 if (strlen(s) < 2 || s[0] != '-' || !(s[1] == 'L' || s[1] == 'R')) {
499 log("Invalid command");
500 goto out;
501 }
502 if (s[1] == 'L')
503 local = 1;
504 if (!local && !compat20) {
505 log("Not supported for SSH protocol version 1");
506 goto out;
507 }
508
509 s += 2;
510 while (*s && isspace(*s))
511 s++;
512
513 if (sscanf(s, "%5[0-9]:%255[^:]:%5[0-9]",
514 sfwd_port, buf, sfwd_host_port) != 3 &&
515 sscanf(s, "%5[0-9]/%255[^/]/%5[0-9]",
516 sfwd_port, buf, sfwd_host_port) != 3) {
517 log("Bad forwarding specification");
518 goto out;
519 }
520 if ((fwd_port = a2port(sfwd_port)) == 0 ||
521 (fwd_host_port = a2port(sfwd_host_port)) == 0) {
522 log("Bad forwarding port(s)");
523 goto out;
524 }
525 if (local) {
526 n = channel_setup_local_fwd_listener(fwd_port, buf,
527 fwd_host_port, options.gateway_ports);
528 if (n <= 0) {
529 log("Port forwarding failed");
530 goto out;
531 }
532 } else
533 channel_request_remote_forwarding(fwd_port, buf,
534 fwd_host_port);
535 log("Forwarding port");
536out:
537 signal(SIGINT, handler);
538 enter_raw_mode();
539 if (cmd)
540 xfree(cmd);
541}
542
473/* process the characters one by one */ 543/* process the characters one by one */
474static int 544static int
475process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len) 545process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len)
@@ -574,6 +644,7 @@ process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len)
574"%c?\r\n\ 644"%c?\r\n\
575Supported escape sequences:\r\n\ 645Supported escape sequences:\r\n\
576~. - terminate connection\r\n\ 646~. - terminate connection\r\n\
647~C - open a command line\r\n\
577~R - Request rekey (SSH protocol 2 only)\r\n\ 648~R - Request rekey (SSH protocol 2 only)\r\n\
578~^Z - suspend ssh\r\n\ 649~^Z - suspend ssh\r\n\
579~# - list forwarded connections\r\n\ 650~# - list forwarded connections\r\n\
@@ -593,6 +664,10 @@ Supported escape sequences:\r\n\
593 xfree(s); 664 xfree(s);
594 continue; 665 continue;
595 666
667 case 'C':
668 process_cmdline(bin, bout, berr);
669 continue;
670
596 default: 671 default:
597 if (ch != escape_char) { 672 if (ch != escape_char) {
598 buffer_put_char(bin, escape_char); 673 buffer_put_char(bin, escape_char);
diff --git a/ssh.1 b/ssh.1
index 43b75dc23..dc7fa2915 100644
--- a/ssh.1
+++ b/ssh.1
@@ -34,7 +34,7 @@
34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36.\" 36.\"
37.\" $OpenBSD: ssh.1,v 1.148 2002/02/18 17:55:20 markus Exp $ 37.\" $OpenBSD: ssh.1,v 1.149 2002/03/21 15:17:26 jakob Exp $
38.Dd September 25, 1999 38.Dd September 25, 1999
39.Dt SSH 1 39.Dt SSH 1
40.Os 40.Os
@@ -297,6 +297,12 @@ Background ssh at logout when waiting for forwarded connection / X11 sessions
297to terminate 297to terminate
298.It Cm ~? 298.It Cm ~?
299Display a list of escape characters 299Display a list of escape characters
300.It Cm ~C
301Open command line (only useful for adding port forwardings using the
302.Fl L
303and
304.Fl R
305options)
300.It Cm ~R 306.It Cm ~R
301Request rekeying of the connection (only useful for SSH protocol version 2 307Request rekeying of the connection (only useful for SSH protocol version 2
302and if the peer supports it) 308and if the peer supports it)