Compare commits

...

45 Commits
patch ... main

Author SHA1 Message Date
Lierfang Support Team
a5df55fe01 Add debian pkg 2025-07-09 15:10:28 +08:00
Virtually Nick
f3f5b9d766 Merge patch branch changes to main. 2025-06-19 16:54:30 -04:00
Virtually Nick
0ab6f664b9 Merge patch branch changes to main. 2025-06-16 15:07:26 -04:00
Corentin SORIANO
519e42f0b5
Merge changes from patch branch back to main. 2025-06-08 09:15:22 +02:00
Michael Jumper
ac46031ee5
Merge changes from patch branch back to main. 2025-06-05 14:31:33 -07:00
Virtually Nick
cb0aac72dd Merge patch branch changes to main. 2025-06-03 16:07:52 -04:00
Corentin SORIANO
d80112c993
Merge changes from patch branch back to main. 2025-06-02 09:34:50 +02:00
Virtually Nick
558c42e4b4 Merge patch branch changes to main. 2025-05-30 08:57:27 -04:00
Corentin SORIANO
07820faa9d
Merge changes from patch branch back to main. 2025-05-29 14:53:01 +02:00
Virtually Nick
5aa8143d69 Merge patch branch changes to main. 2025-05-28 15:15:40 -04:00
Corentin SORIANO
fc5073fb69
Merge changes from patch branch back to main. 2025-05-28 08:25:09 +02:00
Michael Jumper
cdbd0ab699
Merge changes from patch branch back to main. 2025-05-23 14:51:06 -07:00
Virtually Nick
e8ad0b958c
GUACAMOLE-2002: Merge improve warnings about a wrong clipboard buffer size. 2025-05-12 10:37:53 -05:00
eugen-keeper
e9cc550012 GUACAMOLE-2002: Improve warnings about a wrong clipboard buffer size. 2025-05-12 14:46:45 +00:00
Virtually Nick
b52692933f Merge patch branch changes to main. 2025-05-06 19:07:10 -04:00
Virtually Nick
f48c4fba38 Merge patch branch changes to main. 2025-05-02 17:45:32 -04:00
Virtually Nick
4d625e57e8 Merge patch branch changes to main. 2025-05-02 12:57:54 -04:00
Michael Jumper
18b4861be7
Merge changes from patch branch back to main. 2025-05-01 23:58:20 -07:00
Virtually Nick
a585c740aa Merge patch branch changes to main. 2025-05-01 21:48:05 -04:00
Corentin SORIANO
e6a34e2fd6
Merge changes from patch branch back to main. 2025-05-01 09:43:21 +02:00
Virtually Nick
2f09f6d5bb Merge patch branch changes to main. 2025-04-22 15:34:59 -04:00
Virtually Nick
487a7849ca Merge patch branch changes to main. 2025-04-21 12:00:11 -04:00
Virtually Nick
d79f201f25 Merge patch branch changes to main. 2025-03-24 16:51:57 -04:00
Mike Jumper
483a086370
GUACAMOLE-2002: Merge support for configuring clipboard size limits. 2025-03-07 15:06:14 -08:00
eugen-keeper
44c1bd24b7 GUACAMOLE-2002: Allow connection clipboard limits to be configured. 2025-01-23 20:01:11 +00:00
Michael Jumper
32dbdfae14
Merge changes from patch branch back to main. 2025-01-11 01:44:48 -08:00
Michael Jumper
15d5a276fb
Merge changes from patch branch back to main. 2024-12-22 14:51:06 -08:00
Michael Jumper
8e75eea9ce Merge changes from patch branch back to main. 2024-11-09 01:01:23 -08:00
Virtually Nick
02c4578603 Merge patch branch changes to main. 2024-10-23 13:35:52 -04:00
Michael Jumper
783f4c5e34 Merge changes from patch branch back to main. 2024-10-02 00:02:49 -07:00
Michael Jumper
1c1bcc87c8 Merge changes from patch branch back to main. 2024-09-30 10:10:57 -07:00
James Muehlner
844179e838 Merge patch branch changes to main. 2024-09-29 21:40:13 +00:00
James Muehlner
04e90157c0 Merge patch branch changes to main. 2024-09-29 19:14:13 +00:00
Virtually Nick
bdb2aec49b Merge patch branch changes to main. 2024-09-12 14:38:01 -04:00
Virtually Nick
1cbc4d492c Merge patch branch changes to main. 2024-09-11 06:53:41 -04:00
Virtually Nick
09c2d4e360 Merge patch branch changes to main. 2024-09-10 08:24:38 -04:00
Virtually Nick
98f3c8b746 Merge patch branch changes to main. 2024-09-05 19:13:15 -04:00
Michael Jumper
13868fac10 Merge changes from patch branch back to main. 2024-08-30 10:51:32 -07:00
Michael Jumper
a95e66cd91 Merge changes from patch branch back to main. 2024-08-28 14:37:41 -07:00
Michael Jumper
3258efe2be Merge changes from patch branch back to main. 2024-08-27 23:45:41 -07:00
James Muehlner
1a22276d47
GUACAMOLE-663: Merge set pthread stack size for guacd. 2024-08-27 16:01:58 -07:00
Virtually Nick
9709f2c562 GUACAMOLE-663: Set pthread stack size for guacd 2024-08-27 18:55:12 -04:00
Michael Jumper
c18cda2e30 Merge changes from patch branch back to main. 2024-08-20 01:16:54 -07:00
Michael Jumper
c00cb51be9 Merge changes from patch branch back to main. 2024-08-19 00:57:45 -07:00
Michael Jumper
ac8191d79c Merge changes from patch branch back to main. 2024-08-06 16:35:28 -07:00
31 changed files with 351 additions and 41 deletions

