|
35 | 35 | #include "compat/winpr-wtypes.h" |
36 | 36 | #endif |
37 | 37 |
|
| 38 | +#include <errno.h> |
38 | 39 | #include <stddef.h> |
39 | 40 | #include <string.h> |
40 | 41 |
|
@@ -79,6 +80,7 @@ const char* GUAC_RDP_CLIENT_ARGS[] = { |
79 | 80 | "disable-glyph-caching", |
80 | 81 | "preconnection-id", |
81 | 82 | "preconnection-blob", |
| 83 | + "timezone", |
82 | 84 |
|
83 | 85 | #ifdef ENABLE_COMMON_SSH |
84 | 86 | "enable-sftp", |
@@ -356,6 +358,14 @@ enum RDP_ARGS_IDX { |
356 | 358 | */ |
357 | 359 | IDX_PRECONNECTION_BLOB, |
358 | 360 |
|
| 361 | + /** |
| 362 | + * The timezone to pass through to the RDP connection, in IANA format, which |
| 363 | + * will be translated into Windows formats. See the following page for |
| 364 | + * information and list of valid values: |
| 365 | + * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones |
| 366 | + */ |
| 367 | + IDX_TIMEZONE, |
| 368 | + |
359 | 369 | #ifdef ENABLE_COMMON_SSH |
360 | 370 | /** |
361 | 371 | * "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, |
840 | 850 | if (settings->server_layout == NULL) |
841 | 851 | settings->server_layout = guac_rdp_keymap_find(GUAC_DEFAULT_KEYMAP); |
842 | 852 |
|
| 853 | + /* Timezone if provied by client */ |
| 854 | + settings->timezone = |
| 855 | + guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv, |
| 856 | + IDX_TIMEZONE, NULL); |
| 857 | + |
843 | 858 | #ifdef ENABLE_COMMON_SSH |
844 | 859 | /* SFTP enable/disable */ |
845 | 860 | settings->enable_sftp = |
@@ -1013,6 +1028,7 @@ void guac_rdp_settings_free(guac_rdp_settings* settings) { |
1013 | 1028 | free(settings->remote_app); |
1014 | 1029 | free(settings->remote_app_args); |
1015 | 1030 | free(settings->remote_app_dir); |
| 1031 | + free(settings->timezone); |
1016 | 1032 | free(settings->username); |
1017 | 1033 | free(settings->printer_name); |
1018 | 1034 |
|
@@ -1153,7 +1169,8 @@ static char* guac_rdp_strdup(const char* str) { |
1153 | 1169 |
|
1154 | 1170 | } |
1155 | 1171 |
|
1156 | | -void guac_rdp_push_settings(guac_rdp_settings* guac_settings, freerdp* rdp) { |
| 1172 | +void guac_rdp_push_settings(guac_client* client, |
| 1173 | + guac_rdp_settings* guac_settings, freerdp* rdp) { |
1157 | 1174 |
|
1158 | 1175 | BOOL bitmap_cache = !guac_settings->disable_bitmap_caching; |
1159 | 1176 | rdpSettings* rdp_settings = rdp->settings; |
@@ -1264,6 +1281,15 @@ void guac_rdp_push_settings(guac_rdp_settings* guac_settings, freerdp* rdp) { |
1264 | 1281 | #endif |
1265 | 1282 | #endif |
1266 | 1283 |
|
| 1284 | + /* Timezone redirection */ |
| 1285 | + if (guac_settings->timezone) { |
| 1286 | + if (setenv("TZ", guac_settings->timezone, 1)) { |
| 1287 | + guac_client_log(client, GUAC_LOG_WARNING, |
| 1288 | + "Unable to forward timezone: TZ environment variable " |
| 1289 | + "could not be set: %s", strerror(errno)); |
| 1290 | + } |
| 1291 | + } |
| 1292 | + |
1267 | 1293 | /* Device redirection */ |
1268 | 1294 | #ifdef LEGACY_RDPSETTINGS |
1269 | 1295 | #ifdef HAVE_RDPSETTINGS_DEVICEREDIRECTION |
|
0 commit comments