Commit graph

7018 commits

Author SHA1 Message Date
Simon McVittie
dfadf1b68c Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-12-11 13:19:40 +00:00
Simon McVittie
08cc615c26 Merge branch 'dbus-1.16' 2024-12-11 13:16:16 +00:00
Simon McVittie
5d88ad15ea Update NEWS
dbus!501 intentionally not mentioned here, it's a purely internal change.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-12-11 13:16:10 +00:00
Simon McVittie
ff872f76fb cmake: Use a better bug reference
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 648f4c2c37)
2024-12-11 13:13:34 +00:00
Simon McVittie
2565691762 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 229e48f549)
2024-12-11 13:13:30 +00:00
Mohamed Akram
8e0e949643 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().

Closes: #510
(cherry picked from commit 827e952793)
2024-12-11 13:13:17 +00:00
Simon McVittie
648f4c2c37 cmake: Use a better bug reference
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-12-11 13:02:57 +00:00
Simon McVittie
c45d2992b8 Merge branch 'issue538' into 'master'
bus: Update a build system cross-reference

Closes #538

See merge request dbus/dbus!501
2024-12-11 12:51:55 +00:00
Simon McVittie
229e48f549 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>
2024-12-11 12:50:32 +00:00
Simon McVittie
12265328a6 Merge branch 'diagnose-leaked-fd' into 'master'
_dbus_check_fdleaks_leave: Try to describe what the leaked fd is

See merge request dbus/dbus!503
2024-12-11 12:50:14 +00:00
Simon McVittie
3a37279e32 _dbus_check_fdleaks_leave: Try to describe what the leaked fd is
Similar to ebf487ef, but in a different situation.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-12-11 12:48:37 +00:00
Simon McVittie
c0f0516662 Merge branch 'fix-macos-system-bus' into 'master'
sysdeps-unix: Report missing launchd session bus as non-fatal

Closes #510

See merge request dbus/dbus!461
2024-12-10 16:53:11 +00:00
Mohamed Akram
827e952793 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().

Closes: #510
2024-12-10 16:52:25 +00:00
Simon McVittie
b407eba60d Start NEWS for 1.17.x
For now, the changes that have happened in parallel on the 1.16.x branch
are listed under 1.15.91.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-12-10 16:06:21 +00:00
Simon McVittie
8890a5cd69 Merge branch 'dbus-1.16' 2024-12-10 16:05:20 +00:00
Simon McVittie
51b9fadf20 Update NEWS for 1.16.x
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-12-10 16:00:26 +00:00
Simon McVittie
7c65efde7a 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 7cbb7b75dd)
2024-12-10 15:43:57 +00:00
Simon McVittie
08d854af69 sysdeps: Don't check for PROC_SUPER_MAGIC if it isn't defined
Debian GNU/Hurd has fstatfs() but not PROC_SUPER_MAGIC.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/539
Bug-Debian: https://bugs.debian.org/1089641
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 5d7b87496f)
2024-12-10 15:43:43 +00:00
Simon McVittie
fd25d0da1a 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 0735c401a7)
2024-12-10 15:43:38 +00:00
Simon McVittie
dcdc638ea4 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 41c7570e1e)
2024-12-10 15:43:34 +00:00
Simon McVittie
53bcfe2de1 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 9c5b5838f5)
2024-12-10 15:43:31 +00:00
Simon McVittie
9976d957db Merge branch 'issue540' into 'master'
tests: Exercise NSS group lookup before running tests

Closes #540

See merge request dbus/dbus!504
2024-12-10 14:58:02 +00:00
Simon McVittie
7cbb7b75dd 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>
2024-12-10 14:57:13 +00:00
Simon McVittie
e3c3cd6889 Merge branch 'issue530' into 'master'
build: Allow version number to be followed by "-" and a suffix

See merge request dbus/dbus!494
2024-12-10 12:30:37 +00:00
Simon McVittie
c4ec854e64 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>
2024-12-10 12:30:16 +00:00
Simon McVittie
cd667b9556 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.

[1] https://gitlab.kitware.com/cmake/cmake/-/issues/16716

Helps: dbus#530
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-12-10 12:30:16 +00:00
Simon McVittie
9a2ccd09c0 Merge branch 'hurd' into 'master'
sysdeps: Don't check for PROC_SUPER_MAGIC if it isn't defined

