summaryrefslogtreecommitdiff
path: root/dbus
Commit message (Collapse)AuthorAgeFilesLines
...
* Escape socket path when building the D-Bus addressMarc-André Lureau2022-07-181-4/+4
| | | | | | | Fixes: https://gitlab.freedesktop.org/dbus/dbus/-/issues/405 Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* sysdeps: Only open oom_score_adj read/write if we need to write itSimon McVittie2022-07-161-3/+23
| | | | | | | | | | | | | | If we're running in a sandbox, we might not have write access to oom_score_adj. In the common case where we don't have any special protection from the OOM-killer, we can detect that with only read access, and skip the part where we open it for writing. (We would also not have write access to oom_score_adj if we're running with elevated Linux capabilities while not root, but that should never actually happen for dbus-daemon-launch-helper, which is setuid root for production use or has no capabilities during unit-testing.) Signed-off-by: Simon McVittie <smcv@collabora.com>
* dbus: extract out _dbus_server_new_for_dir()Marc-André Lureau2022-07-152-46/+70
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus/win: use SIO_AF_UNIX_GETPEERPID to lookup peer PIDMarc-André Lureau2022-07-151-1/+63
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: add a few directory separator macrosMarc-André Lureau2022-07-151-0/+4
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: move DBUS_IS_DIR_SEPARATOR to dbus-internals.hMarc-André Lureau2022-07-152-12/+10
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: move AF_UNIX code to server-socketMarc-André Lureau2022-07-157-317/+276
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: handle unix server in a new functionMarc-André Lureau2022-07-153-6/+45
| | | | | | | Split _dbus_server_listen_platform_specific() to handle unix listenable address independently, allowing Windows support in following commit. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: move AF_UNIX code to transport-socketMarc-André Lureau2022-07-155-145/+147
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: add _dbus_transport_open_unixexec()Marc-André Lureau2022-07-153-1/+22
| | | | | | | Split _dbus_transport_open_unix_socket() to leave the "unixexec:" handling to the unix-specific unit. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: handle unix transport in a new common functionMarc-André Lureau2022-07-153-12/+43
| | | | | | | Split out the Unix socket handling from open_platform_specific(), enabling "unix:" connectable addresses on Windows in next patch. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: add function for Unix sockets on WindowsMarc-André Lureau2022-07-151-0/+226
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: move _DBUS_MAX_SUN_PATH_LENGTH to sysdeps.hMarc-André Lureau2022-07-152-15/+14
| | | | | | Share the same constant for all systems. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: move unix socket declarations to common sysdeps.hMarc-André Lureau2022-07-152-11/+12
| | | | | | | The function declaration can be moved to system-agnostic header and be implemented on Windows in following commits. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: change unix socket functions to return DBusSocketMarc-André Lureau2022-07-154-51/+58
| | | | | | This will allow to abstract away for Windows Unix socket support. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: simplify socket close() & invalidate() callsMarc-André Lureau2022-07-155-21/+9
| | | | | | Now that _dbus_close_socket() invalidates the socket on its own already. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: set the socket as invalid in _dbus_close_socket()Marc-André Lureau2022-07-152-4/+15
| | | | | | | This can simplify error handling in many situation where a socket is returned, such as in the following commits. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: make _dbus_close_socket() take DBusSocket*Marc-André Lureau2022-07-1511-24/+28
| | | | | | This will allow to invalidate the socket in the following commit. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus/win: fix a code comment about get_tmpdir()Marc-André Lureau2022-07-151-2/+1
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* s/PF_UNIX/AF_UNIXMarc-André Lureau2022-07-151-1/+1
| | | | | | | PF_UNIX is an old BSD 4.x relic, and even there they promise that PF_UNIX is the same as AF_UNIX. (Linux socket(2)) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* Misc style fixMarc-André Lureau2022-07-151-1/+1
| | | | | | | As pointed out by Simon McVittie <smcv@collabora.com>: https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/249#note_1323102 Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus-launch-x11: Ignore X11 connection when checking for memory leaksSimon McVittie2022-07-151-0/+22
| | | | | | | | | | | | | | The X11 connection is opened and never closed. Because dbus-launch forks and continues to run non-trivial code in a forked child, it is not clear whether (or where) it would be safe to close it; instead, we leave it open until process exit, at which point the socket is cleaned up by the kernel. Any memory allocated for the X11 connection is only allocated once per run of dbus-launch, so there's no need to keep track of it, and we can silence these memory leak warnings as uninteresting. Signed-off-by: Simon McVittie <smcv@collabora.com>
* meson: Fix the check for --version-script supportSimon McVittie2022-07-133-3/+21
| | | | | | | At the time we do this check, version_script has not yet been generated, so we have to use something else. Signed-off-by: Simon McVittie <smcv@collabora.com>
* dbus: Only use compile flags from valgrind, not librariesSimon McVittie2022-07-131-1/+1
| | | | | | | | | | Recent versions of valgrind have library code, which we don't need (or want) to link to; all we actually want is <valgrind.h> and <memcheck.h>. I had hoped that this would suppress the Requires.private when generating our .pc file, but it doesn't seem to. Signed-off-by: Simon McVittie <smcv@collabora.com>
* build: Add machine-readable licensing markers to the Meson build systemSimon McVittie2022-07-131-0/+1
| | | | Signed-off-by: Simon McVittie <smcv@collabora.com>
* build: Distribute Meson build system in release tarballsSimon McVittie2022-07-131-0/+2
| | | | | | | As long as we are treating Autotools as a first-class citizen, what we release will be `make distcheck` output. Signed-off-by: Simon McVittie <smcv@collabora.com>
* Add Meson build systemFélix Piédallu2022-07-131-0/+231
| | | | | Signed-off-by: Félix Piédallu <felix@piedallu.me> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* sysdeps-win: display process id of started dbus-daemonRalf Habacker2022-06-271-1/+1
| | | | When verbose mode is enabled, this information is useful for debugging.
* sysdeps-win: Use the `connection readiness` event when starting dbus-daemonRalf Habacker2022-06-271-16/+82
| | | | | | | | | | | | In _dbus_get_autolaunch_address() instead of polling at intervals to see if the shared memory segment is present, the named signal is now used to reliably get the state of dbus-daemon. In _dbus_get_autolaunch_shm() the unnecessary initialization of `address` has been removed, error handling has been improved and the `wait` parameter has been added to select waiting. Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
* sysdeps-win: Let tests access autostarted dbus-daemon's handleRalf Habacker2022-06-272-1/+31
| | | | | | | | This will allow automated tests to kill the autostarted dbus-daemon before continuing to the next test-case, which wasn't previously possible. Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
* sysdeps-win: Add support to give auto launched dbus daemon custom parameterRalf Habacker2022-06-271-1/+22
| | | | | | | For that purpose the function _dbus_test_win_set_autolaunch_command_line_parameter() has been added. Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
* Fix indentation of functions that are later changedRalf Habacker2022-06-271-22/+21
|
* dbus-mempool.c: Ensure element_size is at least sizeof(void *)Alex Richardson2022-05-221-1/+3
| | | | | | I am trying to use DBus on an Arm Morello system where sizeof(void *) is 16 and not 8, so the assertion in the line below can fail unless we ensure that element_size is at least sizeof(void *).
* dbus: remove pam_console/pam_foreground supportMarc-André Lureau2022-05-193-84/+1
| | | | | | | | | | DBUS_CONSOLE_AUTH_DIR is deprecated since 1.11.18, and was intended to have been removed in 1.13. Let's drop the related code now. Fixes: https://gitlab.freedesktop.org/dbus/dbus/-/issues/181 Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=101629 Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: fix unused warningMarc-André Lureau2022-05-191-1/+5
| | | | | | | ../../dbus/dbus-message.c:5462:17: warning: variable ‘len’ set but not used [-Wunused-but-set-variable] 5462 | unsigned char len; Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* dbus: fix warning: label 'oom' defined but not usedMarc-André Lureau2022-05-181-7/+2
| | | | | | | | When DBUS_ENABLE_VERBOSE_MODE is not set, the compiler warns. Let's remove the label. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* On Windows in autolaunch related function use rmutex related functions to ↵Ralf Habacker2022-05-175-69/+77
| | | | | | | | | | | | support thread locking The previously used additional and incomplete functions have been merged into the current rmutex functions to fix the reported bug and reduce the maintenance effort. Fixes #368, #370 Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
* dbus-memory.c: Silence -Wcast-align warningsAlex Richardson2022-05-171-11/+11
| | | | | These values will be appropriately aligned, so we can silence the warning by adding a void* cast.
* dbus-marshal-bytes.c: Silence -Wcast-align warningsAlex Richardson2022-05-171-4/+8
| | | | | We have ensured that the values are aligned at runtime, but Clang's warning cannot see that. Silence the warning with a void* cast.
* dbus-sysdeps-unix.c: Silence -Wcast-align when using CMSG_DATAAlex Richardson2022-05-171-2/+2
| | | | | This triggers when building on FreeBSD with clang, but since we know that the CMSG_DATA() will be aligned we can silence the warning using a cast.
* dbus-string.c: use memcpy() in _dbus_string_insert_{2,4,8}_alignedAlex Richardson2022-05-171-16/+4
| | | | | | | | | This fixes a -Wcast-align warning from Clang, and I believe this could be a genuine issue on some architectures since the octets argument is an unsigned char pointer that only has alignment 1. Using memcpy() instead will generate the same code on architectures that support unaligned loads and stores (i.e. almost all current ones) and individual stores on those that don't (e.g. old MIPS).
* dbus-marshal-basic.c: Silence Clang -Wcast-align false-positivesAlex Richardson2022-05-171-20/+20
| | | | | | | Clang performs the -Wcast-align analysis before code generation and optimizations, so the compiler cannot see that the alignment is actually guaranteed to be sufficient for these casts. Silence the warning by adding casts to void* and/or changing the types of some variables.
* Add doc to platform related [c|r]mutex functionsRalf Habacker2022-05-011-0/+48
|
* Add unit tests for platform-specific mutex implementation.Ralf Habacker2022-05-013-0/+22
| | | | | | | | | | | | | | | | | | | | The tests are enabled with the embedded tests; the required low-level functions from the dbus library are decorated with DBUS_EMBEDDED_TESTS_EXPORT to indicate the appropriate usage. On Windows, all tests are run; on unix-like operating systems, individual tests are disabled: - the tests on #NULL pointers of type DBus[C|R]Mutex, since they point to a data structure and would cause a segment violation when accessed. - the multiple lock test for type DBusCMutex, since it would block the current thread. Since the whole point of "rmutex" is to be able to lock multiple times, the "rmutex double lock" test is enabled on unix-like operating systems too. Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
* Add assertions to the [c|r]mutex related functions on WindowsRalf Habacker2022-05-011-6/+20
| | | | | | | | | | This detects some error conditions that can only occur as a result of a programming error, such as attempting to unlock a mutex that is not locked. Fixes #369 Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
* dbus-string: Add _dbus_string_append_buffer_as_hex()Ralf Habacker2022-05-012-0/+41
| | | | | | | | This function provides a portable way to print data as hex values. Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de> [smcv: Only compile this when needed, improve assertions, coding style] Signed-off-by: Simon McVittie <smcv@collabora.com>
* dbus: Move DBUS_PRIVATE_EXPORT to private headerSimon McVittie2022-05-013-17/+19
| | | | | | | Unlike the rest of the macros in dbus-macros.h, this one would never have made sense to use in a public header. Signed-off-by: Simon McVittie <smcv@collabora.com>
* dbus: Move DBUS_ENABLE_EMBEDDED_TESTS to a new dbus-macros-internal.hSimon McVittie2022-05-014-6/+39
| | | | | | | | | This avoids a circular dependency: I want to use DBUS_ENABLE_EMBEDDED_TESTS in dbus-string.h, but DBUS_ENABLE_EMBEDDED_TESTS was previously defined in dbus-internals.h, which depends on dbus-string.h. Signed-off-by: Simon McVittie <smcv@collabora.com>
* _dbus_string_test(): Fix fatal build error caused by "-Wstrict-aliasing"Ralf Habacker2022-04-212-0/+16
| | | | | | | | | | To fix this problem, the problematic code was replaced by a new function _dbus_string_get_allocated_size(), which uses the existing macro DBUS_CONST_STRING_PREAMBLE for these purposes. Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de> Part-of: https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/275 Reviewed-by: Simon McVittie <smcv@collabora.com>
* sysdeps: On Linux, wrap close_range syscall directly if necessarySimon McVittie2022-04-211-0/+18
| | | | | | | | | This was added to the Linux kernel in version 5.9, but the wrapper wasn't added to glibc until 2.34. Adding our own wrapper for the system call means we can use close_range() on Debian 11 and contemporary distributions. Signed-off-by: Simon McVittie <smcv@collabora.com>