GUACAMOLE-565: Merge add terminal-type parameter for SSH and telnet.

This commit is contained in:
Nick Couchman 2018-05-27 07:18:46 -04:00
commit 4eae5d2e6d
6 changed files with 43 additions and 2 deletions

View File

@ -57,6 +57,7 @@ const char* GUAC_SSH_CLIENT_ARGS[] = {
"read-only", "read-only",
"server-alive-interval", "server-alive-interval",
"backspace", "backspace",
"terminal-type",
NULL NULL
}; };
@ -217,6 +218,12 @@ enum SSH_ARGS_IDX {
*/ */
IDX_BACKSPACE, 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 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, guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv,
IDX_BACKSPACE, 127); 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 */ /* Parsing was successful */
return settings; return settings;
@ -396,6 +408,9 @@ void guac_ssh_settings_free(guac_ssh_settings* settings) {
free(settings->recording_name); free(settings->recording_name);
free(settings->recording_path); free(settings->recording_path);
/* Free terminal emulator type. */
free(settings->terminal_type);
/* Free overall structure */ /* Free overall structure */
free(settings); free(settings);

View File

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

View File

@ -307,7 +307,8 @@ void* ssh_client_thread(void* data) {
" Backspace may not work as expected."); " Backspace may not work as expected.");
/* Request PTY */ /* 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_ttymodes, ttymodeBytes, ssh_client->term->term_width,
ssh_client->term->term_height, 0, 0)) { ssh_client->term->term_height, 0, 0)) {
guac_client_abort(client, GUAC_PROTOCOL_STATUS_UPSTREAM_ERROR, "Unable to allocate PTY."); 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", "create-recording-path",
"read-only", "read-only",
"backspace", "backspace",
"terminal-type",
NULL NULL
}; };
@ -181,6 +182,12 @@ enum TELNET_ARGS_IDX {
*/ */
IDX_BACKSPACE, 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 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, guac_user_parse_args_int(user, GUAC_TELNET_CLIENT_ARGS, argv,
IDX_BACKSPACE, 127); 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 */ /* Parsing was successful */
return settings; return settings;
@ -379,6 +391,9 @@ void guac_telnet_settings_free(guac_telnet_settings* settings) {
free(settings->recording_name); free(settings->recording_name);
free(settings->recording_path); free(settings->recording_path);
/* Free terminal emulator type. */
free(settings->terminal_type);
/* Free overall structure */ /* Free overall structure */
free(settings); free(settings);

View File

@ -214,6 +214,11 @@ typedef struct guac_telnet_settings {
*/ */
int backspace; int backspace;
/**
* The terminal emulator type that is passed to the remote system.
*/
char* terminal_type;
} guac_telnet_settings; } 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 */ /* Terminal type request */
case TELNET_EV_TTYPE: case TELNET_EV_TTYPE:
if (event->ttype.cmd == TELNET_TTYPE_SEND) if (event->ttype.cmd == TELNET_TTYPE_SEND)
telnet_ttype_is(telnet_client->telnet, "linux"); telnet_ttype_is(telnet_client->telnet, settings->terminal_type);
break; break;
/* Environment request */ /* Environment request */