GUACAMOLE-565: Add terminal-type parameter for SSH and Telnet.

Add a terminal-type parameter for SSH and Telnet connections, to specify
the terminal emulator type that is passed to programs. If not specified,
the default type of "linux" is used in keep with existing behavior.
This commit is contained in:
Jim Chen 2018-01-09 23:11:12 -05:00
parent b61a6ab758
commit 87df97317f
6 changed files with 43 additions and 2 deletions

View File

@ -57,6 +57,7 @@ const char* GUAC_SSH_CLIENT_ARGS[] = {
"read-only",
"server-alive-interval",
"backspace",
"terminal-type",
NULL
};
@ -217,6 +218,12 @@ enum SSH_ARGS_IDX {
*/
IDX_BACKSPACE,
/**
* The terminal emulator type that is passed to the remote system (e.g.
* "xterm" or "xterm-256color"). "linux" is used if unspecified.
*/
IDX_TERMINAL_TYPE,
SSH_ARGS_COUNT
};
@ -361,6 +368,11 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user,
guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv,
IDX_BACKSPACE, 127);
/* Read terminal emulator type. */
settings->terminal_type =
guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv,
IDX_TERMINAL_TYPE, "linux");
/* Parsing was successful */
return settings;
@ -396,6 +408,9 @@ void guac_ssh_settings_free(guac_ssh_settings* settings) {
free(settings->recording_name);
free(settings->recording_path);
/* Free terminal emulator type. */
free(settings->terminal_type);
/* Free overall structure */
free(settings);

View File

@ -228,6 +228,11 @@ typedef struct guac_ssh_settings {
*/
int backspace;
/**
* The terminal emulator type that is passed to the remote system.
*/
char* terminal_type;
} guac_ssh_settings;
/**

View File

@ -307,7 +307,8 @@ void* ssh_client_thread(void* data) {
" Backspace may not work as expected.");
/* Request PTY */
if (libssh2_channel_request_pty_ex(ssh_client->term_channel, "linux", sizeof("linux")-1,
if (libssh2_channel_request_pty_ex(ssh_client->term_channel,
settings->terminal_type, strlen(settings->terminal_type),
ssh_ttymodes, ttymodeBytes, ssh_client->term->term_width,
ssh_client->term->term_height, 0, 0)) {
guac_client_abort(client, GUAC_PROTOCOL_STATUS_UPSTREAM_ERROR, "Unable to allocate PTY.");

View File

@ -51,6 +51,7 @@ const char* GUAC_TELNET_CLIENT_ARGS[] = {
"create-recording-path",
"read-only",
"backspace",
"terminal-type",
NULL
};
@ -181,6 +182,12 @@ enum TELNET_ARGS_IDX {
*/
IDX_BACKSPACE,
/**
* The terminal emulator type that is passed to the remote system (e.g.
* "xterm" or "xterm-256color"). "linux" is used if unspecified.
*/
IDX_TERMINAL_TYPE,
TELNET_ARGS_COUNT
};
@ -340,6 +347,11 @@ guac_telnet_settings* guac_telnet_parse_args(guac_user* user,
guac_user_parse_args_int(user, GUAC_TELNET_CLIENT_ARGS, argv,
IDX_BACKSPACE, 127);
/* Read terminal emulator type. */
settings->terminal_type =
guac_user_parse_args_string(user, GUAC_TELNET_CLIENT_ARGS, argv,
IDX_TERMINAL_TYPE, "linux");
/* Parsing was successful */
return settings;
@ -379,6 +391,9 @@ void guac_telnet_settings_free(guac_telnet_settings* settings) {
free(settings->recording_name);
free(settings->recording_path);
/* Free terminal emulator type. */
free(settings->terminal_type);
/* Free overall structure */
free(settings);

View File

@ -214,6 +214,11 @@ typedef struct guac_telnet_settings {
*/
int backspace;
/**
* The terminal emulator type that is passed to the remote system.
*/
char* terminal_type;
} guac_telnet_settings;
/**

View File

@ -216,7 +216,7 @@ static void __guac_telnet_event_handler(telnet_t* telnet, telnet_event_t* event,
/* Terminal type request */
case TELNET_EV_TTYPE:
if (event->ttype.cmd == TELNET_TTYPE_SEND)
telnet_ttype_is(telnet_client->telnet, "linux");
telnet_ttype_is(telnet_client->telnet, settings->terminal_type);
break;
/* Environment request */