Skip to content

Commit

Permalink
GUACAMOLE-422: Add support for passing through TZ in SSH.
Browse files Browse the repository at this point in the history
  • Loading branch information
necouchman committed Nov 11, 2018
1 parent ffdc98d commit 5536b83
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/protocols/ssh/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const char* GUAC_SSH_CLIENT_ARGS[] = {
"terminal-type",
"scrollback",
"locale",
"timezone",
NULL
};

Expand Down Expand Up @@ -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
};
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions src/protocols/ssh/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions src/protocols/ssh/ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5536b83

Please sign in to comment.