Commit Graph

796 Commits

Author SHA1 Message Date
matt335672
f4d73054a9 Use client earlyCapabilities to determine channel join count
We always now indicate we support skipping channel joins. If the client
indicates this too, expect no channel join requests from the client.

If we do get some, process them anyway.
2024-09-29 14:51:38 +01:00
matt335672
fcc82c3499 Announce server RNS_UD_SC_SKIP_CHANNELJOIN_SUPPORTED 2024-09-29 14:20:48 +01:00
matt335672
ba1d93930a Allow keycode set to be specified for the X server
This commit allows a keycode_set to be specified as a module parameter
in xrdp.ini. This has the following effects:-
1) xrdp loads the specified keycode set for mapping RDP scancodes to
   X11 keycodes. These are then passed to xorgxrdp as part of key press/
   key release events.
2) The name of the XKB rules which use the specified keycode set are
   passed to xorgxrdp so that XKB can be configured with rules which
   match the chosen keycodes.

The effect is to remove all keycode set dependencies from xorgxrdp.
Normally evdev rules and evdev keycodes will be used but base rules and
base keycodes can be used instead for applications that require them.
Also, any systems which do not ship the evdev rules can be made to
work with base rules.
2024-08-05 10:58:09 +01:00
matt335672
d83fc8a93f Add xrdp_scancode_defs.h
Add a development header xrdp_scancode_defs.h which contains
common scancode definitions for xrdp and xorgxrdp
2024-08-05 10:44:10 +01:00
matt335672
dc696f5b7f Add missing scancode map for ABNT2 KPPT
The Brazilian ABNT2 Keyboard layout contains a keypad
decimal key which doesn't exist on other keypads:-

https://www.kbdlayout.info/kbdbr/virtualkeys

This key is curently mapped in xorgxrdp to keycode 134 (basic mapping),
but isn't present in the scancode map. It needs to be added so that it
is available to VNC sessions and will be mapped for xorgxrdp when we
move to evdev keycode mappings.
2024-08-05 10:44:10 +01:00
matt335672
7fe5b3ea34 Move pause key processing from xorgxrdp
This commit moves processing of the pause key from xorgxrdp
back to xrdp itself, so that the key can be passed to the VNC
backend.
2024-08-05 10:44:10 +01:00
matt335672
5779edd23f Replace magic numbers in keyboard code with defs
- All scancode definitions are moved to scancode.h
- Magic numbers are replaced where applicable with definitions
2024-08-05 10:44:10 +01:00
matt335672
ef14039c62 Use correct names for key events
Replace definitions in ms-rdpbcgr.h marked as TODO with the
names defined in [MS-RDPBCGR]

Some other simplifications around the fake Unicode event processing
have also been made.
2024-08-05 10:44:10 +01:00
matt335672
c91ef80ca9 Implement scancode indexing
The mapping from scancodes to the indexes used in xrdp_keymap
is not well designed and contains an implicit dependency on
keycode values.

This mapping is alse slightly different from the index used for
the 'keys' map in the xrdp_wm structure.

This commit introduces support for mapping scancodes directly
to 'scancode indexes' suitable for indexing into both structures.

Some renaming is also done; [MS-RDPBCGR] uses the terms scancode
and keyCode interchangeably. An effort is made to use key_code for a
raw value from a TS_KEYBOARD_EVENT, and scancode for a value which is
produced by the scancode module.
2024-08-05 10:44:10 +01:00
matt335672
52dd88b576 Replace binary blob with specified data
This commit changes the license response PDU to be constructed rather
than simply being contained as a binary blob.

Some constants in common/ms-rdpbcgr.h are renamed with the values
from the specification.
2024-07-03 14:20:33 +01:00
matt335672
ce355fc235 Allow for xrdp not being able to delete PID file
If xrdp is running with dropped privileges it won't be able to delete
the PID file it's created. Places where xrdp is stopped need to cater
for this.

It's prefereable to do this than make the PID file writeable by xrdp
with dropped privileges, as this can still lead to DoS attacks if an
attacker manages to modify the PID file from a compromised xrdp
process.
2024-07-01 11:11:21 +01:00
matt335672
b1d8428579 Add code to drop privileges of xrdp daemon 2024-07-01 11:11:21 +01:00
matt335672
ddff9ebb32 Refactor xrdp_listen to allow for privilege drop
- xrdp_listen.c is refactored so we can create the
  listening socket(s) before dropping privileges.
- The code which reads startup params from xrdp.ini
  is moved from xrdp_listen.c to xrdp.c, so it
  is only called once if we test the listen before
  starting the daemon.
2024-07-01 11:11:21 +01:00
matt335672
620f3b6220 Pass KBDFLAGS_EXTENDED1 flag for FP scancode events
The current fastpath code for scancode events is not mapping
the FASTPATH_INPUT_KBDFLAGS_EXTENDED1 flag to the KBDFLAGS_EXTENDED1
flag.
2024-06-12 16:20:12 +01:00
matt335672
f38e215de5 Fix build with devel logging, but without --enable-pixman
If ./configure is used with devel logging, but without --enable-pixman,
the stub pixman development files are used.