View File

@ -47,6 +47,7 @@ AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/socket.h time.h sys/time.h syslo
AC_DEFINE([_GNU_SOURCE], [1], [Uses GNU-specific APIs (if available)])
AC_DEFINE([_XOPEN_SOURCE], [700], [Uses X/Open and POSIX APIs])
AC_DEFINE([__BSD_VISIBLE], [1], [Uses BSD-specific APIs (if available)])
AC_DEFINE([_GNU_SOURCE], [1], [Use GNU sources (if available)])
# Check for availability of non-portable sched_getaffinity() function (one of
# several possible routes for determining the number of available processors)
@ -76,6 +77,9 @@ AC_CHECK_LIB([pthread], [pthread_create], [PTHREAD_LIBS=-lpthread
AC_DEFINE([HAVE_LIBPTHREAD],,
[Whether libpthread was found])])
# Check for pthread_setattr_default_np
AC_CHECK_DECLS([pthread_setattr_default_np], , , [[#include <pthread.h>]])
# librt
AC_CHECK_FUNC([timer_create], [AC_MSG_RESULT([timer_create was found without librt.])],
[AC_CHECK_LIB([rt], [timer_create],

5
debian/changelog vendored Normal file
View File

@ -0,0 +1,5 @@
pxvdi-guacamole (1.6.0) unstable; urgency=medium
* Initial release.
-- Lierfang Support Team <itsupport@lierfang.com> Wed, 09 Jul 2025 10:00:00 +0000

30
debian/control vendored Normal file
View File

@ -0,0 +1,30 @@
Source: pxvdi-guacamole
Section: net
Priority: optional
Maintainer: Lierfang Support Team <itsupport@lierfang.com>
Build-Depends: debhelper-compat (= 13),
libssl-dev,
libvorbis-dev,
libwebp-dev,
libpulse-dev,
libwebsockets-dev,
libvncserver-dev,
libtelnet-dev,
libssh2-1-dev,
libpango1.0-dev,
freerdp2-dev,
libssh-dev,
uuid-dev,
libtool-bin,
libpng-dev,
libjpeg62-turbo-dev,
libcairo2-dev,
libuuid1,
libtool
Standards-Version: 4.1.4
Package: pxvdi-guacamole
Section: net
Priority: optional
Architecture: any
Description: PXVDI Guacamole

22
debian/rules vendored Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
%:
dh $@
override_dh_auto_configure:
dh_auto_configure -- --with-systemd-dir=/lib/systemd/system --disable-static
override_dh_install:
find debian -name "*.la" -delete
dh_install

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
3.0 (native)

View File

@ -30,14 +30,14 @@
#include <string.h>
#include <stdlib.h>
guac_common_clipboard* guac_common_clipboard_alloc() {
guac_common_clipboard* guac_common_clipboard_alloc(int buffer_size) {
guac_common_clipboard* clipboard = guac_mem_alloc(sizeof(guac_common_clipboard));
/* Init clipboard */
clipboard->mimetype[0] = '\0';
clipboard->buffer = guac_mem_alloc(GUAC_COMMON_CLIPBOARD_MAX_LENGTH);
clipboard->available = GUAC_COMMON_CLIPBOARD_MAX_LENGTH;
clipboard->buffer = guac_mem_alloc(buffer_size);
clipboard->available = buffer_size;
clipboard->length = 0;
pthread_mutex_init(&(clipboard->lock), NULL);

View File

@ -32,9 +32,16 @@
#define GUAC_COMMON_CLIPBOARD_BLOCK_SIZE 4096
/**
* The maximum number of bytes to allow within the clipboard.
* The minimum clipboard buffer size in bytes.
* This is the original hardcoded clipboard buffer size.
*/
#define GUAC_COMMON_CLIPBOARD_MAX_LENGTH 262144
#define GUAC_COMMON_CLIPBOARD_MIN_LENGTH 262144
/**
* The maximum clipboard buffer size in bytes.
* This should be enough for a raw 4K picture and even more.
*/
#define GUAC_COMMON_CLIPBOARD_MAX_LENGTH 52428800
/**
* Generic clipboard structure.
@ -72,13 +79,17 @@ typedef struct guac_common_clipboard {
/**
* Creates a new clipboard.
*
* @param buffer_size
* The buffer size in bytes.
*/
guac_common_clipboard* guac_common_clipboard_alloc();
guac_common_clipboard* guac_common_clipboard_alloc(int buffer_size);
/**
* Frees the given clipboard.
*
* @param clipboard The clipboard to free.
* @param clipboard
* The clipboard to free.
*/
void guac_common_clipboard_free(guac_common_clipboard* clipboard);
@ -86,16 +97,22 @@ void guac_common_clipboard_free(guac_common_clipboard* clipboard);
* Sends the contents of the clipboard along the given client, splitting
* the contents as necessary.
*
* @param clipboard The clipboard whose contents should be sent.
* @param client The client to send the clipboard contents on.
* @param clipboard
* The clipboard whose contents should be sent.
*
* @param client
* The client to send the clipboard contents on.
*/
void guac_common_clipboard_send(guac_common_clipboard* clipboard, guac_client* client);
/**
* Clears the clipboard contents and assigns a new mimetype for future data.
*
* @param clipboard The clipboard to reset.
* @param mimetype The mimetype of future data.
* @param clipboard
* The clipboard to reset.
*
* @param mimetype
* The mimetype of future data.
*/
void guac_common_clipboard_reset(guac_common_clipboard* clipboard, const char* mimetype);
@ -104,9 +121,14 @@ void guac_common_clipboard_reset(guac_common_clipboard* clipboard, const char* m
* match the mimetype chosen for the clipboard data by
* guac_common_clipboard_reset().
*
* @param clipboard The clipboard to append data to.
* @param data The data to append.
* @param length The number of bytes to append from the data given.
* @param clipboard
* The clipboard to append data to.
*
* @param data
* The data to append.
*
* @param length
* The number of bytes to append from the data given.
*/
void guac_common_clipboard_append(guac_common_clipboard* clipboard, const char* data, int length);

View File

@ -37,6 +37,7 @@
#include <libgen.h>
#include <netdb.h>
#include <netinet/in.h>
#include <pthread.h>
#include <netinet/tcp.h>
#include <signal.h>
#include <stdio.h>
@ -321,6 +322,14 @@ int main(int argc, char* argv[]) {
/* General */
int retval;
#ifdef HAVE_DECL_PTHREAD_SETATTR_DEFAULT_NP
/* Set default stack size */
pthread_attr_t default_pthread_attr;
pthread_attr_init(&default_pthread_attr);
pthread_attr_setstacksize(&default_pthread_attr, GUACD_THREAD_STACK_SIZE);
pthread_setattr_default_np(&default_pthread_attr);
#endif // HAVE_DECL_PTHREAD_SETATTR_DEFAULT_NP
/* Load configuration */
guacd_config* config = guacd_conf_load();
if (config == NULL || guacd_conf_parse_args(config, argc, argv))

View File

@ -32,6 +32,11 @@
*/
#define GUACD_CLIENT_MAX_CONNECTIONS 65536
/**
* The pthread stack size for the guacd daemon.
*/
#define GUACD_THREAD_STACK_SIZE 8388608
/**
* The number of hash buckets in each process map.
*/

View File

@ -246,6 +246,7 @@ void* guac_kubernetes_client_thread(void* data) {
settings->width, settings->height, settings->resolution);
/* Set optional parameters */
options->clipboard_buffer_size = settings->clipboard_buffer_size;
options->disable_copy = settings->disable_copy;
options->max_scrollback = settings->max_scrollback;
options->font_name = settings->font_name;

View File

@ -56,6 +56,7 @@ const char* GUAC_KUBERNETES_CLIENT_ARGS[] = {
"read-only",
"backspace",
"scrollback",
"clipboard-buffer-size",
"disable-copy",
"disable-paste",
NULL
@ -241,6 +242,11 @@ enum KUBERNETES_ARGS_IDX {
*/
IDX_SCROLLBACK,
/**
* The maximum number of bytes to allow within the clipboard.
*/
IDX_CLIPBOARD_BUFFER_SIZE,
/**
* Whether outbound clipboard access should be blocked. If set to "true",
* it will not be possible to copy data from the terminal to the client
@ -418,6 +424,27 @@ guac_kubernetes_settings* guac_kubernetes_parse_args(guac_user* user,
guac_user_parse_args_int(user, GUAC_KUBERNETES_CLIENT_ARGS, argv,
IDX_BACKSPACE, GUAC_TERMINAL_DEFAULT_BACKSPACE);
/* Set the maximum number of bytes to allow within the clipboard. */
settings->clipboard_buffer_size =
guac_user_parse_args_int(user, GUAC_KUBERNETES_CLIENT_ARGS, argv,
IDX_CLIPBOARD_BUFFER_SIZE, 0);
/* Use default clipboard buffer size if given one is invalid. */
if (settings->clipboard_buffer_size < GUAC_COMMON_CLIPBOARD_MIN_LENGTH) {
settings->clipboard_buffer_size = GUAC_COMMON_CLIPBOARD_MIN_LENGTH;
guac_user_log(user, GUAC_LOG_INFO, "Unspecified or invalid clipboard buffer "
"size: \"%s\". Using the default minimum size: %i.",
argv[IDX_CLIPBOARD_BUFFER_SIZE],
settings->clipboard_buffer_size);
}
else if (settings->clipboard_buffer_size > GUAC_COMMON_CLIPBOARD_MAX_LENGTH) {
settings->clipboard_buffer_size = GUAC_COMMON_CLIPBOARD_MAX_LENGTH;
guac_user_log(user, GUAC_LOG_WARNING, "Invalid clipboard buffer "
"size: \"%s\". Using the default maximum size: %i.",
argv[IDX_CLIPBOARD_BUFFER_SIZE],
settings->clipboard_buffer_size);
}
/* Parse clipboard copy disable flag */
settings->disable_copy =
guac_user_parse_args_boolean(user, GUAC_KUBERNETES_CLIENT_ARGS, argv,

View File

@ -160,6 +160,11 @@ typedef struct guac_kubernetes_settings {
*/
int resolution;
/**
* The maximum number of bytes to allow within the clipboard.
*/
int clipboard_buffer_size;
/**
* Whether outbound clipboard access should be blocked. If set, it will not
* be possible to copy data from the terminal to the client using the

View File

@ -371,7 +371,9 @@ static UINT guac_rdp_cliprdr_format_data_request(CliprdrClientContext* cliprdr,
guac_iconv_write* remote_writer;
const char* input = clipboard->clipboard->buffer;
char* output = guac_mem_alloc(GUAC_COMMON_CLIPBOARD_MAX_LENGTH);
int output_buf_size = clipboard->clipboard->available;
char* output = guac_mem_alloc(output_buf_size);
/* Map requested clipboard format to a guac_iconv writer */
switch (format_data_request->requestedFormatId) {
@ -402,7 +404,7 @@ static UINT guac_rdp_cliprdr_format_data_request(CliprdrClientContext* cliprdr,
BYTE* start = (BYTE*) output;
guac_iconv_read* local_reader = settings->normalize_clipboard ? GUAC_READ_UTF8_NORMALIZED : GUAC_READ_UTF8;
guac_iconv(local_reader, &input, clipboard->clipboard->length,
remote_writer, &output, GUAC_COMMON_CLIPBOARD_MAX_LENGTH);
remote_writer, &output, output_buf_size);
CLIPRDR_FORMAT_DATA_RESPONSE data_response = {
.requestedFormatData = (BYTE*) start,
@ -470,7 +472,8 @@ static UINT guac_rdp_cliprdr_format_data_response(CliprdrClientContext* cliprdr,
return CHANNEL_RC_OK;
}
char received_data[GUAC_COMMON_CLIPBOARD_MAX_LENGTH];
int output_buf_size = clipboard->clipboard->available;
char* received_data = guac_mem_alloc(output_buf_size);
guac_iconv_read* remote_reader;
const char* input = (char*) format_data_response->requestedFormatData;
@ -498,6 +501,7 @@ static UINT guac_rdp_cliprdr_format_data_response(CliprdrClientContext* cliprdr,
default:
guac_client_log(client, GUAC_LOG_DEBUG, "Requested clipboard data "
"in unsupported format (0x%X).", clipboard->requested_format);
guac_mem_free(received_data);
return CHANNEL_RC_OK;
}
@ -512,13 +516,15 @@ static UINT guac_rdp_cliprdr_format_data_response(CliprdrClientContext* cliprdr,
/* Convert, store, and forward the clipboard data received from RDP
* server */
if (guac_iconv(remote_reader, &input, data_len,
GUAC_WRITE_UTF8, &output, sizeof(received_data))) {
int length = strnlen(received_data, sizeof(received_data));
GUAC_WRITE_UTF8, &output, output_buf_size)) {
int length = strnlen(received_data, output_buf_size);
guac_common_clipboard_reset(clipboard->clipboard, "text/plain");
guac_common_clipboard_append(clipboard->clipboard, received_data, length);
guac_common_clipboard_send(clipboard->clipboard, client);
}
guac_mem_free(received_data);
return CHANNEL_RC_OK;
}
@ -618,12 +624,12 @@ static void guac_rdp_cliprdr_channel_disconnected(rdpContext* context,
}
guac_rdp_clipboard* guac_rdp_clipboard_alloc(guac_client* client) {
guac_rdp_clipboard* guac_rdp_clipboard_alloc(guac_client* client, int buffer_size) {
/* Allocate clipboard and underlying storage */
guac_rdp_clipboard* clipboard = guac_mem_zalloc(sizeof(guac_rdp_clipboard));
clipboard->client = client;
clipboard->clipboard = guac_common_clipboard_alloc();
clipboard->clipboard = guac_common_clipboard_alloc(buffer_size);
clipboard->requested_format = CF_TEXT;
return clipboard;

View File

@ -71,11 +71,14 @@ typedef struct guac_rdp_clipboard {
* The guac_client associated with the Guacamole side of the RDP
* connection.
*
* @param buffer_size
* The buffer size in bytes.
*
* @return
* A newly-allocated instance of guac_rdp_clipboard which has been
* initialized for processing Guacamole clipboard data.
*/
guac_rdp_clipboard* guac_rdp_clipboard_alloc(guac_client* client);
guac_rdp_clipboard* guac_rdp_clipboard_alloc(guac_client* client, int buffer_size);
/**
* Initializes clipboard support for RDP and handling of the CLIPRDR channel.

View File

@ -212,9 +212,6 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
rdp_client->input_event_queued = CreateEvent(NULL, TRUE, FALSE, NULL);
/* Init clipboard */
rdp_client->clipboard = guac_rdp_clipboard_alloc(client);
/* Init display update module */
rdp_client->disp = guac_rdp_disp_alloc(client);

View File

@ -140,6 +140,7 @@ const char* GUAC_RDP_CLIENT_ARGS[] = {
"load-balance-info",
"clipboard-buffer-size",
"disable-copy",
"disable-paste",
@ -658,6 +659,11 @@ enum RDP_ARGS_IDX {
* the connection broker, if a connection broker is being used.
*/
IDX_LOAD_BALANCE_INFO,
/**
* The maximum number of bytes to allow within the clipboard.
*/
IDX_CLIPBOARD_BUFFER_SIZE,
/**
* Whether outbound clipboard access should be blocked. If set to "true",
@ -1284,6 +1290,27 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user,
guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv,
IDX_LOAD_BALANCE_INFO, NULL);
/* Set the maximum number of bytes to allow within the clipboard. */
settings->clipboard_buffer_size =
guac_user_parse_args_int(user, GUAC_RDP_CLIENT_ARGS, argv,
IDX_CLIPBOARD_BUFFER_SIZE, 0);
/* Use default clipboard buffer size if given one is invalid. */
if (settings->clipboard_buffer_size < GUAC_COMMON_CLIPBOARD_MIN_LENGTH) {
settings->clipboard_buffer_size = GUAC_COMMON_CLIPBOARD_MIN_LENGTH;
guac_user_log(user, GUAC_LOG_INFO, "Unspecified or invalid clipboard buffer "
"size: \"%s\". Using the default minimum size: %i.",
argv[IDX_CLIPBOARD_BUFFER_SIZE],
settings->clipboard_buffer_size);
}
else if (settings->clipboard_buffer_size > GUAC_COMMON_CLIPBOARD_MAX_LENGTH) {
settings->clipboard_buffer_size = GUAC_COMMON_CLIPBOARD_MAX_LENGTH;
guac_user_log(user, GUAC_LOG_WARNING, "Invalid clipboard buffer "
"size: \"%s\". Using the default maximum size: %i.",
argv[IDX_CLIPBOARD_BUFFER_SIZE],
settings->clipboard_buffer_size);
}
/* Parse clipboard copy disable flag */
settings->disable_copy =
guac_user_parse_args_boolean(user, GUAC_RDP_CLIENT_ARGS, argv,

View File

@ -341,6 +341,11 @@ typedef struct guac_rdp_settings {
*/
char** svc_names;
/**
* The maximum number of bytes to allow within the clipboard.
*/
int clipboard_buffer_size;
/**
* Whether outbound clipboard access should be blocked. If set, it will not
* be possible to copy data from the remote desktop to the client using the

View File

@ -67,6 +67,10 @@ int guac_rdp_user_join_handler(guac_user* user, int argc, char** argv) {
/* Store owner's settings at client level */
rdp_client->settings = settings;
/* Init clipboard */
rdp_client->clipboard =
guac_rdp_clipboard_alloc(user->client, settings->clipboard_buffer_size);
/* Start client thread */
if (pthread_create(&rdp_client->client_thread, NULL,
guac_rdp_client_thread, user->client)) {

View File

@ -22,6 +22,7 @@
#include "argv.h"
#include "client.h"
#include "common/defaults.h"
#include "common/clipboard.h"
#include "settings.h"
#include "terminal/terminal.h"
@ -73,6 +74,7 @@ const char* GUAC_SSH_CLIENT_ARGS[] = {
"scrollback",
"locale",
"timezone",
"clipboard-buffer-size",
"disable-copy",
"disable-paste",
"wol-send-packet",
@ -310,6 +312,11 @@ enum SSH_ARGS_IDX {
*/
IDX_TIMEZONE,
/**
* The maximum number of bytes to allow within the clipboard.
*/
IDX_CLIPBOARD_BUFFER_SIZE,
/**
* Whether outbound clipboard access should be blocked. If set to "true",
* it will not be possible to copy data from the terminal to the client
@ -555,6 +562,27 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user,
guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv,
IDX_TIMEZONE, user->info.timezone);
/* Set the maximum number of bytes to allow within the clipboard. */
settings->clipboard_buffer_size =
guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv,
IDX_CLIPBOARD_BUFFER_SIZE, 0);
/* Use default clipboard buffer size if given one is invalid. */
if (settings->clipboard_buffer_size < GUAC_COMMON_CLIPBOARD_MIN_LENGTH) {
settings->clipboard_buffer_size = GUAC_COMMON_CLIPBOARD_MIN_LENGTH;
guac_user_log(user, GUAC_LOG_INFO, "Unspecified or invalid clipboard buffer "
"size: \"%s\". Using the default minimum size: %i.",
argv[IDX_CLIPBOARD_BUFFER_SIZE],
settings->clipboard_buffer_size);
}
else if (settings->clipboard_buffer_size > GUAC_COMMON_CLIPBOARD_MAX_LENGTH) {
settings->clipboard_buffer_size = GUAC_COMMON_CLIPBOARD_MAX_LENGTH;
guac_user_log(user, GUAC_LOG_WARNING, "Invalid clipboard buffer "
"size: \"%s\". Using the default maximum size: %i.",
argv[IDX_CLIPBOARD_BUFFER_SIZE],
settings->clipboard_buffer_size);
}
/* Parse clipboard copy disable flag */
settings->disable_copy =
guac_user_parse_args_boolean(user, GUAC_SSH_CLIENT_ARGS, argv,

View File

@ -157,6 +157,11 @@ typedef struct guac_ssh_settings {
*/
int resolution;
/**
* The maximum number of bytes to allow within the clipboard.
*/
int clipboard_buffer_size;
/**
* Whether outbound clipboard access should be blocked. If set, it will not
* be possible to copy data from the terminal to the client using the

View File

@ -294,6 +294,7 @@ void* ssh_client_thread(void* data) {
settings->width, settings->height, settings->resolution);
/* Set optional parameters */
options->clipboard_buffer_size = settings->clipboard_buffer_size;
options->disable_copy = settings->disable_copy;
options->max_scrollback = settings->max_scrollback;
options->font_name = settings->font_name;

View File

@ -21,6 +21,7 @@
#include "argv.h"
#include "common/defaults.h"
#include "common/clipboard.h"
#include "settings.h"
#include "terminal/terminal.h"
@ -63,6 +64,7 @@ const char* GUAC_TELNET_CLIENT_ARGS[] = {
"scrollback",
"login-success-regex",
"login-failure-regex",
"clipboard-buffer-size",
"disable-copy",
"disable-paste",
"wol-send-packet",
@ -248,6 +250,11 @@ enum TELNET_ARGS_IDX {
*/
IDX_LOGIN_FAILURE_REGEX,
/**
* The maximum number of bytes to allow within the clipboard.
*/
IDX_CLIPBOARD_BUFFER_SIZE,
/**
* Whether outbound clipboard access should be blocked. If set to "true",
* it will not be possible to copy data from the terminal to the client
@ -520,6 +527,27 @@ guac_telnet_settings* guac_telnet_parse_args(guac_user* user,
guac_user_parse_args_string(user, GUAC_TELNET_CLIENT_ARGS, argv,
IDX_TERMINAL_TYPE, "linux");
/* Set the maximum number of bytes to allow within the clipboard. */
settings->clipboard_buffer_size =
guac_user_parse_args_int(user, GUAC_TELNET_CLIENT_ARGS, argv,
IDX_CLIPBOARD_BUFFER_SIZE, 0);
/* Use default clipboard buffer size if given one is invalid. */
if (settings->clipboard_buffer_size < GUAC_COMMON_CLIPBOARD_MIN_LENGTH) {
settings->clipboard_buffer_size = GUAC_COMMON_CLIPBOARD_MIN_LENGTH;
guac_user_log(user, GUAC_LOG_INFO, "Unspecified or invalid clipboard buffer "
"size: \"%s\". Using the default minimum size: %i.",
argv[IDX_CLIPBOARD_BUFFER_SIZE],
settings->clipboard_buffer_size);
}
else if (settings->clipboard_buffer_size > GUAC_COMMON_CLIPBOARD_MAX_LENGTH) {
settings->clipboard_buffer_size = GUAC_COMMON_CLIPBOARD_MAX_LENGTH;
guac_user_log(user, GUAC_LOG_WARNING, "Invalid clipboard buffer "
"size: \"%s\". Using the default maximum size: %i.",
argv[IDX_CLIPBOARD_BUFFER_SIZE],
settings->clipboard_buffer_size);
}
/* Parse clipboard copy disable flag */
settings->disable_copy =
guac_user_parse_args_boolean(user, GUAC_TELNET_CLIENT_ARGS, argv,

View File

@ -165,6 +165,11 @@ typedef struct guac_telnet_settings {
*/
int resolution;
/**
* The maximum number of bytes to allow within the clipboard.
*/
int clipboard_buffer_size;
/**
* Whether outbound clipboard access should be blocked. If set, it will not
* be possible to copy data from the terminal to the client using the

View File

@ -545,6 +545,7 @@ void* guac_telnet_client_thread(void* data) {
settings->width, settings->height, settings->resolution);
/* Set optional parameters */
options->clipboard_buffer_size = settings->clipboard_buffer_size;
options->disable_copy = settings->disable_copy;
options->max_scrollback = settings->max_scrollback;
options->font_name = settings->font_name;

View File

@ -115,9 +115,6 @@ int guac_client_init(guac_client* client) {
/* Initialize the message lock. */
pthread_mutex_init(&(vnc_client->message_lock), NULL);
/* Init clipboard */
vnc_client->clipboard = guac_common_clipboard_alloc();
/* Set handlers */
client->join_handler = guac_vnc_user_join_handler;
client->join_pending_handler = guac_vnc_join_pending_handler;

View File

@ -77,9 +77,16 @@ int guac_vnc_set_clipboard_encoding(guac_client* client,
int guac_vnc_clipboard_handler(guac_user* user, guac_stream* stream,
char* mimetype) {
/* Clear clipboard and prepare for new data */
guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->data;
guac_common_clipboard_reset(vnc_client->clipboard, mimetype);
/* Ignore stream creation if no clipboard structure is available to handle
* received data */
guac_common_clipboard* clipboard = vnc_client->clipboard;
if (clipboard == NULL)
return 0;
/* Clear clipboard and prepare for new data */
guac_common_clipboard_reset(clipboard, mimetype);
/* Set handlers for clipboard stream */
stream->blob_handler = guac_vnc_clipboard_blob_handler;
@ -90,10 +97,17 @@ int guac_vnc_clipboard_handler(guac_user* user, guac_stream* stream,
int guac_vnc_clipboard_blob_handler(guac_user* user, guac_stream* stream,
void* data, int length) {
guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->data;
/* Ignore received data if no clipboard structure is available to handle
* that data */
guac_common_clipboard* clipboard = vnc_client->clipboard;
if (clipboard == NULL)
return 0;
/* Append new data */
guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->data;
guac_common_clipboard_append(vnc_client->clipboard, (char*) data, length);
guac_common_clipboard_append(clipboard, (char*) data, length);
return 0;
}
@ -101,22 +115,32 @@ int guac_vnc_clipboard_blob_handler(guac_user* user, guac_stream* stream,
int guac_vnc_clipboard_end_handler(guac_user* user, guac_stream* stream) {
guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->data;
/* Ignore end of stream if no clipboard structure is available to handle
* the data that was received */
guac_common_clipboard* clipboard = vnc_client->clipboard;
if (clipboard == NULL)
return 0;
rfbClient* rfb_client = vnc_client->rfb_client;
char output_data[GUAC_COMMON_CLIPBOARD_MAX_LENGTH];
int output_buf_size = clipboard->available;
char* output_data = guac_mem_alloc(output_buf_size);
const char* input = vnc_client->clipboard->buffer;
const char* input = clipboard->buffer;
char* output = output_data;
guac_iconv_write* writer = vnc_client->clipboard_writer;
/* Convert clipboard contents */
guac_iconv(GUAC_READ_UTF8, &input, vnc_client->clipboard->length,
writer, &output, sizeof(output_data));
guac_iconv(GUAC_READ_UTF8, &input, clipboard->length,
writer, &output, output_buf_size);
/* Send via VNC only if finished connecting */
if (rfb_client != NULL)
SendClientCutText(rfb_client, output_data, output - output_data);
guac_mem_free(output_data);
return 0;
}
@ -129,7 +153,8 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) {
if (vnc_client->settings->disable_copy)
return;
char received_data[GUAC_COMMON_CLIPBOARD_MAX_LENGTH];
int output_buf_size = vnc_client->clipboard->available;
char* received_data = guac_mem_alloc(output_buf_size);
const char* input = text;
char* output = received_data;
@ -137,12 +162,13 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) {
/* Convert clipboard contents */
guac_iconv(reader, &input, textlen,
GUAC_WRITE_UTF8, &output, sizeof(received_data));
GUAC_WRITE_UTF8, &output, output_buf_size);
/* Send converted data */
guac_common_clipboard_reset(vnc_client->clipboard, "text/plain");
guac_common_clipboard_append(vnc_client->clipboard, received_data, output - received_data);
guac_common_clipboard_send(vnc_client->clipboard, gc);
guac_mem_free(received_data);
}

View File

@ -22,6 +22,7 @@
#include "argv.h"
#include "client.h"
#include "common/defaults.h"
#include "common/clipboard.h"
#include "settings.h"
#include <guacamole/mem.h>
@ -88,6 +89,7 @@ const char* GUAC_VNC_CLIENT_ARGS[] = {
"recording-include-keys",
"create-recording-path",
"recording-write-existing",
"clipboard-buffer-size",
"disable-copy",
"disable-paste",
"disable-server-input",
@ -363,6 +365,11 @@ enum VNC_ARGS_IDX {
*/
IDX_RECORDING_WRITE_EXISTING,
/**
* The maximum number of bytes to allow within the clipboard.
*/
IDX_CLIPBOARD_BUFFER_SIZE,
/**
* Whether outbound clipboard access should be blocked. If set to "true",
* it will not be possible to copy data from the remote desktop to the
@ -684,6 +691,27 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user,
guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_DISABLE_COPY, false);
/* Set the maximum number of bytes to allow within the clipboard. */
settings->clipboard_buffer_size =
guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_CLIPBOARD_BUFFER_SIZE, 0);
/* Use default clipboard buffer size if given one is invalid. */
if (settings->clipboard_buffer_size < GUAC_COMMON_CLIPBOARD_MIN_LENGTH) {
settings->clipboard_buffer_size = GUAC_COMMON_CLIPBOARD_MIN_LENGTH;
guac_user_log(user, GUAC_LOG_INFO, "Unspecified or invalid clipboard buffer "
"size: \"%s\". Using the default minimum size: %i.",
argv[IDX_CLIPBOARD_BUFFER_SIZE],
settings->clipboard_buffer_size);
}
else if (settings->clipboard_buffer_size > GUAC_COMMON_CLIPBOARD_MAX_LENGTH) {
settings->clipboard_buffer_size = GUAC_COMMON_CLIPBOARD_MAX_LENGTH;
guac_user_log(user, GUAC_LOG_WARNING, "Invalid clipboard buffer "
"size: \"%s\". Using the default maximum size: %i.",
argv[IDX_CLIPBOARD_BUFFER_SIZE],
settings->clipboard_buffer_size);
}
/* Parse clipboard paste disable flag */
settings->disable_paste =
guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv,

View File

@ -157,6 +157,11 @@ typedef struct guac_vnc_settings {
* to use the encoding required by the VNC standard.
*/
char* clipboard_encoding;
/**
* The maximum number of bytes to allow within the clipboard.
*/
int clipboard_buffer_size;
/**
* Whether outbound clipboard access should be blocked. If set, it will not

View File

@ -64,6 +64,10 @@ int guac_vnc_user_join_handler(guac_user* user, int argc, char** argv) {
/* Store owner's settings at client level */
vnc_client->settings = settings;
/* Init clipboard. */
vnc_client->clipboard =
guac_common_clipboard_alloc(settings->clipboard_buffer_size);
/* Start client thread */
if (pthread_create(&vnc_client->client_thread, NULL, guac_vnc_client_thread, user->client)) {
guac_user_log(user, GUAC_LOG_ERROR, "Unable to start VNC client thread.");

View File

@ -242,6 +242,7 @@ guac_terminal_options* guac_terminal_options_create(
options->dpi = dpi;
/* Set default values for all other parameters */
options->clipboard_buffer_size = GUAC_COMMON_CLIPBOARD_MIN_LENGTH;
options->disable_copy = GUAC_TERMINAL_DEFAULT_DISABLE_COPY;
options->max_scrollback = GUAC_TERMINAL_DEFAULT_MAX_SCROLLBACK;
options->font_name = GUAC_TERMINAL_DEFAULT_FONT_NAME;
@ -419,7 +420,7 @@ guac_terminal* guac_terminal_create(guac_client* client,
/* Init terminal state */
term->current_attributes = default_char.attributes;
term->default_char = default_char;
term->clipboard = guac_common_clipboard_alloc();
term->clipboard = guac_common_clipboard_alloc(options->clipboard_buffer_size);
term->disable_copy = options->disable_copy;
/* Calculate available text display area by character size */
@ -2202,14 +2203,17 @@ void guac_terminal_clipboard_append(guac_terminal* terminal,
const char* data, int length) {
/* Allocate and clear space for the converted data */
char output_data[GUAC_COMMON_CLIPBOARD_MAX_LENGTH];
int output_buf_size = terminal->clipboard->available;
char* output_data = guac_mem_alloc(output_buf_size);
char* output = output_data;
/* Convert clipboard contents */
guac_iconv(GUAC_READ_UTF8_NORMALIZED, &data, length,
GUAC_WRITE_UTF8, &output, GUAC_COMMON_CLIPBOARD_MAX_LENGTH);
GUAC_WRITE_UTF8, &output, output_buf_size);
guac_common_clipboard_append(terminal->clipboard, output_data, output - output_data);
guac_mem_free(output_data);
}
void guac_terminal_remove_user(guac_terminal* terminal, guac_user* user) {

View File

@ -180,6 +180,11 @@ typedef guac_stream* guac_terminal_file_download_handler(guac_client* client, ch
*/
typedef struct guac_terminal_options {
/**
* The maximum number of bytes to allow within the clipboard.
*/
int clipboard_buffer_size;
/**
* Whether copying from the terminal clipboard should be blocked. If set,
* the contents of the terminal can still be copied, but will be usable