Add logging of connect/disconnect times
on connection, client IP and name are passed from xrdp to sesman to sesexec, and then back to sesman again. xrdp-sesadmin can now access the connection data from sesman
This commit is contained in:
@@ -72,8 +72,10 @@ handle_connect_session_request(struct trans *self)
|
||||
{
|
||||
int scp_fd = -1;
|
||||
unsigned int scp_flags;
|
||||
|
||||
int rv = ercp_get_connect_session_request(self, &scp_fd, &scp_flags);
|
||||
const char *client_ip;
|
||||
const char *client_name;
|
||||
int rv = ercp_get_connect_session_request(self, &scp_fd, &client_ip,
|
||||
&client_name, &scp_flags);
|
||||
if (rv == 0)
|
||||
{
|
||||
struct trans *scp_trans;
|
||||
@@ -107,10 +109,20 @@ handle_connect_session_request(struct trans *self)
|
||||
scp_status = get_session_fds(g_session_data, scp_flags,
|
||||
&display_fd, &chan_fd);
|
||||
|
||||
// Tell sesman about the new client connection
|
||||
if (g_ecp_trans != NULL)
|
||||
if (scp_status == E_SCP_SCONNECT_OK)
|
||||
{
|
||||
/// TODO: client connect event
|
||||
// Tell sesman about the new client connection
|
||||
strlcpy(g_client_ip, client_ip, sizeof(g_client_ip));
|
||||
strlcpy(g_client_name, client_name, sizeof(g_client_name));
|
||||
g_last_connect_disconnect = time(NULL);
|
||||
|
||||
if (g_ecp_trans != NULL)
|
||||
{
|
||||
(void)ercp_send_client_connect_event(
|
||||
g_ecp_trans, g_client_ip, g_client_name,
|
||||
g_last_connect_disconnect);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Pass the session file descriptors to the client
|
||||
|
||||
@@ -74,6 +74,9 @@ pid_t g_pid;
|
||||
|
||||
struct trans *g_ecp_trans;
|
||||
struct trans *g_ccp_trans;
|
||||
char g_client_ip[MAX_PEER_ADDRSTRLEN];
|
||||
char g_client_name[INFO_CLIENT_NAME_BYTES_UTF8];
|
||||
time_t g_last_connect_disconnect;
|
||||
|
||||
/*
|
||||
* Module-scope globals
|
||||
@@ -486,7 +489,17 @@ sesexec_main_loop(void)
|
||||
// xrdp has gone away.
|
||||
LOG(LOG_LEVEL_INFO, "sesexec_main_loop: "
|
||||
"xrdp has exited");
|
||||
// TODO: Tell sesman xrdp has exited
|
||||
|
||||
g_client_ip[0] = '\0';
|
||||
g_client_name[0] = '\0';
|
||||
g_last_connect_disconnect = time(NULL);
|
||||
|
||||
if (g_ecp_trans != NULL)
|
||||
{
|
||||
(void)ercp_send_client_disconnect_event(
|
||||
g_ecp_trans, g_last_connect_disconnect);
|
||||
|
||||
}
|
||||
close_ccp_trans();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "ccp_application_types.h"
|
||||
#include "xrdp_constants.h"
|
||||
|
||||
struct config_sesman;
|
||||
struct trans;
|
||||
@@ -106,6 +107,21 @@ extern struct trans *g_ecp_trans;
|
||||
*/
|
||||
extern struct trans *g_ccp_trans;
|
||||
|
||||
/**
|
||||
* Last connected client IP address
|
||||
*/
|
||||
extern char g_client_ip[MAX_PEER_ADDRSTRLEN];
|
||||
|
||||
/**
|
||||
* Last connected client name
|
||||
*/
|
||||
extern char g_client_name[INFO_CLIENT_NAME_BYTES_UTF8];
|
||||
|
||||
/**
|
||||
* Last connect / disconnect time
|
||||
*/
|
||||
extern time_t g_last_connect_disconnect;
|
||||
|
||||
/**
|
||||
* Callback to process incoming ERCP data
|
||||
*/
|
||||
|
||||
@@ -101,6 +101,20 @@ discover_trans_conn_in(struct trans *trans, struct trans *new_trans)
|
||||
&sp->guid,
|
||||
g_login_info->ip_addr,
|
||||
session_get_start_time(g_session_data));
|
||||
|
||||
// Tell semsan about the last client connect or disconnect
|
||||
if (g_ccp_trans != NULL)
|
||||
{
|
||||
(void)ercp_send_client_connect_event(new_trans,
|
||||
g_client_ip,
|
||||
g_client_name,
|
||||
g_last_connect_disconnect);
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)ercp_send_client_disconnect_event(new_trans,
|
||||
g_last_connect_disconnect);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
||||
Reference in New Issue
Block a user