From 35bc7c1d65732518186c874ff5425c7c561a0a24 Mon Sep 17 00:00:00 2001 From: Koichiro IWAO Date: Fri, 9 Dec 2016 10:35:21 +0900 Subject: [PATCH 1/7] sesman: unbreak FreeBSD build after #523 --- sesman/session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sesman/session.c b/sesman/session.c index 4b059fbc..783665cf 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -528,10 +528,10 @@ session_start_fork(tbus data, tui8 type, struct SCP_SESSION *s) "setsid failed - pid %d", g_getpid()); } - if (g_setlogin(username) < 0) + if (g_setlogin(s->username) < 0) { log_message(LOG_LEVEL_ERROR, - "setlogin failed for user %s - pid %d", username, + "setlogin failed for user %s - pid %d", s->username, g_getpid()); } } From d97155e2f6a35726f0ee2bde82fbabf4607b87d3 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 9 Dec 2016 03:08:27 +0000 Subject: [PATCH 2/7] Don't use colon to separate IPv6 address from the port IPv6 addresses can have colons in their names, so the final colon can be confusing. --- common/os_calls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/os_calls.c b/common/os_calls.c index 9ebaa880..5db59caa 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -681,7 +681,7 @@ g_sck_close(int sck) char addr[48]; struct sockaddr_in6 *sock_addr_in6 = &sock_info.sock_addr_in6; - g_snprintf(sockname, sizeof(sockname), "AF_INET6 %s:%d", + g_snprintf(sockname, sizeof(sockname), "AF_INET6 %s port %d", inet_ntop(sock_addr_in6->sin6_family, &sock_addr_in6->sin6_addr, addr, sizeof(addr)), ntohs(sock_addr_in6->sin6_port)); From a8fcbf8c2dc48f0e015093e061c5b7efb63fbdc1 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Wed, 7 Dec 2016 23:59:04 -0800 Subject: [PATCH 3/7] Fix support for 32-bpp clients connecting to 16-bpp VNC --- vnc/vnc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vnc/vnc.c b/vnc/vnc.c index 8fe3a8bc..3a91ea9d 100644 --- a/vnc/vnc.c +++ b/vnc/vnc.c @@ -1288,7 +1288,7 @@ lib_mod_connect(struct vnc *v) out_uint8(pixel_format, 0); /* blue shift */ out_uint8s(pixel_format, 3); /* pad */ } - else if (v->mod_bpp == 24) + else if (v->mod_bpp == 24 || v->mod_bpp == 32) { out_uint8(pixel_format, 32); /* bits per pixel */ out_uint8(pixel_format, 24); /* depth */ From 4f04801b11d6e712e97fa50941af8f8b0cdc7f59 Mon Sep 17 00:00:00 2001 From: speidy Date: Sat, 10 Dec 2016 02:00:16 -0500 Subject: [PATCH 4/7] o caps: advertise remotefx codec capsets only when supported (RFX mode, proxy mode) o xrdp_encoder: do not initialze encoder context for RFX when rfxcodec is not supported --- libxrdp/xrdp_caps.c | 2 ++ xrdp/xrdp_encoder.c | 25 +++++++------------------ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/libxrdp/xrdp_caps.c b/libxrdp/xrdp_caps.c index 8d5250d5..a7d1ae1a 100644 --- a/libxrdp/xrdp_caps.c +++ b/libxrdp/xrdp_caps.c @@ -831,12 +831,14 @@ xrdp_caps_send_demand_active(struct xrdp_rdp *self) out_uint8(s, 0x01); /* fAllowDynamicFidelity */ out_uint8(s, 0x01); /* fAllowSubsampling */ out_uint8(s, 0x03); /* colorLossLevel */ +#if defined(XRDP_RFXCODEC) || defined(XRDP_NEUTRINORDP) /* remotefx */ codec_caps_count++; out_uint8a(s, XR_CODEC_GUID_REMOTEFX, 16); out_uint8(s, 0); /* codec id, client sets */ out_uint16_le(s, 256); out_uint8s(s, 256); +#endif /* jpeg */ codec_caps_count++; out_uint8a(s, XR_CODEC_GUID_JPEG, 16); diff --git a/xrdp/xrdp_encoder.c b/xrdp/xrdp_encoder.c index 643fe0aa..5c9832ee 100644 --- a/xrdp/xrdp_encoder.c +++ b/xrdp/xrdp_encoder.c @@ -42,8 +42,10 @@ /*****************************************************************************/ static int process_enc_jpg(struct xrdp_encoder *self, XRDP_ENC_DATA *enc); +#ifdef XRDP_RFXCODEC static int process_enc_rfx(struct xrdp_encoder *self, XRDP_ENC_DATA *enc); +#endif static int process_enc_h264(struct xrdp_encoder *self, XRDP_ENC_DATA *enc); @@ -87,6 +89,7 @@ xrdp_encoder_create(struct xrdp_mm *mm) (32 << 24) | (3 << 16) | (8 << 12) | (8 << 8) | (8 << 4) | 8; self->process_enc = process_enc_jpg; } +#ifdef XRDP_RFXCODEC else if (client_info->rfx_codec_id != 0) { LLOGLN(0, ("xrdp_encoder_create: starting rfx codec session")); @@ -94,13 +97,11 @@ xrdp_encoder_create(struct xrdp_mm *mm) self->in_codec_mode = 1; client_info->capture_code = 2; self->process_enc = process_enc_rfx; -#ifdef XRDP_RFXCODEC - self->codec_handle = - rfxcodec_encode_create(mm->wm->screen->width, - mm->wm->screen->height, - RFX_FORMAT_YUV, 0); -#endif + self->codec_handle = rfxcodec_encode_create(mm->wm->screen->width, + mm->wm->screen->height, + RFX_FORMAT_YUV, 0); } +#endif else if (client_info->h264_codec_id != 0) { LLOGLN(0, ("xrdp_encoder_create: starting h264 codec session")); @@ -296,7 +297,6 @@ process_enc_jpg(struct xrdp_encoder *self, XRDP_ENC_DATA *enc) } #ifdef XRDP_RFXCODEC - /*****************************************************************************/ /* called from encoder thread */ static int @@ -399,17 +399,6 @@ process_enc_rfx(struct xrdp_encoder *self, XRDP_ENC_DATA *enc) return 0; } - -#else - -/*****************************************************************************/ -/* called from encoder thread */ -static int -process_enc_rfx(struct xrdp_encoder *self, XRDP_ENC_DATA *enc) -{ - return 0; -} - #endif /*****************************************************************************/ From 2f8d3ba9da68c120a5a4f156a0da06c135b9e862 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sat, 10 Dec 2016 00:11:28 -0800 Subject: [PATCH 5/7] add unicode support --- common/xrdp_constants.h | 1 + libxrdp/xrdp_caps.c | 3 +- libxrdp/xrdp_fastpath.c | 30 ++++++++++++---- xrdp/xrdp_wm.c | 77 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+), 7 deletions(-) diff --git a/common/xrdp_constants.h b/common/xrdp_constants.h index 7dcb3064..795264a5 100644 --- a/common/xrdp_constants.h +++ b/common/xrdp_constants.h @@ -160,6 +160,7 @@ #define RDP_INPUT_CODEPOINT 1 #define RDP_INPUT_VIRTKEY 2 #define RDP_INPUT_SCANCODE 4 +#define RDP_INPUT_UNICODE 5 #define RDP_INPUT_MOUSE 0x8001 #define RDP_INPUT_MOUSEX 0x8002 diff --git a/libxrdp/xrdp_caps.c b/libxrdp/xrdp_caps.c index 8d5250d5..bb1cd619 100644 --- a/libxrdp/xrdp_caps.c +++ b/libxrdp/xrdp_caps.c @@ -872,9 +872,10 @@ xrdp_caps_send_demand_active(struct xrdp_rdp *self) /* INPUT_FLAG_SCANCODES 0x0001 INPUT_FLAG_MOUSEX 0x0004 + INPUT_FLAG_UNICODE 0x0010 INPUT_FLAG_FASTPATH_INPUT 0x0008 INPUT_FLAG_FASTPATH_INPUT2 0x0020 */ - flags = 0x0001 | 0x0004; + flags = 0x0001 | 0x0004 | 0x0010; if (self->client_info.use_fast_path & 2) { /* 0x0008 INPUT_FLAG_FASTPATH_INPUT */ diff --git a/libxrdp/xrdp_fastpath.c b/libxrdp/xrdp_fastpath.c index 008c8289..daa08373 100644 --- a/libxrdp/xrdp_fastpath.c +++ b/libxrdp/xrdp_fastpath.c @@ -265,12 +265,30 @@ static int APP_CC xrdp_fastpath_process_EVENT_UNICODE(struct xrdp_fastpath *self, int eventFlags, struct stream *s) { - if (!s_check_rem(s, 2)) - { - return 1; - } - in_uint8s(s, 2); - return 0; + int flags; + int code; + + flags = 0; + if (!s_check_rem(s, 2)) + { + return 1; + } + in_uint16_le(s, code); /* keyCode (1 byte) */ + if (eventFlags & FASTPATH_INPUT_KBDFLAGS_RELEASE) + { + flags |= KBD_FLAG_UP; + } + else + { + flags |= KBD_FLAG_DOWN; + } + if (eventFlags & FASTPATH_INPUT_KBDFLAGS_EXTENDED) + { + flags |= KBD_FLAG_EXT; + } + xrdp_fastpath_session_callback(self, RDP_INPUT_UNICODE, + code, 0, flags, 0); + return 0; } /*****************************************************************************/ diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 4917c3aa..26d488ec 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -1525,6 +1525,80 @@ xrdp_wm_key_sync(struct xrdp_wm *self, int device_flags, int key_flags) return 0; } +/*****************************************************************************/ +int APP_CC +xrdp_wm_key_unicode(struct xrdp_wm *self, int device_flags, int unicode) +{ + int index; + + for (index = 8; index < 256; index++) + { + if (unicode == self->keymap.keys_noshift[index].chr) + { + xrdp_wm_key(self, device_flags, index - 8); + return 0; + } + } + + for (index = 8; index < 256; index++) + { + if (unicode == self->keymap.keys_shift[index].chr) + { + if (device_flags & KBD_FLAG_UP) + { + xrdp_wm_key(self, device_flags, index - 8); + xrdp_wm_key(self, KBD_FLAG_UP, 42); + } + else + { + xrdp_wm_key(self, KBD_FLAG_DOWN, 42); + xrdp_wm_key(self, device_flags, index - 8); + } + return 0; + } + } + + for (index = 8; index < 256; index++) + { + if (unicode == self->keymap.keys_altgr[index].chr) + { + if (device_flags & KBD_FLAG_UP) + { + xrdp_wm_key(self, device_flags, index - 8); + xrdp_wm_key(self, KBD_FLAG_UP | KBD_FLAG_EXT, 56); + } + else + { + xrdp_wm_key(self, KBD_FLAG_DOWN | KBD_FLAG_EXT, 56); + xrdp_wm_key(self, device_flags, index - 8); + } + return 0; + } + } + + for (index = 8; index < 256; index++) + { + if (unicode == self->keymap.keys_shiftaltgr[index].chr) + { + if (device_flags & KBD_FLAG_UP) + { + xrdp_wm_key(self, device_flags, index - 8); + xrdp_wm_key(self, KBD_FLAG_UP | KBD_FLAG_EXT, 56); + xrdp_wm_key(self, KBD_FLAG_UP, 42); + } + else + { + xrdp_wm_key(self, KBD_FLAG_DOWN, 42); + xrdp_wm_key(self, KBD_FLAG_DOWN | KBD_FLAG_EXT, 56); + xrdp_wm_key(self, device_flags, index - 8); + } + return 0; + } + } + + return 0; +} + /*****************************************************************************/ int APP_CC xrdp_wm_pu(struct xrdp_wm *self, struct xrdp_bitmap *control) @@ -1721,6 +1795,9 @@ callback(long id, int msg, long param1, long param2, long param3, long param4) case 4: /* RDP_INPUT_SCANCODE */ rv = xrdp_wm_key(wm, param3, param1); break; + case 5: /* RDP_INPUT_UNICODE */ + rv = xrdp_wm_key_unicode(wm, param3, param1); + break; case 0x8001: /* RDP_INPUT_MOUSE */ rv = xrdp_wm_process_input_mouse(wm, param3, param1, param2); break; From 7a1a481ff997d64028de6f0cdc5ab6b42b28f91d Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sat, 10 Dec 2016 00:43:33 -0800 Subject: [PATCH 6/7] use defines for flags --- libxrdp/xrdp_caps.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libxrdp/xrdp_caps.c b/libxrdp/xrdp_caps.c index bb1cd619..bfba63a0 100644 --- a/libxrdp/xrdp_caps.c +++ b/libxrdp/xrdp_caps.c @@ -870,17 +870,10 @@ xrdp_caps_send_demand_active(struct xrdp_rdp *self) out_uint16_le(s, RDP_CAPSET_INPUT); /* 13(0xd) */ out_uint16_le(s, RDP_CAPLEN_INPUT); /* 88(0x58) */ - /* INPUT_FLAG_SCANCODES 0x0001 - INPUT_FLAG_MOUSEX 0x0004 - INPUT_FLAG_UNICODE 0x0010 - INPUT_FLAG_FASTPATH_INPUT 0x0008 - INPUT_FLAG_FASTPATH_INPUT2 0x0020 */ - flags = 0x0001 | 0x0004 | 0x0010; + flags = INPUT_FLAG_SCANCODES | INPUT_FLAG_MOUSEX | INPUT_FLAG_UNICODE; if (self->client_info.use_fast_path & 2) { - /* 0x0008 INPUT_FLAG_FASTPATH_INPUT */ - /* 0x0020 INPUT_FLAG_FASTPATH_INPUT2 */ - flags |= 0x0008 | 0x0020; + flags |= INPUT_FLAG_FASTPATH_INPUT | INPUT_FLAG_FASTPATH_INPUT2; } out_uint16_le(s, flags); out_uint8s(s, 82); From c264862afe5ef3b21f0774bc108782fbc68bede3 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sat, 10 Dec 2016 01:06:45 -0800 Subject: [PATCH 7/7] change some magics to defines --- common/xrdp_constants.h | 6 ++++++ libxrdp/xrdp_fastpath.c | 2 +- xrdp/xrdp_wm.c | 41 ++++++++++++++++++++++------------------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/common/xrdp_constants.h b/common/xrdp_constants.h index 795264a5..3ac8504f 100644 --- a/common/xrdp_constants.h +++ b/common/xrdp_constants.h @@ -623,4 +623,10 @@ #define XRDP_MAX_BITMAP_CACHE_IDX 2000 #define XRDP_BITMAP_CACHE_ENTRIES 2048 +#define XR_MIN_KEY_CODE 8 +#define XR_MAX_KEY_CODE 256 + +#define XR_RDP_SCAN_LSHIFT 42 +#define XR_RDP_SCAN_ALT 56 + #endif diff --git a/libxrdp/xrdp_fastpath.c b/libxrdp/xrdp_fastpath.c index daa08373..33e9c9d0 100644 --- a/libxrdp/xrdp_fastpath.c +++ b/libxrdp/xrdp_fastpath.c @@ -273,7 +273,7 @@ xrdp_fastpath_process_EVENT_UNICODE(struct xrdp_fastpath *self, { return 1; } - in_uint16_le(s, code); /* keyCode (1 byte) */ + in_uint16_le(s, code); /* unicode (2 byte) */ if (eventFlags & FASTPATH_INPUT_KBDFLAGS_RELEASE) { flags |= KBD_FLAG_UP; diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 26d488ec..446939bc 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -1531,66 +1531,69 @@ xrdp_wm_key_unicode(struct xrdp_wm *self, int device_flags, int unicode) { int index; - for (index = 8; index < 256; index++) + for (index = XR_MIN_KEY_CODE; index < XR_MAX_KEY_CODE; index++) { if (unicode == self->keymap.keys_noshift[index].chr) { - xrdp_wm_key(self, device_flags, index - 8); + xrdp_wm_key(self, device_flags, index - XR_MIN_KEY_CODE); return 0; } } - for (index = 8; index < 256; index++) + for (index = XR_MIN_KEY_CODE; index < XR_MAX_KEY_CODE; index++) { if (unicode == self->keymap.keys_shift[index].chr) { if (device_flags & KBD_FLAG_UP) { - xrdp_wm_key(self, device_flags, index - 8); - xrdp_wm_key(self, KBD_FLAG_UP, 42); + xrdp_wm_key(self, device_flags, index - XR_MIN_KEY_CODE); + xrdp_wm_key(self, KBD_FLAG_UP, XR_RDP_SCAN_LSHIFT); } else { - xrdp_wm_key(self, KBD_FLAG_DOWN, 42); - xrdp_wm_key(self, device_flags, index - 8); + xrdp_wm_key(self, KBD_FLAG_DOWN, XR_RDP_SCAN_LSHIFT); + xrdp_wm_key(self, device_flags, index - XR_MIN_KEY_CODE); } return 0; } } - for (index = 8; index < 256; index++) + for (index = XR_MIN_KEY_CODE; index < XR_MAX_KEY_CODE; index++) { if (unicode == self->keymap.keys_altgr[index].chr) { if (device_flags & KBD_FLAG_UP) { - xrdp_wm_key(self, device_flags, index - 8); - xrdp_wm_key(self, KBD_FLAG_UP | KBD_FLAG_EXT, 56); + xrdp_wm_key(self, device_flags, index - XR_MIN_KEY_CODE); + xrdp_wm_key(self, KBD_FLAG_UP | KBD_FLAG_EXT, + XR_RDP_SCAN_ALT); } else { - xrdp_wm_key(self, KBD_FLAG_DOWN | KBD_FLAG_EXT, 56); - xrdp_wm_key(self, device_flags, index - 8); + xrdp_wm_key(self, KBD_FLAG_DOWN | KBD_FLAG_EXT, + XR_RDP_SCAN_ALT); + xrdp_wm_key(self, device_flags, index - XR_MIN_KEY_CODE); } return 0; } } - for (index = 8; index < 256; index++) + for (index = XR_MIN_KEY_CODE; index < XR_MAX_KEY_CODE; index++) { if (unicode == self->keymap.keys_shiftaltgr[index].chr) { if (device_flags & KBD_FLAG_UP) { - xrdp_wm_key(self, device_flags, index - 8); - xrdp_wm_key(self, KBD_FLAG_UP | KBD_FLAG_EXT, 56); - xrdp_wm_key(self, KBD_FLAG_UP, 42); + xrdp_wm_key(self, device_flags, index - XR_MIN_KEY_CODE); + xrdp_wm_key(self, KBD_FLAG_UP | KBD_FLAG_EXT, XR_RDP_SCAN_ALT); + xrdp_wm_key(self, KBD_FLAG_UP, XR_RDP_SCAN_LSHIFT); } else { - xrdp_wm_key(self, KBD_FLAG_DOWN, 42); - xrdp_wm_key(self, KBD_FLAG_DOWN | KBD_FLAG_EXT, 56); - xrdp_wm_key(self, device_flags, index - 8); + xrdp_wm_key(self, KBD_FLAG_DOWN, XR_RDP_SCAN_LSHIFT); + xrdp_wm_key(self, KBD_FLAG_DOWN | KBD_FLAG_EXT, + XR_RDP_SCAN_ALT); + xrdp_wm_key(self, device_flags, index - XR_MIN_KEY_CODE); } return 0; }