Commit graph

7121 commits

Author SHA1 Message Date
Dudemanguy
79e7e69aaa build: add elogind support
Checking the uid of the user seat also works if elogind is used. Add
this as an option to the build and make it mutually exclusive with
enabling systemd.
2025-08-11 14:35:17 +00:00
Simon McVittie
a2ca9bc228 Merge branch 'pollhup-fix' into 'main'
dbus-transport-socket: Handle _DBUS_POLLHUP case in socket_do_iteration

Closes #553

See merge request dbus/dbus!526
2025-08-11 13:55:51 +00:00
Gleb Popov
878f35e5fb dbus-transport-socket: Handle _DBUS_POLLHUP case in socket_do_iteration
Without this change the bus-normal-activation test on FreeBSD ends up with
a busy-loop under one of malloc failures.

Fixes #553
2025-08-11 13:37:56 +00:00
Simon McVittie
48589b3be2 Merge branch 'wip/issue556' into 'main'
sysdeps-pthread: Fix timeout overflow adjustment

Closes #556

See merge request dbus/dbus!532
2025-08-11 13:33:41 +00:00
Johan Bolmsjö
1d73f69afb sysdeps-pthread: Fix timeout overflow adjustment
Fix an off by one error which could produce a tv_nsec value of
1'000'000'000. The valid tv_nsec range is [0, 999,999,999], see
https://en.cppreference.com/w/c/chrono/timespec for reference.

Passing a timespec with a tv_nsec value of 1'000'000'000 to
pthread_cond_timedwait has been observed to cause it to return an error
code which in turn makes the DBUS library abort the application when
compiled with asserts enabled (by PTHREAD_CHECK).

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/556
Reviewed-by: Simon McVittie <smcv@collabora.com>
2025-08-11 14:08:34 +01:00
Simon McVittie
718476760e Merge branch 'wip/smcv/ci' into 'main'
CI: Update FreeBSD image

See merge request dbus/dbus!531
2025-08-08 16:36:45 +00:00
Simon McVittie
538fc647e2 CI: Update FreeBSD to 14.3
14.2 reaches end-of-life in September, and our 14.2-based image has a
sufficiently small amount of space available that it fails to upgrade
now.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-08-08 17:13:45 +01:00
Simon McVittie
a560246feb CI: Update freedesktop.org CI templates
Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-08-08 17:11:43 +01:00
Simon McVittie
37afc6128b Merge branch 'ci' into 'main'
CI: Use a more accurate URL describing the environ problem on FreeBSD

See merge request dbus/dbus!528
2025-06-09 14:02:56 +00:00
Gleb Popov
c1dafe3908 CI: Use a more accurate URL describing the environ problem on FreeBSD 2025-06-08 08:33:00 +00:00
Simon McVittie
6bba6c58c5 Merge branch 'mr524-followup' into 'main'
Make it more obvious that negative timeouts are handled correctly

See merge request dbus/dbus!525
2025-05-23 10:36:45 +00:00
Simon McVittie
481c3cd168 connection, transport: Assert that timeout >= -1 where it matters
We recommend that assertions are disabled in production builds of dbus,
which means that they are "cheap" to add to development builds as
"executable documentation" for our assumptions.

Lower-level code assumes that timeouts must be either -1 to block
forever, or non-negative to block for a finite time (but possibly 0,
to poll without blocking).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-05-23 10:36:33 +00:00
Simon McVittie
e3dcdc6227 connection: Never call _dbus_condvar_wait_timeout() with negative timeout
Previously we were checking for -1 as the special-cased "block forever"
value, but as noted on dbus!524 it is a programming error to call
_dbus_condvar_wait_timeout() with any negative timeout.

Throughout DBusConnection the timeout is in fact constrained to be >= -1
(non-negative to have a timeout, or exactly -1 to block forever) but
checking for non-negative is presumably no more expensive than checking
for exactly -1, so let's be a little more defensive here, to make it
more obvious that we're doing this correctly.

