mirror of https://github.com/neutrinolabs/xrdp
Add libipm interfaces to sesman
Add modules to sesman to handle incoming EICP and ERCP messages
This commit is contained in:
parent
9c2c43693c
commit
3895954b75
|
@ -0,0 +1,111 @@
|
|||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2023
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @file eicp_process.c
|
||||
* @brief eicp (executive initialisation control protocol) handler function
|
||||
* @author Matt Burt
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config_ac.h>
|
||||
#endif
|
||||
|
||||
#include "trans.h"
|
||||
|
||||
#include "eicp.h"
|
||||
#include "eicp_process.h"
|
||||
#include "os_calls.h"
|
||||
#include "pre_session_list.h"
|
||||
#include "scp.h"
|
||||
#include "sesman.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
static int
|
||||
process_sys_login_response(struct pre_session_item *psi)
|
||||
{
|
||||
int rv;
|
||||
int is_logged_in;
|
||||
uid_t uid;
|
||||
int scp_fd;
|
||||
|
||||
rv = eicp_get_sys_login_response(psi->sesexec_trans, &is_logged_in,
|
||||
&uid, &scp_fd);
|
||||
if (rv == 0)
|
||||
{
|
||||
LOG(LOG_LEVEL_INFO, "Received sys login status for %s : %s",
|
||||
psi->username,
|
||||
(is_logged_in) ? "logged in" : "not logged in");
|
||||
|
||||
if (!is_logged_in)
|
||||
{
|
||||
// This shouldn't happen. Close the connection to the
|
||||
// client immediately.
|
||||
psi->dispatcher_action = E_PSD_TERMINATE_PRE_SESSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We've been handed back the client connection */
|
||||
psi->client_trans = scp_init_trans_from_fd(scp_fd,
|
||||
TRANS_TYPE_SERVER,
|
||||
sesman_is_term);
|
||||
if (psi->client_trans == NULL)
|
||||
{
|
||||
LOG(LOG_LEVEL_ERROR, "Can't re-create client connection");
|
||||
g_file_close(scp_fd);
|
||||
psi->dispatcher_action = E_PSD_TERMINATE_PRE_SESSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
psi->client_trans->trans_data_in = sesman_scp_data_in;
|
||||
psi->client_trans->callback_data = (void *)psi;
|
||||
psi->login_state = E_PS_LOGIN_SYS;
|
||||
psi->uid = uid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int
|
||||
eicp_process(struct pre_session_item *psi)
|
||||
{
|
||||
enum eicp_msg_code msgno;
|
||||
int rv = 0;
|
||||
|
||||
switch ((msgno = eicp_msg_in_get_msgno(psi->sesexec_trans)))
|
||||
{
|
||||
case E_EICP_SYS_LOGIN_RESPONSE:
|
||||
rv = process_sys_login_response(psi);
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
char buff[64];
|
||||
eicp_msgno_to_str(msgno, buff, sizeof(buff));
|
||||
LOG(LOG_LEVEL_ERROR, "Ignored EICP message %s", buff);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2023
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @file eicp_process.h
|
||||
* @brief eicp (executive initialisation control protocol) handler function
|
||||
* @author Matt Burt
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EICP_PROCESS_H
|
||||
#define EICP_PROCESS_H
|
||||
|
||||
struct pre_session_item;
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Processes an EICP message
|
||||
* @param sc the sesman connection
|
||||
*
|
||||
*/
|
||||
int
|
||||
eicp_process(struct pre_session_item *psi);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2023
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @file ercp_process.c
|
||||
* @brief ERCP (executive run-time control protocol) handler function
|
||||
* @author Matt Burt
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include <config_ac.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "trans.h"
|
||||
|
||||
#include "ercp.h"
|
||||
#include "ercp_process.h"
|
||||
#include "session_list.h"
|
||||
|
||||
/******************************************************************************/
|
||||
static int
|
||||
process_session_announce_event(struct session_item *si)
|
||||
{
|
||||
int rv;
|
||||
const char *start_ip_addr;
|
||||
|
||||
rv = ercp_get_session_announce_event(si->sesexec_trans,
|
||||
NULL,
|
||||
&si->uid,
|
||||
&si->type,
|
||||
&si->start_width,
|
||||
&si->start_height,
|
||||
&si->bpp,
|
||||
&si->guid,
|
||||
&start_ip_addr,
|
||||
&si->start_time);
|
||||
if (rv == 0)
|
||||
{
|
||||
snprintf(si->start_ip_addr, sizeof(si->start_ip_addr),
|
||||
"%s", start_ip_addr);
|
||||
si->state = E_SESSION_RUNNING;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static void
|
||||
process_session_finished_event(struct session_item *si)
|
||||
{
|
||||
LOG(LOG_LEVEL_INFO, "Session on display %d has finished.",
|
||||
si->display);
|
||||
// Setting the transport down will remove this connection from the list
|
||||
si->sesexec_trans->status = TRANS_STATUS_DOWN;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int
|
||||
ercp_process(struct session_item *si)
|
||||
{
|
||||
enum ercp_msg_code msgno;
|
||||
int rv = 0;
|
||||
|
||||
switch ((msgno = ercp_msg_in_get_msgno(si->sesexec_trans)))
|
||||
{
|
||||
case E_ERCP_SESSION_ANNOUNCE_EVENT:
|
||||
rv = process_session_announce_event(si);
|
||||
break;
|
||||
|
||||
case E_ERCP_SESSION_FINISHED_EVENT:
|
||||
process_session_finished_event(si);
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
char buff[64];
|
||||
ercp_msgno_to_str(msgno, buff, sizeof(buff));
|
||||
LOG(LOG_LEVEL_ERROR, "Ignored EICP message %s", buff);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2023
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @file ercp_process.h
|
||||
* @brief ERCP (executive run-time control protocol) handler function
|
||||
* @author Matt Burt
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ERCP_PROCESS_H
|
||||
#define ERCP_PROCESS_H
|
||||
|
||||
struct session_item;
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Processes an ERCP message
|
||||
* @param sc the sesman connection
|
||||
*
|
||||
*/
|
||||
int
|
||||
ercp_process(struct session_item *si);
|
||||
|
||||
#endif // ERCP_PROCESS_H
|
Loading…
Reference in New Issue