However, in this configuration, the pixman_region_selfcheck() function
is declared, but not defined.

This is a regression introduced in 7e58209b19
2024-06-03 11:46:08 +01:00
Jay Sorg
2bed4f6b9b rename old_capture_code to mark unused 2024-05-28 10:57:55 -07:00
Jay Sorg
112a534f4c change capture_code to enum 2024-05-28 10:57:55 -07:00
matt335672
fe410a595d Update genkeymap executable to use new format 2024-05-24 16:33:08 +01:00
matt335672
b0cfc1a12b Add initial scancode module 2024-05-24 16:33:08 +01:00
matt335672
98d0003715
Merge pull request #3058 from seflerZ/unicode_contr
Add ibus unicode input support
2024-05-20 12:27:52 +01:00
matt335672
4e77772ea2 Fix problems detected by -fsanitize=address 2024-05-07 12:51:30 +01:00
matt335672
a2064e51c1 Some changes to Unicode input processing
- xrdp is not now built with XRDP_IBUS to allow other input
  methods to be more easily supported.
- chansrv is only aked to start an input method if the client
  supports it.
- chansrv sends a status report back to xrdp when asked to start
  and input method.
- ./configure without --enable-ibus now works.
2024-05-05 10:44:19 +08:00
firewave
5eed76f32b fixed -Wunused-function compiler warnings 2024-04-23 18:38:20 +02:00
firewave
fb9c175b11 enabled and fixed -Wmissing-prototypes compiler warnings
Co-authored-by: matt335672 <30179339+matt335672@users.noreply.github.com>
2024-04-23 18:38:20 +02:00
matt335672
f5d8fe5f3d
Merge pull request #2959 from matt335672/remove_librt_from_link
Remove unnecessary '-lrt' from common lib link
2024-03-22 12:08:11 +00:00
matt335672
fb34d742bb
Merge pull request #2910 from matt335672/fix_lfn_performance
Improve performance on long fat networks (LFNs)
2024-03-22 12:07:58 +00:00
Derek Schrock
5afbca4954 Fall back to IPv4 if IPv6 capable but don't have an IPv6 address set
When xrdp is built with IPv6 support it will only fall back to IPv4 if
IPv6 is not supported (EAFNOSUPPORT).  However, if the system is IPv6
capable but doesn't have an IPv6 address set (at least inside a FreeBSD
jail) EPROTONOSUPPORT is returned from socket().
2024-02-25 17:53:44 -05:00
matt335672
e821eddb62 Remove unnecessary '-lrt' from common lib link
The '-lrt' added to the Makefile for the common library appears
to be unnecessary.

- On modern Linuxes, this library has been merged with libc, and the
  supplied library is empty.
- On older ones (e.g. Devuan 4), the library contains routines we
  do not use in xrdp (although we use 'shm_open()' in xorgxrdp).
- On FreeBSD 14 the library contains only mq_*  and timer_* routines
  which, again, are not required.
2024-02-21 12:43:53 +00:00
matt335672
bc9b35c38c Rename struct exit_status in os_calls
This conflicts with struct exit_status in <utmp.h>
2024-02-21 09:24:48 +00:00
matt335672
27ad405cd8 Add a client_resize_mode field
This stores what kind of resizing (if any) can be achieved with
a Deactivation-Reactivation sequence.
2024-02-15 16:48:13 +00:00
matt335672
74598d1cc3 Fix sending of monitor layout PDU
From [MS-RCPBCGR] 3.3.5.12.1:-

> ...The contents of this PDU SHOULD NOT be compressed.
>
> This PDU MUST NOT be sent to a client that has not indicated support for
> it by setting the RNS_UD_CS_SUPPORT_MONITOR_LAYOUT_PDU flag (0x0040)
> in the earlyCapabilityFlags field of the Client Core Data (section
> 2.2.1.3.2).

Also, 2.2.12.1 specifies the source channel must be zero.

