From f42f05aab70b28a9cfd407e26978ebb5263d8787 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 30 May 2017 16:40:33 -0400 Subject: [PATCH 01/23] GUACAMOLE-203: Add option entries for ServerAliveInterval. --- src/protocols/ssh/settings.c | 12 ++++++++++++ src/protocols/ssh/settings.h | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/protocols/ssh/settings.c b/src/protocols/ssh/settings.c index 35f88e0f..91ec9e66 100644 --- a/src/protocols/ssh/settings.c +++ b/src/protocols/ssh/settings.c @@ -51,6 +51,7 @@ const char* GUAC_SSH_CLIENT_ARGS[] = { "recording-name", "create-recording-path", "read-only", + "server-alive-interval", NULL }; @@ -165,6 +166,12 @@ enum SSH_ARGS_IDX { */ IDX_READ_ONLY, + /** + * Number of seconds between sending alive packets. A default of 0 + * tells SSH not to send these packets. + */ + IDX_SERVER_ALIVE_INTERVAL, + SSH_ARGS_COUNT }; @@ -279,6 +286,11 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user, guac_user_parse_args_boolean(user, GUAC_SSH_CLIENT_ARGS, argv, IDX_CREATE_RECORDING_PATH, false); + /* Parse server alive interval */ + settings->server_alive_interval = + guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv, + IDX_SERVER_ALIVE_INTERVAL, 0); + /* Parsing was successful */ return settings; diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h index 6d3e47a5..3440e5b2 100644 --- a/src/protocols/ssh/settings.h +++ b/src/protocols/ssh/settings.h @@ -181,6 +181,11 @@ typedef struct guac_ssh_settings { */ bool create_recording_path; + /** + * The number of seconds between sending server alive messages. + */ + int server_alive_interval; + } guac_ssh_settings; /** From 8ab7e56972f4b7049a886cc6eb425ed2a3bdc277 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 31 May 2017 08:00:09 -0400 Subject: [PATCH 02/23] GUACAMOLE-203: Implement keepalive config in SSH connection. --- src/protocols/ssh/ssh.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index 43e66f8b..fc5e4083 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -224,6 +224,11 @@ void* ssh_client_thread(void* data) { return NULL; } + /* Set keepalive configuration for session */ + if (settings->server_alive_interval > 0) { + libssh2_keepalive_config(ssh_client->session->session, 1, settings->server_alive_interval); + } + pthread_mutex_init(&ssh_client->term_channel_lock, NULL); /* Open channel for terminal */ @@ -318,11 +323,18 @@ void* ssh_client_thread(void* data) { /* While data available, write to terminal */ int bytes_read = 0; + int timeout = 0; for (;;) { /* Track total amount of data read */ int total_read = 0; + /* Set up return value for keepalives */ + int alive = 0; + + /* Timer for keepalives */ + int sleep = 0; + pthread_mutex_lock(&(ssh_client->term_channel_lock)); /* Stop reading at EOF */ @@ -331,6 +343,16 @@ void* ssh_client_thread(void* data) { break; } + /* Send keepalive at configured interval */ + if (settings->server_alive_interval > 0) { + alive = libssh2_keepalive_send(ssh_client->session->session, &timeout); + if (alive > 0) + break; + sleep = timeout * 1000; + } + else + sleep = 1000; + /* Read terminal data */ bytes_read = libssh2_channel_read(ssh_client->term_channel, buffer, sizeof(buffer)); @@ -370,8 +392,8 @@ void* ssh_client_thread(void* data) { .revents = 0, }}; - /* Wait up to one second */ - if (poll(fds, 1, 1000) < 0) + /* Wait up to computed sleep time */ + if (poll(fds, 1, sleep) < 0) break; } From 75019f5e4bd01d5889b496d847b2dd2c64d0244f Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 31 May 2017 08:30:56 -0400 Subject: [PATCH 03/23] GUACAMOLE-203: Add a few more comments to code. --- src/protocols/ssh/ssh.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index fc5e4083..36055c80 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -346,10 +346,12 @@ void* ssh_client_thread(void* data) { /* Send keepalive at configured interval */ if (settings->server_alive_interval > 0) { alive = libssh2_keepalive_send(ssh_client->session->session, &timeout); + /* Sending the keepalive failed, so we break out */ if (alive > 0) break; sleep = timeout * 1000; } + /* If keepalive is not configured, sleep for the default of 1 second */ else sleep = 1000; From f693b02e126e7d3f348744fdf0975278c897add2 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 31 May 2017 19:33:47 -0400 Subject: [PATCH 04/23] GUACAMOLE-203: Tighten up code, implement constant for socket poll timer. --- src/protocols/ssh/settings.h | 5 +++++ src/protocols/ssh/ssh.c | 26 ++++++++++---------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h index 3440e5b2..e831d9e9 100644 --- a/src/protocols/ssh/settings.h +++ b/src/protocols/ssh/settings.h @@ -53,6 +53,11 @@ */ #define GUAC_SSH_DEFAULT_RECORDING_NAME "recording" +/** + * The default polling timer for SSH activity in milliseconds. + */ +#define GUAC_SSH_DEFAULT_POLL_TIMER 1000 + /** * Settings for the SSH connection. The values for this structure are parsed * from the arguments given during the Guacamole protocol handshake using the diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index 36055c80..a1b3d93c 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -225,9 +225,8 @@ void* ssh_client_thread(void* data) { } /* Set keepalive configuration for session */ - if (settings->server_alive_interval > 0) { + if (settings->server_alive_interval > 1) libssh2_keepalive_config(ssh_client->session->session, 1, settings->server_alive_interval); - } pthread_mutex_init(&ssh_client->term_channel_lock, NULL); @@ -323,17 +322,13 @@ void* ssh_client_thread(void* data) { /* While data available, write to terminal */ int bytes_read = 0; - int timeout = 0; for (;;) { /* Track total amount of data read */ int total_read = 0; - /* Set up return value for keepalives */ - int alive = 0; - - /* Timer for keepalives */ - int sleep = 0; + /* Timer for polling socket activity */ + int timer; pthread_mutex_lock(&(ssh_client->term_channel_lock)); @@ -344,16 +339,15 @@ void* ssh_client_thread(void* data) { } /* Send keepalive at configured interval */ - if (settings->server_alive_interval > 0) { - alive = libssh2_keepalive_send(ssh_client->session->session, &timeout); - /* Sending the keepalive failed, so we break out */ - if (alive > 0) + if (settings->server_alive_interval > 1) { + int timeout = 0; + if(libssh2_keepalive_send(ssh_client->session->session, &timeout) > 0) break; - sleep = timeout * 1000; + timer = timeout * 1000; } /* If keepalive is not configured, sleep for the default of 1 second */ else - sleep = 1000; + timer = GUAC_SSH_DEFAULT_POLL_TIMER; /* Read terminal data */ bytes_read = libssh2_channel_read(ssh_client->term_channel, @@ -394,8 +388,8 @@ void* ssh_client_thread(void* data) { .revents = 0, }}; - /* Wait up to computed sleep time */ - if (poll(fds, 1, sleep) < 0) + /* Wait up to computed timer */ + if (poll(fds, 1, timer) < 0) break; } From 1e3d82cc63c6764cdd19d7c51978188021d9391b Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 31 May 2017 19:36:20 -0400 Subject: [PATCH 05/23] GUACAMOLE-203: Update comment for keep alive interval. --- src/protocols/ssh/settings.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/protocols/ssh/settings.c b/src/protocols/ssh/settings.c index 91ec9e66..8843923b 100644 --- a/src/protocols/ssh/settings.c +++ b/src/protocols/ssh/settings.c @@ -168,7 +168,8 @@ enum SSH_ARGS_IDX { /** * Number of seconds between sending alive packets. A default of 0 - * tells SSH not to send these packets. + * tells SSH not to send these packets. A value of 1 is automatically + * changed by libssh2 to 2 to avoid busy-loop corner cases. */ IDX_SERVER_ALIVE_INTERVAL, From 999368420583263207d669165946e217c556af76 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 31 May 2017 19:47:09 -0400 Subject: [PATCH 06/23] GUACAMOLE-203: Warn user if they try to enter keepalive value < 2 seconds. --- src/protocols/ssh/settings.c | 3 +++ src/protocols/ssh/ssh.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/protocols/ssh/settings.c b/src/protocols/ssh/settings.c index 8843923b..98594153 100644 --- a/src/protocols/ssh/settings.c +++ b/src/protocols/ssh/settings.c @@ -291,6 +291,9 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user, settings->server_alive_interval = guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv, IDX_SERVER_ALIVE_INTERVAL, 0); + if (settings->server_alive_interval == 1) + guac_user_log(user, GUAC_LOG_WARNING, "Minimum keepalive interval " + " for libssh2 is 2 seconds."); /* Parsing was successful */ return settings; diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index a1b3d93c..2504df92 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -225,7 +225,7 @@ void* ssh_client_thread(void* data) { } /* Set keepalive configuration for session */ - if (settings->server_alive_interval > 1) + if (settings->server_alive_interval > 0) libssh2_keepalive_config(ssh_client->session->session, 1, settings->server_alive_interval); pthread_mutex_init(&ssh_client->term_channel_lock, NULL); @@ -339,7 +339,7 @@ void* ssh_client_thread(void* data) { } /* Send keepalive at configured interval */ - if (settings->server_alive_interval > 1) { + if (settings->server_alive_interval > 0) { int timeout = 0; if(libssh2_keepalive_send(ssh_client->session->session, &timeout) > 0) break; From e7fc8a0d98aeef29ee7e2d5ff9b7520bdf42dc32 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 31 May 2017 20:17:00 -0400 Subject: [PATCH 07/23] GUACAMOLE-203: Expand SSH keepalives to cover SFTP connections for other protocols. --- src/common-ssh/common-ssh/ssh.h | 2 +- src/common-ssh/ssh.c | 6 +++++- src/protocols/rdp/rdp.c | 2 +- src/protocols/rdp/rdp.h | 5 +++++ src/protocols/ssh/ssh.c | 8 ++------ src/protocols/vnc/vnc.c | 2 +- src/protocols/vnc/vnc.h | 5 +++++ 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/common-ssh/common-ssh/ssh.h b/src/common-ssh/common-ssh/ssh.h index d96ce44c..ff8621e9 100644 --- a/src/common-ssh/common-ssh/ssh.h +++ b/src/common-ssh/common-ssh/ssh.h @@ -98,7 +98,7 @@ void guac_common_ssh_uninit(); * if the connection or authentication were not successful. */ guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client, - const char* hostname, const char* port, guac_common_ssh_user* user); + const char* hostname, const char* port, guac_common_ssh_user* user, const int keepalive); /** * Disconnects and destroys the given SSH session, freeing all associated diff --git a/src/common-ssh/ssh.c b/src/common-ssh/ssh.c index 57bc8217..3bff4b39 100644 --- a/src/common-ssh/ssh.c +++ b/src/common-ssh/ssh.c @@ -414,7 +414,7 @@ static int guac_common_ssh_authenticate(guac_common_ssh_session* common_session) } guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client, - const char* hostname, const char* port, guac_common_ssh_user* user) { + const char* hostname, const char* port, guac_common_ssh_user* user, const int keepalive) { int retval; @@ -532,6 +532,10 @@ guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client, return NULL; } + /* Configure session keepalive */ + if (keepalive > 0) + libssh2_keepalive_config(common_session->session, 1, keepalive); + /* Return created session */ return common_session; diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c index cf9be2ef..bbe76851 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); + settings->sftp_port, rdp_client->sftp_user, rdp_client->sftp_keepalive); /* Fail if SSH connection does not succeed */ if (rdp_client->sftp_session == NULL) { diff --git a/src/protocols/rdp/rdp.h b/src/protocols/rdp/rdp.h index 943155dd..70e909b1 100644 --- a/src/protocols/rdp/rdp.h +++ b/src/protocols/rdp/rdp.h @@ -141,6 +141,11 @@ 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 /** diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index 2504df92..86c1fdfc 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -218,16 +218,12 @@ void* ssh_client_thread(void* data) { /* Open SSH session */ ssh_client->session = guac_common_ssh_create_session(client, - settings->hostname, settings->port, ssh_client->user); + settings->hostname, settings->port, ssh_client->user, settings->server_alive_interval); if (ssh_client->session == NULL) { /* Already aborted within guac_common_ssh_create_session() */ return NULL; } - /* Set keepalive configuration for session */ - if (settings->server_alive_interval > 0) - libssh2_keepalive_config(ssh_client->session->session, 1, settings->server_alive_interval); - pthread_mutex_init(&ssh_client->term_channel_lock, NULL); /* Open channel for terminal */ @@ -262,7 +258,7 @@ void* ssh_client_thread(void* data) { guac_client_log(client, GUAC_LOG_DEBUG, "Reconnecting for SFTP..."); ssh_client->sftp_session = guac_common_ssh_create_session(client, settings->hostname, - settings->port, ssh_client->user); + settings->port, ssh_client->user, settings->server_alive_interval); if (ssh_client->sftp_session == NULL) { /* Already aborted within guac_common_ssh_create_session() */ return NULL; diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c index 8678ee29..4410e5f7 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); + settings->sftp_port, vnc_client->sftp_user, vnc_client->sftp_keepalive); /* Fail if SSH connection does not succeed */ if (vnc_client->sftp_session == NULL) { diff --git a/src/protocols/vnc/vnc.h b/src/protocols/vnc/vnc.h index 0edbcd47..a09f3ed3 100644 --- a/src/protocols/vnc/vnc.h +++ b/src/protocols/vnc/vnc.h @@ -108,6 +108,11 @@ 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 /** From 03403e3ea5cb132901c68cbc39b2ed6ac02a9fbc Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 31 May 2017 20:52:07 -0400 Subject: [PATCH 08/23] GUACAMOLE-203: Correct implementation of SSH keepalive option for SFTP connections across all protocols. --- 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(-) diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c index bbe76851..7b52a917 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) { diff --git a/src/protocols/rdp/rdp.h b/src/protocols/rdp/rdp.h index 70e909b1..943155dd 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 /** diff --git a/src/protocols/rdp/rdp_settings.c b/src/protocols/rdp/rdp_settings.c index 998f0a21..32c09415 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 */ diff --git a/src/protocols/rdp/rdp_settings.h b/src/protocols/rdp/rdp_settings.h index 3ff634ad..47e5289a 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 /** diff --git a/src/protocols/vnc/settings.c b/src/protocols/vnc/settings.c index 0977af19..60e2f61c 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 */ diff --git a/src/protocols/vnc/settings.h b/src/protocols/vnc/settings.h index 17626676..ba1bfdde 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 /** diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c index 4410e5f7..9aac436b 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) { diff --git a/src/protocols/vnc/vnc.h b/src/protocols/vnc/vnc.h index a09f3ed3..0edbcd47 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 /** From 57ee3841802cd3de5fdb60d5cb3aa9b48b39c6f9 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 1 Jun 2017 22:46:20 -0700 Subject: [PATCH 09/23] GUACAMOLE-314: Bump version numbers to 0.9.13-incubating. --- configure.ac | 2 +- doc/Doxyfile | 2 +- src/guacd/man/guacd.8 | 2 +- src/guacd/man/guacd.conf.5 | 2 +- src/guacenc/man/guacenc.1 | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index a61534a4..b4cc2d37 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ # AC_PREREQ([2.61]) -AC_INIT([guacamole-server], [0.9.12-incubating]) +AC_INIT([guacamole-server], [0.9.13-incubating]) AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects]) AM_SILENT_RULES([yes]) diff --git a/doc/Doxyfile b/doc/Doxyfile index 23eaf03e..59035644 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -22,7 +22,7 @@ # PROJECT_NAME = libguac -PROJECT_NUMBER = 0.9.12-incubating +PROJECT_NUMBER = 0.9.13-incubating # # Warn about undocumented parameters and return values, but do not fill output diff --git a/src/guacd/man/guacd.8 b/src/guacd/man/guacd.8 index c68af365..8e497e35 100644 --- a/src/guacd/man/guacd.8 +++ b/src/guacd/man/guacd.8 @@ -16,7 +16,7 @@ .\" specific language governing permissions and limitations .\" under the License. .\" -.TH guacd 8 "9 Jan 2017" "version 0.9.11-incubating" "Guacamole" +.TH guacd 8 "1 Jun 2017" "version 0.9.13-incubating" "Guacamole" . .SH NAME guacd \- Guacamole proxy daemon diff --git a/src/guacd/man/guacd.conf.5 b/src/guacd/man/guacd.conf.5 index 4605f7d7..49dd7da7 100644 --- a/src/guacd/man/guacd.conf.5 +++ b/src/guacd/man/guacd.conf.5 @@ -16,7 +16,7 @@ .\" specific language governing permissions and limitations .\" under the License. .\" -.TH guacd.conf 5 "9 Jan 2017" "version 0.9.11-incubating" "Guacamole" +.TH guacd.conf 5 "1 Jun 2017" "version 0.9.13-incubating" "Guacamole" . .SH NAME /etc/guacamole/guacd.conf \- Configuration file for guacd diff --git a/src/guacenc/man/guacenc.1 b/src/guacenc/man/guacenc.1 index 95202e42..a36617a2 100644 --- a/src/guacenc/man/guacenc.1 +++ b/src/guacenc/man/guacenc.1 @@ -16,7 +16,7 @@ .\" specific language governing permissions and limitations .\" under the License. .\" -.TH guacenc 1 "9 Jan 2017" "version 0.9.11-incubating" "Guacamole" +.TH guacenc 1 "1 Jun 2017" "version 0.9.13-incubating" "Guacamole" . .SH NAME guacenc \- Guacamole video encoder From 584c108d1abfb960c2b215e832aa5bd580f345da Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 1 Jun 2017 22:52:12 -0700 Subject: [PATCH 10/23] GUACAMOLE-314: Bump libtool version info (interface added, none changed/removed). --- src/libguac/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libguac/Makefile.am b/src/libguac/Makefile.am index 787dfe7a..4590e9fc 100644 --- a/src/libguac/Makefile.am +++ b/src/libguac/Makefile.am @@ -104,7 +104,7 @@ libguac_la_CFLAGS = \ -Werror -Wall -pedantic -Iguacamole libguac_la_LDFLAGS = \ - -version-info 13:0:1 \ + -version-info 14:0:2 \ @CAIRO_LIBS@ \ @JPEG_LIBS@ \ @PNG_LIBS@ \ From 070bd2572170f84c95d1c2801959a85e640dbfbe Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 14 Jun 2017 08:27:09 -0400 Subject: [PATCH 11/23] GUACAMOLE-203: if statement style tweak --- src/protocols/ssh/ssh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index 86c1fdfc..59039bb6 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -337,7 +337,7 @@ void* ssh_client_thread(void* data) { /* Send keepalive at configured interval */ if (settings->server_alive_interval > 0) { int timeout = 0; - if(libssh2_keepalive_send(ssh_client->session->session, &timeout) > 0) + if (libssh2_keepalive_send(ssh_client->session->session, &timeout) > 0) break; timer = timeout * 1000; } From 193051dfd534f18ef6d87b0359d2802daee6d195 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 14 Jun 2017 08:40:07 -0400 Subject: [PATCH 12/23] GUACAMOLE-203: Change parameter name for consistency --- src/protocols/rdp/rdp_settings.c | 6 +++--- src/protocols/vnc/settings.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/protocols/rdp/rdp_settings.c b/src/protocols/rdp/rdp_settings.c index 32c09415..2b6635f8 100644 --- a/src/protocols/rdp/rdp_settings.c +++ b/src/protocols/rdp/rdp_settings.c @@ -84,7 +84,7 @@ const char* GUAC_RDP_CLIENT_ARGS[] = { "sftp-private-key", "sftp-passphrase", "sftp-directory", - "sftp-keepalive", + "sftp-server-alive-interval", #endif "recording-path", @@ -373,7 +373,7 @@ enum RDP_ARGS_IDX { * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner * cases. */ - IDX_SFTP_KEEPALIVE, + IDX_SFTP_SERVER_ALIVE_INTERVAL, #endif /** @@ -787,7 +787,7 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user, /* Default keepalive value */ settings->sftp_keepalive = guac_user_parse_args_int(user, GUAC_RDP_CLIENT_ARGS, argv, - IDX_SFTP_KEEPALIVE, 0); + IDX_SFTP_SERVER_ALIVE_INTERVAL, 0); if (settings->sftp_keepalive == 1) guac_user_log(user, GUAC_LOG_WARNING, "The minimum allowed " "value for keepalives by libssh2 is 2 seconds."); diff --git a/src/protocols/vnc/settings.c b/src/protocols/vnc/settings.c index 60e2f61c..a9e4228a 100644 --- a/src/protocols/vnc/settings.c +++ b/src/protocols/vnc/settings.c @@ -66,7 +66,7 @@ const char* GUAC_VNC_CLIENT_ARGS[] = { "sftp-private-key", "sftp-passphrase", "sftp-directory", - "sftp-keepalive", + "sftp-server-alive-interval", #endif "recording-path", @@ -232,10 +232,10 @@ enum VNC_ARGS_IDX { /** * 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 + * of 1 is automatically incremented to 2 by libssh2 to avoid busy loop corner * cases. */ - IDX_SFTP_KEEPALIVE, + IDX_SFTP_SERVER_ALIVE_INTERVAL, #endif /** @@ -408,7 +408,7 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user, /* Default keepalive value */ settings->sftp_keepalive = guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv, - IDX_SFTP_KEEPALIVE, 0); + IDX_SFTP_SERVER_ALIVE_INTERVAL, 0); if (settings->sftp_keepalive == 1) guac_user_log(user, GUAC_LOG_WARNING, "The minimum allowed " "value for keepalives by libssh2 is 2 seconds."); From df718395e8a40f48aa863dafc9bfb902abc070ae Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 14 Jun 2017 10:17:28 -0400 Subject: [PATCH 13/23] GUACAMOLE-203: Change alive interval from int to unsigned. --- src/protocols/rdp/rdp.c | 2 +- src/protocols/rdp/rdp_settings.c | 6 +++--- src/protocols/rdp/rdp_settings.h | 2 +- src/protocols/ssh/settings.h | 2 +- src/protocols/vnc/settings.c | 6 +++--- src/protocols/vnc/settings.h | 2 +- src/protocols/vnc/vnc.c | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c index 7b52a917..d06fad32 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, settings->sftp_keepalive); + settings->sftp_port, rdp_client->sftp_user, settings->sftp_server_alive_interval); /* Fail if SSH connection does not succeed */ if (rdp_client->sftp_session == NULL) { diff --git a/src/protocols/rdp/rdp_settings.c b/src/protocols/rdp/rdp_settings.c index 2b6635f8..98ecdbbf 100644 --- a/src/protocols/rdp/rdp_settings.c +++ b/src/protocols/rdp/rdp_settings.c @@ -785,12 +785,12 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user, IDX_SFTP_DIRECTORY, NULL); /* Default keepalive value */ - settings->sftp_keepalive = + settings->sftp_server_alive_interval = guac_user_parse_args_int(user, GUAC_RDP_CLIENT_ARGS, argv, IDX_SFTP_SERVER_ALIVE_INTERVAL, 0); - if (settings->sftp_keepalive == 1) + if (settings->sftp_server_alive_interval == 1) guac_user_log(user, GUAC_LOG_WARNING, "The minimum allowed " - "value for keepalives by libssh2 is 2 seconds."); + "value for keepalives is 2 seconds."); #endif /* Read recording path */ diff --git a/src/protocols/rdp/rdp_settings.h b/src/protocols/rdp/rdp_settings.h index 47e5289a..e2013b7b 100644 --- a/src/protocols/rdp/rdp_settings.h +++ b/src/protocols/rdp/rdp_settings.h @@ -366,7 +366,7 @@ typedef struct guac_rdp_settings { * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner * cases. */ - int sftp_keepalive; + unsigned sftp_server_alive_interval; #endif /** diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h index e831d9e9..101caf70 100644 --- a/src/protocols/ssh/settings.h +++ b/src/protocols/ssh/settings.h @@ -189,7 +189,7 @@ typedef struct guac_ssh_settings { /** * The number of seconds between sending server alive messages. */ - int server_alive_interval; + unsigned server_alive_interval; } guac_ssh_settings; diff --git a/src/protocols/vnc/settings.c b/src/protocols/vnc/settings.c index a9e4228a..cf1d8bca 100644 --- a/src/protocols/vnc/settings.c +++ b/src/protocols/vnc/settings.c @@ -406,12 +406,12 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user, IDX_SFTP_DIRECTORY, NULL); /* Default keepalive value */ - settings->sftp_keepalive = + settings->sftp_server_alive_interval = guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv, IDX_SFTP_SERVER_ALIVE_INTERVAL, 0); - if (settings->sftp_keepalive == 1) + if (settings->sftp_server_alive_interval == 1) guac_user_log(user, GUAC_LOG_WARNING, "The minimum allowed " - "value for keepalives by libssh2 is 2 seconds."); + "value for keepalives is 2 seconds."); #endif /* Read recording path */ diff --git a/src/protocols/vnc/settings.h b/src/protocols/vnc/settings.h index ba1bfdde..a9ce82c5 100644 --- a/src/protocols/vnc/settings.h +++ b/src/protocols/vnc/settings.h @@ -180,7 +180,7 @@ typedef struct guac_vnc_settings { * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner * cases. */ - int sftp_keepalive; + unsigned sftp_server_alive_interval; #endif /** diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c index 9aac436b..81d46f1b 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, settings->sftp_keepalive); + settings->sftp_port, vnc_client->sftp_user, settings->sftp_server_alive_interval); /* Fail if SSH connection does not succeed */ if (vnc_client->sftp_session == NULL) { From 89b9a905db221da2b2c0c8c035141b3f4d8c15da Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 14 Jun 2017 11:11:32 -0400 Subject: [PATCH 14/23] GUACAMOLE-203: Tweak warning message sent to users. --- src/protocols/rdp/rdp_settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/protocols/rdp/rdp_settings.c b/src/protocols/rdp/rdp_settings.c index 98ecdbbf..eebf9028 100644 --- a/src/protocols/rdp/rdp_settings.c +++ b/src/protocols/rdp/rdp_settings.c @@ -790,7 +790,7 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user, IDX_SFTP_SERVER_ALIVE_INTERVAL, 0); if (settings->sftp_server_alive_interval == 1) guac_user_log(user, GUAC_LOG_WARNING, "The minimum allowed " - "value for keepalives is 2 seconds."); + "value for keepalives is 2 seconds, this will be rounded up."); #endif /* Read recording path */ From af4d76214773187da5d93241c88dac05148502eb Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 14 Jun 2017 12:49:49 -0400 Subject: [PATCH 15/23] GUACAMOLE-203: Move warning about minimum alive interval to single place in common code. --- src/common-ssh/ssh.c | 6 ++++++ src/protocols/rdp/rdp_settings.c | 3 --- src/protocols/ssh/settings.c | 3 --- src/protocols/vnc/settings.c | 3 --- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/common-ssh/ssh.c b/src/common-ssh/ssh.c index 3bff4b39..00f6327a 100644 --- a/src/common-ssh/ssh.c +++ b/src/common-ssh/ssh.c @@ -536,6 +536,12 @@ guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client, if (keepalive > 0) libssh2_keepalive_config(common_session->session, 1, keepalive); + /* Warn if keepalive below minimum value */ + if (keepalive == 1) { + guac_user_log(user, GUAC_LOG_WARNING, "keepalive interval will " + "be rounded up to minimum value of 2."); + } + /* Return created session */ return common_session; diff --git a/src/protocols/rdp/rdp_settings.c b/src/protocols/rdp/rdp_settings.c index eebf9028..f73ef9d9 100644 --- a/src/protocols/rdp/rdp_settings.c +++ b/src/protocols/rdp/rdp_settings.c @@ -788,9 +788,6 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user, settings->sftp_server_alive_interval = guac_user_parse_args_int(user, GUAC_RDP_CLIENT_ARGS, argv, IDX_SFTP_SERVER_ALIVE_INTERVAL, 0); - if (settings->sftp_server_alive_interval == 1) - guac_user_log(user, GUAC_LOG_WARNING, "The minimum allowed " - "value for keepalives is 2 seconds, this will be rounded up."); #endif /* Read recording path */ diff --git a/src/protocols/ssh/settings.c b/src/protocols/ssh/settings.c index 98594153..8843923b 100644 --- a/src/protocols/ssh/settings.c +++ b/src/protocols/ssh/settings.c @@ -291,9 +291,6 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user, settings->server_alive_interval = guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv, IDX_SERVER_ALIVE_INTERVAL, 0); - if (settings->server_alive_interval == 1) - guac_user_log(user, GUAC_LOG_WARNING, "Minimum keepalive interval " - " for libssh2 is 2 seconds."); /* Parsing was successful */ return settings; diff --git a/src/protocols/vnc/settings.c b/src/protocols/vnc/settings.c index cf1d8bca..697466df 100644 --- a/src/protocols/vnc/settings.c +++ b/src/protocols/vnc/settings.c @@ -409,9 +409,6 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user, settings->sftp_server_alive_interval = guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv, IDX_SFTP_SERVER_ALIVE_INTERVAL, 0); - if (settings->sftp_server_alive_interval == 1) - guac_user_log(user, GUAC_LOG_WARNING, "The minimum allowed " - "value for keepalives is 2 seconds."); #endif /* Read recording path */ From 8c24c77d555312d4227ab79713a5c2333a76c623 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 14 Jun 2017 13:00:30 -0400 Subject: [PATCH 16/23] GUACAMOLE-203: Change timer to timeout --- src/protocols/ssh/settings.h | 4 ++-- src/protocols/ssh/ssh.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h index 101caf70..ea9f5ace 100644 --- a/src/protocols/ssh/settings.h +++ b/src/protocols/ssh/settings.h @@ -54,9 +54,9 @@ #define GUAC_SSH_DEFAULT_RECORDING_NAME "recording" /** - * The default polling timer for SSH activity in milliseconds. + * The default polling timeout for SSH activity in milliseconds. */ -#define GUAC_SSH_DEFAULT_POLL_TIMER 1000 +#define GUAC_SSH_DEFAULT_POLL_TIMEOUT 1000 /** * Settings for the SSH connection. The values for this structure are parsed diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index 59039bb6..afbfe331 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -343,7 +343,7 @@ void* ssh_client_thread(void* data) { } /* If keepalive is not configured, sleep for the default of 1 second */ else - timer = GUAC_SSH_DEFAULT_POLL_TIMER; + timer = GUAC_SSH_DEFAULT_POLL_TIMEOUT; /* Read terminal data */ bytes_read = libssh2_channel_read(ssh_client->term_channel, From ed77114038dd7c6ef13517efe528b09074641d02 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 14 Jun 2017 13:01:01 -0400 Subject: [PATCH 17/23] GUACAMOLE-203: Fix issue using guac_client_log instead of guac_user_log. --- src/common-ssh/ssh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common-ssh/ssh.c b/src/common-ssh/ssh.c index 00f6327a..50ab7e0b 100644 --- a/src/common-ssh/ssh.c +++ b/src/common-ssh/ssh.c @@ -538,7 +538,7 @@ guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client, /* Warn if keepalive below minimum value */ if (keepalive == 1) { - guac_user_log(user, GUAC_LOG_WARNING, "keepalive interval will " + guac_client_log(client, GUAC_LOG_WARNING, "keepalive interval will " "be rounded up to minimum value of 2."); } From 05dfb1a6ae931564458ba6f66360bd12a9ae783f Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sun, 25 Jun 2017 04:49:05 -0400 Subject: [PATCH 18/23] GUACAMOLE-203: Deal correctly with negative keepalive values. --- src/common-ssh/ssh.c | 14 +++++++++----- src/protocols/rdp/rdp_settings.h | 2 +- src/protocols/ssh/settings.h | 2 +- src/protocols/vnc/settings.h | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/common-ssh/ssh.c b/src/common-ssh/ssh.c index 50ab7e0b..d7da64a8 100644 --- a/src/common-ssh/ssh.c +++ b/src/common-ssh/ssh.c @@ -532,16 +532,20 @@ guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client, return NULL; } - /* Configure session keepalive */ - if (keepalive > 0) - libssh2_keepalive_config(common_session->session, 1, keepalive); - /* Warn if keepalive below minimum value */ - if (keepalive == 1) { + if (keepalive < 0) { + keepalive = 0; + guac_client_log(client, GUAC_LOG_WARNING, "negative keepalive intervals " + "are converted to 0, disabling keepalive."); + } + else if(keepalive == 1) { guac_client_log(client, GUAC_LOG_WARNING, "keepalive interval will " "be rounded up to minimum value of 2."); } + /* Configure session keepalive */ + libssh2_keepalive_config(common_session->session, 1, keepalive); + /* Return created session */ return common_session; diff --git a/src/protocols/rdp/rdp_settings.h b/src/protocols/rdp/rdp_settings.h index e2013b7b..8edb79e4 100644 --- a/src/protocols/rdp/rdp_settings.h +++ b/src/protocols/rdp/rdp_settings.h @@ -366,7 +366,7 @@ typedef struct guac_rdp_settings { * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner * cases. */ - unsigned sftp_server_alive_interval; + int sftp_server_alive_interval; #endif /** diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h index ea9f5ace..f49d054d 100644 --- a/src/protocols/ssh/settings.h +++ b/src/protocols/ssh/settings.h @@ -189,7 +189,7 @@ typedef struct guac_ssh_settings { /** * The number of seconds between sending server alive messages. */ - unsigned server_alive_interval; + int server_alive_interval; } guac_ssh_settings; diff --git a/src/protocols/vnc/settings.h b/src/protocols/vnc/settings.h index a9ce82c5..3c7b2587 100644 --- a/src/protocols/vnc/settings.h +++ b/src/protocols/vnc/settings.h @@ -180,7 +180,7 @@ typedef struct guac_vnc_settings { * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner * cases. */ - unsigned sftp_server_alive_interval; + int sftp_server_alive_interval; #endif /** From 711cdd69298fddeff8a641bcb21aab401ea5e59f Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sun, 25 Jun 2017 05:13:12 -0400 Subject: [PATCH 19/23] GUACAMOLE-203: Allow keepalive param to be modified inside the function. --- src/common-ssh/ssh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common-ssh/ssh.c b/src/common-ssh/ssh.c index d7da64a8..00c9f948 100644 --- a/src/common-ssh/ssh.c +++ b/src/common-ssh/ssh.c @@ -414,7 +414,7 @@ static int guac_common_ssh_authenticate(guac_common_ssh_session* common_session) } guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client, - const char* hostname, const char* port, guac_common_ssh_user* user, const int keepalive) { + const char* hostname, const char* port, guac_common_ssh_user* user, int keepalive) { int retval; From 041fcc4651613a383e4d208e603486072ed81594 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sun, 25 Jun 2017 05:13:22 -0400 Subject: [PATCH 20/23] GUACAMOLE-203: Change remaining instances of timer to timeout. --- src/protocols/ssh/ssh.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index afbfe331..aa9fdaee 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -323,8 +323,8 @@ void* ssh_client_thread(void* data) { /* Track total amount of data read */ int total_read = 0; - /* Timer for polling socket activity */ - int timer; + /* Timeout for polling socket activity */ + int timeout; pthread_mutex_lock(&(ssh_client->term_channel_lock)); @@ -336,14 +336,14 @@ void* ssh_client_thread(void* data) { /* Send keepalive at configured interval */ if (settings->server_alive_interval > 0) { - int timeout = 0; + timeout = 0; if (libssh2_keepalive_send(ssh_client->session->session, &timeout) > 0) break; - timer = timeout * 1000; + timeout *= 1000; } /* If keepalive is not configured, sleep for the default of 1 second */ else - timer = GUAC_SSH_DEFAULT_POLL_TIMEOUT; + timeout = GUAC_SSH_DEFAULT_POLL_TIMEOUT; /* Read terminal data */ bytes_read = libssh2_channel_read(ssh_client->term_channel, @@ -384,8 +384,8 @@ void* ssh_client_thread(void* data) { .revents = 0, }}; - /* Wait up to computed timer */ - if (poll(fds, 1, timer) < 0) + /* Wait up to computed timeout */ + if (poll(fds, 1, timeout) < 0) break; } From 650f7a0a320cb9c3834cfff2a53c890b529c9577 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sun, 25 Jun 2017 14:10:42 -0400 Subject: [PATCH 21/23] GUACAMOLE-203: if is not a function... --- src/common-ssh/ssh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common-ssh/ssh.c b/src/common-ssh/ssh.c index 00c9f948..cec3d538 100644 --- a/src/common-ssh/ssh.c +++ b/src/common-ssh/ssh.c @@ -538,7 +538,7 @@ guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client, guac_client_log(client, GUAC_LOG_WARNING, "negative keepalive intervals " "are converted to 0, disabling keepalive."); } - else if(keepalive == 1) { + else if (keepalive == 1) { guac_client_log(client, GUAC_LOG_WARNING, "keepalive interval will " "be rounded up to minimum value of 2."); } From a5efbb593327544b62996f14c2080ad14e152439 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sun, 25 Jun 2017 14:56:50 -0400 Subject: [PATCH 22/23] GUACAMOLE-203: Fix function prototype to remove const. --- src/common-ssh/common-ssh/ssh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common-ssh/common-ssh/ssh.h b/src/common-ssh/common-ssh/ssh.h index ff8621e9..8026549d 100644 --- a/src/common-ssh/common-ssh/ssh.h +++ b/src/common-ssh/common-ssh/ssh.h @@ -98,7 +98,7 @@ void guac_common_ssh_uninit(); * if the connection or authentication were not successful. */ guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client, - const char* hostname, const char* port, guac_common_ssh_user* user, const int keepalive); + const char* hostname, const char* port, guac_common_ssh_user* user, int keepalive); /** * Disconnects and destroys the given SSH session, freeing all associated From e5a1b4d8ae50041aac9c71b025af9401c12c165a Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 4 Jun 2017 13:05:11 -0700 Subject: [PATCH 23/23] GUACAMOLE-326: Explicitly deny attempted reads/writes to Windows named data streams (like "foo:Zone.identifier" for the file "foo"). --- src/protocols/rdp/rdp_fs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/protocols/rdp/rdp_fs.c b/src/protocols/rdp/rdp_fs.c index 28019d8e..88668d82 100644 --- a/src/protocols/rdp/rdp_fs.c +++ b/src/protocols/rdp/rdp_fs.c @@ -654,6 +654,10 @@ int guac_rdp_fs_normalize_path(const char* path, char* abs_path) { } /* end if separator */ + /* We do not currently support named streams */ + else if (c == ':') + return 1; + } /* end for each character */ /* If no components, the path is simply root */