Skip to content

Conversation

@matt335672
Copy link
Member

Fixes #3543
Fixes #1188
Helps with #2765

The draft PR builds on #3547. It uses a new link between sesexec and xrdp to allow sesexec to request xrdp to exit if another client wishes to connect to the same session.

So, if I start a session with:-

xfreerdp /v:<host> /u:<user> /p:<password> /tune:FreeRDP_SupportErrorInfoPdu:true /drive:C,/tmp

and then connect to the same session from elsewhere with the same command, the first command is terminated with these errors (on FreeRDP version 3.16.0):-

[19:54:02:528] [16973:0000424f] [INFO][com.freerdp.core] - [rdp_print_errinfo]: ERRINFO_DISCONNECTED_BY_OTHER_CONNECTION (0x00000005):Another user connected to the server, forcing the disconnection of the current connection.
[19:54:02:529] [16973:0000424f] [ERROR][com.freerdp.core] - [rdp_set_error_info]: ERRINFO_DISCONNECTED_BY_OTHER_CONNECTION [0x00010005]
[19:54:02:529] [16973:0000424f] [ERROR][com.freerdp.core.rdp] - [rdp_recv_callback_int][0x6404001dc8c0]: CONNECTION_STATE_CAPABILITIES_EXCHANGE_DEMAND_ACTIVE status STATE_RUN_QUIT_SESSION [-2]
[19:54:02:529] [16973:0000424f] [ERROR][com.freerdp.core.transport] - [transport_check_fds]: transport_check_fds: transport->ReceiveCallback() - STATE_RUN_QUIT_SESSION [-2]
[19:54:02:531] [16973:00004287] [WARN][com.freerdp.channels.drdynvc.client] - [check_open_close_receive]: {Microsoft::Windows::RDS::DisplayControl:2} OnOpen=(nil), OnClose=0x733a5bca83eb

The session which is now connected can reconnect to chansrv and so copy-paste and drive redirections work as expected.

I've kept this draft for now, as I'm still testing, and also:-

  1. I want to get some info regarding the connection available in the xrdp-sesadmin output
  2. I need to document the new messages

When this is done, I'm likely to merge #3547, followed by this one.

@matt335672 matt335672 force-pushed the close_on_reconnect branch from 4d0ed79 to 2d541d0 Compare July 15, 2025 10:52
@matt335672
Copy link
Member Author

Although more testing is required, this PR is now feature complete.

With a connected session:-

$ xrdp-sesadmin -c=list
Session ID: 3397
	Display: :11
	User: testuser
	Session type: Xorg
	Screen size: 1280x1024, color depth 24
	Started: Fri Jul 18 11:41:37 2025
	Start IP address: <snipped>
	Connection state: connected
	Connected client IP: <snipped>
	Connected client name: andelain
	Connection start time: Fri Jul 18 11:42:30 2025

when the session disconnects:-

$ xrdp-sesadmin -c=list
Session ID: 3397
	Display: :11
	User: testuser
	Session type: Xorg
	Screen size: 1280x1024, color depth 24
	Started: Fri Jul 18 11:41:37 2025
	Start IP address: <snipped>
	Connection state: disconnected
	Connection end time: Fri Jul 18 11:52:01 2025

Also, with this in /etc/xrdp/reconnect.sh:-

#!/bin/sh

# Write procedures here you want to execute on reconnect
env | sort >/run/user/$(id -u)/reconnect.log

I get the following variables in the reconnect.log:-

XRDP_CLIENT_IP=<snipped>
XRDP_CLIENT_NAME=andelain

There's clearly more that can be done in terms of improving the xrdp-sesadmin interface, but I'm not planning on doing that as part of this PR - there's plenty enough in here for the time being.

@matt335672 matt335672 force-pushed the close_on_reconnect branch 2 times, most recently from d075203 to 379c82e Compare July 18, 2025 11:07
This allows sesexec to send a reason for a connection close
request to xrdp.

xrdp is also updated to support server initiated disconnection sequences
from [MS-RDPBCGR] 1.3.1.4, along with reporting a reason to the client
for the disconnection.
sesexec can now tell the xrdp process to exit, and is aware when
the xrdp process exits.
This name better matches the name from [MS-RDPBCGR]. Also, the size
of the UTF-8 buffer allocated for the client name is not large
enough for some of the names which could potentially be passed across
in UTF-16 from the client.
on connection, client IP and name are passed from xrdp to sesman to
sesexec, and then back to sesman again.

xrdp-sesadmin can now access the connection data from sesman
@matt335672 matt335672 force-pushed the close_on_reconnect branch from 379c82e to 159947c Compare July 21, 2025 10:30
@matt335672 matt335672 marked this pull request as ready for review July 21, 2025 10:31
@matt335672 matt335672 merged commit 3d244ec into neutrinolabs:devel Jul 21, 2025
14 checks passed
@matt335672 matt335672 deleted the close_on_reconnect branch July 21, 2025 13:37
@matt335672
Copy link
Member Author

The wiki is now updated with development and release wiki pages. The development pages describe the new interactions indroduced by this PR and #3547

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Making a second connection to a connected session is not supported Copy/paste is not working on XRDP

2 participants