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

This commit is contained in:
Nick Couchman 2017-05-31 20:52:07 -04:00 committed by Nick Couchman
parent e7fc8a0d98
commit 03403e3ea5
8 changed files with 51 additions and 12 deletions

View File

@ -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) {

View File

@ -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
/**

View File

@ -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 */

View File

@ -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
/**

View File

@ -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 */

View File

@ -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
/**

View File

@ -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) {

View File

@ -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
/**