This is the only caller of _dbus_condvar_wait_timeout() in our codebase.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-05-23 10:36:33 +00:00
Simon McVittie
cee059de0c threads: Assert that timeout is non-negative
As noted in dbus!524 by source code inspection, the Unix/pthread
implementation assumes that the timeout is non-negative and does not
support a mode where it blocks forever (which we normally represent as
a negative timeout, like POSIX poll(2)).

This means that it would be a programming error if we ever call
this with a negative timeout, so put an equivalent assertion in the
platform-independent layer. We recommend that assertions are disabled in
production builds, so it's "cheap" to have a redundant assertion here.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-05-23 10:36:33 +00:00
Simon McVittie
626ae07151 timeout: Assert that the timeout interval is non-negative
We should never allocate a DBusTimeout with a negative timeout set:
if we want to wait forever for an event to happen, that's represented
by the absence of a DBusTimeout.

This ensures that code in DBusConnection can safely assume that the
timeout retrieved from a DBusTimeout will always be in its allowed range
(-1 to INT_MAX inclusive).

I've checked that all current callers get this right.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-05-23 10:36:33 +00:00
Simon McVittie
7b272b7d8b timeout: Document fallibility of _dbus_timeout_new()
Like all other functions that allocate memory, libdbus assumes that this
can fail on OOM.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-05-23 10:36:33 +00:00
Simon McVittie
51f72a14e0 connection: Make _dbus_connection_do_iteration_unlocked() static
It has no callers outside this translation unit.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-05-23 10:36:33 +00:00
Simon McVittie
0e8331151d Merge branch 'asserts' into 'main'
Fix building with asserts enabled in FreeBSD

See merge request dbus/dbus!527
2025-05-22 10:16:19 +00:00
Gleb Popov
2bf407f5bb Fix building with asserts enabled in FreeBSD
The backtrace() function on FreeBSD resides in the libexecinfo library, so
we need to link to it.
2025-05-19 10:32:55 +03:00
Simon McVittie
91eb832de0 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-05-16 12:18:48 +01:00
Simon McVittie
aa53ceb2b9 Merge branch 'dbus-connection-timeout' into 'main'
dbus-connection: Avoid computing a negative timeout

See merge request dbus/dbus!524
2025-05-16 10:26:34 +00:00
Gleb Popov
a834a877c6 Assert that timeout >= 0 in _dbus_platform_condvar_wait_timeout 2025-05-16 10:26:23 +00:00
Gleb Popov
fdb6746d85 dbus-connection: Avoid computing a negative timeout
Getting into the `if (timeout == NULL)` block means that
timeout_milliseconds == -1, so it doesn't make sense to do arithmetic on it.

Pass -1 instead of a nonsensical value in this case
2025-05-16 10:26:23 +00:00
Simon McVittie
5035f4bda6 Merge branch 'no-hard-coded-tmpdir' into 'main'
build: Don't use build-time TMPDIR, TEMP, TMP as socket directory

Closes #551

See merge request dbus/dbus!522
2025-05-16 10:22:18 +00:00
Ralf Habacker
91d9e604d4 cmake: Make DBUS_SESSION_SOCKET_DIR in CMakeCache.txt consistent with config.h
It's unexpected to have DBUS_SESSION_SOCKET_DIR take different values in
CMakeCache.txt, which lists the variables that are available to be set
by the caller, and in config.h, which makes their final values available
to the C code. If DBUS_SESSION_SOCKET_DIR is empty and we are running
on Unix, set it to its dynamically-chosen fallback before storing it in
the cache.

[smcv: Add commit message]
Co-authored-by: Simon McVittie <smcv@collabora.com>
2025-05-16 10:22:11 +00:00
Simon McVittie
d7afc131bf build: Don't use build-time TMPDIR, TEMP, TMP as socket directory
When the ancestor of this code was introduced in 2003 (commit e45e4382),
it was presumably most common to have these variables either unset, or
set to a value that is system-wide and remains valid in the long term,
such as /tmp or /var/tmp.

