log client ip with pid, etc
This commit is contained in:
parent
7176f14647
commit
25369460a1
@ -969,6 +969,41 @@ g_tcp_accept(int sck)
|
||||
return ret ;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
g_sck_accept(int sck, char *addr, int addr_bytes, char *port, int port_bytes)
|
||||
{
|
||||
int ret;
|
||||
char ipAddr[256];
|
||||
struct sockaddr_in s;
|
||||
#if defined(_WIN32)
|
||||
signed int i;
|
||||
#else
|
||||
unsigned int i;
|
||||
#endif
|
||||
|
||||
i = sizeof(struct sockaddr_in);
|
||||
memset(&s, 0, i);
|
||||
ret = accept(sck, (struct sockaddr *)&s, &i);
|
||||
if (ret > 0)
|
||||
{
|
||||
g_snprintf(ipAddr, 255, "A connection received from: %s port %d",
|
||||
inet_ntoa(s.sin_addr), ntohs(s.sin_port));
|
||||
log_message(LOG_LEVEL_INFO,ipAddr);
|
||||
if (s.sin_family == AF_INET)
|
||||
{
|
||||
g_snprintf(addr, addr_bytes, "%s", inet_ntoa(s.sin_addr));
|
||||
g_snprintf(port, port_bytes, "%d", ntohs(s.sin_port));
|
||||
}
|
||||
if (s.sin_family == AF_UNIX)
|
||||
{
|
||||
g_strncpy(addr, "", addr_bytes - 1);
|
||||
g_strncpy(port, "", port_bytes - 1);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
g_write_ip_address(int rcv_sck, char *ip_address, int bytes)
|
||||
|
@ -62,6 +62,8 @@ int APP_CC g_tcp_local_bind(int sck, const char* port);
|
||||
int APP_CC g_tcp_bind_address(int sck, const char* port, const char* address);
|
||||
int APP_CC g_tcp_listen(int sck);
|
||||
int APP_CC g_tcp_accept(int sck);
|
||||
int APP_CC g_sck_accept(int sck, char *addr, int addr_bytes,
|
||||
char *port, int port_bytes);
|
||||
int APP_CC g_tcp_recv(int sck, void* ptr, int len, int flags);
|
||||
int APP_CC g_tcp_send(int sck, const void* ptr, int len, int flags);
|
||||
int APP_CC g_tcp_last_error_would_block(int sck);
|
||||
|
@ -197,7 +197,8 @@ trans_check_wait_objs(struct trans *self)
|
||||
{
|
||||
if (g_tcp_can_recv(self->sck, 0))
|
||||
{
|
||||
in_sck = g_tcp_accept(self->sck);
|
||||
in_sck = g_sck_accept(self->sck, self->addr, sizeof(self->addr),
|
||||
self->port, sizeof(self->port));
|
||||
|
||||
if (in_sck == -1)
|
||||
{
|
||||
@ -223,6 +224,8 @@ trans_check_wait_objs(struct trans *self)
|
||||
in_trans->type1 = TRANS_TYPE_SERVER;
|
||||
in_trans->status = TRANS_STATUS_UP;
|
||||
in_trans->is_term = self->is_term;
|
||||
g_strncpy(in_trans->addr, self->addr, sizeof(self->addr) - 1);
|
||||
g_strncpy(in_trans->port, self->port, sizeof(self->port) - 1);
|
||||
|
||||
if (self->trans_conn_in(self, in_trans) != 0)
|
||||
{
|
||||
@ -466,7 +469,7 @@ trans_write_copy(struct trans *self)
|
||||
{
|
||||
temp_s = (struct stream *) (temp_s->next_packet);
|
||||
}
|
||||
temp_s->next_packet = wait_s;
|
||||
temp_s->next_packet = (char *) wait_s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -55,6 +55,8 @@ struct trans
|
||||
char* listen_filename;
|
||||
tis_term is_term; /* used to test for exit */
|
||||
struct stream* wait_s;
|
||||
char addr[256];
|
||||
char port[256];
|
||||
};
|
||||
|
||||
struct trans* APP_CC
|
||||
|
@ -93,6 +93,8 @@ struct xrdp_client_info
|
||||
int pointer_flags; /* 0 color, 1 new, 2 no new */
|
||||
int use_fast_path;
|
||||
int require_credentials; /* when true, credentials *must* be passed on cmd line */
|
||||
char client_addr[256];
|
||||
char client_port[256];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -587,6 +587,14 @@ xrdp_rdp_incoming(struct xrdp_rdp *self)
|
||||
MCS_USERCHANNEL_BASE;
|
||||
xrdp_rdp_parse_client_mcs_data(self);
|
||||
DEBUG(("out xrdp_rdp_incoming mcs channel %d", self->mcs_channel));
|
||||
|
||||
g_strncpy(self->client_info.client_addr,
|
||||
self->sec_layer->mcs_layer->iso_layer->tcp_layer->trans->addr,
|
||||
sizeof(self->client_info.client_addr) - 1);
|
||||
g_strncpy(self->client_info.client_port,
|
||||
self->sec_layer->mcs_layer->iso_layer->tcp_layer->trans->port,
|
||||
sizeof(self->client_info.client_port) - 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -149,8 +149,12 @@ lib_mod_log_peer(struct mod *mod)
|
||||
my_pid = g_getpid();
|
||||
if (g_sck_get_peer_cred(mod->sck, &pid, &uid, &gid) == 0)
|
||||
{
|
||||
log_message(LOG_LEVEL_INFO, "lib_mod_log_peer: xrdp pid %d connected "
|
||||
"to X11rdp pid %d", my_pid, pid);
|
||||
log_message(LOG_LEVEL_INFO, "lib_mod_log_peer: xrdp_pid=%d connected "
|
||||
"to X11rdp_pid=%d X11rdp_uid=%d X11rdp_gid=%d "
|
||||
"client_ip=%s client_port=%s",
|
||||
my_pid, pid, uid, gid,
|
||||
mod->client_info.client_addr,
|
||||
mod->client_info.client_port);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user