diff --git a/docs/man/xrdp.ini.5.in b/docs/man/xrdp.ini.5.in index da5b7c06..581fcac9 100644 --- a/docs/man/xrdp.ini.5.in +++ b/docs/man/xrdp.ini.5.in @@ -232,7 +232,7 @@ This option can have one of the following values: \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 \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 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" This is an example \fBxrdp.ini\fR: @@ -369,8 +379,9 @@ password={base64}cGFzc3dvcmQhCg== .SH "SEE ALSO" .BR xrdp (8), -.BR sesman (8), -.BR sesrun (8), +.BR xrdp\-chansrv (8), +.BR xrdp\-sesman (8), +.BR xrdp\-sesrun (8), .BR sesman.ini (5) For more info on \fBxrdp\fR see diff --git a/xrdp/xrdp.ini.in b/xrdp/xrdp.ini.in index 699b9911..d6bb0595 100644 --- a/xrdp/xrdp.ini.in +++ b/xrdp/xrdp.ini.in @@ -182,9 +182,6 @@ tcutils=true ; for debugging xrdp, in section xrdp1, change port=-1 to this: #port=/tmp/.xrdp/xrdp_display_10 -; for debugging xrdp, add following line to section xrdp1 -#chansrvport=/tmp/.xrdp/xrdp_chansrv_socket_7210 - ; ; Session types @@ -214,7 +211,10 @@ port=-1 ; Disable requested encodings to support buggy VNC servers ; (1 = ExtendedDesktopSize) #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] name=vnc-any diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 4679bd6b..915c3b32 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -34,6 +34,7 @@ #include #endif #endif /* USE_PAM */ +#include #include "xrdp_encoder.h" #include "xrdp_sockets.h" @@ -2160,6 +2161,54 @@ getPAMAdditionalErrorInfo(const int pamError, struct xrdp_mm *self) } #endif +/*************************************************************************//** + * Parses a chansrvport string + * + * This will be in one of the following formats:- + * UNIX path to a domain socket + * DISPLAY() Use chansrv on X Display + * + * @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 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) { - g_strncpy(chansrvport, value, 255); - self->usechansrv = 1; + if (parse_chansrvport(value, chansrvport, sizeof(chansrvport)) == 0) + { + self->usechansrv = 1; + } } }