Commit Graph

980 Commits

Author SHA1 Message Date
metalefty 27f0febb04
Merge pull request #3218 from metalefty/gfx_codec_order
GFX: add config which to prefer H264 vs RFX
2024-08-29 22:51:57 +09:00
matt335672 5351511272 Further changes to selectable H.264 support
- Fix CI errors
- tconfig_load_gfx() removes H.264 from the supported codec list
  if significant errors are found loading the H.264 configuration
- tconfig_load_gfx() always produces a usable config, even if the
  specified file can't be loaded
2024-08-29 21:02:36 +09:00
matt335672 1ac216da1d Rework codec order in tconfig
Replaced codec idx values with a list of codecs from the
config file.

Added some logging for debugging
2024-08-28 21:18:05 +09:00
Koichiro Iwao 2c2585cc90 GFX: use the preferred codec preferred in the config (H264 or RFX) 2024-08-27 11:46:52 +09:00
Koichiro Iwao 7238f8f99d Introduce XRDP_H264 macro to indicate any H264 encoder enabled 2024-08-27 11:46:52 +09:00
Koichiro Iwao 07e4e23c7b tconfig: add config which to prefer H264 vs RFX 2024-08-27 11:46:47 +09:00
matt335672 8f21f43768
Merge pull request #3198 from matt335672/add_pointer_guards
Add guards to xrdp_mm_module_cleanup
2024-08-26 16:06:38 +01:00
Koichiro Iwao b9d593bc11 tconfig: refine logging 2024-08-24 12:43:58 +09:00
Koichiro Iwao 16ef3dc3a8 tconfig: set proper default value for fps_den 2024-08-24 00:07:11 +09:00
Koichiro Iwao 6aeb364c8d x264: Update x264 encoding parameters 2024-08-23 14:01:19 +09:00
Koichiro Iwao 010b6a3dbf x264: apply encoding parameters per connection type 2024-08-23 10:41:04 +09:00
Koichiro Iwao d50c2fd4e4 tconfig: Makefile changes 2024-08-23 10:40:58 +09:00
Koichiro Iwao b3513ba8df tconfig: add new toml config parser for gfx.toml 2024-08-23 10:40:44 +09:00
matt335672 413c8c833d Add guards to xrdp_mm_module_cleanup
Adds pointer checks to less commonly used codepaths to prevent
a possible SEGV on process shutdown.
2024-08-06 13:05:14 +01:00
matt335672 3f568b42fb Store TS_SYNC_EVENT before module load
When a connection is made to a system with the client numlock pressed, a
TS_SYNC_EVENT is sent before the module is loaded. This TS_SYNC_EVENT
correctly contains the NumLock status as 'pressed'. The event is, however,
discarded as the module isn't loaded.

When the module is loaded, a TS_SYNC_EVENT is not sent again unless
client focus is removed from the xrdp window and re-applied. As a
result, the NumLock state is incorrect unless this is done.

This commit stores the last TS_SYNC_EVENT sent before a module is
loaded. When the module is loaded, the sync state can be correctly
communicated to the module.
2024-08-05 10:58:09 +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 c9a2039858 Move and rename xrdp_load_keyboard_layout()
xrdp_load_keyboard_layout() is used exclusively by the xup module to
work out the parameters to pass to xorgxrdp for XKB. This function
does not need to be called locally from the SEC module.

This commit moves the function to xrdp/lang.c and renames it as
xrdp_init_xkb_layout(). The module interface is modified so that xup can
call this function. Other modules do not need to call it.
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
metalefty f1d3b21177
Merge pull request #3189 from metalefty/tarball
Include {xrdp,sesman}.ini.in instead of substituted .ini in tarball
2024-08-01 21:17:43 +09:00
Koichiro Iwao 5e95fc0cb3 Include {xrdp,sesman}.ini.in instead of substituted .ini in tarball
These config files are intended to be substituted during the build
process. The substituted .ini files should not be included in release
tarballs.

Fixes:  #3187
(cherry picked from commit 19bacc6e49)
2024-08-01 20:40:25 +09:00
metalefty ecebe4588a
Merge pull request #2973 from metalefty/compression-level-options
GFX: selectable lossy compression levels
2024-07-30 10:22:20 +09:00
metalefty 19c111c74c
Merge pull request from GHSA-7w22-h4w7-8j5j
Enforce no login screen if require_credentials is set
2024-07-11 09:37:12 +09:00
matt335672 48255da29a Add xrdp-chkpriv script to check xrdp privileges 2024-07-01 11:11:21 +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 2446c206e6 xrdp: PID file handling tidy-ups
Now we have g_file_open_rw() we don't need to try to write to
the PID file to see if we can. Just leave the file open and write to
it after forking.
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 17a56567d2 Add params to allow xrdp to be run as non-root
runtime_user and runtime_group are added to the xrdp.ini file
so that the service knows how to reduce privilege
2024-07-01 11:11:21 +01:00
matt335672 8ac2f6db34 Enforce no login screen if require_credentials is set
If the setting require_credentials is true, there should be no way
for the user to get to a login screen.

