Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion common/os_calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2740,7 +2740,10 @@ g_create_path(const char *path)

if (!g_directory_exist(copypath))
{
if (!g_create_dir(copypath))
// Create and check again to avoid a race with another
// process making the same traversal
(void)g_create_dir(copypath);
if (!g_directory_exist(copypath))
{
status = 0;
break;
Expand Down
40 changes: 38 additions & 2 deletions common/string_calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ g_text2bool(const char *s)
}

/*****************************************************************************/
int
g_get_display_num_from_display(const char *display_text)
static int
get_display_num_from_display(const char *display_text)
{
int rv = -1;
const char *p;
Expand Down Expand Up @@ -191,6 +191,42 @@ g_get_display_num_from_display(const char *display_text)
return rv;
}

/*****************************************************************************/
int
g_get_display_string(char buff[], unsigned int bufflen)
{
const char *str;
const char *p = NULL;
int rv = 0;

if ((str = g_getenv("WAYLAND_DISPLAY")) != NULL)
{
// Return the unqualified part of the name
p = strrchr(str, '/');
p = (p != NULL) ? (p + 1) : str;
strlcpy(buff, p, bufflen);
}
else if ((str = g_getenv("DISPLAY")) != NULL)
{
int n = get_display_num_from_display(str);

if (n >= 0)
{
g_snprintf(buff, bufflen, ":%d", n);
}
else
{
rv = -1;
}
}
else
{
rv = -1;
}

return rv;
}

/*****************************************************************************/
/* returns length of text */
int
Expand Down
11 changes: 7 additions & 4 deletions common/string_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,17 @@ char *
g_bytes_to_hexdump(const char *src, int len);

/**
* Extracts the display number from an X11 display string
* Extracts the display string from either DISPLAY or WAYLAND_DISPLAY
*
* @param Display string (i.e. g_getenv("DISPLAY"))
* @param buff Buffer for result
* @param bufflen Length for result
*
* @result <0 if the string could not be parsed, or >=0 for a display number
* Result will be (e.g.) ":10" for X11 or "wayland-1" for Wayland
*
* @result != 0 if the string could not be found or parsed
*/
int
g_get_display_num_from_display(const char *display_text);
g_get_display_string(char buff[], unsigned int bufflen);

/**
* Converts a bitmask into a string for output purposes
Expand Down
21 changes: 14 additions & 7 deletions common/xrdp_sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
#define SCP_LISTEN_PORT_BASE_STR "sesman.socket"

/* names of socket files within XRDP_SOCKET_PATH, qualified by
* display number */
#define XRDP_CHANSRV_BASE_STR "xrdp_chansrv_socket_%d"
#define CHANSRV_PORT_OUT_BASE_STR "xrdp_chansrv_audio_out_socket_%d"
#define CHANSRV_PORT_IN_BASE_STR "xrdp_chansrv_audio_in_socket_%d"
#define CHANSRV_API_BASE_STR "xrdpapi_%d"
#define XRDP_X11RDP_BASE_STR "xrdp_display_%d"
#define XRDP_DISCONNECT_BASE_STR "xrdp_disconnect_display_%d"
* display name (with leading colon stripped) */
#define XRDP_CHANSRV_BASE_STR "xrdp_chansrv_socket_%s"
#define CHANSRV_PORT_OUT_BASE_STR "xrdp_chansrv_audio_out_socket_%s"
#define CHANSRV_PORT_IN_BASE_STR "xrdp_chansrv_audio_in_socket_%s"
#define CHANSRV_API_BASE_STR "xrdpapi_%s"
#define XRDP_X11RDP_BASE_STR "xrdp_display_%s"
#define XRDP_DISCONNECT_BASE_STR "xrdp_disconnect_display_%s"

/* fullpath declarations */
#define XRDP_CHANSRV_STR XRDP_SOCKET_PATH "/" XRDP_CHANSRV_BASE_STR
Expand All @@ -67,4 +67,11 @@
/* fullpath to an X11 display socket */
#define X11_UNIX_SOCKET_STR X11_UNIX_SOCKET_DIRECTORY "/X%d"

/* Use this to strip a colon from an X11 display name.
*
* This is for compatibility with previous versions of xrdp, which
* used X11 display numbers only. Using this macro results in the same
* behaviour for X11 sessions, but no change for Wayland sessions */
#define STRIP_COLON(dname) (((dname)[0] == ':') ? (dname) + 1 : (dname))

#endif
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ AC_CONFIG_FILES([
sesman/chansrv/Makefile
sesman/Makefile
sesman/sesexec/Makefile
sesman/sesexec/wayland/Makefile
sesman/tools/Makefile
tests/Makefile
tests/common/Makefile
Expand Down
16 changes: 14 additions & 2 deletions docs/man/sesman.ini.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,19 @@ Multiple \fIparam\fR lines are supported. This first line specifies the
path to the X11 server executable. Following lines specify command line
arguments passed to the X11 server.

.SH "LABWC"
Following parameters can be used in the \fB[Labwc]\fR section.

.TP
\fBLabwcExe\fR=\fI/path/to/executable\fR
Defaults to \fIlabwc\fR. Specify the path to a labwc executable, if
the executable you wish to use is not on the standard PATH.

.TP
\fBWayvncExe\fR=\fI/path/to/executable\fR
Defaults to \fIwayvnc\fR. Specify the path to a wayvnc executable, if
the executable you wish to use is not on the standard PATH.

.SH "CHANSRV"
Following parameters can be used in the \fB[Chansrv]\fR section.

Expand All @@ -408,8 +421,7 @@ If first character is not a '/', this is relative to $HOME.
The following substitutions are made in this string:-
%U - Username
%u - Numeric UID
%d - Numeric display number (ex 10)
%D - Display environment variable (ex :10.0)
%d - Display identifier (e.g. "10" for X11, or "wayland-1" for Wayland)
%% - Percent character
.HP 3
1) The directory path permissions MUST be configured correctly by
Expand Down
5 changes: 4 additions & 1 deletion docs/man/xrdp.ini.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,11 @@ values supported for a particular release of \fBxrdp\fR(8) are documented in
\fBcode\fR=\fI<number>\fR|\fI0\fR
Specifies the session type. \fI0\fR is Xvnc over TCP,
\fI1\fR is Xvnc over a UNIX domain socket,
and \fI20\fR is Xorg with xorgxrdp modules.
\fI20\fR is Xorg with xorgxrdp modules,
\fI1000\fR is labwc (Wayland), and
\fI1001\fR is labwc (Wayland) over VNC
The default is \fI0\fR on non-FIPS systems, and \fI1\fR on FIPS systems.
Wayland is currently experimental.
.TP
\fBchansrvport\fR=\fBDISPLAY(\fR\fIn\fR\fB)\fR|\fBDISPLAY(\fR\fIn,u\fR\fB)\fR||\fI/path/to/domain-socket\fR
Asks xrdp to connect to a manually started \fBxrdp-chansrv\fR instance.
Expand Down
27 changes: 17 additions & 10 deletions libipm/eicp.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ eicp_send_logout_request(struct trans *trans)

int
eicp_send_create_session_request(struct trans *trans,
unsigned int display,
int x11_display,
enum scp_session_type type,
unsigned short width,
unsigned short height,
Expand All @@ -284,8 +284,8 @@ eicp_send_create_session_request(struct trans *trans,
return libipm_msg_out_simple_send(
trans,
(int)E_EICP_CREATE_SESSION_REQUEST,
"uyqqyss",
display,
"iyqqyss",
x11_display,
type,
width,
height,
Expand All @@ -298,7 +298,7 @@ eicp_send_create_session_request(struct trans *trans,

int
eicp_get_create_session_request(struct trans *trans,
unsigned int *display,
int *x11_display,
enum scp_session_type *type,
unsigned short *width,
unsigned short *height,
Expand All @@ -307,16 +307,16 @@ eicp_get_create_session_request(struct trans *trans,
const char **directory)
{
/* Intermediate values */
uint32_t i_display;
int32_t i_x11_display;
uint8_t i_type;
uint16_t i_width;
uint16_t i_height;
uint8_t i_bpp;

int rv = libipm_msg_in_parse(
trans,
"uyqqyss",
&i_display,
"iyqqyss",
&i_x11_display,
&i_type,
&i_width,
&i_height,
Expand All @@ -326,7 +326,7 @@ eicp_get_create_session_request(struct trans *trans,

if (rv == 0)
{
*display = i_display;
*x11_display = i_x11_display;
*type = (enum scp_session_type)i_type;
*width = i_width;
*height = i_height;
Expand All @@ -341,19 +341,21 @@ eicp_get_create_session_request(struct trans *trans,
int
eicp_send_create_session_response(struct trans *trans,
enum scp_screate_status status,
const char *display,
const struct guid *guid)
{
struct libipm_fsb guid_descriptor = { (void *)guid, sizeof(*guid) };
return libipm_msg_out_simple_send(
trans, (int)E_EICP_CREATE_SESSION_RESPONSE,
"iB", status, &guid_descriptor);
"isB", status, display, &guid_descriptor);
}

/*****************************************************************************/

int
eicp_get_create_session_response(struct trans *trans,
enum scp_screate_status *status,
const char **display,
struct guid *guid)
{
/* Intermediate values */
Expand All @@ -362,14 +364,19 @@ eicp_get_create_session_response(struct trans *trans,
const struct libipm_fsb guid_descriptor = { (void *)guid, sizeof(*guid) };
int rv = libipm_msg_in_parse(
trans,
"iB",
"isB",
&i_status,
display,
&guid_descriptor);

if (rv == 0)
{
*status = (enum scp_screate_status)i_status;
}
else
{
*display = "";
}

return rv;
}
14 changes: 10 additions & 4 deletions libipm/eicp.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ eicp_send_logout_request(struct trans *trans);
* Send an E_EICP_CREATE_SESSION_REQUEST (sesman)
*
* @param trans EICP transport
* @param display X display number to use
* @param x11_display X11 display number to use, or -1 if not X11
* @param type Session type
* @param width Initial session width
* @param height Initial session height
Expand All @@ -292,7 +292,7 @@ eicp_send_logout_request(struct trans *trans);
*/
int
eicp_send_create_session_request(struct trans *trans,
unsigned int display,
int x11_display,
enum scp_session_type type,
unsigned short width,
unsigned short height,
Expand All @@ -305,7 +305,7 @@ eicp_send_create_session_request(struct trans *trans,
* Parse an incoming E_EICP_CREATE_SESSION_REQUEST (sesexec)
*
* @param trans EICP transport
* @param[out] display X display number to use
* @param[out] x11_display X display number to use
* @param[out] type Session type
* @param[out] width Initial session width
* @param[out] height Initial session height
Expand All @@ -319,7 +319,7 @@ eicp_send_create_session_request(struct trans *trans,
*/
int
eicp_get_create_session_request(struct trans *trans,
unsigned int *display,
int *x11_display,
enum scp_session_type *type,
unsigned short *width,
unsigned short *height,
Expand All @@ -336,12 +336,15 @@ eicp_get_create_session_request(struct trans *trans,
*
* @param trans EICP transport
* @param status Status of creation request
* @param display Display name, either (e.g) ":n" (X11) or
* "wayland-n" (Wayland)
* @param guid GUID of session
* @return != 0 for error
*/
int
eicp_send_create_session_response(struct trans *trans,
enum scp_screate_status status,
const char *display,
const struct guid *guid);


Expand All @@ -354,12 +357,15 @@ eicp_send_create_session_response(struct trans *trans,
*
* @param trans EICP transport
* @param[out] status Status of creation request
* @param display Display name, either (e.g) ":n" (X11) or
* "wayland-n" (Wayland)
* @param[out] guid GUID of session
* @return != 0 for error
*/
int
eicp_get_create_session_response(struct trans *trans,
enum scp_screate_status *status,
const char **display,
struct guid *guid);

#endif /* EICP_H */
Loading