Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5df55fe01 | ||
|
|
f3f5b9d766 | ||
|
|
0ab6f664b9 | ||
|
|
519e42f0b5 | ||
|
|
ac46031ee5 | ||
|
|
cb0aac72dd | ||
|
|
d80112c993 | ||
|
|
558c42e4b4 | ||
|
|
07820faa9d | ||
|
|
5aa8143d69 | ||
|
|
fc5073fb69 | ||
|
|
cdbd0ab699 | ||
|
|
e8ad0b958c | ||
|
|
e9cc550012 | ||
|
|
b52692933f | ||
|
|
f48c4fba38 | ||
|
|
4d625e57e8 | ||
|
|
18b4861be7 | ||
|
|
a585c740aa | ||
|
|
e6a34e2fd6 | ||
|
|
2f09f6d5bb | ||
|
|
487a7849ca | ||
|
|
d79f201f25 | ||
|
|
483a086370 | ||
|
|
44c1bd24b7 | ||
|
|
32dbdfae14 | ||
|
|
15d5a276fb | ||
|
|
8e75eea9ce | ||
|
|
02c4578603 | ||
|
|
783f4c5e34 | ||
|
|
1c1bcc87c8 | ||
|
|
844179e838 | ||
|
|
04e90157c0 | ||
|
|
bdb2aec49b | ||
|
|
1cbc4d492c | ||
|
|
09c2d4e360 | ||
|
|
98f3c8b746 | ||
|
|
13868fac10 | ||
|
|
a95e66cd91 | ||
|
|
3258efe2be | ||
|
|
1a22276d47 | ||
|
|
9709f2c562 | ||
|
|
c18cda2e30 | ||
|
|
c00cb51be9 | ||
|
|
ac8191d79c |
@ -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([_GNU_SOURCE], [1], [Uses GNU-specific APIs (if available)])
|
||||||
AC_DEFINE([_XOPEN_SOURCE], [700], [Uses X/Open and POSIX APIs])
|
AC_DEFINE([_XOPEN_SOURCE], [700], [Uses X/Open and POSIX APIs])
|
||||||
AC_DEFINE([__BSD_VISIBLE], [1], [Uses BSD-specific APIs (if available)])
|
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
|
# Check for availability of non-portable sched_getaffinity() function (one of
|
||||||
# several possible routes for determining the number of available processors)
|
# 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],,
|
AC_DEFINE([HAVE_LIBPTHREAD],,
|
||||||
[Whether libpthread was found])])
|
[Whether libpthread was found])])
|
||||||
|
|
||||||
|
# Check for pthread_setattr_default_np
|
||||||
|
AC_CHECK_DECLS([pthread_setattr_default_np], , , [[#include <pthread.h>]])
|
||||||
|
|
||||||
# librt
|
# librt
|
||||||
AC_CHECK_FUNC([timer_create], [AC_MSG_RESULT([timer_create was found without librt.])],
|
AC_CHECK_FUNC([timer_create], [AC_MSG_RESULT([timer_create was found without librt.])],
|
||||||
[AC_CHECK_LIB([rt], [timer_create],
|
[AC_CHECK_LIB([rt], [timer_create],
|
||||||
|
|||||||
5
debian/changelog
vendored
Normal file
5
debian/changelog
vendored
Normal 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
30
debian/control
vendored
Normal 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
22
debian/rules
vendored
Executable 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
1
debian/source/format
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
3.0 (native)
|
||||||
@ -30,14 +30,14 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.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));
|
guac_common_clipboard* clipboard = guac_mem_alloc(sizeof(guac_common_clipboard));
|
||||||
|
|
||||||
/* Init clipboard */
|
/* Init clipboard */
|
||||||
clipboard->mimetype[0] = '\0';
|
clipboard->mimetype[0] = '\0';
|
||||||
clipboard->buffer = guac_mem_alloc(GUAC_COMMON_CLIPBOARD_MAX_LENGTH);
|
clipboard->buffer = guac_mem_alloc(buffer_size);
|
||||||
clipboard->available = GUAC_COMMON_CLIPBOARD_MAX_LENGTH;
|
clipboard->available = buffer_size;
|
||||||
clipboard->length = 0;
|
clipboard->length = 0;
|
||||||
|
|
||||||
pthread_mutex_init(&(clipboard->lock), NULL);
|
pthread_mutex_init(&(clipboard->lock), NULL);
|
||||||
|
|||||||
@ -32,9 +32,16 @@
|
|||||||
#define GUAC_COMMON_CLIPBOARD_BLOCK_SIZE 4096
|
#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.
|
* Generic clipboard structure.
|
||||||
@ -72,13 +79,17 @@ typedef struct guac_common_clipboard {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new 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.
|
* 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);
|
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
|
* Sends the contents of the clipboard along the given client, splitting
|
||||||
* the contents as necessary.
|
* the contents as necessary.
|
||||||
*
|
*
|
||||||
* @param clipboard The clipboard whose contents should be sent.
|
* @param clipboard
|
||||||
* @param client The client to send the clipboard contents on.
|
* 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);
|
void guac_common_clipboard_send(guac_common_clipboard* clipboard, guac_client* client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the clipboard contents and assigns a new mimetype for future data.
|
* Clears the clipboard contents and assigns a new mimetype for future data.
|
||||||
*
|
*
|
||||||
* @param clipboard The clipboard to reset.
|
* @param clipboard
|
||||||
* @param mimetype The mimetype of future data.
|
* The clipboard to reset.
|
||||||
|
*
|
||||||
|
* @param mimetype
|
||||||
|
* The mimetype of future data.
|
||||||
*/
|
*/
|
||||||
void guac_common_clipboard_reset(guac_common_clipboard* clipboard, const char* mimetype);
|
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
|
* match the mimetype chosen for the clipboard data by
|
||||||
* guac_common_clipboard_reset().
|
* guac_common_clipboard_reset().
|
||||||
*
|
*
|
||||||
* @param clipboard The clipboard to append data to.
|
* @param clipboard
|
||||||
* @param data The data to append.
|
* The clipboard to append data to.
|
||||||
* @param length The number of bytes to append from the data given.
|
*
|
||||||
|
* @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);
|
void guac_common_clipboard_append(guac_common_clipboard* clipboard, const char* data, int length);
|
||||||
|
|
||||||
|
|||||||
@ -37,6 +37,7 @@
|
|||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <pthread.h>
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -321,6 +322,14 @@ int main(int argc, char* argv[]) {
|
|||||||
/* General */
|
/* General */
|
||||||
int retval;
|
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 */
|
/* Load configuration */
|
||||||
guacd_config* config = guacd_conf_load();
|
guacd_config* config = guacd_conf_load();
|
||||||
if (config == NULL || guacd_conf_parse_args(config, argc, argv))
|
if (config == NULL || guacd_conf_parse_args(config, argc, argv))
|
||||||
|
|||||||
@ -32,6 +32,11 @@
|
|||||||
*/
|
*/
|
||||||
#define GUACD_CLIENT_MAX_CONNECTIONS 65536
|
#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.
|
* The number of hash buckets in each process map.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -246,6 +246,7 @@ void* guac_kubernetes_client_thread(void* data) {
|
|||||||
settings->width, settings->height, settings->resolution);
|
settings->width, settings->height, settings->resolution);
|
||||||
|
|
||||||
/* Set optional parameters */
|
/* Set optional parameters */
|
||||||
|
options->clipboard_buffer_size = settings->clipboard_buffer_size;
|
||||||
options->disable_copy = settings->disable_copy;
|
options->disable_copy = settings->disable_copy;
|
||||||
options->max_scrollback = settings->max_scrollback;
|
options->max_scrollback = settings->max_scrollback;
|
||||||
options->font_name = settings->font_name;
|
options->font_name = settings->font_name;
|
||||||
|
|||||||
@ -56,6 +56,7 @@ const char* GUAC_KUBERNETES_CLIENT_ARGS[] = {
|
|||||||
"read-only",
|
"read-only",
|
||||||
"backspace",
|
"backspace",
|
||||||
"scrollback",
|
"scrollback",
|
||||||
|
"clipboard-buffer-size",
|
||||||
"disable-copy",
|
"disable-copy",
|
||||||
"disable-paste",
|
"disable-paste",
|
||||||
NULL
|
NULL
|
||||||
@ -241,6 +242,11 @@ enum KUBERNETES_ARGS_IDX {
|
|||||||
*/
|
*/
|
||||||
IDX_SCROLLBACK,
|
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",
|
* 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
|
* 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,
|
guac_user_parse_args_int(user, GUAC_KUBERNETES_CLIENT_ARGS, argv,
|
||||||
IDX_BACKSPACE, GUAC_TERMINAL_DEFAULT_BACKSPACE);
|
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 */
|
/* Parse clipboard copy disable flag */
|
||||||
settings->disable_copy =
|
settings->disable_copy =
|
||||||
guac_user_parse_args_boolean(user, GUAC_KUBERNETES_CLIENT_ARGS, argv,
|
guac_user_parse_args_boolean(user, GUAC_KUBERNETES_CLIENT_ARGS, argv,
|
||||||
|
|||||||
@ -160,6 +160,11 @@ typedef struct guac_kubernetes_settings {
|
|||||||
*/
|
*/
|
||||||
int resolution;
|
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
|
* 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
|
* be possible to copy data from the terminal to the client using the
|
||||||
|
|||||||
@ -371,7 +371,9 @@ static UINT guac_rdp_cliprdr_format_data_request(CliprdrClientContext* cliprdr,
|
|||||||
|
|
||||||
guac_iconv_write* remote_writer;
|
guac_iconv_write* remote_writer;
|
||||||
const char* input = clipboard->clipboard->buffer;
|
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 */
|
/* Map requested clipboard format to a guac_iconv writer */
|
||||||
switch (format_data_request->requestedFormatId) {
|
switch (format_data_request->requestedFormatId) {
|
||||||
@ -402,7 +404,7 @@ static UINT guac_rdp_cliprdr_format_data_request(CliprdrClientContext* cliprdr,
|
|||||||
BYTE* start = (BYTE*) output;
|
BYTE* start = (BYTE*) output;
|
||||||
guac_iconv_read* local_reader = settings->normalize_clipboard ? GUAC_READ_UTF8_NORMALIZED : GUAC_READ_UTF8;
|
guac_iconv_read* local_reader = settings->normalize_clipboard ? GUAC_READ_UTF8_NORMALIZED : GUAC_READ_UTF8;
|
||||||
guac_iconv(local_reader, &input, clipboard->clipboard->length,
|
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 = {
|
CLIPRDR_FORMAT_DATA_RESPONSE data_response = {
|
||||||
.requestedFormatData = (BYTE*) start,
|
.requestedFormatData = (BYTE*) start,
|
||||||
@ -470,7 +472,8 @@ static UINT guac_rdp_cliprdr_format_data_response(CliprdrClientContext* cliprdr,
|
|||||||
return CHANNEL_RC_OK;
|
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;
|
guac_iconv_read* remote_reader;
|
||||||
const char* input = (char*) format_data_response->requestedFormatData;
|
const char* input = (char*) format_data_response->requestedFormatData;
|
||||||
@ -498,6 +501,7 @@ static UINT guac_rdp_cliprdr_format_data_response(CliprdrClientContext* cliprdr,
|
|||||||
default:
|
default:
|
||||||
guac_client_log(client, GUAC_LOG_DEBUG, "Requested clipboard data "
|
guac_client_log(client, GUAC_LOG_DEBUG, "Requested clipboard data "
|
||||||
"in unsupported format (0x%X).", clipboard->requested_format);
|
"in unsupported format (0x%X).", clipboard->requested_format);
|
||||||
|
guac_mem_free(received_data);
|
||||||
return CHANNEL_RC_OK;
|
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
|
/* Convert, store, and forward the clipboard data received from RDP
|
||||||
* server */
|
* server */
|
||||||
if (guac_iconv(remote_reader, &input, data_len,
|
if (guac_iconv(remote_reader, &input, data_len,
|
||||||
GUAC_WRITE_UTF8, &output, sizeof(received_data))) {
|
GUAC_WRITE_UTF8, &output, output_buf_size)) {
|
||||||
int length = strnlen(received_data, sizeof(received_data));
|
int length = strnlen(received_data, output_buf_size);
|
||||||
guac_common_clipboard_reset(clipboard->clipboard, "text/plain");
|
guac_common_clipboard_reset(clipboard->clipboard, "text/plain");
|
||||||
guac_common_clipboard_append(clipboard->clipboard, received_data, length);
|
guac_common_clipboard_append(clipboard->clipboard, received_data, length);
|
||||||
guac_common_clipboard_send(clipboard->clipboard, client);
|
guac_common_clipboard_send(clipboard->clipboard, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guac_mem_free(received_data);
|
||||||
|
|
||||||
return CHANNEL_RC_OK;
|
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 */
|
/* Allocate clipboard and underlying storage */
|
||||||
guac_rdp_clipboard* clipboard = guac_mem_zalloc(sizeof(guac_rdp_clipboard));
|
guac_rdp_clipboard* clipboard = guac_mem_zalloc(sizeof(guac_rdp_clipboard));
|
||||||
clipboard->client = client;
|
clipboard->client = client;
|
||||||
clipboard->clipboard = guac_common_clipboard_alloc();
|
clipboard->clipboard = guac_common_clipboard_alloc(buffer_size);
|
||||||
clipboard->requested_format = CF_TEXT;
|
clipboard->requested_format = CF_TEXT;
|
||||||
|
|
||||||
return clipboard;
|
return clipboard;
|
||||||
|
|||||||
@ -71,11 +71,14 @@ typedef struct guac_rdp_clipboard {
|
|||||||
* The guac_client associated with the Guacamole side of the RDP
|
* The guac_client associated with the Guacamole side of the RDP
|
||||||
* connection.
|
* connection.
|
||||||
*
|
*
|
||||||
|
* @param buffer_size
|
||||||
|
* The buffer size in bytes.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
* A newly-allocated instance of guac_rdp_clipboard which has been
|
* A newly-allocated instance of guac_rdp_clipboard which has been
|
||||||
* initialized for processing Guacamole clipboard data.
|
* 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.
|
* Initializes clipboard support for RDP and handling of the CLIPRDR channel.
|
||||||
|
|||||||
@ -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);
|
rdp_client->input_event_queued = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
|
||||||
/* Init clipboard */
|
|
||||||
rdp_client->clipboard = guac_rdp_clipboard_alloc(client);
|
|
||||||
|
|
||||||
/* Init display update module */
|
/* Init display update module */
|
||||||
rdp_client->disp = guac_rdp_disp_alloc(client);
|
rdp_client->disp = guac_rdp_disp_alloc(client);
|
||||||
|
|
||||||
|
|||||||
@ -140,6 +140,7 @@ const char* GUAC_RDP_CLIENT_ARGS[] = {
|
|||||||
|
|
||||||
"load-balance-info",
|
"load-balance-info",
|
||||||
|
|
||||||
|
"clipboard-buffer-size",
|
||||||
"disable-copy",
|
"disable-copy",
|
||||||
"disable-paste",
|
"disable-paste",
|
||||||
|
|
||||||
@ -658,6 +659,11 @@ enum RDP_ARGS_IDX {
|
|||||||
* the connection broker, if a connection broker is being used.
|
* the connection broker, if a connection broker is being used.
|
||||||
*/
|
*/
|
||||||
IDX_LOAD_BALANCE_INFO,
|
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",
|
* 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,
|
guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv,
|
||||||
IDX_LOAD_BALANCE_INFO, NULL);
|
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 */
|
/* Parse clipboard copy disable flag */
|
||||||
settings->disable_copy =
|
settings->disable_copy =
|
||||||
guac_user_parse_args_boolean(user, GUAC_RDP_CLIENT_ARGS, argv,
|
guac_user_parse_args_boolean(user, GUAC_RDP_CLIENT_ARGS, argv,
|
||||||
|
|||||||
@ -341,6 +341,11 @@ typedef struct guac_rdp_settings {
|
|||||||
*/
|
*/
|
||||||
char** svc_names;
|
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
|
* 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
|
* be possible to copy data from the remote desktop to the client using the
|
||||||
|
|||||||
@ -67,6 +67,10 @@ int guac_rdp_user_join_handler(guac_user* user, int argc, char** argv) {
|
|||||||
/* Store owner's settings at client level */
|
/* Store owner's settings at client level */
|
||||||
rdp_client->settings = settings;
|
rdp_client->settings = settings;
|
||||||
|
|
||||||
|
/* Init clipboard */
|
||||||
|
rdp_client->clipboard =
|
||||||
|
guac_rdp_clipboard_alloc(user->client, settings->clipboard_buffer_size);
|
||||||
|
|
||||||
/* Start client thread */
|
/* Start client thread */
|
||||||
if (pthread_create(&rdp_client->client_thread, NULL,
|
if (pthread_create(&rdp_client->client_thread, NULL,
|
||||||
guac_rdp_client_thread, user->client)) {
|
guac_rdp_client_thread, user->client)) {
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
#include "argv.h"
|
#include "argv.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "common/defaults.h"
|
#include "common/defaults.h"
|
||||||
|
#include "common/clipboard.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "terminal/terminal.h"
|
#include "terminal/terminal.h"
|
||||||
|
|
||||||
@ -73,6 +74,7 @@ const char* GUAC_SSH_CLIENT_ARGS[] = {
|
|||||||
"scrollback",
|
"scrollback",
|
||||||
"locale",
|
"locale",
|
||||||
"timezone",
|
"timezone",
|
||||||
|
"clipboard-buffer-size",
|
||||||
"disable-copy",
|
"disable-copy",
|
||||||
"disable-paste",
|
"disable-paste",
|
||||||
"wol-send-packet",
|
"wol-send-packet",
|
||||||
@ -310,6 +312,11 @@ enum SSH_ARGS_IDX {
|
|||||||
*/
|
*/
|
||||||
IDX_TIMEZONE,
|
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",
|
* 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
|
* 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,
|
guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv,
|
||||||
IDX_TIMEZONE, user->info.timezone);
|
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 */
|
/* Parse clipboard copy disable flag */
|
||||||
settings->disable_copy =
|
settings->disable_copy =
|
||||||
guac_user_parse_args_boolean(user, GUAC_SSH_CLIENT_ARGS, argv,
|
guac_user_parse_args_boolean(user, GUAC_SSH_CLIENT_ARGS, argv,
|
||||||
|
|||||||
@ -157,6 +157,11 @@ typedef struct guac_ssh_settings {
|
|||||||
*/
|
*/
|
||||||
int resolution;
|
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
|
* 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
|
* be possible to copy data from the terminal to the client using the
|
||||||
|
|||||||
@ -294,6 +294,7 @@ void* ssh_client_thread(void* data) {
|
|||||||
settings->width, settings->height, settings->resolution);
|
settings->width, settings->height, settings->resolution);
|
||||||
|
|
||||||
/* Set optional parameters */
|
/* Set optional parameters */
|
||||||
|
options->clipboard_buffer_size = settings->clipboard_buffer_size;
|
||||||
options->disable_copy = settings->disable_copy;
|
options->disable_copy = settings->disable_copy;
|
||||||
options->max_scrollback = settings->max_scrollback;
|
options->max_scrollback = settings->max_scrollback;
|
||||||
options->font_name = settings->font_name;
|
options->font_name = settings->font_name;
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "argv.h"
|
#include "argv.h"
|
||||||
#include "common/defaults.h"
|
#include "common/defaults.h"
|
||||||
|
#include "common/clipboard.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "terminal/terminal.h"
|
#include "terminal/terminal.h"
|
||||||
|
|
||||||
@ -63,6 +64,7 @@ const char* GUAC_TELNET_CLIENT_ARGS[] = {
|
|||||||
"scrollback",
|
"scrollback",
|
||||||
"login-success-regex",
|
"login-success-regex",
|
||||||
"login-failure-regex",
|
"login-failure-regex",
|
||||||
|
"clipboard-buffer-size",
|
||||||
"disable-copy",
|
"disable-copy",
|
||||||
"disable-paste",
|
"disable-paste",
|
||||||
"wol-send-packet",
|
"wol-send-packet",
|
||||||
@ -248,6 +250,11 @@ enum TELNET_ARGS_IDX {
|
|||||||
*/
|
*/
|
||||||
IDX_LOGIN_FAILURE_REGEX,
|
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",
|
* 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
|
* 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,
|
guac_user_parse_args_string(user, GUAC_TELNET_CLIENT_ARGS, argv,
|
||||||
IDX_TERMINAL_TYPE, "linux");
|
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 */
|
/* Parse clipboard copy disable flag */
|
||||||
settings->disable_copy =
|
settings->disable_copy =
|
||||||
guac_user_parse_args_boolean(user, GUAC_TELNET_CLIENT_ARGS, argv,
|
guac_user_parse_args_boolean(user, GUAC_TELNET_CLIENT_ARGS, argv,
|
||||||
|
|||||||
@ -165,6 +165,11 @@ typedef struct guac_telnet_settings {
|
|||||||
*/
|
*/
|
||||||
int resolution;
|
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
|
* 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
|
* be possible to copy data from the terminal to the client using the
|
||||||
|
|||||||
@ -545,6 +545,7 @@ void* guac_telnet_client_thread(void* data) {
|
|||||||
settings->width, settings->height, settings->resolution);
|
settings->width, settings->height, settings->resolution);
|
||||||
|
|
||||||
/* Set optional parameters */
|
/* Set optional parameters */
|
||||||
|
options->clipboard_buffer_size = settings->clipboard_buffer_size;
|
||||||
options->disable_copy = settings->disable_copy;
|
options->disable_copy = settings->disable_copy;
|
||||||
options->max_scrollback = settings->max_scrollback;
|
options->max_scrollback = settings->max_scrollback;
|
||||||
options->font_name = settings->font_name;
|
options->font_name = settings->font_name;
|
||||||
|
|||||||
@ -115,9 +115,6 @@ int guac_client_init(guac_client* client) {
|
|||||||
/* Initialize the message lock. */
|
/* Initialize the message lock. */
|
||||||
pthread_mutex_init(&(vnc_client->message_lock), NULL);
|
pthread_mutex_init(&(vnc_client->message_lock), NULL);
|
||||||
|
|
||||||
/* Init clipboard */
|
|
||||||
vnc_client->clipboard = guac_common_clipboard_alloc();
|
|
||||||
|
|
||||||
/* Set handlers */
|
/* Set handlers */
|
||||||
client->join_handler = guac_vnc_user_join_handler;
|
client->join_handler = guac_vnc_user_join_handler;
|
||||||
client->join_pending_handler = guac_vnc_join_pending_handler;
|
client->join_pending_handler = guac_vnc_join_pending_handler;
|
||||||
|
|||||||
@ -77,9 +77,16 @@ int guac_vnc_set_clipboard_encoding(guac_client* client,
|
|||||||
int guac_vnc_clipboard_handler(guac_user* user, guac_stream* stream,
|
int guac_vnc_clipboard_handler(guac_user* user, guac_stream* stream,
|
||||||
char* mimetype) {
|
char* mimetype) {
|
||||||
|
|
||||||
/* Clear clipboard and prepare for new data */
|
|
||||||
guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->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 */
|
/* Set handlers for clipboard stream */
|
||||||
stream->blob_handler = guac_vnc_clipboard_blob_handler;
|
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,
|
int guac_vnc_clipboard_blob_handler(guac_user* user, guac_stream* stream,
|
||||||
void* data, int length) {
|
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 */
|
/* Append new data */
|
||||||
guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->data;
|
guac_common_clipboard_append(clipboard, (char*) data, length);
|
||||||
guac_common_clipboard_append(vnc_client->clipboard, (char*) data, length);
|
|
||||||
|
|
||||||
return 0;
|
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) {
|
int guac_vnc_clipboard_end_handler(guac_user* user, guac_stream* stream) {
|
||||||
|
|
||||||
guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->data;
|
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;
|
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;
|
char* output = output_data;
|
||||||
guac_iconv_write* writer = vnc_client->clipboard_writer;
|
guac_iconv_write* writer = vnc_client->clipboard_writer;
|
||||||
|
|
||||||
/* Convert clipboard contents */
|
/* Convert clipboard contents */
|
||||||
guac_iconv(GUAC_READ_UTF8, &input, vnc_client->clipboard->length,
|
guac_iconv(GUAC_READ_UTF8, &input, clipboard->length,
|
||||||
writer, &output, sizeof(output_data));
|
writer, &output, output_buf_size);
|
||||||
|
|
||||||
/* Send via VNC only if finished connecting */
|
/* Send via VNC only if finished connecting */
|
||||||
if (rfb_client != NULL)
|
if (rfb_client != NULL)
|
||||||
SendClientCutText(rfb_client, output_data, output - output_data);
|
SendClientCutText(rfb_client, output_data, output - output_data);
|
||||||
|
|
||||||
|
guac_mem_free(output_data);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +153,8 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) {
|
|||||||
if (vnc_client->settings->disable_copy)
|
if (vnc_client->settings->disable_copy)
|
||||||
return;
|
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;
|
const char* input = text;
|
||||||
char* output = received_data;
|
char* output = received_data;
|
||||||
@ -137,12 +162,13 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) {
|
|||||||
|
|
||||||
/* Convert clipboard contents */
|
/* Convert clipboard contents */
|
||||||
guac_iconv(reader, &input, textlen,
|
guac_iconv(reader, &input, textlen,
|
||||||
GUAC_WRITE_UTF8, &output, sizeof(received_data));
|
GUAC_WRITE_UTF8, &output, output_buf_size);
|
||||||
|
|
||||||
/* Send converted data */
|
/* Send converted data */
|
||||||
guac_common_clipboard_reset(vnc_client->clipboard, "text/plain");
|
guac_common_clipboard_reset(vnc_client->clipboard, "text/plain");
|
||||||
guac_common_clipboard_append(vnc_client->clipboard, received_data, output - received_data);
|
guac_common_clipboard_append(vnc_client->clipboard, received_data, output - received_data);
|
||||||
guac_common_clipboard_send(vnc_client->clipboard, gc);
|
guac_common_clipboard_send(vnc_client->clipboard, gc);
|
||||||
|
|
||||||
|
guac_mem_free(received_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
#include "argv.h"
|
#include "argv.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "common/defaults.h"
|
#include "common/defaults.h"
|
||||||
|
#include "common/clipboard.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include <guacamole/mem.h>
|
#include <guacamole/mem.h>
|
||||||
@ -88,6 +89,7 @@ const char* GUAC_VNC_CLIENT_ARGS[] = {
|
|||||||
"recording-include-keys",
|
"recording-include-keys",
|
||||||
"create-recording-path",
|
"create-recording-path",
|
||||||
"recording-write-existing",
|
"recording-write-existing",
|
||||||
|
"clipboard-buffer-size",
|
||||||
"disable-copy",
|
"disable-copy",
|
||||||
"disable-paste",
|
"disable-paste",
|
||||||
"disable-server-input",
|
"disable-server-input",
|
||||||
@ -363,6 +365,11 @@ enum VNC_ARGS_IDX {
|
|||||||
*/
|
*/
|
||||||
IDX_RECORDING_WRITE_EXISTING,
|
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",
|
* 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
|
* 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,
|
guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv,
|
||||||
IDX_DISABLE_COPY, false);
|
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 */
|
/* Parse clipboard paste disable flag */
|
||||||
settings->disable_paste =
|
settings->disable_paste =
|
||||||
guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv,
|
guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv,
|
||||||
|
|||||||
@ -157,6 +157,11 @@ typedef struct guac_vnc_settings {
|
|||||||
* to use the encoding required by the VNC standard.
|
* to use the encoding required by the VNC standard.
|
||||||
*/
|
*/
|
||||||
char* clipboard_encoding;
|
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
|
* Whether outbound clipboard access should be blocked. If set, it will not
|
||||||
|
|||||||
@ -64,6 +64,10 @@ int guac_vnc_user_join_handler(guac_user* user, int argc, char** argv) {
|
|||||||
/* Store owner's settings at client level */
|
/* Store owner's settings at client level */
|
||||||
vnc_client->settings = settings;
|
vnc_client->settings = settings;
|
||||||
|
|
||||||
|
/* Init clipboard. */
|
||||||
|
vnc_client->clipboard =
|
||||||
|
guac_common_clipboard_alloc(settings->clipboard_buffer_size);
|
||||||
|
|
||||||
/* Start client thread */
|
/* Start client thread */
|
||||||
if (pthread_create(&vnc_client->client_thread, NULL, guac_vnc_client_thread, user->client)) {
|
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.");
|
guac_user_log(user, GUAC_LOG_ERROR, "Unable to start VNC client thread.");
|
||||||
|
|||||||
@ -242,6 +242,7 @@ guac_terminal_options* guac_terminal_options_create(
|
|||||||
options->dpi = dpi;
|
options->dpi = dpi;
|
||||||
|
|
||||||
/* Set default values for all other parameters */
|
/* 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->disable_copy = GUAC_TERMINAL_DEFAULT_DISABLE_COPY;
|
||||||
options->max_scrollback = GUAC_TERMINAL_DEFAULT_MAX_SCROLLBACK;
|
options->max_scrollback = GUAC_TERMINAL_DEFAULT_MAX_SCROLLBACK;
|
||||||
options->font_name = GUAC_TERMINAL_DEFAULT_FONT_NAME;
|
options->font_name = GUAC_TERMINAL_DEFAULT_FONT_NAME;
|
||||||
@ -419,7 +420,7 @@ guac_terminal* guac_terminal_create(guac_client* client,
|
|||||||
/* Init terminal state */
|
/* Init terminal state */
|
||||||
term->current_attributes = default_char.attributes;
|
term->current_attributes = default_char.attributes;
|
||||||
term->default_char = default_char;
|
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;
|
term->disable_copy = options->disable_copy;
|
||||||
|
|
||||||
/* Calculate available text display area by character size */
|
/* 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) {
|
const char* data, int length) {
|
||||||
|
|
||||||
/* Allocate and clear space for the converted data */
|
/* 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;
|
char* output = output_data;
|
||||||
|
|
||||||
/* Convert clipboard contents */
|
/* Convert clipboard contents */
|
||||||
guac_iconv(GUAC_READ_UTF8_NORMALIZED, &data, length,
|
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_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) {
|
void guac_terminal_remove_user(guac_terminal* terminal, guac_user* user) {
|
||||||
|
|||||||
@ -180,6 +180,11 @@ typedef guac_stream* guac_terminal_file_download_handler(guac_client* client, ch
|
|||||||
*/
|
*/
|
||||||
typedef struct guac_terminal_options {
|
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,
|
* Whether copying from the terminal clipboard should be blocked. If set,
|
||||||
* the contents of the terminal can still be copied, but will be usable
|
* the contents of the terminal can still be copied, but will be usable
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user