Simon McVittie [Tue, 18 Feb 2025 10:37:28 +0000 (10:37 +0000)]
selinux: Don't include unused reference count in verbose logging
libselinux 3.8 includes an API break in which the `refcnt` field of
struct security_id_t (originally intended to be a reference count, but
in practice always initialized to 1 and never modified) was renamed and
repurposed as an `id` field. This caused a build failure if dbus was
compiled with both SELinux support and verbose mode, for example in the
instrumented debug build that Debian includes in the `dbus-tests` package.
This particular piece of debug logging has little value, so just
remove it.
Reference: https://github.com/SELinuxProject/selinux/commit/e5fd7b078fb8eb0b15eb5beaccd0e6a07ec26758
Bug-Debian: https://bugs.debian.org/1096212 Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Tue, 17 Dec 2024 12:48:00 +0000 (12:48 +0000)]
README: Stop describing odd/even as Linux kernel versioning
The Linux kernel hasn't used this versioning scheme for years
(the last odd-numbered development branch was 2.5).
We are still using the odd/even versioning scheme, and so are some other
library projects. Cite GLib and SDL as better examples of projects that
still use it.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Tue, 17 Dec 2024 12:44:57 +0000 (12:44 +0000)]
README.win, README.cygwin: Describe dbus4win, etc. as historical
The merge of Windows-specific dbus ports into the same git repository
as the original Unix-only implementation was a long time ago now,
and exists on several stable-branches, not just master.
This also avoids explicitly mentioning the name of the master branch,
which is likely to be renamed to main in future.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Tue, 17 Dec 2024 12:42:36 +0000 (12:42 +0000)]
INSTALL, README: Simplify Meson vs. CMake recommendation
Now that 1.16.0 has been released and 1.15.x is EOL, it's misleading
to say that Meson is the recommended build system for Unix only on the
master branch: it's the recommended build system for Unix on the
dbus-1.16 branch, too.
This also avoids explicitly naming the master branch, which is likely
to get renamed to main.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 13 Dec 2024 10:53:23 +0000 (10:53 +0000)]
meson: Don't interpolate the result of configure_file() into a format()
configure_file() returns a file object, which was not intended to be a
valid parameter for format() (even though in practice it works the way
we wanted it to), causing newer Meson versions to report deprecation
warnings.
If the version of Meson is new enough, we can use the full_path()
method. Otherwise, we'll have to re-compute the output filename.
Simon McVittie [Fri, 13 Dec 2024 10:53:23 +0000 (10:53 +0000)]
meson: Don't interpolate the result of configure_file() into a format()
configure_file() returns a file object, which was not intended to be a
valid parameter for format() (even though in practice it works the way
we wanted it to), causing newer Meson versions to report deprecation
warnings.
If the version of Meson is new enough, we can use the full_path()
method. Otherwise, we'll have to re-compute the output filename.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 13 Dec 2024 10:54:56 +0000 (10:54 +0000)]
CI: Use Debian 12 as default container
I don't think we use this for anything any more, because all build
targets run in some more specific container; but just in case it's
used, we should select the current stable release of Debian and not a
previous, EOL version.
Simon McVittie [Fri, 13 Dec 2024 10:54:56 +0000 (10:54 +0000)]
CI: Use Debian 12 as default container
I don't think we use this for anything any more, because all build
targets run in some more specific container; but just in case it's
used, we should select the current stable release of Debian and not a
previous, EOL version.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Ralf Habacker [Wed, 11 Dec 2024 14:33:44 +0000 (15:33 +0100)]
cmake: add missing environment variables for running tests
To achieve comparable results with Meson, the test environment should
provide the same set of environment variables when used in the source
code or the test environment.
Ralf Habacker [Wed, 11 Dec 2024 14:33:44 +0000 (15:33 +0100)]
cmake: add missing environment variables for running tests
To achieve comparable results with Meson, the test environment should
provide the same set of environment variables when used in the source
code or the test environment.
Simon McVittie [Tue, 10 Dec 2024 11:00:28 +0000 (11:00 +0000)]
bus: Update a build system cross-reference
We no longer have an Autotools build system, but Meson sets the same
environment variables that Autotools used to set. CMake does not, yet,
but ideally should.
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/538 Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 229e48f549dfb1af891545fd978974dd462777da)
Mohamed Akram [Tue, 10 Dec 2024 13:30:19 +0000 (17:30 +0400)]
sysdeps-unix: Report missing launchd session bus as non-fatal
init_connections_unlocked() is called when connecting to any of the
well-known buses, and it initializes all of the well-known addresses:
session, system and starter. This means that a failure here causes
failure to connect to any one of the well-known buses, even if the
failure is actually only relevant to a different well-known bus.
As such, it should only fail on genuinely fatal errors, for example
an out-of-memory condition. It calls init_session_address() and
indirectly _dbus_lookup_session_address(), which therefore need to
have similar behaviour.
Previously, _dbus_lookup_session_address() would fail with a
fatal error whenever the macOS session bus was not correctly set up,
but that breaks the ability to connect to the system bus on macOS,
even though the system bus is not directly related to the session bus.
Instead, we should report a missing session bus as "not supported",
reserving an unsuccessful result for fatal situations like
out-of-memory. This brings _dbus_lookup_session_address_launchd()
into line with the error behaviour of _dbus_lookup_user_bus().
Simon McVittie [Tue, 10 Dec 2024 11:00:28 +0000 (11:00 +0000)]
bus: Update a build system cross-reference
We no longer have an Autotools build system, but Meson sets the same
environment variables that Autotools used to set. CMake does not, yet,
but ideally should.
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/538 Signed-off-by: Simon McVittie <smcv@collabora.com>
Mohamed Akram [Tue, 10 Dec 2024 13:30:19 +0000 (17:30 +0400)]
sysdeps-unix: Report missing launchd session bus as non-fatal
init_connections_unlocked() is called when connecting to any of the
well-known buses, and it initializes all of the well-known addresses:
session, system and starter. This means that a failure here causes
failure to connect to any one of the well-known buses, even if the
failure is actually only relevant to a different well-known bus.
As such, it should only fail on genuinely fatal errors, for example
an out-of-memory condition. It calls init_session_address() and
indirectly _dbus_lookup_session_address(), which therefore need to
have similar behaviour.
Previously, _dbus_lookup_session_address() would fail with a
fatal error whenever the macOS session bus was not correctly set up,
but that breaks the ability to connect to the system bus on macOS,
even though the system bus is not directly related to the session bus.
Instead, we should report a missing session bus as "not supported",
reserving an unsuccessful result for fatal situations like
out-of-memory. This brings _dbus_lookup_session_address_launchd()
into line with the error behaviour of _dbus_lookup_user_bus().
Simon McVittie [Tue, 10 Dec 2024 14:31:59 +0000 (14:31 +0000)]
tests: Exercise NSS group lookup before running tests
Similar to #256, NSS plugins might open file descriptors the first time
they look up a system group, and leave them open. To avoid detecting
this as a leak, do one group lookup (which we expect to fail) before
starting testing, so that the fd is already open the first time we
call _dbus_check_fdleaks_enter(), and therefore is not considered to
have been leaked in _dbus_check_fdleaks_leave().
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/540 Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 7cbb7b75dd2803fcb0c6edb18d5c43e4eaeee704)
Simon McVittie [Mon, 9 Dec 2024 17:12:18 +0000 (17:12 +0000)]
internals: Use negative numbers to indicate no malloc failure simulation
If we set the countdown to simulating a failed allocation to
_DBUS_INT_MAX, then it will decrement every time we allocate memory,
eventually reaching 0 and triggering a simulated malloc failure.
In practice this does not happen during unit testing, because all of
our tests are (intentionally!) short enough that this can't happen,
but it can happen if a build of dbus with embedded tests enabled is
used for the "real" dbus-daemon or a "real" D-Bus service, either
during debugging or unintentionally, as noted on dbus/dbus!493.
We cannot simply special-case `_DBUS_INT_MAX` to never be decremented,
because _dbus_test_oom_handling() relies on the counter being
decremented even while we are not simulating malloc failure, as a way
to count the number of allocations as an upper bound for how long to
set the countdown during subsequent test runs.
Instead, reserve all negative numbers to represent the absence of
malloc failure simulation, while still being able to count allocations
by comparing two different negative numbers.
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/535 Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 0735c401a7b3c9e56096fcde8139e773067302bd)
Simon McVittie [Mon, 9 Dec 2024 18:16:46 +0000 (18:16 +0000)]
cmake: Make intrusive (formerly embedded) tests into a separate option
Previously, the CMake build enabled tests by default, and enabled both
modular and intrusive (embedded) tests with a single option. This is
a really bad idea if anyone is using CMake-built binaries in production.
DBUS_BUILD_TESTS now enables only the modular tests, which are safe to
enable in production builds.
A new DBUS_ENABLE_INTRUSIVE_TESTS option enables the intrusive test
instrumentation.
To preserve existing test coverage, explicitly enable the intrusive
tests in most CMake-based Gitlab-CI jobs (Debian native, openSUSE native,
Windows).
In jobs that have a mirrored pair of production/debug builds (openSUSE
and Debian mingw32/mingw64 cmake), instead we leave the production
build as-is and only build full test coverage in the debug build.
Co-authored-by: Philip Withnall <philip@tecnocode.co.uk> Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 41c7570e1ea803e9635d9bcabba5fc221c94e7e6)
Simon McVittie [Mon, 9 Dec 2024 17:45:32 +0000 (17:45 +0000)]
Rename "embedded tests" to "intrusive tests"
This hopefully helps to get across the point that enabling these tests
adds instrumentation to libdbus and dbus-daemon, with a potentially
significant impact on code size, performance and security.
To avoid a huge diffstat which would be difficult to review, the cpp
macro that is checked by most of the C code is still
DBUS_ENABLE_EMBEDDED_TESTS, which is defined or undefined under exactly
the same conditions as the new DBUS_ENABLE_INTRUSIVE_TESTS.
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/537 Co-authored-by: Philip Withnall <philip@tecnocode.co.uk> Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 9c5b5838f5ff667225a913f97006816e3e401d55)
Simon McVittie [Tue, 10 Dec 2024 14:31:59 +0000 (14:31 +0000)]
tests: Exercise NSS group lookup before running tests
Similar to #256, NSS plugins might open file descriptors the first time
they look up a system group, and leave them open. To avoid detecting
this as a leak, do one group lookup (which we expect to fail) before
starting testing, so that the fd is already open the first time we
call _dbus_check_fdleaks_enter(), and therefore is not considered to
have been leaked in _dbus_check_fdleaks_leave().
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/540 Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 6 Dec 2024 17:49:02 +0000 (17:49 +0000)]
build: Bump version number to 1.16.99-alpha
This is a placeholder for the first release in the 1.17.x branch, which
is not yet ready, but is intended to be labelled as 1.17.0-alpha when
it is released.
Helps: dbus#530 Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 6 Dec 2024 17:48:04 +0000 (17:48 +0000)]
build: Allow version number to be followed by "-" and a suffix
Some distributions are known to have shipped dbus 1.15.x as though it
was a stable release, and it isn't clear whether they knew that we use
the odd/even versioning convention like GLib does.
If we add a -alpha, -beta, -rc suffix to development versions starting
from 1.17.0, then distros that know we use odd/even versioning will
know that our development versions are not a stable-branch, and so will
distros that mistakenly think we use the "semantic versioning"
versioning convention popularized by <https://semver.org/>.
(We intentionally do not use semver, because semver would require us to
ship a new minor version every time we add new API, and we do not have
the resources to provide security support for an unlimited number of
minor versions in parallel: we need to be able to nominate a subset of
our releases as having longer-term security support, in a way that signals
to distros that these are the releases they should prefer to ship.)
CMake's `project()` doesn't allow this version number format[1], but
we intend to use version numbers where the (major, minor, micro) tuple
is enough to uniquely identify a release, so we can just tell CMake our
version number without the suffix and there will be no ambiguity.
Similarly, the dash is not allowed in GNU ld version scripts, so use
the form of the version number without the suffix there.
Simon McVittie [Mon, 9 Dec 2024 17:12:18 +0000 (17:12 +0000)]
internals: Use negative numbers to indicate no malloc failure simulation
If we set the countdown to simulating a failed allocation to
_DBUS_INT_MAX, then it will decrement every time we allocate memory,
eventually reaching 0 and triggering a simulated malloc failure.
In practice this does not happen during unit testing, because all of
our tests are (intentionally!) short enough that this can't happen,
but it can happen if a build of dbus with embedded tests enabled is
used for the "real" dbus-daemon or a "real" D-Bus service, either
during debugging or unintentionally, as noted on dbus/dbus!493.
We cannot simply special-case `_DBUS_INT_MAX` to never be decremented,
because _dbus_test_oom_handling() relies on the counter being
decremented even while we are not simulating malloc failure, as a way
to count the number of allocations as an upper bound for how long to
set the countdown during subsequent test runs.
Instead, reserve all negative numbers to represent the absence of
malloc failure simulation, while still being able to count allocations
by comparing two different negative numbers.
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/535 Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Mon, 9 Dec 2024 18:16:46 +0000 (18:16 +0000)]
cmake: Make intrusive (formerly embedded) tests into a separate option
Previously, the CMake build enabled tests by default, and enabled both
modular and intrusive (embedded) tests with a single option. This is
a really bad idea if anyone is using CMake-built binaries in production.
DBUS_BUILD_TESTS now enables only the modular tests, which are safe to
enable in production builds.
A new DBUS_ENABLE_INTRUSIVE_TESTS option enables the intrusive test
instrumentation.
To preserve existing test coverage, explicitly enable the intrusive
tests in most CMake-based Gitlab-CI jobs (Debian native, openSUSE native,
Windows).
In jobs that have a mirrored pair of production/debug builds (openSUSE
and Debian mingw32/mingw64 cmake), instead we leave the production
build as-is and only build full test coverage in the debug build.
Co-authored-by: Philip Withnall <philip@tecnocode.co.uk> Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Mon, 9 Dec 2024 17:45:32 +0000 (17:45 +0000)]
Rename "embedded tests" to "intrusive tests"
This hopefully helps to get across the point that enabling these tests
adds instrumentation to libdbus and dbus-daemon, with a potentially
significant impact on code size, performance and security.
To avoid a huge diffstat which would be difficult to review, the cpp
macro that is checked by most of the C code is still
DBUS_ENABLE_EMBEDDED_TESTS, which is defined or undefined under exactly
the same conditions as the new DBUS_ENABLE_INTRUSIVE_TESTS.
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/537 Co-authored-by: Philip Withnall <philip@tecnocode.co.uk> Signed-off-by: Simon McVittie <smcv@collabora.com>
Ralf Habacker [Mon, 1 Nov 2021 12:01:59 +0000 (13:01 +0100)]
cmake: In client configuration file get DBus1_xxx variables from cmake target
The DBus1_xxx variables defined in DBusConfig.cmake for Windows builds
are currently hard-coded values and independent of those of the underlying
cmake target.
To avoid this, these values are retrieved from the corresponding cmake
target. In addition, the cmake allows the construction of the resulting
relocatable runtime paths.
Ralf Habacker [Mon, 1 Nov 2021 12:01:59 +0000 (13:01 +0100)]
cmake: In client configuration file get DBus1_xxx variables from cmake target
The DBus1_xxx variables defined in DBusConfig.cmake for Windows builds
are currently hard-coded values and independent of those of the underlying
cmake target.
To avoid this, these values are retrieved from the corresponding cmake
target. In addition, the cmake allows the construction of the resulting
relocatable runtime paths.
Simon McVittie [Mon, 9 Dec 2024 17:06:06 +0000 (17:06 +0000)]
release-checklist: Give a better reference for deprecation warnings
Commit 4ebb275ab7 disabled deprecation warnings in the Autotools build
system, which we no longer have. Future stable-branches will want to
disable deprecation warnings in Meson instead.
Simon McVittie [Mon, 9 Dec 2024 17:04:39 +0000 (17:04 +0000)]
release-checklist: Fix sequencing
`meson dist` requires the version you intend to release to have been
committed already, and does not create any generated files in the
`${srcdir}` that are intended to be committed to git.
Simon McVittie [Mon, 9 Dec 2024 17:06:06 +0000 (17:06 +0000)]
release-checklist: Give a better reference for deprecation warnings
Commit 4ebb275ab7 disabled deprecation warnings in the Autotools build
system, which we no longer have. Future stable-branches will want to
disable deprecation warnings in Meson instead.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Mon, 9 Dec 2024 17:04:39 +0000 (17:04 +0000)]
release-checklist: Fix sequencing
`meson dist` requires the version you intend to release to have been
committed already, and does not create any generated files in the
`${srcdir}` that are intended to be committed to git.
Signed-off-by: Simon McVittie <smcv@collabora.com>
If there is a pending OOM watch and at the same time there is no
timeout, poll is entered with infinite timeout, because infinite
is expressed with a negative number, which is smaller than any
actual timeout.
Introduce min_poll_timeout(), which returns the smaller non-negative
number of the two, or the larger negative number if both numbers
are negative.
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/536 Signed-off-by: Petr Malat <oss@malat.biz>
[smcv: adjust whitespace] Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit a6023f49acfda099a7ccac9ebd804d553ec9d666)
If there is a pending OOM watch and at the same time there is no
timeout, poll is entered with infinite timeout, because infinite
is expressed with a negative number, which is smaller than any
actual timeout.
Introduce min_poll_timeout(), which returns the smaller non-negative
number of the two, or the larger negative number if both numbers
are negative.
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/536 Signed-off-by: Petr Malat <oss@malat.biz>
[smcv: adjust whitespace] Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 29 Nov 2024 11:46:32 +0000 (11:46 +0000)]
build: Check for socket(), socketpair() in -lsocket if necessary
On older Solaris, these functions exist in -lsocket rather than in the
standard C library. If we can't find them immediately, try again with
-lsocket added to the dependencies.
Later, use network_libs when checking for optional functions like
socketpair(), so that we will detect it correctly. If socketpair() is
not found, dbus compiles successfully without it, but dbus-daemon will
not start because it cannot set up reload signalling.
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/531 Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Tue, 19 Nov 2024 13:11:13 +0000 (13:11 +0000)]
Completely remove the Containers1 interface
This interface is still not ready for production use. To minimize
confusion, let's remove it from the 1.16.x stable branch. We can have
another try during the 1.17.x cycle, via dbus/dbus!449.
Signed-off-by: Simon McVittie <smcv@collabora.com>