Move xrdp to new SCP interface
This commit is contained in:
parent
c0cb03801c
commit
a55992b1a0
@ -12,7 +12,7 @@ AM_CPPFLAGS = \
|
|||||||
-DXRDP_SOCKET_PATH=\"${socketdir}\" \
|
-DXRDP_SOCKET_PATH=\"${socketdir}\" \
|
||||||
-I$(top_builddir) \
|
-I$(top_builddir) \
|
||||||
-I$(top_srcdir)/common \
|
-I$(top_srcdir)/common \
|
||||||
-I$(top_srcdir)/sesman/libscp \
|
-I$(top_srcdir)/libipm \
|
||||||
-I$(top_srcdir)/libxrdp \
|
-I$(top_srcdir)/libxrdp \
|
||||||
$(IMLIB2_CFLAGS)
|
$(IMLIB2_CFLAGS)
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ xrdp_SOURCES = \
|
|||||||
|
|
||||||
xrdp_LDADD = \
|
xrdp_LDADD = \
|
||||||
$(top_builddir)/common/libcommon.la \
|
$(top_builddir)/common/libcommon.la \
|
||||||
$(top_builddir)/sesman/libscp/libscp.la \
|
$(top_builddir)/libipm/libipm.la \
|
||||||
$(top_builddir)/libxrdp/libxrdp.la \
|
$(top_builddir)/libxrdp/libxrdp.la \
|
||||||
$(IMLIB2_LIBS) \
|
$(IMLIB2_LIBS) \
|
||||||
$(XRDP_EXTRA_LIBS)
|
$(XRDP_EXTRA_LIBS)
|
||||||
|
189
xrdp/xrdp_mm.c
189
xrdp/xrdp_mm.c
@ -28,7 +28,7 @@
|
|||||||
#include "ms-rdpedisp.h"
|
#include "ms-rdpedisp.h"
|
||||||
#include "ms-rdpbcgr.h"
|
#include "ms-rdpbcgr.h"
|
||||||
|
|
||||||
#include "libscp_connection.h"
|
#include "scp.h"
|
||||||
|
|
||||||
#ifdef USE_PAM
|
#ifdef USE_PAM
|
||||||
#if defined(HAVE__PAM_TYPES_H)
|
#if defined(HAVE__PAM_TYPES_H)
|
||||||
@ -225,23 +225,10 @@ static int
|
|||||||
xrdp_mm_send_gateway_login(struct xrdp_mm *self, const char *username,
|
xrdp_mm_send_gateway_login(struct xrdp_mm *self, const char *username,
|
||||||
const char *password)
|
const char *password)
|
||||||
{
|
{
|
||||||
int rv = 0;
|
|
||||||
enum SCP_CLIENT_STATES_E e;
|
|
||||||
|
|
||||||
xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
|
xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
|
||||||
"sending login info to session manager, please wait...");
|
"sending login info to session manager, please wait...");
|
||||||
|
|
||||||
e = scp_v0c_gateway_request(self->pam_auth_trans, username, password);
|
return scp_send_gateway_request(self->pam_auth_trans, username, password);
|
||||||
|
|
||||||
if (e != SCP_CLIENT_STATE_OK)
|
|
||||||
{
|
|
||||||
xrdp_wm_log_msg(self->wm, LOG_LEVEL_WARNING,
|
|
||||||
"Error sending gateway login request to sesman [%s]",
|
|
||||||
scp_client_state_to_str(e));
|
|
||||||
rv = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -249,7 +236,6 @@ xrdp_mm_send_gateway_login(struct xrdp_mm *self, const char *username,
|
|||||||
static int
|
static int
|
||||||
xrdp_mm_send_login(struct xrdp_mm *self)
|
xrdp_mm_send_login(struct xrdp_mm *self)
|
||||||
{
|
{
|
||||||
enum SCP_CLIENT_STATES_E e;
|
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
int xserverbpp;
|
int xserverbpp;
|
||||||
const char *username;
|
const char *username;
|
||||||
@ -271,44 +257,48 @@ xrdp_mm_send_login(struct xrdp_mm *self)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char *domain;
|
enum scp_session_type type;
|
||||||
|
|
||||||
/* this code is either 0 for Xvnc, 10 for X11rdp or 20 for Xorg */
|
/* this code is either 0 for Xvnc, 10 for X11rdp or 20 for Xorg */
|
||||||
self->code = xrdp_mm_get_value_int(self, "code", 0);
|
self->code = xrdp_mm_get_value_int(self, "code", 0);
|
||||||
|
switch (self->code)
|
||||||
xserverbpp = xrdp_mm_get_value_int(self, "xserverbpp",
|
|
||||||
self->wm->screen->bpp);
|
|
||||||
|
|
||||||
domain = self->wm->client_info->domain;
|
|
||||||
/* Don't send domains starting with '_' - see
|
|
||||||
* xrdp_login_wnd.c:xrdp_wm_parse_domain_information()
|
|
||||||
*/
|
|
||||||
if (domain[0] == '_')
|
|
||||||
{
|
{
|
||||||
domain = "";
|
case 0:
|
||||||
|
type = SCP_SESSION_TYPE_XVNC;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 10:
|
||||||
|
type = SCP_SESSION_TYPE_XRDP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 20:
|
||||||
|
type = SCP_SESSION_TYPE_XORG;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
|
||||||
|
"Unrecognised session code %d", self->code);
|
||||||
|
rv = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
|
if (rv == 0)
|
||||||
"sending login info to session manager. "
|
|
||||||
"Please wait...");
|
|
||||||
e = scp_v0c_create_session_request(self->sesman_trans,
|
|
||||||
username,
|
|
||||||
password,
|
|
||||||
self->code,
|
|
||||||
self->wm->screen->width,
|
|
||||||
self->wm->screen->height,
|
|
||||||
xserverbpp,
|
|
||||||
domain,
|
|
||||||
self->wm->client_info->program,
|
|
||||||
self->wm->client_info->directory,
|
|
||||||
self->wm->client_info->connection_description);
|
|
||||||
|
|
||||||
if (e != SCP_CLIENT_STATE_OK)
|
|
||||||
{
|
{
|
||||||
xrdp_wm_log_msg(self->wm, LOG_LEVEL_WARNING,
|
xserverbpp = xrdp_mm_get_value_int(self, "xserverbpp",
|
||||||
"Error sending create session to sesman [%s]",
|
self->wm->screen->bpp);
|
||||||
scp_client_state_to_str(e));
|
|
||||||
rv = 1;
|
xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
|
||||||
|
"sending login info to session manager. "
|
||||||
|
"Please wait...");
|
||||||
|
rv = scp_send_create_session_request(
|
||||||
|
self->sesman_trans,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
type,
|
||||||
|
self->wm->screen->width,
|
||||||
|
self->wm->screen->height,
|
||||||
|
xserverbpp,
|
||||||
|
self->wm->client_info->program,
|
||||||
|
self->wm->client_info->directory,
|
||||||
|
self->wm->client_info->connection_description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1775,11 +1765,14 @@ xrdp_mm_process_channel_data(struct xrdp_mm *self, tbus param1, tbus param2,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void
|
static int
|
||||||
xrdp_mm_scp_process_msg(struct xrdp_mm *self,
|
xrdp_mm_process_gateway_response(struct xrdp_mm *self)
|
||||||
const struct scp_v0_reply_type *msg)
|
|
||||||
{
|
{
|
||||||
if (msg->is_gw_auth_response)
|
int auth_result;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
rv = scp_get_gateway_response(self->pam_auth_trans, &auth_result);
|
||||||
|
if (rv == 0)
|
||||||
{
|
{
|
||||||
const char *additionalError;
|
const char *additionalError;
|
||||||
char pam_error[128];
|
char pam_error[128];
|
||||||
@ -1790,12 +1783,12 @@ xrdp_mm_scp_process_msg(struct xrdp_mm *self,
|
|||||||
|
|
||||||
xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO,
|
xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO,
|
||||||
"Reply from access control: %s",
|
"Reply from access control: %s",
|
||||||
getPAMError(msg->auth_result,
|
getPAMError(auth_result,
|
||||||
pam_error, sizeof(pam_error)));
|
pam_error, sizeof(pam_error)));
|
||||||
|
|
||||||
if (msg->auth_result != 0)
|
if (auth_result != 0)
|
||||||
{
|
{
|
||||||
additionalError = getPAMAdditionalErrorInfo(msg->auth_result, self);
|
additionalError = getPAMAdditionalErrorInfo(auth_result, self);
|
||||||
if (additionalError && additionalError[0])
|
if (additionalError && additionalError[0])
|
||||||
{
|
{
|
||||||
xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, "%s",
|
xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, "%s",
|
||||||
@ -1812,11 +1805,26 @@ xrdp_mm_scp_process_msg(struct xrdp_mm *self,
|
|||||||
xrdp_mm_connect_sm(self);
|
xrdp_mm_connect_sm(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
static int
|
||||||
|
xrdp_mm_process_create_session_response(struct xrdp_mm *self)
|
||||||
|
{
|
||||||
|
int auth_result;
|
||||||
|
int display;
|
||||||
|
struct guid guid;
|
||||||
|
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
rv = scp_get_create_session_response(self->sesman_trans, &auth_result,
|
||||||
|
&display, &guid);
|
||||||
|
if (rv == 0)
|
||||||
{
|
{
|
||||||
const char *username;
|
const char *username;
|
||||||
char displayinfo[64];
|
char displayinfo[64];
|
||||||
int auth_successful = (msg->auth_result != 0);
|
|
||||||
|
|
||||||
/* Sort out some logging information */
|
/* Sort out some logging information */
|
||||||
if ((username = xrdp_mm_get_value(self, "username")) == NULL)
|
if ((username = xrdp_mm_get_value(self, "username")) == NULL)
|
||||||
@ -1824,7 +1832,7 @@ xrdp_mm_scp_process_msg(struct xrdp_mm *self,
|
|||||||
username = "???";
|
username = "???";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg->display == 0)
|
if (display == 0)
|
||||||
{
|
{
|
||||||
/* A returned display of zero doesn't mean anything useful, and
|
/* A returned display of zero doesn't mean anything useful, and
|
||||||
* can confuse the user. It's most likely authentication has
|
* can confuse the user. It's most likely authentication has
|
||||||
@ -1834,15 +1842,15 @@ xrdp_mm_scp_process_msg(struct xrdp_mm *self,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_snprintf(displayinfo, sizeof(displayinfo),
|
g_snprintf(displayinfo, sizeof(displayinfo),
|
||||||
" on display %d", msg->display);
|
" on display %d", display);
|
||||||
}
|
}
|
||||||
|
|
||||||
xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO,
|
xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO,
|
||||||
"login %s for user %s%s",
|
"login %s for user %s%s",
|
||||||
(auth_successful ? "successful" : "failed"),
|
((auth_result == 0) ? "successful" : "failed"),
|
||||||
username, displayinfo);
|
username, displayinfo);
|
||||||
|
|
||||||
if (!auth_successful)
|
if (auth_result != 0)
|
||||||
{
|
{
|
||||||
/* Authentication failure */
|
/* Authentication failure */
|
||||||
cleanup_sesman_connection(self);
|
cleanup_sesman_connection(self);
|
||||||
@ -1852,11 +1860,13 @@ xrdp_mm_scp_process_msg(struct xrdp_mm *self,
|
|||||||
{
|
{
|
||||||
/* Authentication successful - carry on with the connect
|
/* Authentication successful - carry on with the connect
|
||||||
* state machine */
|
* state machine */
|
||||||
self->display = msg->display;
|
self->display = display;
|
||||||
self->guid = msg->guid;
|
self->guid = guid;
|
||||||
xrdp_mm_connect_sm(self);
|
xrdp_mm_connect_sm(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -1865,30 +1875,37 @@ static int
|
|||||||
xrdp_mm_scp_data_in(struct trans *trans)
|
xrdp_mm_scp_data_in(struct trans *trans)
|
||||||
{
|
{
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
int available;
|
||||||
|
|
||||||
if (trans == NULL)
|
rv = scp_msg_in_check_available(trans, &available);
|
||||||
|
if (rv == 0 && available)
|
||||||
{
|
{
|
||||||
rv = 1;
|
|
||||||
}
|
|
||||||
else if (scp_v0c_reply_available(trans))
|
|
||||||
{
|
|
||||||
struct scp_v0_reply_type reply;
|
|
||||||
struct xrdp_mm *self = (struct xrdp_mm *)(trans->callback_data);
|
struct xrdp_mm *self = (struct xrdp_mm *)(trans->callback_data);
|
||||||
enum SCP_CLIENT_STATES_E e = scp_v0c_get_reply(trans, &reply);
|
enum scp_msg_code msgno;
|
||||||
if (e != SCP_CLIENT_STATE_OK)
|
|
||||||
|
switch ((msgno = scp_msg_in_start(trans)))
|
||||||
{
|
{
|
||||||
const char *src = (trans == self->pam_auth_trans)
|
case E_SCP_GATEWAY_RESPONSE:
|
||||||
? "PAM authenticator"
|
rv = xrdp_mm_process_gateway_response(self);
|
||||||
: "sesman";
|
break;
|
||||||
xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
|
|
||||||
"Error reading response from %s [%s]",
|
case E_SCP_CREATE_SESSION_RESPONSE:
|
||||||
src, scp_client_state_to_str(e));
|
rv = xrdp_mm_process_create_session_response(self);
|
||||||
rv = 1;
|
break;
|
||||||
}
|
|
||||||
else
|
default:
|
||||||
{
|
{
|
||||||
xrdp_mm_scp_process_msg(self, &reply);
|
char buff[64];
|
||||||
|
scp_msgno_to_str(msgno, buff, sizeof(buff));
|
||||||
|
const char *src = (trans == self->pam_auth_trans)
|
||||||
|
? "PAM authenticator"
|
||||||
|
: "sesman";
|
||||||
|
LOG(LOG_LEVEL_ERROR, "Ignored SCP message %s from %s",
|
||||||
|
buff, src);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scp_msg_in_reset(trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
@ -2205,11 +2222,13 @@ xrdp_mm_scp_connect(struct xrdp_mm *self, const char *target, const char *ip)
|
|||||||
xrdp_mm_get_sesman_port(port, sizeof(port));
|
xrdp_mm_get_sesman_port(port, sizeof(port));
|
||||||
xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
|
xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
|
||||||
"connecting to %s on %s:%s", target, ip, port);
|
"connecting to %s on %s:%s", target, ip, port);
|
||||||
t = scp_connect(ip, port, g_is_term,
|
t = scp_connect(ip, port, g_is_term);
|
||||||
xrdp_mm_scp_data_in, self);
|
|
||||||
if (t != NULL)
|
if (t != NULL)
|
||||||
{
|
{
|
||||||
/* fully connect */
|
/* fully connected */
|
||||||
|
t->trans_data_in = xrdp_mm_scp_data_in;
|
||||||
|
t->callback_data = self;
|
||||||
|
|
||||||
xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, "%s connect ok", target);
|
xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, "%s connect ok", target);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user