[clientloop.c ssh.1]
     add built-in command line for adding new port forwardings on the fly.
     based on a patch from brian wellington. ok markus@.
This commit is contained in:
Ben Lindstrom 2002-03-22 03:24:32 +00:00
parent 58b391b1bd
commit 5589f4b55f
3 changed files with 88 additions and 3 deletions

View File

@ -111,6 +111,10 @@
[ssh-add.c] [ssh-add.c]
ignore errors for nonexisting default keys in ssh-add, ignore errors for nonexisting default keys in ssh-add,
fixes http://bugzilla.mindrot.org/show_bug.cgi?id=158 fixes http://bugzilla.mindrot.org/show_bug.cgi?id=158
- jakob@cvs.openbsd.org 2002/03/21 15:17:26
[clientloop.c ssh.1]
add built-in command line for adding new port forwardings on the fly.
based on a patch from brian wellington. ok markus@.
20020317 20020317
- (tim) [configure.ac] Assume path given with --with-pid-dir=PATH is wanted, - (tim) [configure.ac] Assume path given with --with-pid-dir=PATH is wanted,
@ -7957,4 +7961,4 @@
- Wrote replacements for strlcpy and mkdtemp - Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1 - Released 1.0pre1
$Id: ChangeLog,v 1.1956 2002/03/22 03:21:16 mouring Exp $ $Id: ChangeLog,v 1.1957 2002/03/22 03:24:32 mouring Exp $

View File

@ -59,7 +59,7 @@
*/ */
#include "includes.h" #include "includes.h"
RCSID("$OpenBSD: clientloop.c,v 1.96 2002/02/06 14:55:15 markus Exp $"); RCSID("$OpenBSD: clientloop.c,v 1.97 2002/03/21 15:17:26 jakob Exp $");
#include "ssh.h" #include "ssh.h"
#include "ssh1.h" #include "ssh1.h"
@ -81,6 +81,7 @@ RCSID("$OpenBSD: clientloop.c,v 1.96 2002/02/06 14:55:15 markus Exp $");
#include "atomicio.h" #include "atomicio.h"
#include "sshtty.h" #include "sshtty.h"
#include "misc.h" #include "misc.h"
#include "readpass.h"
/* import options */ /* import options */
extern Options options; extern Options options;
@ -470,6 +471,75 @@ client_process_net_input(fd_set * readset)
} }
} }
static void
process_cmdline(Buffer *bin, Buffer *bout, Buffer *berr)
{
char string[1024];
void (*handler)(int);
char *s, *cmd;
u_short fwd_port, fwd_host_port;
char buf[1024], sfwd_port[6], sfwd_host_port[6];
int local = 0;
int n;
leave_raw_mode();
handler = signal(SIGINT, SIG_IGN);
s = read_passphrase("\r\nssh> ", RP_ECHO);
if (s == NULL)
goto out;
cmd = s;
while (*s && isspace(*s))
s++;
if (*s == 0)
goto out;
if (strlen(s) < 2 || s[0] != '-' || !(s[1] == 'L' || s[1] == 'R')) {
log("Invalid command");
goto out;
}
if (s[1] == 'L')
local = 1;
if (!local && !compat20) {
log("Not supported for SSH protocol version 1");
goto out;
}
s += 2;
while (*s && isspace(*s))
s++;
if (sscanf(s, "%5[0-9]:%255[^:]:%5[0-9]",
sfwd_port, buf, sfwd_host_port) != 3 &&
sscanf(s, "%5[0-9]/%255[^/]/%5[0-9]",
sfwd_port, buf, sfwd_host_port) != 3) {
log("Bad forwarding specification");
goto out;
}
if ((fwd_port = a2port(sfwd_port)) == 0 ||
(fwd_host_port = a2port(sfwd_host_port)) == 0) {
log("Bad forwarding port(s)");
goto out;
}
if (local) {
n = channel_setup_local_fwd_listener(fwd_port, buf,
fwd_host_port, options.gateway_ports);
if (n <= 0) {
log("Port forwarding failed");
goto out;
}
} else
channel_request_remote_forwarding(fwd_port, buf,
fwd_host_port);
log("Forwarding port");
out:
signal(SIGINT, handler);
enter_raw_mode();
if (cmd)
xfree(cmd);
}
/* process the characters one by one */ /* process the characters one by one */
static int static int
process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len) process_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)
"%c?\r\n\ "%c?\r\n\
Supported escape sequences:\r\n\ Supported escape sequences:\r\n\
~. - terminate connection\r\n\ ~. - terminate connection\r\n\
~C - open a command line\r\n\
~R - Request rekey (SSH protocol 2 only)\r\n\ ~R - Request rekey (SSH protocol 2 only)\r\n\
~^Z - suspend ssh\r\n\ ~^Z - suspend ssh\r\n\
~# - list forwarded connections\r\n\ ~# - list forwarded connections\r\n\
@ -593,6 +664,10 @@ Supported escape sequences:\r\n\
xfree(s); xfree(s);
continue; continue;
case 'C':
process_cmdline(bin, bout, berr);
continue;
default: default:
if (ch != escape_char) { if (ch != escape_char) {
buffer_put_char(bin, escape_char); buffer_put_char(bin, escape_char);

8
ssh.1
View File

@ -34,7 +34,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: ssh.1,v 1.148 2002/02/18 17:55:20 markus Exp $ .\" $OpenBSD: ssh.1,v 1.149 2002/03/21 15:17:26 jakob Exp $
.Dd September 25, 1999 .Dd September 25, 1999
.Dt SSH 1 .Dt SSH 1
.Os .Os
@ -297,6 +297,12 @@ Background ssh at logout when waiting for forwarded connection / X11 sessions
to terminate to terminate
.It Cm ~? .It Cm ~?
Display a list of escape characters Display a list of escape characters
.It Cm ~C
Open command line (only useful for adding port forwardings using the
.Fl L
and
.Fl R
options)
.It Cm ~R .It Cm ~R
Request rekeying of the connection (only useful for SSH protocol version 2 Request rekeying of the connection (only useful for SSH protocol version 2
and if the peer supports it) and if the peer supports it)