Commit Graph

743 Commits

Author SHA1 Message Date
matt335672 0758fe03a6 Add UTF-16 LE I/O routines
These are intended to replace UTF-16 uses of mbstowcs() / wcstombs()
2023-10-18 10:07:49 +01:00
matt335672 0463e552dc Add UTF-8 / UTF-32 conversion routines
These are intended to replace non-UTF-16 uses of mbstowcs() / wcstombs()
2023-10-18 10:07:49 +01:00
matt335672 d11617adbe Remove dependency on signal() function
Replaces uses of signal() with sigaction() which should be far
more portable.
2023-10-09 14:05:29 +01:00
matt335672 cf677da22c Add getgrouplist() support to os_calls
On enterprise systems, using getgrouplist() (if available)
is more efficient than iterating over the members of the group,
and is also more likely to work
2023-10-04 11:02:07 +01:00
Keith Gable 9305008ba8 Tolerate XRDP_ENABLE_VSOCK being defined but the platform is neither FreeBSD nor Linux 2023-09-24 12:32:10 -07:00
Keith Gable 5ffca14b2f Change indent style to allman 2023-09-24 12:27:00 -07:00
Keith Gable 572ee7686d On FreeBSD, use AF_HYPERV in place of vsock 2023-09-23 21:28:24 -07:00
matt335672 ce42e3e12d Replace g_strsignal() with g_sig2text()
This call provides a textual representation of a signal number, i.e.
SIGHUP is mapped to "SIGHUP"

Unit tests are also added.
2023-06-12 16:19:17 +01:00
matt335672 0f32661056 Add g_strsignal() to string_calls module 2023-06-08 16:32:24 +01:00
matt335672 ac65538a48 Re-implement fifo code
Following informal option testing, a more performant fifo
implementation has been chosen which makes fewer, larger
allocations, but which does not have bad edge-case performance

Clearing the contents of a fifo is a common operation which generally
involves freeing memory. Support has been added to the fifo interface
for doing this.
2023-05-22 14:43:22 +01:00
Jay Sorg c250529e8e add large cursor support, posix shm 2023-05-16 10:20:24 -07:00
Daniel Richard G b191d87e33 Move Linux's no_new_privs call into os_calls
This helps keep the application code free of platform-specific cruft.
Also remove a needless #include<sys/prctl.h> from sesman/session_list.c.
2023-05-15 17:40:46 -04:00
Daniel Richard G 1c0c923ad1 Split g_file_open() into _ro() and _rw() variants
Rename g_file_open() to g_file_open_rw(), and add a new g_file_open_ro()
call that wraps the common g_file_open_ex(file, 1, 0, 0, 0) idiom. This
will make the file access mode more explicit in the code.

Change all calls to g_file_open() to the _ro() or _rw() variant as
appropriate, and replace g_file_open_ex(file, 1, 0, 0, 0) with the _ro()
call.

Lastly, add tests for the two new calls to test_os_calls.c (code
courteously provided by matt335672).
2023-05-15 17:38:31 -04:00
Daniel Richard G 42d32e7496 Use config_ac.h consistently and correctly 2023-05-12 13:49:53 -04:00
matt335672 e96d77bac1 Remove g_mk_socket_path() from codepaths
The socket dir is only used if we are starting a session
with sesman. Consequently, it only makes sense to create
this directory within sesman itself.
2023-05-02 11:55:22 +01:00
matt335672 cf5e1961d3 os_calls: Add g_setpgid() 2023-05-02 11:55:22 +01:00
matt335672 65ff618479 os_calls: Add g_executable_exist() 2023-05-02 11:55:22 +01:00
matt335672 ff24984cf3 os_calls: Add g_file_is_open() 2023-05-02 11:55:22 +01:00
matt335672 f08355a325 Ensure commonly used file descriptors are close-on-exec 2023-04-24 14:20:14 +01:00
matt335672 1c798cee47 Logging: Add LOG_DEVEL_LOG_LEAKING_FDS 2023-04-24 14:20:14 +01:00
matt335672 d712f3527a os_calls: Add g_get_open_fds() 2023-04-24 11:57:38 +01:00
matt335672 b811fdb36b os_calls: Add g_file_{get,set}_cloexec() functions
Allows us to avoid file descriptor leaks when running a new executable
2023-04-24 11:11:04 +01:00
matt335672 3ee8eb9c9e
Merge pull request #2592 from matt335672/restructure_session_start
Restructure session start
2023-03-27 10:38:37 +01:00
Jay Sorg 2d8b52f744 common: change g_malloc, g_free, g_memset, g_memcpy, and g_memmove to macros 2023-03-25 12:22:19 -07:00
matt335672 8b9f9b40c8 os_calls changes
- Add g_pipe()
- Add g_file_duplicate_on()
- Rework struct exit_status to make it easier to parse
- Add optional status return to g_waitchild()
2023-03-23 18:12:06 +00:00
Nexarian 5273624089 Fixing some comments 2023-03-14 02:02:09 -04:00
matt335672 3bd1820407 Fix regression caused by move to poll() 2023-03-13 20:02:05 +00:00
matt335672 621b3fc6dc Add g_execvp_list() to os_calls 2023-03-06 16:03:55 +00:00
matt335672 c3d697de16 Add list_add_strdup() etc 2023-03-06 15:58:13 +00:00
matt335672 a317c3de5d Fix regression in list module 2023-03-06 15:47:49 +00:00
Nexarian 89e178e7c9 Add function to split string into list.
- With working unit tests.
2023-03-03 18:33:33 -05:00
matt335672 86d0d0e9fd Addressed review comments 2023-02-13 14:28:29 +00:00
matt335672 78fa1c15b2 Replace select() system call with poll()
poll() is specified in POSIX.1-2001 as a simpler interface for
multiplexed file descriptors than select(). It also provides more
functionality.

