You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2017/09/27 02:47:33 UTC

[1/2] incubator-guacamole-server git commit: GUACAMOLE-396: Fixing ssh socket for IPv6 address

Repository: incubator-guacamole-server
Updated Branches:
  refs/heads/master 4e8096093 -> afb554a01


GUACAMOLE-396: Fixing ssh socket for IPv6 address

Root Cause:
In the ssh library of guacd, the TCP socket for connecting to ssh server is created with AF_INET. So it does not support IPv6 address.

Solution:
When guacd creates the socket for ssh in guac_common_ssh_create_session(), stop using hard coded AF_INET for socket() call, use the address family which is returned from getaddrinfo().

Test:
- Connected successfully via ssh connections with IPv4 and IPv6 hosts.
- No connection error in guacd logs.
- Simulated a connection failure with specifying a ssh server which does not exist. guacd worked well in this case.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/commit/f5597016
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/f5597016
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/f5597016

Branch: refs/heads/master
Commit: f559701645f6bf49aa384a5b5f80ae1e73280245
Parents: 4e80960
Author: James <10...@users.noreply.github.com>
Authored: Mon Sep 25 16:57:33 2017 -0700
Committer: sanhex <sa...@gmail.com>
Committed: Tue Sep 26 17:19:18 2017 -0700

----------------------------------------------------------------------
 src/common-ssh/ssh.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/f5597016/src/common-ssh/ssh.c
----------------------------------------------------------------------
diff --git a/src/common-ssh/ssh.c b/src/common-ssh/ssh.c
index cec3d53..d3e1e42 100644
--- a/src/common-ssh/ssh.c
+++ b/src/common-ssh/ssh.c
@@ -431,20 +431,11 @@ guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client,
         .ai_protocol = IPPROTO_TCP
     };
 
-    /* Get socket */
-    fd = socket(AF_INET, SOCK_STREAM, 0);
-    if (fd < 0) {
-        guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR,
-                "Unable to create socket: %s", strerror(errno));
-        return NULL;
-    }
-
     /* Get addresses connection */
     if ((retval = getaddrinfo(hostname, port, &hints, &addresses))) {
         guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR,
                 "Error parsing given address or port: %s",
                 gai_strerror(retval));
-        close(fd);
         return NULL;
     }
 
@@ -461,6 +452,14 @@ guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client,
             guac_client_log(client, GUAC_LOG_DEBUG,
                     "Unable to resolve host: %s", gai_strerror(retval));
 
+        /* Get socket */
+        fd = socket(current_address->ai_family, SOCK_STREAM, 0);
+        if (fd < 0) {
+            guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR,
+                    "Unable to create socket: %s", strerror(errno));
+            return NULL;
+        }
+
         /* Connect */
         if (connect(fd, current_address->ai_addr,
                         current_address->ai_addrlen) == 0) {
@@ -475,11 +474,11 @@ guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client,
         }
 
         /* Otherwise log information regarding bind failure */
-        else
-            guac_client_log(client, GUAC_LOG_DEBUG, "Unable to connect to "
-                    "host %s, port %s: %s",
-                    connected_address, connected_port, strerror(errno));
+        guac_client_log(client, GUAC_LOG_DEBUG, "Unable to connect to "
+                "host %s, port %s: %s",
+                connected_address, connected_port, strerror(errno));
 
+        close(fd);
         current_address = current_address->ai_next;
 
     }
@@ -491,7 +490,6 @@ guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client,
     if (current_address == NULL) {
         guac_client_abort(client, GUAC_PROTOCOL_STATUS_UPSTREAM_NOT_FOUND,
                 "Unable to connect to any addresses.");
-        close(fd);
         return NULL;
     }
 


[2/2] incubator-guacamole-server git commit: GUACAMOLE-396: Merge support for connecting to IPv6 hosts via SSH.

Posted by mj...@apache.org.
GUACAMOLE-396: Merge support for connecting to IPv6 hosts via SSH.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/commit/afb554a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/afb554a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/afb554a0

Branch: refs/heads/master
Commit: afb554a0149391693615226060f567a5f2ef7d49
Parents: 4e80960 f559701
Author: Michael Jumper <mj...@apache.org>
Authored: Tue Sep 26 19:46:17 2017 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue Sep 26 19:46:17 2017 -0700

----------------------------------------------------------------------
 src/common-ssh/ssh.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
----------------------------------------------------------------------