Commit Graph

68 Commits

Author SHA1 Message Date
firewave fb9c175b11 enabled and fixed `-Wmissing-prototypes` compiler warnings
Co-authored-by: matt335672 <30179339+matt335672@users.noreply.github.com>
2024-04-23 18:38:20 +02:00
matt335672 f08355a325 Ensure commonly used file descriptors are close-on-exec 2023-04-24 14:20:14 +01:00
matt335672 b1147f5faa CVE-2022-23479
Detect attempts to overflow input buffer

If application code hasn't properly sanitised the header_size
for a transport, it is possible for read requests to be issued
which overflow the input buffer. This change detects this
at a low level and bounces the read request.
2022-12-09 17:34:25 +00:00
a1346054 7fe18cc1c0
fix typos 2022-09-03 02:01:48 +00:00
matt335672 79bec8110c Unify connection fields for the connected client
The connected client is currently described in two places in
the xrdp_client_info structure:-

1) In the connection_description field. This was introduced as
   field client_ip by commit d797b2cf49
   for xrdp v0.6.0

2) In the client_addr and client_port fields introduced by commit
   25369460a1 for xrdp v0.8.0

This commit unifies these two sets of fields into a single
set of fields describing the connection IP and port (for
AF_INET/AF_INET6 connections only) and a connection description
for all connection types.

The code in os_calls to provide client logging has been simplified
somewhat which should make it easier to add new connection types (e.g.
AF_VSOCK).

The old connection_description field used to be passed to sesman to
inform sesman of the IP address of the client, and also to provide
a string for 'C' field session policy matching. 'C' field session policy
matching does not actually need this string (see #2239), and so now only
the IP field is passed to sesman.
2022-05-18 12:35:07 +01:00
matt335672 1d190c6ea8 Prevent unnecessary close of sck = -1 in trans_listen_address() 2022-04-01 11:51:11 +01:00
matt335672 275eaf7683 Rework transport connect logic
There are a number of ways the existing transport connect logic in
trans_connect could be improved for POSIX compatibility, and also
slightly tidied up:-
1) The same socket is re-used for multiple connect attempts following
   failure which isn't behaviour defined by POSIX.1-2017 (although it
   works on Linux).
2) An asynchronous connect is started, and then after a short
   delay connect() is called again on the same socket. POSIX.1-2017
   is clear that in this situation EALREADY is returned before the
   connection is established, but is silent on the behaviour expected
   when the connection is established. Returning success is an option,
   but so is returning EISCONN. The current code assumes the connect()
   call will succeed.
3) The code contains two virtually identical, quite complex loops for
   TCP and UNIX sockets, differing only in the calls to create a socket
   and connect it.
4) trans_connect() contains looping and retry logic, but this isn't
   seen as sufficient by the chansrv connect code in xrdp/xrdp_mm.c and
   the Xorg connect code in xup/xup.c. Both of these implement their own
   looping and retry logic on top of the logic in trans_connect(),
   resulting in slightly unpredictable behaviour with regard to
   timeouts.
5) A socket number can technically be zero, but in a couple of places
   this isn't allowed for.

This PR attempts to correct the implementation of trans_connect(),
and also to simplify the areas it is called from.

