Skip to content
Open
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
2 changes: 2 additions & 0 deletions docs/man/sesman.ini.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ Alternatively combine one-or-more of the following options
\fBD\fR - Sessions are separated by initial display size
.HP 4
\fBI\fR - Sessions are separated by IP address
.HP 4
\fBI\fR - Sessions are separated by port configuration of XRDP server
.RE

.IP
Expand Down
16 changes: 10 additions & 6 deletions libipm/eicp.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,19 +279,21 @@ eicp_send_create_session_request(struct trans *trans,
unsigned short height,
unsigned char bpp,
const char *shell,
const char *directory)
const char *directory,
const char *port)
{
return libipm_msg_out_simple_send(
trans,
(int)E_EICP_CREATE_SESSION_REQUEST,
"uyqqyss",
"uyqqysss",
display,
type,
width,
height,
bpp,
shell,
directory);
directory,
port);
}

/*****************************************************************************/
Expand All @@ -304,7 +306,8 @@ eicp_get_create_session_request(struct trans *trans,
unsigned short *height,
unsigned char *bpp,
const char **shell,
const char **directory)
const char **directory,
const char **port)
{
/* Intermediate values */
uint32_t i_display;
Expand All @@ -315,14 +318,15 @@ eicp_get_create_session_request(struct trans *trans,

int rv = libipm_msg_in_parse(
trans,
"uyqqyss",
"uyqqysss",
&i_display,
&i_type,
&i_width,
&i_height,
&i_bpp,
shell,
directory);
directory,
port);

if (rv == 0)
{
Expand Down
8 changes: 6 additions & 2 deletions libipm/eicp.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ eicp_send_logout_request(struct trans *trans);
* @param bpp Session bits-per-pixel (ignored for Xorg sessions)
* @param shell User program to run. May be ""
* @param directory Directory to run the program in. May be ""
* @param port Port(s) that xrdp listens on. May be ""
* @return != 0 for error
*
* The UID for the session must have been set by a previous call.
Expand All @@ -298,7 +299,8 @@ eicp_send_create_session_request(struct trans *trans,
unsigned short height,
unsigned char bpp,
const char *shell,
const char *directory);
const char *directory,
const char *port);


/**
Expand All @@ -312,6 +314,7 @@ eicp_send_create_session_request(struct trans *trans,
* @param[out] bpp Session bits-per-pixel (ignored for Xorg sessions)
* @param[out] shell User program to run. May be ""
* @param[out] directory Directory to run the program in. May be ""
* @param[out] port Port(s) that xrdp listens on. May be ""
* @return != 0 for error
*
* Returned string pointers are valid until scp_msg_in_reset() is
Expand All @@ -325,7 +328,8 @@ eicp_get_create_session_request(struct trans *trans,
unsigned short *height,
unsigned char *bpp,
const char **shell,
const char **directory);
const char **directory,
const char **port);

/**
* Send an E_EICP_CREATE_SESSION_RESPONSE
Expand Down
16 changes: 10 additions & 6 deletions libipm/ercp.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,15 @@ ercp_send_session_announce_event(struct trans *trans,
unsigned char bpp,
const struct guid *guid,
const char *start_ip_addr,
time_t start_time)
time_t start_time,
const char *port)
{
struct libipm_fsb guid_descriptor = { (void *)guid, sizeof(*guid) };

return libipm_msg_out_simple_send(
trans,
(int)E_ERCP_SESSION_ANNOUNCE_EVENT,
"uiyqqyBsx",
"uiyqqyBsxs",
display,
uid,
type,
Expand All @@ -171,7 +172,8 @@ ercp_send_session_announce_event(struct trans *trans,
bpp,
&guid_descriptor,
start_ip_addr,
(int64_t)start_time);
(int64_t)start_time,
port);
}

/*****************************************************************************/
Expand All @@ -186,7 +188,8 @@ ercp_get_session_announce_event(struct trans *trans,
unsigned char *bpp,
struct guid *guid,
const char **start_ip_addr,
time_t *start_time)
time_t *start_time,
const char **port)
{
/* Intermediate values */
uint32_t i_display;
Expand All @@ -201,7 +204,7 @@ ercp_get_session_announce_event(struct trans *trans,

int rv = libipm_msg_in_parse(
trans,
"uiyqqyBsx",
"uiyqqyBsxs",
&i_display,
&i_uid,
&i_type,
Expand All @@ -210,7 +213,8 @@ ercp_get_session_announce_event(struct trans *trans,
&i_bpp,
&guid_descriptor,
start_ip_addr,
&i_start_time);
&i_start_time,
port);

if (rv == 0)
{
Expand Down
8 changes: 6 additions & 2 deletions libipm/ercp.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ ercp_msg_in_reset(struct trans *trans);
* @param guid Session GUID
* @param start_ip_addr Starting IP address of client
* @param start_time Session start time
* @param port Port listend to by xrdp client
* @return != 0 for error
*/
int
Expand All @@ -184,7 +185,8 @@ ercp_send_session_announce_event(struct trans *trans,
unsigned char bpp,
const struct guid *guid,
const char *start_ip_addr,
time_t start_time);
time_t start_time,
const char *port);


/**
Expand All @@ -202,6 +204,7 @@ ercp_send_session_announce_event(struct trans *trans,
* @param[out] guid Session GUID
* @param[out] start_ip_addr Starting IP address of client
* @param[out] start_time Session start time
* @param[out] port Port listened to by xrdp client
* @return != 0 for error
*/
int
Expand All @@ -214,7 +217,8 @@ ercp_get_session_announce_event(struct trans *trans,
unsigned char *bpp,
struct guid *guid,
const char **start_ip_addr,
time_t *start_time);
time_t *start_time,
const char **port);


/**
Expand Down
31 changes: 20 additions & 11 deletions libipm/scp.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,18 +419,20 @@ scp_send_create_session_request(struct trans *trans,
unsigned short height,
unsigned char bpp,
const char *shell,
const char *directory)
const char *directory,
const char *port)
{
return libipm_msg_out_simple_send(
trans,
(int)E_SCP_CREATE_SESSION_REQUEST,
"yqqyss",
"yqqysss",
type,
width,
height,
bpp,
shell,
directory);
directory,
port);
}

/*****************************************************************************/
Expand All @@ -442,7 +444,8 @@ scp_get_create_session_request(struct trans *trans,
unsigned short *height,
unsigned char *bpp,
const char **shell,
const char **directory)
const char **directory,
const char **port)
{
/* Intermediate values */
uint8_t i_type;
Expand All @@ -452,13 +455,14 @@ scp_get_create_session_request(struct trans *trans,

int rv = libipm_msg_in_parse(
trans,
"yqqyss",
"yqqysss",
&i_type,
&i_width,
&i_height,
&i_bpp,
shell,
directory);
directory,
port);

if (rv == 0)
{
Expand Down Expand Up @@ -743,7 +747,7 @@ scp_send_list_sessions_response(
rv = libipm_msg_out_simple_send(
trans,
(int)E_SCP_LIST_SESSIONS_RESPONSE,
"iiuyqqyxisssx",
"iiuyqqyxisssxs",
status,
info->sid,
info->display,
Expand All @@ -756,7 +760,8 @@ scp_send_list_sessions_response(
info->start_ip_addr,
info->client_ip,
info->client_name,
(int64_t)info->last_connect_disconnect);
(int64_t)info->last_connect_disconnect,
info->xrdp_listening_port);
}

return rv;
Expand Down Expand Up @@ -797,10 +802,11 @@ scp_get_list_sessions_response(
char *i_client_ip;
char *i_client_name;
int64_t i_last_connect_disconnect;
char *i_port;

rv = libipm_msg_in_parse(
trans,
"iuyqqyxisssx",
"iuyqqyxisssxs",
&i_sid,
&i_display,
&i_type,
Expand All @@ -812,7 +818,8 @@ scp_get_list_sessions_response(
&i_start_ip_addr,
&i_client_ip,
&i_client_name,
&i_last_connect_disconnect);
&i_last_connect_disconnect,
&i_port);

if (rv == 0)
{
Expand All @@ -821,7 +828,8 @@ scp_get_list_sessions_response(
unsigned int len = sizeof(struct scp_session_info) +
g_strlen(i_start_ip_addr) + 1 +
g_strlen(i_client_ip) + 1 +
g_strlen(i_client_name) + 1;
g_strlen(i_client_name) + 1 +
g_strlen(i_port) + 1;
if ((p = (struct scp_session_info *)g_malloc(len, 1)) == NULL)
{
*status = E_SCP_LS_NO_MEMORY;
Expand Down Expand Up @@ -851,6 +859,7 @@ scp_get_list_sessions_response(
COPY_STRING(p->client_ip, i_client_ip);
COPY_STRING(p->client_name, i_client_name);
p->last_connect_disconnect = i_last_connect_disconnect;
COPY_STRING(p->xrdp_listening_port, i_port);
#undef COPY_STRING
}
}
Expand Down
8 changes: 6 additions & 2 deletions libipm/scp.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ scp_send_logout_request(struct trans *trans);
* @param bpp Session bits-per-pixel (ignored for Xorg sessions)
* @param shell User program to run. May be ""
* @param directory Directory to run the program in. May be ""
* @param port Port(s) that xrdp listens on. May be ""
* @return != 0 for error
*
* Server replies with E_SCP_CREATE_SESSION_RESPONSE
Expand All @@ -355,7 +356,8 @@ scp_send_create_session_request(struct trans *trans,
unsigned short height,
unsigned char bpp,
const char *shell,
const char *directory);
const char *directory,
const char *port);


/**
Expand All @@ -368,6 +370,7 @@ scp_send_create_session_request(struct trans *trans,
* @param[out] bpp Session bits-per-pixel (ignored for Xorg sessions)
* @param[out] shell User program to run. May be ""
* @param[out] directory Directory to run the program in. May be ""
* @param[out] port Port(s) that xrdp listens on. May be ""
* @return != 0 for error
*
* Returned string pointers are valid until scp_msg_in_reset() is
Expand All @@ -380,7 +383,8 @@ scp_get_create_session_request(struct trans *trans,
unsigned short *height,
unsigned char *bpp,
const char **shell,
const char **directory);
const char **directory,
const char **port);

/**
* Send an E_SCP_CREATE_SESSION_RESPONSE (SCP server)
Expand Down
3 changes: 2 additions & 1 deletion libipm/scp_application_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ struct scp_session_info
char *start_ip_addr; ///< IP address of starting client
char *client_ip; ///< Current client IP
char *client_name; ///< Current client name
time_t last_connect_disconnect; ///< Time of last client connect/disconnect
time_t last_connect_disconnect; ///< Time of last client connect/disconnect}
char *xrdp_listening_port; ///< Port xrdp listened on when setting up session
};

/**
Expand Down
6 changes: 5 additions & 1 deletion sesman/ercp_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ process_session_announce_event(struct session_item *si)
{
int rv;
const char *start_ip_addr;
const char *port;
unsigned int display;

rv = ercp_get_session_announce_event(si->sesexec_trans,
Expand All @@ -54,7 +55,8 @@ process_session_announce_event(struct session_item *si)
&si->bpp,
&si->guid,
&start_ip_addr,
&si->start_time);
&si->start_time,
&port);
if (rv == 0)
{
// We may already know the display we sent sesexec. If we do,
Expand All @@ -71,6 +73,8 @@ process_session_announce_event(struct session_item *si)
{
snprintf(si->start_ip_addr, sizeof(si->start_ip_addr),
"%s", start_ip_addr);
snprintf(si->xrdp_listening_port, sizeof(si->xrdp_listening_port),
"%s", port);
si->display = display;

si->state = E_SESSION_RUNNING;
Expand Down
1 change: 1 addition & 0 deletions sesman/libsesman/sesman_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ static const struct bitmask_char policy_bits[] =
{ SESMAN_CFG_SESS_POLICY_B, 'B' },
{ SESMAN_CFG_SESS_POLICY_D, 'D' },
{ SESMAN_CFG_SESS_POLICY_I, 'I' },
{ SESMAN_CFG_SESS_POLICY_P, 'P' },
BITMASK_CHAR_END_OF_LIST
};

Expand Down
3 changes: 2 additions & 1 deletion sesman/libsesman/sesman_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ enum SESMAN_CFG_SESS_POLICY_BITS
SESMAN_CFG_SESS_POLICY_U = (1 << 2),
SESMAN_CFG_SESS_POLICY_B = (1 << 3),
SESMAN_CFG_SESS_POLICY_D = (1 << 4),
SESMAN_CFG_SESS_POLICY_I = (1 << 5)
SESMAN_CFG_SESS_POLICY_I = (1 << 5),
SESMAN_CFG_SESS_POLICY_P = (1 << 6)
};

/**
Expand Down
Loading