In testing, a compressed monitor layout PDU causes mstsc.exe
to exit with a protocol error.
2024-02-15 16:47:15 +00:00
metalefty
45fd497645
Merge pull request #2891 from neutrinolabs/gfx_mainline_merge_work
Gfx mainline merge work
2024-02-08 21:50:16 +09:00
Koichiro Iwao
47d4ab1339 Apply astyle 3.4 code formatter 2024-02-08 15:52:54 +09:00
matt335672
54acca43cf Resize state machine: A fix and a question (#2929)
* Store EGFX state before entering resize state machine

At present the EGFX state is destroyed by states WMRZ_EGFX_DELETE_SURFACE
through WRMZ_EGFX_DELETE. This means that at WMRZ_EGFX_INITIALIZE we
cannot distinguish between EGFX not being ever used, and EGFX
having been torn down. Consequently, when running non-GFX, we don't
correctly recover the session.

* Allow multiple reasons for suppress_output

Replaces the single boolean for suppress_output with
a bitmask, to allow output to be suppressed for
more than one reason

* Disable output during resize

* Add states to dynamic resize

Adds states to the dynamic resize state machine so we wait for a
Deactivation-Reactivation sequence to finish before sending pointer
updates, etc.

* suppress module output during the dynamic resize

* Add support for dynamic resize to VNC backend

xrdp_mm needs to be informed when a resize has been performed so that
the resize stte machine can be updsate.
2024-01-31 19:08:29 -05:00
matt335672
d9783a9529 Don't pass drdynvc to neutrinoRDP
Since v0.9.9, xrdp has assumed that the "drdynvc" static virtual
channel is available for its exclusive use. With GFX support, it
is necessary to codify this to prevent this sequence of operations:-

- NeutrinoRDP target sends DVC Capabilities Request PDU
- target responds wih DVC Capabilities Response PDU
- xrdp processes this, starting the GFX virtual channel again

In the future, if NeutrinoRDP requires access to virtual channels,
data may somehow need to be passed through to the target while being
parsed and handled appropriately within xrdp.
2024-01-31 19:08:29 -05:00
Nexarian
2e1f7f1484 Adding KEY_FRAME_REQUESTED parameter. 2024-01-31 19:08:29 -05:00
jsorg71
c961563403 GFX: sort versions, flags to return the highest version we support in… (#2911)
* GFX: sort versions, flags to return the highest version we support in caps advertise

* GFX: simpify swtich in caps_advertise

* GFX: log skipped capability versions in caps_advertise
2024-01-31 19:08:29 -05:00
Nexarian
584a894490 Add 0 as valid g_obj_wait timeout instead of having it be equivalent to -1. 2024-01-31 19:08:29 -05:00
Nexarian
65137e6edb More integration work from mainline_merge_shm
- Introduce functional EGFX caps.
- Prototype of RFX Progressive working.
- Update resizing to work with it.
- Refactoring
2024-01-31 19:08:29 -05:00
Nexarian
afa70e464a Initial rfx progressive integration
- Mostly base functions and utilities necessary to enable RFX
  Progressive
- Add more EGFX work & mode flags.
- Update encoder.
- Does not yet include caps determination to enable RFX progressive
  (yet).
- Update protocol constants
2024-01-31 19:08:29 -05:00
matt335672
b23d6f89d5 Improve performance on long fat networks (LFNs)
On Linux, the TCP send buffer size is increased to 32768 if it is less
that this (which it normally is). This however has the effect of disabling
dynamic buffer sizing, leading to a maximum available bandwidth of

max_bandwidth = 262144 (bits) / round_trip_time (secs)

This is not noticeable on a LAN with an RTT of around 0.5ms, but
very noticeable on a WAN with an RTT of 0.25s.

Comments in the config file and manpage in this area are improved, as
is the logging if the parameters are actually set.
2024-01-11 11:53:54 +00:00
matt335672
b80f07d2a7 Improve portability
- Use clearenv() if it exists
- Don't rely on <limits.h> being pulled in by <sys/param.h>
- Rename the DEFAULT_TYPE macro in sesrun.c.  This name appears to be
  used on Solaris. It's not a good choice.
2024-01-11 11:16:06 +00:00
matt335672
62a51dead9 Fix g_strtrim() regression
Commit 36ea4a3 failed to take UTF-8 characters into account on
platforms with signed char.
2024-01-02 11:07:28 +00:00
r-a-sattarov
aa8c651e38 common/arch.h: added e2k arch definition
Ref: https://en.wikipedia.org/wiki/Elbrus_(computer)
2023-12-11 22:34:17 +03:00
matt335672
c52a173db0 Use symbolic constants in the modules for WM events 2023-11-27 15:42:24 +00:00
matt335672
cdf574cf6c Allow for empty fields in TS_EXTENDED_INFO_PACKET
Some clients appears to be sending cbClientAddress and/or cbClientDir
as 0 in the TS_EXTENDED_INFO_PACKET. This appears to be at odds with
[MS-RDPBCGR] which requires mandatory terminators for these fields.
2023-11-13 10:26:20 +00:00
matt335672
50cff2eb75
Merge pull request #2794 from matt335672/utf_changes_new
Improve Unicode support
2023-11-02 10:57:39 +00:00
matt335672
76d12c50a8
Merge pull request #2838 from matt335672/fix_devredir_ordering
Fix message ordering in devredir
2023-10-26 15:28:10 +01:00
matt335672
7ceff70c1c Fix message ordering in devredir
The drive redirector is not compliant with the message ordering
in [MS-RDPEFS], causing FreeRDP 2.11.2 ro fail on redirecting drives.
2023-10-26 15:17:17 +01:00
matt335672
675dd77807 Parameterise the sockdir with the UID of the user
The top level socket directory is now called XRDP_SOCKET_ROOT_PATH.
Below that are user-specific directories referred to with the
XRDP_SOCKET_PATH macro - this name is hard-coded into xorgxrdp and
the audio modules as an environment variable.

XRDP_SOCKET_PATH now looks like $XRDP_SOCKET_ROOT_PATH/<uid>

XRDP_SOCKET_PATH is only writeable by the user, and readable by the user
and the xrdp process.
2023-10-23 18:14:46 +01:00