GUACAMOLE-422: Add support for passing through TZ in SSH.
Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/5536b836 Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/5536b836 Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/5536b836 Branch: refs/heads/master Commit: 5536b836addb27dc6c8433b6afef2f9ad24d399d Parents: ffdc98d Author: Nick Couchman <vn...@apache.org> Authored: Sat Jun 2 12:00:22 2018 -0400 Committer: Nick Couchman <vn...@apache.org> Committed: Sun Nov 11 14:11:40 2018 -0500 ---------------------------------------------------------------------- src/protocols/ssh/settings.c | 18 ++++++++++++++++++ src/protocols/ssh/settings.h | 4 ++++ src/protocols/ssh/ssh.c | 4 ++++ 3 files changed, 26 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/5536b836/src/protocols/ssh/settings.c ---------------------------------------------------------------------- diff --git a/src/protocols/ssh/settings.c b/src/protocols/ssh/settings.c index 82f7eb2..820da51 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); http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/5536b836/src/protocols/ssh/settings.h ---------------------------------------------------------------------- diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h index 03abd91..e4d99e1 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; http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/5536b836/src/protocols/ssh/ssh.c ---------------------------------------------------------------------- diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index 80b84de..9e79454 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) {