This PR replaces the select() calls used in xrdp with poll()
equivalents.
2023-02-13 14:28:29 +00:00
matt335672 5aa5624551 Add memory allocation checking to the list module
The list module lacks memory allocation checking, and
consequently can coredump on list_create() or
list_add_item().
2023-02-13 10:37:46 +00:00
Derek Schrock 1e5b42893c Add g_set_alarm to set an alarm calling func after secs seconds 2023-02-11 18:01:12 -05:00
metalefty c463a0e865
Merge pull request #2541 from metalefty/log_time
log: fix syslog glitch after #2386
2023-02-10 09:06:12 +09:00
Koichiro IWAO ec2f165af4 log: fix syslog glitch after #2386
The tail of new datetime format was sticking out.
2023-02-09 17:09:28 +09:00
Nexarian 7542dfc4f2
Merge pull request #2533 from Nexarian/Nexarian/update-pixman-region-header
Add functions and reformat pixman-region.h
2023-02-05 19:16:53 -05:00
Nexarian 7520c69049 Add functions and reformat pixman-region.h
- Update pixman-region.h header
-- Reformat so all lines fit within 80 characters.
-- Update define guard to use convention for the rest of XRDP.

Add pixman_region_not_empty and pixman_region_extents in anticipation of
using it for EGFX in the future.
2023-02-04 15:07:13 -05:00
matt335672 a5034e3572 Implement g_sck_send_fd_set() and g_sck_recv_fd_set() 2023-01-30 14:31:16 +00:00
matt335672 1fbcdffff1 Use unsigned int for some data lengths 2023-01-30 14:31:16 +00:00
Nexarian db5ea2f214 Initial EGFX tests.
- Rearranging imports.
- Remove unnecessary check to g_is_wait_obj_set.
- Use g_get_term everywhere.
- Misc updates.
2023-01-23 23:05:24 -05:00
matt335672 48e46d183a Add g_setallusercontext() for *BSD systems 2023-01-05 10:52:08 +00:00
matt335672 47ace4acfd Fix g_sck_get_peer_cred() on FreeBSD
Socket level should be SOL_LOCAL rather than SOL_SOCKET - See
'man unix'.
2022-12-22 11:35:02 +00:00
matt335672 a16e56f711 Add function to get user information by UID
Moving to a uid_t to store the user information makes a lot
of sense. When doing this, we need a function to get information
about a user from the uid_t

As well as creating the function g_getuser_info_by_uid() we also
rename g_getuser_info() to g_getuser_info_by_name() and make the
parameter ordering more usual.
2022-12-22 11:35:02 +00:00
matt335672 a4fb635a5d
Merge pull request #2453 from matt335672/update_kerberos
Fix the kerberos module
2022-12-14 10:44:31 +00:00
matt335672 cce78b0698
Merge pull request #2407 from alexpevzner/devel
LogFile=- redirects log to stdout, which is useful for debugging
2022-12-12 20:33:04 +00:00
matt335672 df83fbf9bf Fix const-correctness for g_system() 2022-12-12 19:52:27 +00: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
matt335672 c3bb7dc294 guid_new() returns GUIDs compatible with RFC4122 2022-11-10 14:19:19 +00:00