From 5536b836addb27dc6c8433b6afef2f9ad24d399d Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 2 Jun 2018 12:00:22 -0400 Subject: [PATCH] GUACAMOLE-422: Add support for passing through TZ in SSH. --- src/protocols/ssh/settings.c | 18 ++++++++++++++++++ src/protocols/ssh/settings.h | 4 ++++ src/protocols/ssh/ssh.c | 4 ++++ 3 files changed, 26 insertions(+) diff --git a/src/protocols/ssh/settings.c b/src/protocols/ssh/settings.c index 82f7eb20..820da51e 100644 --- a/src/protocols/ssh/settings.c +++ b/src/protocols/ssh/settings.c @@ -61,6 +61,7 @@ const char* GUAC_SSH_CLIENT_ARGS[] = { "terminal-type", "scrollback", "locale", + "timezone", NULL }; @@ -246,6 +247,15 @@ enum SSH_ARGS_IDX { * variable to be set. */ IDX_LOCALE, + + /** + * The timezone that is passed from the client system to the + * remote server, or null if not specified. If set, and allowed + * by the remote SSH server, the TZ environment variable will be + * set on the remote session, causing the session to be localized + * to the specified timezone. + */ + IDX_TIMEZONE, SSH_ARGS_COUNT }; @@ -410,6 +420,11 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user, guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv, IDX_LOCALE, NULL); + /* Read the client timezone. */ + settings->timezone = + guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv, + IDX_TIMEZONE, NULL); + /* Parsing was successful */ return settings; @@ -452,6 +467,9 @@ void guac_ssh_settings_free(guac_ssh_settings* settings) { /* Free locale */ free(settings->locale); + /* Free the client timezone. */ + free(settings->timezone); + /* Free overall structure */ free(settings); diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h index 03abd91d..e4d99e14 100644 --- a/src/protocols/ssh/settings.h +++ b/src/protocols/ssh/settings.h @@ -253,6 +253,10 @@ typedef struct guac_ssh_settings { * environment variable. */ char* locale; + /** + * The client timezone to pass to the remote system. + */ + char* timezone; } guac_ssh_settings; diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index 80b84de1..9e79454b 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -256,6 +256,10 @@ void* ssh_client_thread(void* data) { return NULL; } + /* Set the client timezone */ + if (settings->timezone != NULL) + libssh2_channel_setenv(ssh_client->term_channel, "TZ", settings->timezone); + #ifdef ENABLE_SSH_AGENT /* Start SSH agent forwarding, if enabled */ if (ssh_client->enable_agent) {