Add CCP support to xrdp

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.
This commit is contained in:
matt335672
2025-07-08 12:32:34 +01:00
parent 7433ded30d
commit d015535065
15 changed files with 296 additions and 50 deletions
+39 -2
View File
@@ -73,9 +73,46 @@ libxrdp_exit(struct xrdp_session *session)
/******************************************************************************/
int EXPORT_CC
libxrdp_disconnect(struct xrdp_session *session)
libxrdp_disconnect(struct xrdp_session *session, int errinfo)
{
return xrdp_rdp_disconnect((struct xrdp_rdp *)session->rdp);
int rv = 0;
struct trans *trans = NULL;
struct xrdp_rdp *rdp = NULL;
int early_capability_flags = 0;
if (session != NULL)
{
trans = session->trans;
rdp = (struct xrdp_rdp *)session->rdp;
if (session->client_info != NULL)
{
early_capability_flags =
session->client_info->mcs_early_capability_flags;
}
}
if (trans != NULL && trans->status == TRANS_STATUS_UP &&
trans->sck >= 0 && rdp != NULL)
{
/* Only send the error info PDU if the client has
* indicated it can receive it */
if ((early_capability_flags & RNS_UD_CS_SUPPORT_ERRINFO_PDU) != 0)
{
rv = xrdp_rdp_send_set_error(rdp, errinfo);
}
if (rv == 0)
{
rv = xrdp_rdp_send_deactivate(rdp);
}
if (rv == 0)
{
rv = xrdp_rdp_disconnect(rdp);
}
}
return rv;
}
/******************************************************************************/
+12
View File
@@ -456,6 +456,18 @@ xrdp_rdp_send_deactivate(struct xrdp_rdp *self);
int
xrdp_rdp_send_session_info(struct xrdp_rdp *self, const char *data,
int data_bytes);
/**
* Send a [MS-RDPBCGR] TS_SET_ERROR_INFO_PDU message
* @param self xrdp_rdp struct
* @param reason errinfo code ([MS-RDPBCGR] 2.2.5.1.1)
* @return != 0 for error
* The caller is responsible for checking the client supports
* reception of this message (see 2.2.5.1)
*/
int
xrdp_rdp_send_set_error(struct xrdp_rdp *self, int reason);
/**
* Request output suppress or resume
*
+11 -1
View File
@@ -104,8 +104,18 @@ struct xrdp_session *
libxrdp_init(tbus id, struct trans *trans, const char *xrdp_ini);
int
libxrdp_exit(struct xrdp_session *session);
/**
* Sends a disconnect sequence from the server ([MS-RDPBCGR] 1.3.1.4.x)
* @param session xrdp session
* @param errinfo Reason ([MS-RDPBCGR] 2.2.5.1.1)
* @return != 0 for an error
*
* After this call, the rdp channel is closed and cannot be re-used. This
* routine can be called more than once, but only the first call is
* effective.
*/
int
libxrdp_disconnect(struct xrdp_session *session);
libxrdp_disconnect(struct xrdp_session *session, int errinfo);
int
libxrdp_process_incoming(struct xrdp_session *session);
int EXPORT_CC
+3 -6
View File
@@ -1364,11 +1364,9 @@ xrdp_rdp_send_disconnect_query_response(struct xrdp_rdp *self)
return 0;
}
#if 0 /* not used */
/*****************************************************************************/
/* Send a [MS-RDPBCGR] TS_SET_ERROR_INFO_PDU message */
static int
xrdp_rdp_send_disconnect_reason(struct xrdp_rdp *self, int reason)
int
xrdp_rdp_send_set_error(struct xrdp_rdp *self, int reason)
{
struct stream *s;
@@ -1378,7 +1376,7 @@ xrdp_rdp_send_disconnect_reason(struct xrdp_rdp *self, int reason)
if (xrdp_rdp_init_data(self, s) != 0)
{
LOG(LOG_LEVEL_ERROR,
"xrdp_rdp_send_disconnect_reason: xrdp_rdp_init_data failed");
"xrdp_rdp_send_set_error_pdu: xrdp_rdp_init_data failed");
free_stream(s);
return 1;
}
@@ -1399,7 +1397,6 @@ xrdp_rdp_send_disconnect_reason(struct xrdp_rdp *self, int reason)
free_stream(s);
return 0;
}
#endif
/*****************************************************************************/
/* Process a [MS-RDPRFX] TS_FRAME_ACKNOWLEDGE_PDU message */