However, on modern systems they are sometimes set to a value that is
itself temporary, for example /var/folders/${some_long_path}/T on macOS,
or user-specific, for example /tmp/user/$(id -u) on Linux with
libpam-tmpdir. These values are certainly not useful to hard-code into
libdbus and dbus-daemon during installation: they will not be usable
when running dbus-related programs after a reboot or as a different user.

So, instead of assuming TMPDIR, TEMP and TMP remain valid long-term,
we now hard-code /tmp as our default.

As before, system integrators can override this default with
`-Dsession_socket_dir=...` (Meson) or `-DDBUS_SESSION_SOCKET_DIR=...`
(CMake) if a different directory is more appropriate than /tmp.
However, system integrators should note that because AF_UNIX paths have
a relatively short length limit (typically 108 bytes), a short path is
better than a long path in this context.

Resolves: dbus/dbus#551
Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-05-16 10:22:11 +00:00
Simon McVittie
f7952eb8e8 meson: Make default directory for test sockets follow session
This makes it a bit easier to override both temporary directories used
for sockets to the same place. If a directory is suitable for production
use for the session bus' temporary sockets, the same directory is very
likely to be suitable for build-time tests as well, and using that
directory for both purposes makes the tests more realistic.

The non-default CMake build system already did the equivalent of this:
it doesn't have an equivalent of test_socket_dir, and setting its
equivalent of session_socket_dir affects both.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-05-16 10:22:11 +00:00
Simon McVittie
f2d18135fb meson: Only set session_socket_dir on Unix
This makes it a little bit clearer that it's OK for the default value
to be Unix-specific. The CMake build system already has the equivalent
of this.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-05-16 10:22:11 +00:00
Simon McVittie
a363b7c998 build: Only define DBUS_SESSION_SOCKET_DIR on Unix
This is not used on Windows (in fact it's only used in the
dbus-cleanup-sockets(1) tool) so it's OK for it to have a value like /tmp
that would be inappropriate on Windows. Make that more obvious.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-05-16 10:22:11 +00:00
Simon McVittie
8a9fddb26d build: Only define DBUS_TEST_SOCKET_DIR on Unix platforms
This makes it more obvious that it is currently only used on Unix,
and therefore it's OK for it to have a default that wouldn't work
on Windows.

The non-default CMake build system already didn't set the variable when
building for Windows.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-05-16 10:22:11 +00:00
Simon McVittie
d18c7f6889 meson: Remove a leftover reference to make check
Meson build-time tests are run with `meson test` instead, but let's
say "automated tests" generically, rather than a specific command.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-05-16 10:22:11 +00:00
Simon McVittie
29c90f7697 Merge branch 'launchd-not-open-source' into 'main'
spec: launchd is no longer open-source

See merge request dbus/dbus!523
2025-05-01 09:38:28 +00:00
Akihiro Suda
676093c185
spec: launchd is no longer open-source
launchd is apparently proprietary since OS X Yosemite v10.10 (2014).

The last known open-source version is
https://github.com/apple-oss-distributions/launchd/releases/tag/launchd-842.92.1
(OS X Mavericks v10.9.4).

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-05-01 09:27:21 +09:00
Simon McVittie
4e8a83ca94 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-04-28 12:51:18 +01:00
Simon McVittie
427e9d61dd Merge branch 'local-peercred' into 'main'
Support LOCAL_PEERCRED found on FreeBSD and MacOS in _dbus_read_credentials_socket()

See merge request dbus/dbus!520
2025-04-28 11:46:14 +00:00
Alex S
667d78ff0b Support LOCAL_PEERCRED found on FreeBSD and MacOS in _dbus_read_credentials_socket() 2025-03-14 11:50:55 +03:00
Simon McVittie
cddd0a7c94 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-03-07 16:21:50 +00:00
Simon McVittie
4acb9d7cea Merge branch 'auth-timeout-comment' into 'main'
bus: Correct commented-out default auth_timeout in system.conf

