diff options
-rw-r--r-- | common/os_calls.c | 35 | ||||
-rw-r--r-- | common/os_calls.h | 2 | ||||
-rw-r--r-- | common/trans.c | 7 | ||||
-rw-r--r-- | common/trans.h | 2 | ||||
-rw-r--r-- | common/xrdp_client_info.h | 2 | ||||
-rw-r--r-- | libxrdp/xrdp_rdp.c | 8 | ||||
-rw-r--r-- | xup/xup.c | 8 |
7 files changed, 60 insertions, 4 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index 3ed08a97..2d5b4280 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -970,6 +970,41 @@ g_tcp_accept(int sck) } /*****************************************************************************/ +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) { diff --git a/common/os_calls.h b/common/os_calls.h index 8085911d..b6e1c91a 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -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); diff --git a/common/trans.c b/common/trans.c index 5d5c6125..bb349298 100644 --- a/common/trans.c +++ b/common/trans.c @@ -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; } diff --git a/common/trans.h b/common/trans.h index b7b9c20d..350f05cc 100644 --- a/common/trans.h +++ b/common/trans.h @@ -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 diff --git a/common/xrdp_client_info.h b/common/xrdp_client_info.h index 43ff3f82..2dff7358 100644 --- a/common/xrdp_client_info.h +++ b/common/xrdp_client_info.h @@ -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 diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c index 1a7e717f..da43ed23 100644 --- a/libxrdp/xrdp_rdp.c +++ b/libxrdp/xrdp_rdp.c @@ -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 { |