As part of the PR, the signature of the server_is_term member of the
xrdp module interface is changed to match the signature expected by the
is_term member of a struct trans. This allows for trans_connect()
in xrdp modules to directly access g_is_term() within the main xrdp
executable. At the moment this functionality is only used by the xup
module.
2022-03-31 20:48:07 +01:00
matt335672 8f4860cb55 Add subclassing capability to struct trans 2022-03-15 10:23:27 +00:00
matt335672 8b8cfbe119 Improve wrapping of openssl module 2022-01-28 12:23:40 +00:00
matt335672 c9afd804a4 Minor const and comment fixes 2021-07-27 13:36:34 +01:00
Alexandre Quesnel 2ab3b97ba0 Migrating logging to LOG() and LOG_DEVEL() in common/* 2021-03-14 23:33:31 +00:00
Alexandre Quesnel bb9d3079c0 Fixing formatting with astyle in common/* 2021-03-14 23:33:31 +00:00
matt335672 0a1a8f40e5 Moved a lot of string funcs to string_calls module 2020-12-22 11:57:24 +00:00
Matt Burt 1f8bb57fd6 Improve source_info commenting and fix neutrino slow link 2020-10-20 09:55:17 +01:00
matt335672 da3114007c Address possible memory out-of-bounds accesses 2020-04-15 09:57:05 +01:00
Jay Sorg ee65ccb31d use address for tcp:// and tcp6:// and vsock:// 2019-07-01 17:56:50 -07:00
Jay Sorg 0bc7803eaa add TCP V4 and V6 only socket functions 2019-06-29 23:59:18 -07:00
Jay Sorg 0ed82f71e8 xrdp: check term event for more responsive shutdown 2019-04-01 23:14:09 -07:00
Ben Cohen 3b5b7a5935 UDS file deleted after first connection
If you run xrdp with a Unix Domain Socket (UDS) for the port specified in
/etc/xrdp/xrdp.ini then the first connection succeeds but subsequent
connections fail.  In fact the UDS is deleted from the filesystem as soon
as the first connection is established.

Test case:

1. Edit /etc/xrdp/xrdp.ini to set "port=/var/run/xrdp-local.socket".

2. Restart xrdp.

3. Run the following.  When rdesktop starts up and the logon dialog is
   displayed, press "Cancel".

   sudo socat TCP-LISTEN:12345 UNIX-CONNECT:/var/run/xrdp-local.socket &
   rdesktop localhost:12345

4. Run the following:

    sudo socat TCP-LISTEN:12346 UNIX-CONNECT:/var/run/xrdp-local.socket &
    rdesktop localhost:12346

Expected behaviour: rdesktop starts up and displays the logon dialog.
Observed behaviour: rdesktop exits with "ERROR: Connection closed" and
                    socat exits with "No such file or directory.

This is because in the child process after forking, xrdp_listen_fork()
calls trans_delete() which deletes the UDS.  Simply commenting out the
g_file_delete() and g_free() fixes this, but that isn't a proper solution
because trans_delete() is called from elsewhere where the UDS might no
longer be wanted.

Fix by adding a function trans_delete_from_child() that frees and clears
listen_filename before calling trans_delete(), and call the new function
from xrdp_listen_fork().

(Workaround: set "fork=false" in /etc/xrdp/xrdp.ini, because
trans_delete() is then not called.)
2018-03-27 09:22:49 +03:00
Jay Sorg c6c513b23c use g_memcpy, braces 2017-11-07 18:20:45 -08:00
Jay Sorg 26507644e3 vsock, move some defines 2017-11-07 18:20:45 -08:00
Justin Terry (VM) 50bd624cc4 Implements XRDP over vsock
1. Implements the ability to use AV_VSOCK for the transport rather than TCP.
2. Updates the ini file to be able to conditionally turn this feature on.
2017-11-07 18:20:45 -08:00
Pavel Roskin 6ed4c969f4 Eliminate APP_CC and DEFAULT_CC 2017-03-14 00:21:48 -07:00
Pavel Roskin b2d3dcf169 Include config_ac.h from all source files 2017-03-04 00:52:34 -08:00
Koichiro IWAO e94ab10e14 TLS: new method to specify SSL/TLS version
SSL/TLS protocols only listed in ssl_protocols should be used.
The name "ssl_protocols" comes from nginx.

Resolves #428.
2017-02-27 14:17:25 +09:00
Koichiro IWAO 40e8194122 TLS: log TLS version and cipher 2016-11-22 10:50:30 +09:00
Alex Illsley 47124df4ed new options for xrdp.ini disableSSlv3=yes and tls_ciphers=HIGH and code to implement 2016-08-25 11:20:47 -07:00
Pavel Roskin 0c72ee2371 Use char* for TLS send and receive
This is consistent with ssl_tls_read() and ssl_tls_write(). C++ warnings
are fixed without adding any casts.
2016-07-08 04:29:56 +00:00
Jay Sorg fac0907a3c trans: set non blocking socket after accept 2016-04-27 18:16:45 -07:00
Jay Sorg 0655272b9c common: call recv/send before can_recv/can_send 2016-04-06 16:37:34 -07:00
Jay Sorg 2893fefc91 common: check for term in force send and recv 2016-01-11 18:06:29 -08:00
Jay Sorg 4f128c530c no logic change, remove trailing space 2015-12-11 20:37:43 -08:00
Jay Sorg e1c7aa377f common: fix possible deadlock in trans 2015-11-02 17:57:11 -08:00
Jay Sorg fd793bd213 rename g_tcp_can_recv to g_sck_can_recv 2015-10-07 22:17:12 -07:00
Jay Sorg 6384bae1e7 common: changes to trans for timeout 2015-08-18 21:10:23 -07:00
Jay Sorg 6c23b85593 add timeout to trans_get_wait_objs_rw 2015-07-13 01:10:48 -07:00
Jay Sorg 136e072513 fix problem caused by b56aa98 for tls connections 2015-07-12 01:38:30 -07:00
Jay Sorg b56aa9832e work on main loop changes 2015-07-05 23:14:46 -07:00
Jay Sorg cc0406dddf common: move tls calls to ssl_calls 2014-11-25 18:55:37 -08:00
Jay Sorg 5a8bf87c7f common: tls, fix for pending reads 2014-11-21 20:49:01 -08:00
speidy 4015f526db work on tls mode 2014-08-22 09:13:33 +03:00
Laxmikant Rashinkar 56e43c4a38 Merge branch 'devel' of github.com:NeutrinoLabs/xrdp into devel 2014-07-26 13:33:44 -07:00
Laxmikant Rashinkar 27055d5762 coverity: improper use of negative value 2014-07-26 13:33:23 -07:00
speidy 0f9bd232d9 common: indent fix 2014-07-26 09:04:22 +03:00
speidy c612683119 common: trans indentation fix 2014-07-26 08:14:19 +03:00
Idan Freiberg df87033489 trans: work on TLS 2014-07-23 15:37:47 +03:00
Idan Freiberg afdf638c7b libxrdp, common: work on TLS mode 2014-07-23 15:31:45 +03:00
Idan Freiberg f0b6c6b1d1 libxrdp: started adding TLS support 2014-07-15 18:29:40 +03:00
Jay Sorg 05a281a3f8 common: trans UDS rights change 2014-05-15 18:04:04 -07:00
Jay Sorg 374633e63f common: no logic change, update comments 2014-03-01 23:26:40 -08:00