|
0 |
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
|
|
1 |
Date: Fri, 12 Aug 2011 19:05:11 +0200
|
|
2 |
Subject: Really fix using alternate ssh ports
|
|
3 |
|
|
4 |
Many,many thanks to Luca Capello for debugging this.
|
|
5 |
|
|
6 |
Closes: #637548
|
|
7 |
---
|
|
8 |
src/virt-viewer-app.c | 18 ++++++++++++++----
|
|
9 |
1 files changed, 14 insertions(+), 4 deletions(-)
|
|
10 |
|
|
11 |
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
|
|
12 |
index 918e788..6d3d9be 100644
|
|
13 |
--- a/src/virt-viewer-app.c
|
|
14 |
+++ b/src/virt-viewer-app.c
|
|
15 |
@@ -319,7 +319,7 @@ virt_viewer_app_open_tunnel_ssh(const char *sshhost,
|
|
16 |
int n = 0;
|
|
17 |
|
|
18 |
cmd[n++] = "ssh";
|
|
19 |
- if (!sshport) {
|
|
20 |
+ if (sshport) {
|
|
21 |
cmd[n++] = "-p";
|
|
22 |
sprintf(portstr, "%d", sshport);
|
|
23 |
cmd[n++] = portstr;
|
|
24 |
@@ -635,6 +635,8 @@ virt_viewer_app_activate(VirtViewerApp *self)
|
|
25 |
if (priv->transport &&
|
|
26 |
g_strcasecmp(priv->transport, "ssh") == 0 &&
|
|
27 |
!priv->direct) {
|
|
28 |
+ gchar *p = NULL;
|
|
29 |
+
|
|
30 |
if (priv->gport) {
|
|
31 |
virt_viewer_app_trace(self, "Opening indirect TCP connection to display at %s:%s\n",
|
|
32 |
priv->ghost, priv->gport);
|
|
33 |
@@ -642,14 +644,22 @@ virt_viewer_app_activate(VirtViewerApp *self)
|
|
34 |
virt_viewer_app_trace(self, "Opening indirect UNIX connection to display at %s\n",
|
|
35 |
priv->unixsock);
|
|
36 |
}
|
|
37 |
- virt_viewer_app_trace(self, "Setting up SSH tunnel via %s@%s:%d\n",
|
|
38 |
- priv->user, priv->host, priv->port ? priv->port : 22);
|
|
39 |
+ if (priv->port)
|
|
40 |
+ p = g_strdup_printf(":%d", priv->port);
|
|
41 |
+
|
|
42 |
+ virt_viewer_app_trace(self, "Setting up SSH tunnel via %s%s%s%s\n",
|
|
43 |
+ priv->user ? priv->user : "",
|
|
44 |
+ priv->user ? "@" : "",
|
|
45 |
+ priv->host, p ? p : "");
|
|
46 |
+ g_free(p);
|
|
47 |
|
|
48 |
if ((fd = virt_viewer_app_open_tunnel_ssh(priv->host, priv->port,
|
|
49 |
priv->user, priv->ghost,
|
|
50 |
priv->gport, priv->unixsock)) < 0)
|
|
51 |
return -1;
|
|
52 |
} else if (priv->unixsock) {
|
|
53 |
+
|
|
54 |
+
|
|
55 |
virt_viewer_app_trace(self, "Opening direct UNIX connection to display at %s",
|
|
56 |
priv->unixsock);
|
|
57 |
if ((fd = virt_viewer_app_open_unix_sock(priv->unixsock)) < 0)
|
|
58 |
@@ -1311,7 +1321,7 @@ virt_viewer_app_set_connect_info(VirtViewerApp *self,
|
|
59 |
priv->transport = g_strdup(transport);
|
|
60 |
priv->unixsock = g_strdup(unixsock);
|
|
61 |
priv->user = g_strdup(user);
|
|
62 |
- priv->port = 0;
|
|
63 |
+ priv->port = port;
|
|
64 |
|
|
65 |
virt_viewer_app_update_pretty_address(self);
|
|
66 |
}
|
|
67 |
--
|