GUACAMOLE-422: Merge support for specifying the timezone of RDP and SSH sessions.

This commit is contained in:
Michael Jumper 2018-11-12 09:12:19 -08:00
commit 0d435e2435
6 changed files with 73 additions and 3 deletions

View File

@ -719,7 +719,7 @@ static int guac_rdp_handle_connection(guac_client* client) {
guac_common_cursor_set_pointer(rdp_client->display->cursor);
/* Push desired settings to FreeRDP */
guac_rdp_push_settings(settings, rdp_inst);
guac_rdp_push_settings(client, settings, rdp_inst);
/* Connect to RDP server */
if (!freerdp_connect(rdp_inst)) {

View File

@ -35,6 +35,7 @@
#include "compat/winpr-wtypes.h"
#endif
#include <errno.h>
#include <stddef.h>
#include <string.h>
@ -79,6 +80,7 @@ const char* GUAC_RDP_CLIENT_ARGS[] = {
"disable-glyph-caching",
"preconnection-id",
"preconnection-blob",
"timezone",
#ifdef ENABLE_COMMON_SSH
"enable-sftp",
@ -356,6 +358,14 @@ enum RDP_ARGS_IDX {
*/
IDX_PRECONNECTION_BLOB,
/**
* The timezone to pass through to the RDP connection, in IANA format, which
* will be translated into Windows formats. See the following page for
* information and list of valid values:
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
*/
IDX_TIMEZONE,
#ifdef ENABLE_COMMON_SSH
/**
* "true" if SFTP should be enabled for the RDP connection, "false" or
@ -840,6 +850,11 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user,
if (settings->server_layout == NULL)
settings->server_layout = guac_rdp_keymap_find(GUAC_DEFAULT_KEYMAP);
/* Timezone if provied by client */
settings->timezone =
guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv,
IDX_TIMEZONE, NULL);
#ifdef ENABLE_COMMON_SSH
/* SFTP enable/disable */
settings->enable_sftp =
@ -1013,6 +1028,7 @@ void guac_rdp_settings_free(guac_rdp_settings* settings) {
free(settings->remote_app);
free(settings->remote_app_args);
free(settings->remote_app_dir);
free(settings->timezone);
free(settings->username);
free(settings->printer_name);
@ -1153,7 +1169,8 @@ static char* guac_rdp_strdup(const char* str) {
}
void guac_rdp_push_settings(guac_rdp_settings* guac_settings, freerdp* rdp) {
void guac_rdp_push_settings(guac_client* client,
guac_rdp_settings* guac_settings, freerdp* rdp) {
BOOL bitmap_cache = !guac_settings->disable_bitmap_caching;
rdpSettings* rdp_settings = rdp->settings;
@ -1264,6 +1281,15 @@ void guac_rdp_push_settings(guac_rdp_settings* guac_settings, freerdp* rdp) {
#endif
#endif
/* Timezone redirection */
if (guac_settings->timezone) {
if (setenv("TZ", guac_settings->timezone, 1)) {
guac_client_log(client, GUAC_LOG_WARNING,
"Unable to forward timezone: TZ environment variable "
"could not be set: %s", strerror(errno));
}
}
/* Device redirection */
#ifdef LEGACY_RDPSETTINGS
#ifdef HAVE_RDPSETTINGS_DEVICEREDIRECTION

View File

@ -341,6 +341,11 @@ typedef struct guac_rdp_settings {
*/
char* preconnection_blob;
/**
* The timezone to pass through to the RDP connection.
*/
char* timezone;
#ifdef ENABLE_COMMON_SSH
/**
* Whether SFTP should be enabled for the VNC connection.
@ -547,13 +552,17 @@ extern const char* GUAC_RDP_CLIENT_ARGS[];
/**
* Save all given settings to the given freerdp instance.
*
* @param client
* The guac_client object providing the settings.
*
* @param guac_settings
* The guac_rdp_settings object to save.
*
* @param rdp
* The RDP instance to save settings to.
*/
void guac_rdp_push_settings(guac_rdp_settings* guac_settings, freerdp* rdp);
void guac_rdp_push_settings(guac_client* client,
guac_rdp_settings* guac_settings, freerdp* rdp);
/**
* Returns the width of the RDP session display.

View File

@ -61,6 +61,7 @@ const char* GUAC_SSH_CLIENT_ARGS[] = {
"terminal-type",
"scrollback",
"locale",
"timezone",
NULL
};
@ -246,6 +247,16 @@ enum SSH_ARGS_IDX {
* variable to be set.
*/
IDX_LOCALE,
/**
* The timezone that is to be passed to the remote system, via the
* TZ environment variable. By default, no timezone is forwarded
* and the timezone of the remote system will be used. This
* setting will only work if the SSH server allows the TZ variable
* to be set. Timezones should be in standard IANA format, see:
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
*/
IDX_TIMEZONE,
SSH_ARGS_COUNT
};
@ -410,6 +421,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 +468,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);

View File

@ -254,6 +254,11 @@ typedef struct guac_ssh_settings {
*/
char* locale;
/**
* The client timezone to pass to the remote system.
*/
char* timezone;
} guac_ssh_settings;
/**

View File

@ -256,6 +256,17 @@ void* ssh_client_thread(void* data) {
return NULL;
}
/* Set the client timezone */
if (settings->timezone != NULL) {
if (libssh2_channel_setenv(ssh_client->term_channel, "TZ",
settings->timezone)) {
guac_client_log(client, GUAC_LOG_WARNING,
"Unable to set the timezone: SSH server "
"refused to set \"TZ\" variable.");
}
}
#ifdef ENABLE_SSH_AGENT
/* Start SSH agent forwarding, if enabled */
if (ssh_client->enable_agent) {