This commit makes the following changes if this flag is active:-
- Makes the checks around TS_INFO_PACKET more explicit.
- Closes the connection if the first login attempt fails.
2024-06-27 11:53:52 +01:00
matt335672 1d927add29
Merge pull request #3111 from matt335672/investigate_gfx_min_max_issue
Fix min/max monitor placing issue
2024-06-19 09:13:40 +01:00
matt335672 a1b7c17906 Replace 'dvorak' keyboard description with 'us(dvorak)'
In the words of @iskunk

It is no longer possible to refer to the Dvorak layout as just "dvorak"
(as when one would run "setxkbmap dvorak"); one must now use either
"us dvorak" or "us(dvorak)"

See https://bugs.debian.org/1063725
2024-06-12 10:46:32 +01:00
matt335672 095f0d0e4c Fix min/max monitor placing issue
when a multi-monitor session has the top-left vertex of the primary
monitor at a desktop location other than (0,0), minimising and maximising
the session results in the (0,0) co-ordinate of the entire desktop being
placed at the top-left of the primary monitor.

The implementation seems to be at odds with [MS-RDPEGFX] 2.2.2.14 which
suggests the monitorDefArray of the RDPGFX_RESET_GRAPHICS_PDU should be
the same as that in the Monitor Layout PDU ([MS-RDPBCGR] 2.2.12.1)
2024-06-10 20:01:56 +01:00
matt335672 985b0de35e Add explicit object for the encoder finishing
On a resize, the encoder is deleted. At present this is done by asking
the encoder to exit, and then waiting a second.

- On slower systems, a second may not be enough, and so the encoder
  data structures are freed while they are still being used by the
  encoder.
- On quicker systems, resizes are delayed by hundreds of milliseconds
  longer than they need to be.

This commit adds a wait object which the encoder can use to signal it
has actually finished.
2024-06-03 16:00:31 +01:00
matt335672 809df89c08 Prevent SEGV when resizing with GFX
The xrdp_enc_data contains a union for handling surface commands
and gfx commands. Memory processing is different for these two
options.

The default destructor for the encoder FIFO only knows about surface
commands. Consequently, if the encoder has queued GFX data when the
encoder is closed, the destructor processes the queued data as if
it contained surface commands rather than GFX commands. This typically
causes a SEGV as the drects field of the overlaid surface command
structure is not pointing at anything valid when it is freed.
2024-06-03 15:50:16 +01:00
Jay Sorg 4dcf59c8f4 remove some unnecessary code 2024-05-28 10:57:55 -07:00
Jay Sorg 485e64ee76 fix for odd width, height 2024-05-28 10:57:55 -07:00
Jay Sorg 112a534f4c change capture_code to enum 2024-05-28 10:57:55 -07:00
Jay Sorg 96ff6fdba8 multimon fixes 2024-05-28 10:57:55 -07:00
Jay Sorg 57ed8e9d52 format 2024-05-28 10:57:55 -07:00
Jay Sorg b583a8d510 xrdp_encoder.c changes for x264 2024-05-28 10:57:55 -07:00
Jay Sorg ab97002c22 add xrdp_encoder_x264.c/h 2024-05-28 10:57:55 -07:00
matt335672 3d5c8822a1 Fix keyload load errors detected by unit testing
The code to clear the memory for the key mappings was incorrect,
due to array type decaying to a pointer
2024-05-24 16:34:31 +01:00
matt335672 1cb2ce06cd Update xrdp to use new keymap file format 2024-05-24 16:33:08 +01:00
matt335672 c12c475e04 Add devel logging for key events 2024-05-24 16:33:08 +01:00
matt335672 d32737a993
Merge pull request #3022 from sasha0552/devel
Add mappings for media keys (VNC)
2024-05-24 16:24:15 +01:00
sefler cad94531da fix tab 2024-05-15 00:05:17 +08:00
sefler d512b0dbc0 add missing "break" statement 2024-05-14 23:59:38 +08:00