From 62e086bdbc922e98d5decae473b27ff413dffce5 Mon Sep 17 00:00:00 2001 From: Corentin SORIANO Date: Tue, 29 Oct 2024 13:42:53 +0100 Subject: [PATCH] GUACAMOLE-288: Add parameter to limit the usage of multiple monitors. --- src/protocols/rdp/channels/disp.c | 4 ++++ src/protocols/rdp/settings.c | 12 ++++++++++++ src/protocols/rdp/settings.h | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/src/protocols/rdp/channels/disp.c b/src/protocols/rdp/channels/disp.c index bad459b94..db43e57b8 100644 --- a/src/protocols/rdp/channels/disp.c +++ b/src/protocols/rdp/channels/disp.c @@ -195,6 +195,10 @@ void guac_rdp_disp_update_size(guac_rdp_disp* disp, int height = disp->requested_height; int monitors_count = disp->requested_monitors; + /* Prevent opening too many monitors than allowed */ + if (settings->max_secondary_monitors < monitors_count) + monitors_count = settings->max_secondary_monitors; + /* Do not update size if no requests have been received */ if (width == 0 || height == 0) return; diff --git a/src/protocols/rdp/settings.c b/src/protocols/rdp/settings.c index eb7c45d5f..6a5586a03 100644 --- a/src/protocols/rdp/settings.c +++ b/src/protocols/rdp/settings.c @@ -128,6 +128,7 @@ const char* GUAC_RDP_CLIENT_ARGS[] = { "create-recording-path", "recording-write-existing", "resize-method", + "secondary-monitors", "enable-audio-input", "enable-touch", "read-only", @@ -598,6 +599,12 @@ enum RDP_ARGS_IDX { */ IDX_RESIZE_METHOD, + /** + * The maximum allowed count of secondary monitors. + * 0 to disable. + */ + IDX_SECONDARY_MONITORS, + /** * "true" if audio input (microphone) should be enabled for the RDP * connection, "false" or blank otherwise. @@ -1234,6 +1241,11 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user, settings->resize_method = GUAC_RESIZE_NONE; } + /* Maximum secondary monitors (default 0 = disabled) */ + settings->max_secondary_monitors = + guac_user_parse_args_int(user, GUAC_RDP_CLIENT_ARGS, argv, + IDX_SECONDARY_MONITORS, 0); + /* RDP Graphics Pipeline enable/disable */ settings->enable_gfx = !guac_user_parse_args_boolean(user, GUAC_RDP_CLIENT_ARGS, argv, diff --git a/src/protocols/rdp/settings.h b/src/protocols/rdp/settings.h index 253b7628b..b337e7b44 100644 --- a/src/protocols/rdp/settings.h +++ b/src/protocols/rdp/settings.h @@ -596,6 +596,11 @@ typedef struct guac_rdp_settings { */ guac_rdp_resize_method resize_method; + /** + * The maximum allowed count of secondary monitors. + */ + int max_secondary_monitors; + /** * Whether audio input (microphone) is enabled. */