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:
matt335672
2025-07-17 14:52:27 +01:00
parent ac95cdffc3
commit cd98b013f1
15 changed files with 367 additions and 39 deletions
+54 -1
View File
@@ -91,6 +91,51 @@ process_session_finished_event(struct session_item *si)
si->sesexec_trans->status = TRANS_STATUS_DOWN;
}
/******************************************************************************/
static int
process_client_connect_event(struct session_item *si)
{
int rv;
const char *client_ip;
const char *client_name;
time_t connect_time;
rv = ercp_get_client_connect_event(si->sesexec_trans,
&client_ip, &client_name, &connect_time);
if (rv == 0)
{
strlcpy(si->client_ip, client_ip, sizeof(si->client_ip));
strlcpy(si->client_name, client_name, sizeof(si->client_name));
si->last_connect_disconnect = connect_time;
LOG(LOG_LEVEL_INFO,
"sesman: Session on display :%d is connected from client '%s'",
si->display, si->client_name);
}
return rv;
}
/******************************************************************************/
static int
process_client_disconnect_event(struct session_item *si)
{
int rv;
time_t disconnect_time;
rv = ercp_get_client_disconnect_event(si->sesexec_trans, &disconnect_time);
if (rv == 0)
{
si->client_ip[0] = '\0';
si->client_name[0] = '\0';
si->last_connect_disconnect = disconnect_time;
LOG(LOG_LEVEL_INFO,
"sesman: Session on display :%d has no client connection",
si->display);
}
return rv;
}
/******************************************************************************/
int
ercp_process(struct session_item *si)
@@ -108,11 +153,19 @@ ercp_process(struct session_item *si)
process_session_finished_event(si);
break;
case E_ERCP_CLIENT_CONNECT_EVENT:
rv = process_client_connect_event(si);
break;
case E_ERCP_CLIENT_DISCONNECT_EVENT:
rv = process_client_disconnect_event(si);
break;
default:
{
char buff[64];
ercp_msgno_to_str(msgno, buff, sizeof(buff));
LOG(LOG_LEVEL_ERROR, "Ignored EICP message %s", buff);
LOG(LOG_LEVEL_ERROR, "Ignored ERCP message %s", buff);
}
}
return rv;