GUACAMOLE-381: Disable outbound transfers from terminal protocols if "disable-copy" is set.

This commit is contained in:
Michael Jumper 2019-02-19 12:11:14 -08:00
parent 254615509a
commit 228cea4af1
6 changed files with 29 additions and 11 deletions

View File

@ -237,7 +237,7 @@ void* guac_kubernetes_client_thread(void* data) {
/* Create terminal */
kubernetes_client->term = guac_terminal_create(client,
kubernetes_client->clipboard,
kubernetes_client->clipboard, settings->disable_copy,
settings->max_scrollback, settings->font_name, settings->font_size,
settings->resolution, settings->width, settings->height,
settings->color_scheme, settings->backspace);

View File

@ -207,9 +207,10 @@ void* ssh_client_thread(void* data) {
/* Create terminal */
ssh_client->term = guac_terminal_create(client, ssh_client->clipboard,
settings->max_scrollback, settings->font_name, settings->font_size,
settings->resolution, settings->width, settings->height,
settings->color_scheme, settings->backspace);
settings->disable_copy, settings->max_scrollback,
settings->font_name, settings->font_size, settings->resolution,
settings->width, settings->height, settings->color_scheme,
settings->backspace);
/* Fail if terminal init failed */
if (ssh_client->term == NULL) {

View File

@ -568,7 +568,7 @@ void* guac_telnet_client_thread(void* data) {
/* Create terminal */
telnet_client->term = guac_terminal_create(client,
telnet_client->clipboard,
telnet_client->clipboard, settings->disable_copy,
settings->max_scrollback, settings->font_name, settings->font_size,
settings->resolution, settings->width, settings->height,
settings->color_scheme, settings->backspace);

View File

@ -375,8 +375,10 @@ void guac_terminal_select_end(guac_terminal* terminal) {
}
/* Send data */
guac_common_clipboard_send(terminal->clipboard, client);
guac_socket_flush(socket);
if (!terminal->disable_copy) {
guac_common_clipboard_send(terminal->clipboard, client);
guac_socket_flush(socket);
}
guac_terminal_notify(terminal);

View File

@ -306,8 +306,8 @@ void* guac_terminal_thread(void* data) {
}
guac_terminal* guac_terminal_create(guac_client* client,
guac_common_clipboard* clipboard, int max_scrollback,
const char* font_name, int font_size, int dpi,
guac_common_clipboard* clipboard, bool disable_copy,
int max_scrollback, const char* font_name, int font_size, int dpi,
int width, int height, const char* color_scheme,
const int backspace) {
@ -404,6 +404,7 @@ guac_terminal* guac_terminal_create(guac_client* client,
term->current_attributes = default_char.attributes;
term->default_char = default_char;
term->clipboard = clipboard;
term->disable_copy = disable_copy;
/* Calculate character size */
int rows = height / term->display->char_height;

View File

@ -511,6 +511,14 @@ struct guac_terminal {
*/
char backspace;
/**
* Whether copying from the terminal clipboard should be blocked. If set,
* the contents of the terminal can still be copied, but will be usable
* only within the terminal itself. The clipboard contents will not be
* automatically streamed to the client.
*/
bool disable_copy;
};
/**
@ -533,6 +541,12 @@ struct guac_terminal {
* clipboard instructions. This clipboard will not be automatically
* freed when this terminal is freed.
*
* @param disable_copy
* Whether copying from the terminal clipboard should be blocked. If set,
* the contents of the terminal can still be copied, but will be usable
* only within the terminal itself. The clipboard contents will not be
* automatically streamed to the client.
*
* @param max_scrollback
* The maximum number of rows to allow within the scrollback buffer. The
* user may still alter the size of the scrollback buffer using terminal
@ -575,8 +589,8 @@ struct guac_terminal {
* which renders all text to the given client.
*/
guac_terminal* guac_terminal_create(guac_client* client,
guac_common_clipboard* clipboard, int max_scrollback,
const char* font_name, int font_size, int dpi,
guac_common_clipboard* clipboard, bool disable_copy,
int max_scrollback, const char* font_name, int font_size, int dpi,
int width, int height, const char* color_scheme,
const int backspace);