--- Begin Message ---
Package: xvnc4viewer
Version: 4.1.1+X4.3.0-31
Severity: wishlist
Tags: patch
I sometimes have occasion to use xvnc4viewer to access an X display
behind a gateway host whose ssh server listens on a non-standard port.
To date, I've had to use a stub shell script via $VNC_VIA_CMD that
passes the appropriate -p option to ssh. Other VNC viewer programs I've
used, however, allow the gateway to be specified as "host:port" for
precisely this reason, and I believe this would be useful functionality
to add to xvnc4viewer's -via option. The necessary modifications are
fairly small; I've attached a patch. Thank you for your consideration.
-sbigham
-- System Information:
Debian Release: 5.0
APT prefers stable
APT policy: (990, 'stable'), (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.26-2-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages xvnc4viewer depends on:
ii libc6 2.10.2-2 GNU C Library: Shared libraries
ii libgcc1 1:4.3.3-3 GCC support library
ii libice6 2:1.0.4-1 X11 Inter-Client Exchange library
ii libsm6 2:1.0.3-2 X11 Session Management library
ii libstdc++6 4.3.3-3 The GNU Standard C++ Library v3
ii libx11-6 2:1.1.5-2 X11 client-side library
ii libxext6 2:1.0.4-1 X11 miscellaneous extension librar
ii zlib1g 1:1.2.3.3.dfsg-12 compression library - runtime
xvnc4viewer recommends no packages.
xvnc4viewer suggests no packages.
-- no debconf information
--- unix/vncviewer/vncviewer.cxx.orig 2010-02-06 16:02:39.000000000 -0500
+++ unix/vncviewer/vncviewer.cxx 2010-02-06 17:42:09.000000000 -0500
@@ -168,9 +168,9 @@
/* Tunnelling support. */
static void
-interpretViaParam (char **gatewayHost, char **remoteHost,
- int *remotePort, char **vncServerName,
- int localPort)
+interpretViaParam (char **gatewayHost, int *sshPort,
+ char **remoteHost, int *remotePort,
+ char **vncServerName, int localPort)
{
const int SERVER_PORT_OFFSET = 5900;
char *pos = strchr (*vncServerName, ':');
@@ -196,25 +196,39 @@
*remoteHost = *vncServerName;
*gatewayHost = strDup (via.getValueStr ());
+ pos = strchr (*gatewayHost, ':');
+ if (pos == NULL)
+ *sshPort = 22;
+ else {
+ size_t len;
+ *pos++ = '\0';
+ len = strlen (pos);
+ if (!len || strspn (pos, "0123456789") != len)
+ usage ();
+ *sshPort = atoi (pos);
+ }
+
*vncServerName = new char[50];
sprintf (*vncServerName, "localhost::%d", localPort);
}
static void
-createTunnel (const char *gatewayHost, const char *remoteHost,
- int remotePort, int localPort)
+createTunnel (const char *gatewayHost, int sshPort,
+ const char *remoteHost, int remotePort, int localPort)
{
char *cmd = getenv ("VNC_VIA_CMD");
char *percent;
- char lport[10], rport[10];
+ char lport[10], rport[10], sport[10];
sprintf (lport, "%d", localPort);
sprintf (rport, "%d", remotePort);
+ sprintf (sport, "%d", sshPort);
setenv ("G", gatewayHost, 1);
setenv ("H", remoteHost, 1);
setenv ("R", rport, 1);
setenv ("L", lport, 1);
+ setenv ("P", sport, 1);
if (!cmd)
- cmd = "/usr/bin/ssh -f -L \"$L\":\"$H\":\"$R\" \"$G\" sleep 20";
+ cmd = "/usr/bin/ssh -f -L \"$L\":\"$H\":\"$R\" -p \"$P\" \"$G\" sleep 20";
/* Compatibility with TightVNC's method. */
while ((percent = strchr (cmd, '%')) != NULL)
*percent = '$';
@@ -272,14 +286,15 @@
/* Tunnelling support. */
if (strlen (via.getValueStr ()) > 0) {
char *gatewayHost = "";
+ int sshPort = 22;
char *remoteHost = "localhost";
int localPort = findFreeTcpPort ();
int remotePort;
if (!vncServerName)
usage();
- interpretViaParam (&gatewayHost, &remoteHost, &remotePort,
+ interpretViaParam (&gatewayHost, &sshPort, &remoteHost, &remotePort,
&vncServerName, localPort);
- createTunnel (gatewayHost, remoteHost, remotePort, localPort);
+ createTunnel (gatewayHost, sshPort, remoteHost, remotePort, localPort);
}
Socket* sock = 0;
--- unix/vncviewer/vncviewer.man.orig 2010-02-06 16:02:39.000000000 -0500
+++ unix/vncviewer/vncviewer.man 2010-02-06 17:35:46.000000000 -0500
@@ -180,20 +180,23 @@
prefix from the entries in "/usr/include/X11/keysymdef.h"). Default is F8.
.TP
-\fB\-via\fR \fIgateway\fR
+\fB\-via\fR \fIgateway\fP[:\fIport\fP]
Automatically create encrypted TCP tunnel to the \fIgateway\fR machine
before connection, connect to the \fIhost\fR through that tunnel
(TightVNC\-specific). By default, this option invokes SSH local port
forwarding, assuming that SSH client binary can be accessed as
-/usr/bin/ssh. Note that when using the \fB\-via\fR option, the host
-machine name should be specified as known to the gateway machine, e.g.
-"localhost" denotes the \fIgateway\fR, not the machine where vncviewer
-was launched. The environment variable \fIVNC_VIA_CMD\fR can override
-the default tunnel command of
-\fB/usr/bin/ssh\ -f\ -L\ "$L":"$H":"$R"\ "$G"\ sleep\ 20\fR. The tunnel
-command is executed with the environment variables \fIL\fR, \fIH\fR,
-\fIR\fR, and \fIG\fR taken the values of the local port number, the remote
-host, the port number on the remote host, and the gateway machine
+/usr/bin/ssh. If the SSH server on the gateway machine listens on a
+non-default port, you can specify this port by appending ":" and the port
+number to the gateway name. Note that when using the \fB\-via\fR option,
+the host machine name should be specified as known to the gateway machine,
+e.g. "localhost" denotes the \fIgateway\fR, not the machine where
+vncviewer was launched. The environment variable \fIVNC_VIA_CMD\fR can
+override the default tunnel command of
+\fB/usr/bin/ssh\ -f\ -L\ "$L":"$H":"$R"\ -p\ "$P"\ "$G"\ sleep\ 20\fR. The
+tunnel command is executed with the environment variables \fIL\fR, \fIH\fR,
+\fIR\fR, \fIG\fR and \fIP\fR taken the values of the local port number, the
+remote host, the port number on the remote host, the gateway machine, and
+the SSH server port on the gateway machine (22 if not specified),
respectively.
.SH SEE ALSO
--- End Message ---