Closes #539

See merge request dbus/dbus!500
2024-12-10 11:30:05 +00:00
Simon McVittie
5d7b87496f sysdeps: Don't check for PROC_SUPER_MAGIC if it isn't defined
Debian GNU/Hurd has fstatfs() but not PROC_SUPER_MAGIC.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/539
Bug-Debian: https://bugs.debian.org/1089641
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-12-10 11:29:46 +00:00
Simon McVittie
85ae05c422 Merge branch 'issue535' into 'master'
internals: Use negative numbers to indicate no malloc failure simulation

Closes #535

See merge request dbus/dbus!496
2024-12-10 11:28:49 +00:00
Simon McVittie
0735c401a7 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>
2024-12-10 11:10:39 +00:00
Simon McVittie
d928aaf2c6 Merge branch 'intrusive' into 'master'
Rename "embedded tests" to "intrusive tests"

Closes #537

See merge request dbus/dbus!495
2024-12-10 11:09:26 +00:00
Simon McVittie
41c7570e1e 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>
2024-12-10 10:25:51 +00:00
Simon McVittie
9c5b5838f5 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>
2024-12-10 10:25:23 +00:00
Ralf Habacker
d440173062 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.

(cherry picked from commit 29c2e9141a)
2024-12-10 10:24:10 +00:00
Simon McVittie
9907deedb1 memory: Remove redundant guard around _dbus_decrement_fail_alloc_counter()
This function is already inside `#ifdef DBUS_ENABLE_EMBEDDED_TESTS`
and doesn't need a second layer of the same guard.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 6e61173d64)
2024-12-10 10:24:04 +00:00
Simon McVittie
2ff58f5083 Merge branch 'cmake-fixes' into 'master'
cmake: In client configuration file get DBus1_xxx variables from cmake target

See merge request dbus/dbus!499
2024-12-10 10:19:57 +00:00
Ralf Habacker
29c2e9141a 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.
2024-12-10 10:12:10 +01:00
Simon McVittie
7cc31643c7 Merge branch 'mem-double-guard' into 'master'
memory: Remove redundant guard around _dbus_decrement_fail_alloc_counter()

See merge request dbus/dbus!497
2024-12-09 23:26:19 +00:00
Simon McVittie
6e61173d64 memory: Remove redundant guard around _dbus_decrement_fail_alloc_counter()
This function is already inside `#ifdef DBUS_ENABLE_EMBEDDED_TESTS`
and doesn't need a second layer of the same guard.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-12-09 18:25:52 +00:00
Simon McVittie
80eac5c99e release-checklist: Use a more copy-paste'able scp/rsync destination
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 7dc12d17c8)
2024-12-09 17:07:08 +00:00
Simon McVittie
cb7f88f8a9 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>
(cherry picked from commit f651834427)
2024-12-09 17:07:07 +00:00
Simon McVittie
642a22a0bd 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>
(cherry picked from commit b97b083f9a)
2024-12-09 17:07:07 +00:00
Simon McVittie
7dc12d17c8 release-checklist: Use a more copy-paste'able scp/rsync destination
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-12-09 17:06:29 +00:00
Simon McVittie
f651834427 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>
2024-12-09 17:06:06 +00:00
Simon McVittie
b97b083f9a 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>
2024-12-09 17:04:39 +00:00
Petr Malat
2633d6ba96 _dbus_loop_iterate: Fix OOM retry timeout handling
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 a6023f49ac)
2024-12-09 17:03:01 +00:00
Simon McVittie
013f4f3c9c Merge branch 'oom_retry_tmout' into 'master'
_dbus_loop_iterate: Fix OOM retry timeout handling

Closes #536

See merge request dbus/dbus!493
2024-12-09 16:52:39 +00:00
Petr Malat
a6023f49ac _dbus_loop_iterate: Fix OOM retry timeout handling
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>
2024-12-09 16:36:10 +00:00
Simon McVittie
57eaa412f0 Bump version to 1.16.99 to start 1.17.x branch
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-12-06 16:52:25 +00:00
Simon McVittie
f54a4909e3 Merge branch 'dbus-1.16', rejecting stable-branch-only changes 2024-12-06 16:51:13 +00:00