Add DISPLAY(n) ass a valid form of chansrvport

This commit is contained in:
matt335672 2021-04-13 12:12:08 +01:00
parent 86c87b6f15
commit 32b676472a
3 changed files with 71 additions and 9 deletions

View File

@ -232,7 +232,7 @@ This option can have one of the following values:
\fBINFO\fR or \fB3\fR \- Logs errors, warnings and informational messages \fBINFO\fR or \fB3\fR \- Logs errors, warnings and informational messages
\fBDEBUG\fR or \fB4\fR \- Log everything. If \fBsesman\fR is compiled in debug mode, this options will output many more low\-level message, useful for developers \fBDEBUG\fR or \fB4\fR \- Log everything. If \fBxrdp-sesman\fR is compiled in debug mode, this options will output many more low\-level message, useful for developers
.TP .TP
\fBEnableSyslog\fR=\fI[true|false]\fR \fBEnableSyslog\fR=\fI[true|false]\fR
@ -338,6 +338,16 @@ values supported for a particular release of \fBxrdp\fR(8) are documented in
Specifies the session type. The default, \fI0\fR, is Xvnc, \fI10\fR is Specifies the session type. The default, \fI0\fR, is Xvnc, \fI10\fR is
X11rdp, and \fI20\fR is Xorg with xorgxrdp modules. X11rdp, and \fI20\fR is Xorg with xorgxrdp modules.
.TP
\fBchansrvport\fR=\fBDISPLAY(\fR\fIn\fR\fB)\fR|\fI/path/to/domain-socket\fR
Asks xrdp to connect to a manually started \fBxrdp-chansrv\fR instance.
This can be useful if you wish to use to use xrdp to connect to a VNC session
which has been started other than by \fBxrdp-sesman\fR, as you can then make
use of \fBxrdp\-chansrv\fR facilities in the VNC session.
The first form of this setting is recommended, replacing \fIn\fR with the
X11 display number of the session.
.SH "EXAMPLES" .SH "EXAMPLES"
This is an example \fBxrdp.ini\fR: This is an example \fBxrdp.ini\fR:
@ -369,8 +379,9 @@ password={base64}cGFzc3dvcmQhCg==
.SH "SEE ALSO" .SH "SEE ALSO"
.BR xrdp (8), .BR xrdp (8),
.BR sesman (8), .BR xrdp\-chansrv (8),
.BR sesrun (8), .BR xrdp\-sesman (8),
.BR xrdp\-sesrun (8),
.BR sesman.ini (5) .BR sesman.ini (5)
For more info on \fBxrdp\fR see For more info on \fBxrdp\fR see

View File

@ -182,9 +182,6 @@ tcutils=true
; for debugging xrdp, in section xrdp1, change port=-1 to this: ; for debugging xrdp, in section xrdp1, change port=-1 to this:
#port=/tmp/.xrdp/xrdp_display_10 #port=/tmp/.xrdp/xrdp_display_10
; for debugging xrdp, add following line to section xrdp1
#chansrvport=/tmp/.xrdp/xrdp_chansrv_socket_7210
; ;
; Session types ; Session types
@ -214,7 +211,10 @@ port=-1
; Disable requested encodings to support buggy VNC servers ; Disable requested encodings to support buggy VNC servers
; (1 = ExtendedDesktopSize) ; (1 = ExtendedDesktopSize)
#disabled_encodings_mask=0 #disabled_encodings_mask=0
; Use this to connect to a chansrv instance created outside of sesman
; (e.g. as part of an x11vnc console session). Replace '0' with the
; display number of the session
#chansrvport=DISPLAY(0)
[vnc-any] [vnc-any]
name=vnc-any name=vnc-any

View File

@ -34,6 +34,7 @@
#include <security/pam_constants.h> #include <security/pam_constants.h>
#endif #endif
#endif /* USE_PAM */ #endif /* USE_PAM */
#include <ctype.h>
#include "xrdp_encoder.h" #include "xrdp_encoder.h"
#include "xrdp_sockets.h" #include "xrdp_sockets.h"
@ -2160,6 +2161,54 @@ getPAMAdditionalErrorInfo(const int pamError, struct xrdp_mm *self)
} }
#endif #endif
/*************************************************************************//**
* Parses a chansrvport string
*
* This will be in one of the following formats:-
* <path> UNIX path to a domain socket
* DISPLAY(<num>) Use chansrv on X Display <num>
*
* @param value assigned to chansrvport
* @param dest Output buffer
* @param dest_size Total size of output buffer, including terminator space
* @return 0 for success
*/
static int
parse_chansrvport(const char *value, char *dest, int dest_size)
{
int rv = 0;
if (g_strncmp(value, "DISPLAY(", 8) == 0)
{
const char *p = value + 8;
const char *end = p;
/* Check next chars are digits followed by ')' */
while (isdigit(*end))
{
++end;
}
if (end == p || *end != ')')
{
LOG(LOG_LEVEL_WARNING, "Ignoring invalid chansrvport string '%s'",
value);
rv = -1;
}
else
{
g_snprintf(dest, dest_size, XRDP_CHANSRV_STR, g_atoi(p));
}
}
else
{
g_strncpy(dest, value, dest_size - 1);
}
return rv;
}
/*****************************************************************************/ /*****************************************************************************/
int int
xrdp_mm_connect(struct xrdp_mm *self) xrdp_mm_connect(struct xrdp_mm *self)
@ -2238,8 +2287,10 @@ xrdp_mm_connect(struct xrdp_mm *self)
} }
else if (g_strcasecmp(name, "chansrvport") == 0) else if (g_strcasecmp(name, "chansrvport") == 0)
{ {
g_strncpy(chansrvport, value, 255); if (parse_chansrvport(value, chansrvport, sizeof(chansrvport)) == 0)
self->usechansrv = 1; {
self->usechansrv = 1;
}
} }
} }