From badc612a8acd09602d33111a1fd4b242284b9e3d Mon Sep 17 00:00:00 2001 From: TOMATO-ONE Date: Fri, 23 Jul 2021 13:31:04 +0000 Subject: [PATCH 1/2] override keyboard infomation #1950 --- common/xrdp_client_info.h | 13 ++++++++++++- libxrdp/xrdp_rdp.c | 12 ++++++++++++ libxrdp/xrdp_sec.c | 29 +++++++++++++++++++++++++++-- xrdp/xrdp.ini.in | 6 ++++++ 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/common/xrdp_client_info.h b/common/xrdp_client_info.h index 48522105..c95d0649 100644 --- a/common/xrdp_client_info.h +++ b/common/xrdp_client_info.h @@ -33,6 +33,14 @@ struct monitor_info int is_primary; }; +/* xrdp keyboard overrids */ +struct xrdp_keyboard_overrides +{ + int type; + int subtype; + int layout; +}; + /** * Information about the xrdp client * @@ -172,9 +180,12 @@ struct xrdp_client_info int enable_token_login; char domain_user_separator[16]; + + /* xrdp.override_* values */ + struct xrdp_keyboard_overrides xrdp_keyboard_overrides; }; /* yyyymmdd of last incompatible change to xrdp_client_info */ -#define CLIENT_INFO_CURRENT_VERSION 20210225 +#define CLIENT_INFO_CURRENT_VERSION 20210723 #endif diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c index b8528377..59ddd97f 100644 --- a/libxrdp/xrdp_rdp.c +++ b/libxrdp/xrdp_rdp.c @@ -278,6 +278,18 @@ xrdp_rdp_read_config(const char *xrdp_ini, struct xrdp_client_info *client_info) { g_strncpy(client_info->domain_user_separator, value, sizeof(client_info->domain_user_separator) - 1); } + else if (g_strcasecmp(item, "xrdp.override_keyboard_type") == 0) + { + client_info->xrdp_keyboard_overrides.type = g_atoix(value); + } + else if (g_strcasecmp(item, "xrdp.override_keyboard_subtype") == 0) + { + client_info->xrdp_keyboard_overrides.subtype = g_atoix(value); + } + else if (g_strcasecmp(item, "xrdp.override_keylayout") == 0) + { + client_info->xrdp_keyboard_overrides.layout = g_atoix(value); + } } list_delete(items); diff --git a/libxrdp/xrdp_sec.c b/libxrdp/xrdp_sec.c index 8978c0af..2ad3f4cb 100644 --- a/libxrdp/xrdp_sec.c +++ b/libxrdp/xrdp_sec.c @@ -374,9 +374,34 @@ xrdp_load_keyboard_layout(struct xrdp_client_info *client_info) char keyboard_cfg_file[256] = { 0 }; char rdp_layout[256] = { 0 }; - LOG(LOG_LEVEL_INFO, "xrdp_load_keyboard_layout: keyboard_type [%d] keyboard_subtype [%d]", - client_info->keyboard_type, client_info->keyboard_subtype); + const struct xrdp_keyboard_overrides *ko = + &client_info->xrdp_keyboard_overrides; + LOG(LOG_LEVEL_INFO, "xrdp_load_keyboard_layout: Keyboard information sent" + " by the RDP client, keyboard_type:[0x%02X], keyboard_subtype:[0x%02X]," + " keylayout:[0x%08X]", + client_info->keyboard_type, client_info->keyboard_subtype, + client_info->keylayout); + + if (ko->type != 0) + { + LOG(LOG_LEVEL_INFO, "overrode keyboard_type 0x%02X" + " with 0x%02X", client_info->keyboard_type, ko->type); + client_info->keyboard_type = ko->type; + } + if (ko->subtype != 0) + { + LOG(LOG_LEVEL_INFO, "overrode keyboard_subtype 0x%02X" + " with 0x%02X", client_info->keyboard_subtype, + ko->subtype); + client_info->keyboard_subtype = ko->subtype; + } + if (ko->layout != 0) + { + LOG(LOG_LEVEL_INFO, "overrode keylayout 0x%08X" + " with 0x%08X", client_info->keylayout, ko->layout); + client_info->keylayout = ko->layout; + } /* infer model/variant */ /* TODO specify different X11 keyboard models/variants */ g_memset(client_info->model, 0, sizeof(client_info->model)); diff --git a/xrdp/xrdp.ini.in b/xrdp/xrdp.ini.in index c84aad13..d2290f44 100644 --- a/xrdp/xrdp.ini.in +++ b/xrdp/xrdp.ini.in @@ -63,6 +63,12 @@ ssl_protocols=TLSv1.2, TLSv1.3 ; for example when the server is multi homed with SSSd #domain_user_separator=@ +; The following options will override the keyboard layout settings. +; These options are for DEBUG and are not recommended for regular use. +#xrdp.override_keyboard_type=0x04 +#xrdp.override_keyboard_subtype=0x01 +#xrdp.override_keylayout=0x00000409 + ; Section name to use for automatic login if the client sends username ; and password. If empty, the domain name sent by the client is used. ; If empty and no domain name is given, the first suitable section in From 7847b2380893a56ab57ad401716d5ecfbeafa1be Mon Sep 17 00:00:00 2001 From: TOMATO-ONE Date: Sun, 15 Aug 2021 23:54:26 +0900 Subject: [PATCH 2/2] Bug fix when parameter is 0 --- libxrdp/xrdp_rdp.c | 4 ++++ libxrdp/xrdp_sec.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c index 59ddd97f..3d7df482 100644 --- a/libxrdp/xrdp_rdp.c +++ b/libxrdp/xrdp_rdp.c @@ -50,6 +50,10 @@ xrdp_rdp_read_config(const char *xrdp_ini, struct xrdp_client_info *client_info) char *tmp = NULL; int tmp_length = 0; + client_info->xrdp_keyboard_overrides.type = -1; + client_info->xrdp_keyboard_overrides.subtype = -1; + client_info->xrdp_keyboard_overrides.layout = -1; + /* initialize (zero out) local variables: */ items = list_create(); items->auto_free = 1; diff --git a/libxrdp/xrdp_sec.c b/libxrdp/xrdp_sec.c index 2ad3f4cb..c5b34272 100644 --- a/libxrdp/xrdp_sec.c +++ b/libxrdp/xrdp_sec.c @@ -383,20 +383,20 @@ xrdp_load_keyboard_layout(struct xrdp_client_info *client_info) client_info->keyboard_type, client_info->keyboard_subtype, client_info->keylayout); - if (ko->type != 0) + if (ko->type != -1) { LOG(LOG_LEVEL_INFO, "overrode keyboard_type 0x%02X" " with 0x%02X", client_info->keyboard_type, ko->type); client_info->keyboard_type = ko->type; } - if (ko->subtype != 0) + if (ko->subtype != -1) { LOG(LOG_LEVEL_INFO, "overrode keyboard_subtype 0x%02X" " with 0x%02X", client_info->keyboard_subtype, ko->subtype); client_info->keyboard_subtype = ko->subtype; } - if (ko->layout != 0) + if (ko->layout != -1) { LOG(LOG_LEVEL_INFO, "overrode keylayout 0x%08X" " with 0x%08X", client_info->keylayout, ko->layout);