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/06/25 19:02:22 UTC

[08/21] incubator-guacamole-server git commit: GUACAMOLE-203: Correct implementation of SSH keepalive option for SFTP connections across all protocols.

GUACAMOLE-203: Correct implementation of SSH keepalive option for SFTP connections across all protocols.


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/03403e3e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/03403e3e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/03403e3e

Branch: refs/heads/master
Commit: 03403e3ea5cb132901c68cbc39b2ed6ac02a9fbc
Parents: e7fc8a0
Author: Nick Couchman <vn...@apache.org>
Authored: Wed May 31 20:52:07 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Wed May 31 21:03:14 2017 -0400

----------------------------------------------------------------------
 src/protocols/rdp/rdp.c          |  2 +-
 src/protocols/rdp/rdp.h          |  5 -----
 src/protocols/rdp/rdp_settings.c | 16 ++++++++++++++++
 src/protocols/rdp/rdp_settings.h |  8 ++++++++
 src/protocols/vnc/settings.c     | 17 +++++++++++++++++
 src/protocols/vnc/settings.h     |  8 ++++++++
 src/protocols/vnc/vnc.c          |  2 +-
 src/protocols/vnc/vnc.h          |  5 -----
 8 files changed, 51 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/03403e3e/src/protocols/rdp/rdp.c
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c
index bbe7685..7b52a91 100644
--- a/src/protocols/rdp/rdp.c
+++ b/src/protocols/rdp/rdp.c
@@ -977,7 +977,7 @@ void* guac_rdp_client_thread(void* data) {
         /* Attempt SSH connection */
         rdp_client->sftp_session =
             guac_common_ssh_create_session(client, settings->sftp_hostname,
-                    settings->sftp_port, rdp_client->sftp_user, rdp_client->sftp_keepalive);
+                    settings->sftp_port, rdp_client->sftp_user, settings->sftp_keepalive);
 
         /* Fail if SSH connection does not succeed */
         if (rdp_client->sftp_session == NULL) {

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/03403e3e/src/protocols/rdp/rdp.h
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/rdp.h b/src/protocols/rdp/rdp.h
index 70e909b..943155d 100644
--- a/src/protocols/rdp/rdp.h
+++ b/src/protocols/rdp/rdp.h
@@ -141,11 +141,6 @@ typedef struct guac_rdp_client {
      * An SFTP-based filesystem.
      */
     guac_common_ssh_sftp_filesystem* sftp_filesystem;
-
-    /**
-     * A keepalive interval for SFTP connections.
-     */
-    int sftp_keepalive;
 #endif
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/03403e3e/src/protocols/rdp/rdp_settings.c
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/rdp_settings.c b/src/protocols/rdp/rdp_settings.c
index 998f0a2..32c0941 100644
--- a/src/protocols/rdp/rdp_settings.c
+++ b/src/protocols/rdp/rdp_settings.c
@@ -84,6 +84,7 @@ const char* GUAC_RDP_CLIENT_ARGS[] = {
     "sftp-private-key",
     "sftp-passphrase",
     "sftp-directory",
+    "sftp-keepalive",
 #endif
 
     "recording-path",
@@ -366,6 +367,13 @@ enum RDP_ARGS_IDX {
      */
     IDX_SFTP_DIRECTORY,
 
+    /**
+     * The interval at which SSH keepalive messages are sent to the server for
+     * SFTP connections.  The default is 0 (disabling keepalives), and a value
+     * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner
+     * cases.
+     */
+    IDX_SFTP_KEEPALIVE,
 #endif
 
     /**
@@ -775,6 +783,14 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user,
     settings->sftp_directory =
         guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv,
                 IDX_SFTP_DIRECTORY, NULL);
+
+    /* Default keepalive value */
+    settings->sftp_keepalive =
+        guac_user_parse_args_int(user, GUAC_RDP_CLIENT_ARGS, argv,
+                IDX_SFTP_KEEPALIVE, 0);
+    if (settings->sftp_keepalive == 1)
+        guac_user_log(user, GUAC_LOG_WARNING, "The minimum allowed "
+                "value for keepalives by libssh2 is 2 seconds.");
 #endif
 
     /* Read recording path */

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/03403e3e/src/protocols/rdp/rdp_settings.h
----------------------------------------------------------------------
diff --git a/src/protocols/rdp/rdp_settings.h b/src/protocols/rdp/rdp_settings.h
index 3ff634a..47e5289 100644
--- a/src/protocols/rdp/rdp_settings.h
+++ b/src/protocols/rdp/rdp_settings.h
@@ -359,6 +359,14 @@ typedef struct guac_rdp_settings {
      * the destination directory is otherwise ambiguous).
      */
     char* sftp_directory;
+
+    /**
+     * The interval at which SSH keepalive messages are sent to the server for
+     * SFTP connections.  The default is 0 (disabling keepalives), and a value
+     * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner
+     * cases.
+     */
+    int sftp_keepalive;
 #endif
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/03403e3e/src/protocols/vnc/settings.c
----------------------------------------------------------------------
diff --git a/src/protocols/vnc/settings.c b/src/protocols/vnc/settings.c
index 0977af1..60e2f61 100644
--- a/src/protocols/vnc/settings.c
+++ b/src/protocols/vnc/settings.c
@@ -66,6 +66,7 @@ const char* GUAC_VNC_CLIENT_ARGS[] = {
     "sftp-private-key",
     "sftp-passphrase",
     "sftp-directory",
+    "sftp-keepalive",
 #endif
 
     "recording-path",
@@ -227,6 +228,14 @@ enum VNC_ARGS_IDX {
      * the destination directory is otherwise ambiguous).
      */
     IDX_SFTP_DIRECTORY,
+
+    /**
+     * The interval at which SSH keepalive messages are sent to the server for
+     * SFTP connections.  The default is 0 (disabling keepalives), and a value
+     * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner
+     * cases.
+     */
+    IDX_SFTP_KEEPALIVE,
 #endif
 
     /**
@@ -395,6 +404,14 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user,
     settings->sftp_directory =
         guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv,
                 IDX_SFTP_DIRECTORY, NULL);
+
+    /* Default keepalive value */
+    settings->sftp_keepalive =
+        guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv,
+                IDX_SFTP_KEEPALIVE, 0);
+    if (settings->sftp_keepalive == 1)
+        guac_user_log(user, GUAC_LOG_WARNING, "The minimum allowed "
+                "value for keepalives by libssh2 is 2 seconds.");
 #endif
 
     /* Read recording path */

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/03403e3e/src/protocols/vnc/settings.h
----------------------------------------------------------------------
diff --git a/src/protocols/vnc/settings.h b/src/protocols/vnc/settings.h
index 1762667..ba1bfdd 100644
--- a/src/protocols/vnc/settings.h
+++ b/src/protocols/vnc/settings.h
@@ -173,6 +173,14 @@ typedef struct guac_vnc_settings {
      * the destination directory is otherwise ambiguous).
      */
     char* sftp_directory;
+
+    /**
+     * The interval at which SSH keepalive messages are sent to the server for
+     * SFTP connections.  The default is 0 (disabling keepalives), and a value
+     * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner
+     * cases.
+     */
+    int sftp_keepalive;
 #endif
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/03403e3e/src/protocols/vnc/vnc.c
----------------------------------------------------------------------
diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c
index 4410e5f..9aac436 100644
--- a/src/protocols/vnc/vnc.c
+++ b/src/protocols/vnc/vnc.c
@@ -261,7 +261,7 @@ void* guac_vnc_client_thread(void* data) {
         /* Attempt SSH connection */
         vnc_client->sftp_session =
             guac_common_ssh_create_session(client, settings->sftp_hostname,
-                    settings->sftp_port, vnc_client->sftp_user, vnc_client->sftp_keepalive);
+                    settings->sftp_port, vnc_client->sftp_user, settings->sftp_keepalive);
 
         /* Fail if SSH connection does not succeed */
         if (vnc_client->sftp_session == NULL) {

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/03403e3e/src/protocols/vnc/vnc.h
----------------------------------------------------------------------
diff --git a/src/protocols/vnc/vnc.h b/src/protocols/vnc/vnc.h
index a09f3ed..0edbcd4 100644
--- a/src/protocols/vnc/vnc.h
+++ b/src/protocols/vnc/vnc.h
@@ -108,11 +108,6 @@ typedef struct guac_vnc_client {
      * An SFTP-based filesystem.
      */
     guac_common_ssh_sftp_filesystem* sftp_filesystem;
-
-    /**
-     * The interval at which to send SSH keepalive messages for SFTP.
-     */
-    int sftp_keepalive;
 #endif
 
     /**