diff --git a/src/protocols/ssh/settings.c b/src/protocols/ssh/settings.c index e0be6cf3..82f7eb20 100644 --- a/src/protocols/ssh/settings.c +++ b/src/protocols/ssh/settings.c @@ -60,6 +60,7 @@ const char* GUAC_SSH_CLIENT_ARGS[] = { "backspace", "terminal-type", "scrollback", + "locale", NULL }; @@ -238,6 +239,14 @@ enum SSH_ARGS_IDX { */ IDX_SCROLLBACK, + /** + * The locale that should be forwarded to the remote system via the LANG + * environment variable. By default, no locale is forwarded. This setting + * will only have an effect if the SSH server allows the LANG environment + * variable to be set. + */ + IDX_LOCALE, + SSH_ARGS_COUNT }; @@ -396,6 +405,11 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user, guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv, IDX_TERMINAL_TYPE, "linux"); + /* Read locale */ + settings->locale = + guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv, + IDX_LOCALE, NULL); + /* Parsing was successful */ return settings; @@ -435,6 +449,9 @@ void guac_ssh_settings_free(guac_ssh_settings* settings) { /* Free terminal emulator type. */ free(settings->terminal_type); + /* Free locale */ + free(settings->locale); + /* Free overall structure */ free(settings); diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h index 81dcd699..03abd91d 100644 --- a/src/protocols/ssh/settings.h +++ b/src/protocols/ssh/settings.h @@ -248,6 +248,12 @@ typedef struct guac_ssh_settings { */ char* terminal_type; + /** + * The locale that should be forwarded to the remote system via the LANG + * environment variable. + */ + char* locale; + } guac_ssh_settings; /** diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index cddb2fed..80b84de1 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -320,6 +320,16 @@ void* ssh_client_thread(void* data) { return NULL; } + /* Forward specified locale */ + if (settings->locale != NULL) { + if (libssh2_channel_setenv(ssh_client->term_channel, "LANG", + settings->locale)) { + guac_client_log(client, GUAC_LOG_WARNING, + "Unable to forward locale: SSH server refused to set " + "\"LANG\" environment variable."); + } + } + /* If a command is specified, run that instead of a shell */ if (settings->command != NULL) { if (libssh2_channel_exec(ssh_client->term_channel, settings->command)) {