See merge request dbus/dbus!519
2025-03-07 16:03:39 +00:00
Simon McVittie
9746758a2e bus: Correct commented-out default auth_timeout in system.conf
Commit 54d26df5 "config: change default auth_timeout to 5 seconds"
reduced the hard-coded default from 30 to 5 seconds, and the
commented-out informational copy of this information in system.conf
reflected that.

Commit 02e1ddf9 'Revert "config: change default auth_timeout to 5 seconds"'
subsequently increased hard-coded default back to 30 seconds, but did
not update the commented-out version in this file.

See also CVE-2014-3639, fd.o #80919, fd.o #86431.

Fixes: 1a36f983 "Document default limits in system.conf.in"
Fixes: 02e1ddf9 'Revert "config: change default auth_timeout to 5 seconds"'
Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-03-07 16:02:50 +00:00
Simon McVittie
fb07df7cab Merge branch 'ci-jobs' into 'main'
CI: Adjust which CI jobs are run by default

See merge request dbus/dbus!518
2025-02-28 15:11:45 +00:00
Simon McVittie
0c7ecfd8cd CI: Don't build on FreeBSD with CMake by default
We recommend the Meson build system for all target operating systems
other than Windows. We do try to keep CMake builds operational on Linux
to make life easier for developers, but the `opensuse cmake debug` job,
which runs by default, is sufficient for that.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-02-28 14:44:19 +00:00
Simon McVittie
1cb9b8bffe CI: Enable Windows build with Meson, gcc and UCRT64
This was broken for a while (see dbus#462, dbus!426, dbus!429, dbus!512)
but now it works again. Let's not allow it to regress without someone
noticing.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-02-28 14:42:50 +00:00
Simon McVittie
c6780cbd31 Merge branch 'subprojects' into 'main'
build: Improve options used for fallback Meson subprojects

See merge request dbus/dbus!516
2025-02-28 14:36:56 +00:00
Simon McVittie
0a01eb02ae build: If GLib is a subproject, disable GObject-Introspection
We don't need this and it will only slow down the build.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-02-28 13:03:13 +00:00
Simon McVittie
57abac5bc8 build: Link subprojects statically if built as a subproject
If we're building a dependency as a fallback subproject, we don't want
to be responsible for installing it as a shared library. Anyone wanting
shared libraries should install the dependencies separately.

Ideally we'd do this with MSVC too, but that doesn't currently link
successfully (dbus#549).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-02-28 13:03:07 +00:00
Simon McVittie
3ca6a3fec4 build: Never make compiler warnings in subprojects fatal
If one of our subprojects has compiler warnings, fixing them is
out-of-scope for dbus.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-02-28 12:29:55 +00:00
Simon McVittie
0d820a6e17 build: Indent GLib subproject options consistently
Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-02-28 12:05:02 +00:00
Simon McVittie
8514f7bfa0 build: If expat is a submodule, explicitly disable its unit tests
If we're falling back to building a local copy of expat, running or
debugging its unit tests is out-of-scope for maintenance of dbus.
In fact this is the default in the meson_options.txt provided by
WrapDB[1], but explicit is better than implicit.

[1] https://github.com/mesonbuild/wrapdb/blob/HEAD/subprojects/packagefiles/expat/meson_options.txt

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-02-28 12:03:55 +00:00
Simon McVittie
20de6d82c6 Merge branch 'update-wraps' into 'main'
Update GLib fallback subproject to latest stable release

See merge request dbus/dbus!426
2025-02-27 23:10:31 +00:00
Simon McVittie
0a3b1f9d11 CI: Never run the test suites of subprojects
Some of them fail when run on Windows, and debugging the test suite
for a subproject is out-of-scope for dbus.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-02-27 19:27:06 +00:00