]> git.ipfire.org Git - thirdparty/dbus.git/log
thirdparty/dbus.git
3 years agodbus-internals: use size_t in _DBUS_ALIGN_VALUE()
Alex Richardson [Fri, 12 Aug 2022 10:18:05 +0000 (10:18 +0000)] 
dbus-internals: use size_t in _DBUS_ALIGN_VALUE()

When targeting CHERI-enabled architectures such as Arm Morello, performing
a bitwise and with uintptr_t values can result in an ambiguous operation
compiler warning. Fix this warning by telling  compiler which operand is
(potentially) a pointer and which one is an integer by changing the
boundary type to size_t. This change has no functional effect on other
architectures but is required to build with -Werror for Morello.

Example warning message:
```
warning: binary expression on capability types 'unsigned __intcap' and 'unsigned __intcap'; it is not clear which should be used as the source of provenance; currently provenance is inherited from the left-hand side [-Wcheri-provenance]
  _dbus_assert (_DBUS_ALIGN_VALUE (insert_at, 8) == (unsigned) insert_at);
```

3 years agoclang-format: don't align escaped newlines in macro definitions
Alex Richardson [Wed, 14 Sep 2022 23:55:31 +0000 (23:55 +0000)] 
clang-format: don't align escaped newlines in macro definitions

3 years agoclang-format: add spaces before parens
Alex Richardson [Wed, 14 Sep 2022 23:19:06 +0000 (23:19 +0000)] 
clang-format: add spaces before parens

Previously, clang-format was not adding a space after sizeof.

3 years agoMerge branch 'fix-freebsd-ci' into 'master'
Simon McVittie [Wed, 21 Sep 2022 11:31:43 +0000 (11:31 +0000)] 
Merge branch 'fix-freebsd-ci' into 'master'

gitlab-ci: update FreeBSD CI image to 13.1

See merge request dbus/dbus!347

3 years agogitlab-ci: update FreeBSD CI image to 13.1
Alex Richardson [Wed, 21 Sep 2022 08:33:33 +0000 (08:33 +0000)] 
gitlab-ci: update FreeBSD CI image to 13.1

FreeBSD 13.0 has reached EOL and it appears packages
are built against a newer baseline now, so we end up
with missing symbol errors:
ld-elf.so.1: /lib/libc.so.7: version FBSD_1.7 required by /usr/local/lib/libpython3.9.so.1.0 not found

It also appears that the fdpass test still fails on 13.1, so update the
condition to less than 14.0

3 years agoUpdate NEWS
Simon McVittie [Mon, 19 Sep 2022 09:44:58 +0000 (10:44 +0100)] 
Update NEWS

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoMerge branch 'test-socket-dir' into 'master'
Simon McVittie [Thu, 15 Sep 2022 19:13:21 +0000 (19:13 +0000)] 
Merge branch 'test-socket-dir' into 'master'

test: Use DBUS_TEST_SOCKET_DIR to create the test socket

See merge request dbus/dbus!334

3 years agotest: Use DBUS_TEST_SOCKET_DIR to create the test socket
Alex Richardson [Fri, 12 Aug 2022 10:15:14 +0000 (10:15 +0000)] 
test: Use DBUS_TEST_SOCKET_DIR to create the test socket

I am trying to run cross-compiled tests in QEMU with the build directory
mounted via smbfs, and therefore creating the sockets in the CWD does not
work. Using DBUS_TEST_SOCKET_DIR (/tmp by default) allows me to run the
tests successfully.

3 years agocmake: define DBUS_TEST_SOCKET_DIR in the config header
Alex Richardson [Sun, 29 May 2022 10:02:53 +0000 (10:02 +0000)] 
cmake: define DBUS_TEST_SOCKET_DIR in the config header

This matches autotools.

3 years agomeson: define DBUS_TEST_SOCKET_DIR in the config header
Alex Richardson [Fri, 12 Aug 2022 10:14:09 +0000 (10:14 +0000)] 
meson: define DBUS_TEST_SOCKET_DIR in the config header

This matches autotools

3 years agoMerge branch 'mempool-flex-array-followup' into 'master'
Simon McVittie [Thu, 15 Sep 2022 17:02:35 +0000 (17:02 +0000)] 
Merge branch 'mempool-flex-array-followup' into 'master'

mempool: Require C99 flexible arrays

See merge request dbus/dbus!344

3 years agomempool: Require C99 flexible arrays
Simon McVittie [Thu, 15 Sep 2022 14:30:44 +0000 (15:30 +0100)] 
mempool: Require C99 flexible arrays

dbus 1.15.x officially requires C99, so we can do this unconditionally
on the 1.15.x branch.

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoMerge branch 'mempool-flex-array' into 'master'
Simon McVittie [Thu, 15 Sep 2022 16:46:46 +0000 (16:46 +0000)] 
Merge branch 'mempool-flex-array' into 'master'

dbus-mempool: Use flexible or zero-length arrays if possible

See merge request dbus/dbus!343

3 years agodbus-mempool: Use flexible or zero-length arrays if possible
Simon McVittie [Wed, 14 Sep 2022 15:23:23 +0000 (16:23 +0100)] 
dbus-mempool: Use flexible or zero-length arrays if possible

If the elements field has a fixed nonzero size, accessing elements
beyond that size is technically undefined behaviour, which is caught
by some options of the undefined behaviour sanitizer. Try to use a C99
flexible array, or failing that, a zero-length array (which is a popular
non-standard syntax to achieve the same thing).

dbus 1.15.x has C99 as a requirement, but this commit avoids assuming
C99 in order to make this change backportable to 1.14.x if it becomes
necessary to do so (for example to be able to run tests or fuzzers
against 1.14.x, or if compilers' defaults become more strict).

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoUpdate NEWS for 1.15.x branch
Simon McVittie [Mon, 12 Sep 2022 20:40:56 +0000 (21:40 +0100)] 
Update NEWS for 1.15.x branch

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoMerge branch 'msys2-packages' into 'master'
Simon McVittie [Mon, 12 Sep 2022 19:19:49 +0000 (19:19 +0000)] 
Merge branch 'msys2-packages' into 'master'

CI: Don't pin msys2 packages to a specific version at all

See merge request dbus/dbus!338

3 years agoCI: Don't pin msys2 packages to a specific version at all
Simon McVittie [Mon, 12 Sep 2022 17:13:48 +0000 (18:13 +0100)] 
CI: Don't pin msys2 packages to a specific version at all

Similar to dbus/dbus!286, but more so: just use the package names,
ignoring their version numbers completely.

pcre2 is not strictly needed at the moment, but it'll be a dependency
for GLib >= 2.73.x (older versions used pcre). For a bit of
future-proofing, download both pcre and pcre2.

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoMerge branch 'windows-no-tap' into 'master'
Simon McVittie [Mon, 12 Sep 2022 19:00:27 +0000 (19:00 +0000)] 
Merge branch 'windows-no-tap' into 'master'

TAP-related workarounds in Meson build system

Closes #414

See merge request dbus/dbus!340

3 years agotest: Don't use strict TAP parsing on Windows
Simon McVittie [Mon, 12 Sep 2022 18:36:16 +0000 (19:36 +0100)] 
test: Don't use strict TAP parsing on Windows

Debug messages in a background thread can corrupt the machine-readable
TAP output, and in particular GWin32AppInfo emits debug messages from
a background thread when we link to libgio.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/414
Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agobuild: Only work around Meson 0.63.0 bugs for version 0.63.0
Simon McVittie [Mon, 12 Sep 2022 18:23:54 +0000 (19:23 +0100)] 
build: Only work around Meson 0.63.0 bugs for version 0.63.0

mesonbuild/meson#10577 was fixed in 0.63.1.

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoMerge branch 'fix/412' into 'master'
Simon McVittie [Thu, 18 Aug 2022 13:25:16 +0000 (13:25 +0000)] 
Merge branch 'fix/412' into 'master'

_dbus_message_iter_append_check: Fix ifdef check

Closes #412

See merge request dbus/dbus!336

3 years ago_dbus_message_iter_append_check: Fix ifdef check
Johannes Kauffmann [Thu, 18 Aug 2022 12:26:26 +0000 (12:26 +0000)] 
_dbus_message_iter_append_check: Fix ifdef check

With internal DBus checks disabled, but with assertions enabled, the
function would be ifdef'ed out. This is problematic, since the function
is called from within an assertion statement in _dbus_variant_write().

Fixes #412.

Co-authored-by: Simon McVittie <smcv@collabora.com>
3 years agoMerge branch 'add-freebsd-ci' into 'master'
Simon McVittie [Wed, 10 Aug 2022 11:33:11 +0000 (11:33 +0000)] 
Merge branch 'add-freebsd-ci' into 'master'

Add a FreeBSD CI job

See merge request dbus/dbus!280

3 years agoUpdate NEWS to mention FreeBSD CI
Alex Richardson [Tue, 9 Aug 2022 21:52:56 +0000 (21:52 +0000)] 
Update NEWS to mention FreeBSD CI

3 years agoAdd myself to AUTHORS
Alex Richardson [Tue, 9 Aug 2022 21:51:07 +0000 (21:51 +0000)] 
Add myself to AUTHORS

3 years agogitlab-ci: Add a FreeBSD meson job
Alex Richardson [Tue, 9 Aug 2022 17:49:23 +0000 (17:49 +0000)] 
gitlab-ci: Add a FreeBSD meson job

Also bump the FDO_DISTRIBUTION_TAG to ensure the disk images
include meson.

3 years agotools/ci-install.sh: Install meson build dependencies on FreeBSD
Alex Richardson [Tue, 9 Aug 2022 15:58:36 +0000 (15:58 +0000)] 
tools/ci-install.sh: Install meson build dependencies on FreeBSD

Python is already installed, but we need the python3 package to get the
/usr/local/bin/python3 symlink rather than the one with the version suffix.

3 years agotest/fdpass.c: skip test that fails on FreeBSD 13.0
Alex Richardson [Tue, 9 Aug 2022 10:56:18 +0000 (10:56 +0000)] 
test/fdpass.c: skip test that fails on FreeBSD 13.0

The /odd-limit/at test passes on 13.1 and 14.0 images, but fails on 13.1.
Debugging has not given me any useful hints why this may be the case, so
disable this test on 13.0 for now.

This allows us to drop the ci_test_fatal: "no" override which will ensure
that any FreeBSD regressions are caught.

3 years agogitlab-ci: Add a FreeBSD autotools CI job
Alex Richardson [Tue, 9 Aug 2022 16:53:52 +0000 (16:53 +0000)] 
gitlab-ci: Add a FreeBSD autotools CI job

Now that the underlying issues with FreeBSD autotools CI have been fixed,
we can add a CI job to prevent future regressions.

3 years agoci-build.sh: Add a autotools ci_variant without the docs archive
Alex Richardson [Tue, 9 Aug 2022 17:40:58 +0000 (17:40 +0000)] 
ci-build.sh: Add a autotools ci_variant without the docs archive

This is needed to add autotools support to the FreeBSD CI since we don't
include all the packages needed to build dbus-docs.tar.xz.

3 years agogitlab-ci: Use GNU make on FreeBSD
Alex Richardson [Tue, 9 Aug 2022 08:31:03 +0000 (08:31 +0000)] 
gitlab-ci: Use GNU make on FreeBSD

The Makefile.am files contain % pattern rules that are not supported by
`make` (bmake) on FreeBSD. Since the replacing the patterns is non-trivial,
this commit updates the CI script to use GNU make when building on FreeBSD.

3 years agogitlab-ci: Don't use sudo for the FreeBSD job
Alex Richardson [Tue, 9 Aug 2022 15:47:38 +0000 (15:47 +0000)] 
gitlab-ci: Don't use sudo for the FreeBSD job

We are already building as root and sudo is not currently installed on
the CI image, so the autotools build fails without this change.

3 years agogitlab-ci: Install pkg-config on FreeBSD
Alex Richardson [Mon, 8 Aug 2022 21:21:18 +0000 (21:21 +0000)] 
gitlab-ci: Install pkg-config on FreeBSD

Without this change the autotools build system fails to find glib and
reports an error. The CMake build worked prior to this change since CMake
has fallback logic to find glib even without pkg-config.

3 years agogitlab-ci: Add a FreeBSD CMake CI job
Alex Richardson [Wed, 25 May 2022 20:51:13 +0000 (20:51 +0000)] 
gitlab-ci: Add a FreeBSD CMake CI job

This uses https://gitlab.freedesktop.org/freedesktop/ci-templates,
and runs the FreeBSD build+test inside a QEMU VM.
This depends on the recently merged ci-templates MR
https://gitlab.freedesktop.org/freedesktop/ci-templates/-/merge_requests/142,
so we bump the required ci-templates commit hash.

There is one undiagnosed failure in test-fdpass that needs investigation,
so for now failures are permitted. Autotools and meson jobs will be added
in follow-up commits.

3 years agodbus-sysdeps-util-unix.c: Avoid including sys/syslimits.h
Alex Richardson [Tue, 9 Aug 2022 10:17:57 +0000 (10:17 +0000)] 
dbus-sysdeps-util-unix.c: Avoid including sys/syslimits.h

This header is GCC specific header that on my system just contains
`#include_next <limits.h>`. FreeBSD also provides this header but it
contains a `#warning` that it should not be used. Replace the one use
with `#include <limit.h>` and drop the configure checks.

3 years agocmake: Always try to find pkg-config
Alex Richardson [Sun, 29 May 2022 12:58:49 +0000 (12:58 +0000)] 
cmake: Always try to find pkg-config

Commit 97bdefd4e2598e6ea72337acb4230928594bda81 move the
include(FindPkgConfig) call into a Linux-specific codepath, so pkg-config
was not being detected on FreeBSD. This mean that the check for
PKG_CONFIG_FOUND to determine whether to install .pc files later on
would always fail and .pc files were not installed on FreeBSD.

3 years agodbus-launch-x11.c: Silence clang -Wcast-align warning
Alex Richardson [Mon, 8 Aug 2022 21:03:57 +0000 (21:03 +0000)] 
dbus-launch-x11.c: Silence clang -Wcast-align warning

In this case the cast is safe since the manual guarantees that the
underlying storage is an array of `long`.

3 years agotest-utils-glibc.c: Fix -Werror,-Wmissing-noreturn on FreeBSD
Alex Richardson [Mon, 8 Aug 2022 20:38:31 +0000 (20:38 +0000)] 
test-utils-glibc.c: Fix -Werror,-Wmissing-noreturn on FreeBSD

Add a conditional _DBUS_GNUC_NORETURN to avoid
`error: function 'back_to_root' could be declared with attribute 'noreturn'`

3 years agotest-utils-glib.c: Avoid using a non-portable errno value
Alex Richardson [Mon, 8 Aug 2022 19:49:40 +0000 (19:49 +0000)] 
test-utils-glib.c: Avoid using a non-portable errno value

ENODATA is not available on FreeBSD. Since the actual errno value here
does not matter, use EPERM instead.
This fixes the DBus build on FreeBSD.

3 years agodbus-sysdeps-unix.c: Fix unused function warning on FreeBSD
Alex Richardson [Mon, 8 Aug 2022 19:17:12 +0000 (19:17 +0000)] 
dbus-sysdeps-unix.c: Fix unused function warning on FreeBSD

The function close_ignore_error() is only used in some cases. To avoid
duplicating the #ifdef condition, this patch moves the check just before
the definition of _dbus_close_all().

3 years agotools/ci-build.sh: Ensure that $builddir is set
Alex Richardson [Mon, 8 Aug 2022 15:29:56 +0000 (15:29 +0000)] 
tools/ci-build.sh: Ensure that $builddir is set

When adding the new FreeBSD CI, this was not implicitly forwarded to QEMU,
so the build script failed with confusing errors. Add an explicit check
that the variable is set to make those cases easier to debug.

3 years agotools/ci-install.sh: Add FreeBSD support
Alex Richardson [Wed, 25 May 2022 20:51:29 +0000 (20:51 +0000)] 
tools/ci-install.sh: Add FreeBSD support

This adds support for installing the required packages on FreeBSD.

3 years agotools/ci-{build,install}.sh: Use a portable interpreter argument
Alex Richardson [Wed, 25 May 2022 21:33:17 +0000 (21:33 +0000)] 
tools/ci-{build,install}.sh: Use a portable interpreter argument

FreeBSD has bash installed as /usr/local/bin/bash, so hardcoding /bin/bash
does not work. Instead use the portable replacement using env which will
find bash in $PATH.

3 years agoMerge branch 'cxx-only-on-windows' into 'master'
Simon McVittie [Wed, 10 Aug 2022 10:38:26 +0000 (10:38 +0000)] 
Merge branch 'cxx-only-on-windows' into 'master'

meson: Only require C++ compiler when building for Windows

See merge request dbus/dbus!333

3 years agomeson: Only require C++ compiler when building for Windows
Simon McVittie [Mon, 25 Jul 2022 13:30:02 +0000 (14:30 +0100)] 
meson: Only require C++ compiler when building for Windows

dbus is generally a C-only project, but the Windows side has a tiny
amount of C++ to initialize global locks (because Windows doesn't have
a direct equivalent of PTHREAD_MUTEX_INITIALIZER). We don't need a C++
compiler when building for a non-Windows OS, so there's no need to
find it or check which options it supports.

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoNEWS: Update Dependencies section
Simon McVittie [Tue, 26 Jul 2022 10:37:28 +0000 (11:37 +0100)] 
NEWS: Update Dependencies section

dbus!332 increased the CMake dependency.

The Meson build system is new, but it seems reasonable to mention the
new (optional) dependencies at top level.

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoMerge branch 'cmake-current-source-dir' into 'master'
Ralf Habacker [Tue, 26 Jul 2022 04:31:13 +0000 (04:31 +0000)] 
Merge branch 'cmake-current-source-dir' into 'master'

cmake: Fix top-level directory references when vendored into a larger project

See merge request dbus/dbus!332

3 years agoUpdate NEWS
Jordan Williams [Fri, 22 Jul 2022 20:40:49 +0000 (15:40 -0500)] 
Update NEWS

3 years agoAdd name to AUTHORS
Jordan Williams [Fri, 22 Jul 2022 20:30:00 +0000 (15:30 -0500)] 
Add name to AUTHORS

3 years agoUse project relative paths in CMake files
Jordan Williams [Sat, 23 Jul 2022 11:21:44 +0000 (06:21 -0500)] 
Use project relative paths in CMake files

This makes it possible for projects to incorporate D-Bus as a CMake sub-project in a larger CMake project.
Before this PR, doing so would result in many errors.
This is because CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR would point to directories above the D-Bus project.
Using paths relative to the project directory, PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR, corrects for this.

3 years agoBump CMake version to 3.4
Jordan Williams [Fri, 22 Jul 2022 19:27:14 +0000 (14:27 -0500)] 
Bump CMake version to 3.4

With the minimum version set to 3.4, none of the policies need to be set explicitly to the `NEW` behavior.
Each of the policies removed here was introduced before CMake version 3.4.
By default then, each of them will be set to NEW automatically.
This is part of the behavior of cmake_minimum_required.
The cmake_policy commands are therefore redundant and have been removed.

3 years agorelease-checklist: Add a reminder to update both Autotools and Meson
Simon McVittie [Sat, 23 Jul 2022 10:21:39 +0000 (11:21 +0100)] 
release-checklist: Add a reminder to update both Autotools and Meson

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoMove release checklist to its own file
Simon McVittie [Sat, 23 Jul 2022 10:19:28 +0000 (11:19 +0100)] 
Move release checklist to its own file

In other projects I've found that having a separate file that only
lists the release steps makes them easier to check.

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoMerge branch 'require-c99' into 'master'
Simon McVittie [Wed, 20 Jul 2022 13:27:46 +0000 (13:27 +0000)] 
Merge branch 'require-c99' into 'master'

Officially drop support for non-C99 compilers, and start using C99 low-hanging fruit

Closes #404

See merge request dbus/dbus!331

3 years agobuild: Assume stdint.h is provided
Simon McVittie [Tue, 19 Jul 2022 19:44:58 +0000 (20:44 +0100)] 
build: Assume stdint.h is provided

We now require a (mostly-)C99 compiler, meaning we can rely on having
Standard C stdint.h.

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoRemove fallback implementation of strtoll(), strtoull()
Simon McVittie [Tue, 19 Jul 2022 19:42:51 +0000 (20:42 +0100)] 
Remove fallback implementation of strtoll(), strtoull()

We now require a (mostly-)C99 compiler, which guarantees the presence
of these functions.

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agocmake: Stop redefining snprintf() to _snprintf() on MSVC
Simon McVittie [Tue, 19 Jul 2022 19:40:34 +0000 (20:40 +0100)] 
cmake: Stop redefining snprintf() to _snprintf() on MSVC

We now require a mostly-C99 compiler like MSVC 2015, which provides
Standard C snprintf().

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoRemove emulation of va_copy() in non-C99 compilers
Simon McVittie [Tue, 19 Jul 2022 19:37:19 +0000 (20:37 +0100)] 
Remove emulation of va_copy() in non-C99 compilers

dbus now requires a (mostly-)C99 compiler, which guarantees the presence
of Standard C va_copy().

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agobuild: Remove support for emulating inline with __inline or __inline__
Simon McVittie [Tue, 19 Jul 2022 19:34:15 +0000 (20:34 +0100)] 
build: Remove support for emulating inline with __inline or __inline__

We now require a (mostly-)C99 compiler, and C99 guarantees the presence
of the inline keyword.

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoNEWS, README.win: Officially drop support for non-C99 compilers
Simon McVittie [Tue, 19 Jul 2022 19:30:57 +0000 (20:30 +0100)] 
NEWS, README.win: Officially drop support for non-C99 compilers

We're considering MSVC 2015 to be sufficiently close to C99 for our
purposes, and we now have CI for it, so we can easily check whether any
desired C99 feature works. Other pre-C99 compilers are obsolete.

Resolves: dbus#404
Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoUpdate NEWS
Simon McVittie [Tue, 19 Jul 2022 19:27:29 +0000 (20:27 +0100)] 
Update NEWS

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoMerge branch '30x-faster-testing' into 'master'
Simon McVittie [Mon, 18 Jul 2022 13:06:58 +0000 (13:06 +0000)] 
Merge branch '30x-faster-testing' into 'master'

tests: Speed up bus-dispatch OOM testing by a factor of 30

See merge request dbus/dbus!328

3 years agodispatch test: Pass in test data directory as a C string
Simon McVittie [Sun, 17 Jul 2022 15:20:14 +0000 (16:20 +0100)] 
dispatch test: Pass in test data directory as a C string

This reduces duplication a little bit.

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agotest/bus: Break up dispatch test into three separate tests
Simon McVittie [Fri, 15 Jul 2022 14:41:14 +0000 (15:41 +0100)] 
test/bus: Break up dispatch test into three separate tests

This is really three separate test-cases: one for traditional
activation as a direct child process of the dbus-daemon, and two for
traditional activation (successful and failing) via the setuid
dbus-daemon-launch-helper on Unix.

The ones where activation succeeds extremely slow, as a result of the
instrumentation for simulating malloc() failures combined with a large
number of memory operations, particularly when using AddressSanitizer.

Splitting up "OOM" tests like these has a disproportionately good impact
on the time they take, because the simulated malloc() failure
instrumentation repeats the entire test making the first malloc() fail,
then making the second malloc() fail, and so on. For allocation failures
in the second half of the test, this means we repeat the first half of
the test with no malloc() failures a very large number of times, which
is not a good use of time, because we already tested it successfully.

Even when not using the "OOM" instrumentation, splitting up these tests
lets them run in parallel, which is also a major time saving.

Needless to say, this speeds up testing considerably. On my modern but
unexceptional x86 laptop, in a typical debug build with Meson, the old
dispatch test took just over 21 minutes, which drops to about 40 seconds
each for the new normal-activation and helper-activation tests (and for
most of that time, they're running in parallel, so the wall-clock time
taken for the whole test suite is somewhere around a minute).

In a debug build with Meson, gcc and AddressSanitizer, the old dispatch
test takes longer than my patience will allow, and the new separate
tests take about 5-6 minutes each. Reduce their timeout accordingly, but
not as far as the default for slow tests (5 minutes) to allow some
headroom for AddressSanitizer or slower systems.

The failed-helper-activation test is almost instantaneous, and no longer
needs to be marked as slow.

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agotest/bus: Factor out common setup/teardown code
Simon McVittie [Fri, 15 Jul 2022 14:27:24 +0000 (15:27 +0100)] 
test/bus: Factor out common setup/teardown code

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoMerge branch 'uid-0-in-userns' into 'master'
Simon McVittie [Mon, 18 Jul 2022 11:15:17 +0000 (11:15 +0000)] 
Merge branch 'uid-0-in-userns' into 'master'

test: Skip tests that involve switching uid if unable to do so

Closes #407

See merge request dbus/dbus!330

3 years agotest: Skip tests that involve switching uid if unable to do so
Simon McVittie [Mon, 18 Jul 2022 10:14:08 +0000 (11:14 +0100)] 
test: Skip tests that involve switching uid if unable to do so

In a Linux user namespace, it is possible that we are uid 0 but are
unable to switch to some other uid like DBUS_USER or DBUS_TEST_USER,
because the other uid is not "mapped" in the user namespace, resulting
in setuid() or setresuid() failing with EINVAL "Invalid argument".
For example, it's easy for this to happen when running under the
bubblewrap tool.

Try to drop privileges in a child process, and skip the test if we
are unable to do so.

Resolves: dbus#407
Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoMerge branch 'issue-405' into 'master'
Simon McVittie [Mon, 18 Jul 2022 09:27:44 +0000 (09:27 +0000)] 
Merge branch 'issue-405' into 'master'

Escape socket path when building the D-Bus address

See merge request dbus/dbus!329

3 years agoEscape socket path when building the D-Bus address
Marc-André Lureau [Fri, 15 Jul 2022 15:13:47 +0000 (19:13 +0400)] 
Escape socket path when building the D-Bus address

Fixes:
https://gitlab.freedesktop.org/dbus/dbus/-/issues/405

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agoMerge branch 'oom-score-adj' into 'master'
Simon McVittie [Sun, 17 Jul 2022 19:01:43 +0000 (19:01 +0000)] 
Merge branch 'oom-score-adj' into 'master'

Improve dbus-daemon-launch-helper behaviour if it cannot write oom_score_adj

See merge request dbus/dbus!291

3 years agosysdeps: Only open oom_score_adj read/write if we need to write it
Simon McVittie [Fri, 1 Apr 2022 17:56:26 +0000 (18:56 +0100)] 
sysdeps: Only open oom_score_adj read/write if we need to write it

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>
3 years agoactivation-helper: Never crash if unable to write oom_score_adj
Simon McVittie [Fri, 1 Apr 2022 17:58:34 +0000 (18:58 +0100)] 
activation-helper: Never crash if unable to write oom_score_adj

_dbus_warn() normally only logs a warning, but can be made fatal by
environment variables. In particular, we do that during unit testing,
which can result in a build-time test failure if dbus is built in a
sandbox environment that prevents write access.

_dbus_log() does only the logging part of _dbus_warn(), which seems
more appropriate here.

Signed-off-by: Simon McVittie <smcv@collabora.com>
3 years agoMerge branch 'win32-uds' into 'master'
Simon McVittie [Fri, 15 Jul 2022 16:14:55 +0000 (16:14 +0000)] 
Merge branch 'win32-uds' into 'master'

Add Unix socket support on Windows

See merge request dbus/dbus!249

3 years agospec: AF_UNIX now available on Windows as well
Marc-André Lureau [Fri, 25 Mar 2022 10:45:39 +0000 (14:45 +0400)] 
spec: AF_UNIX now available on Windows as well

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agospec: try to improve comment about AF_UNIX path
Marc-André Lureau [Fri, 25 Mar 2022 10:39:14 +0000 (14:39 +0400)] 
spec: try to improve comment about AF_UNIX path

The comment refers to the nul-padding of sockaddr_un member sun_path and
using an addrlen of sizeof(sockaddr_un). There is not much need to
document an old now "broken" behaviour.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agodbus: extract out _dbus_server_new_for_dir()
Marc-André Lureau [Fri, 25 Mar 2022 12:23:38 +0000 (16:23 +0400)] 
dbus: extract out _dbus_server_new_for_dir()

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agogitlab: skip failing runtime directory check, add FIXME
Marc-André Lureau [Thu, 24 Mar 2022 12:59:16 +0000 (16:59 +0400)] 
gitlab: skip failing runtime directory check, add FIXME

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agodbus/win: use SIO_AF_UNIX_GETPEERPID to lookup peer PID
Marc-André Lureau [Tue, 15 Feb 2022 12:51:02 +0000 (16:51 +0400)] 
dbus/win: use SIO_AF_UNIX_GETPEERPID to lookup peer PID

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agotest: enable AF_UNIX server-oom test on !unix
Marc-André Lureau [Wed, 9 Feb 2022 10:03:12 +0000 (14:03 +0400)] 
test: enable AF_UNIX server-oom test on !unix

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agotest/server-oom: do not hardcode /tmp
Marc-André Lureau [Thu, 24 Mar 2022 11:42:05 +0000 (15:42 +0400)] 
test/server-oom: do not hardcode /tmp

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agotest: enable AF_UNIX relay tests on !unix
Marc-André Lureau [Wed, 9 Feb 2022 08:23:56 +0000 (12:23 +0400)] 
test: enable AF_UNIX relay tests on !unix

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agotest/relay: do not hardcode /tmp on !unix
Marc-André Lureau [Thu, 24 Mar 2022 11:39:44 +0000 (15:39 +0400)] 
test/relay: do not hardcode /tmp on !unix

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agotest: enable AF_UNIX loopback tests on !unix
Marc-André Lureau [Wed, 9 Feb 2022 07:34:35 +0000 (11:34 +0400)] 
test: enable AF_UNIX loopback tests on !unix

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agotests/loopback: do not hardcode /tmp for !unix
Marc-André Lureau [Thu, 17 Mar 2022 13:12:41 +0000 (17:12 +0400)] 
tests/loopback: do not hardcode /tmp for !unix

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agotest: fix loopback AF_UNIX tests to work on Windows
Marc-André Lureau [Wed, 9 Feb 2022 07:56:19 +0000 (11:56 +0400)] 
test: fix loopback AF_UNIX tests to work on Windows

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agotest: enable AF_UNIX corrupt test on !unix
Marc-André Lureau [Wed, 9 Feb 2022 08:25:54 +0000 (12:25 +0400)] 
test: enable AF_UNIX corrupt test on !unix

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agotests/corrupt: do not hardcode /tmp on !unix
Marc-André Lureau [Thu, 17 Mar 2022 13:13:26 +0000 (17:13 +0400)] 
tests/corrupt: do not hardcode /tmp on !unix

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agotest: add test_check_af_unix_works()
Marc-André Lureau [Wed, 9 Feb 2022 08:32:23 +0000 (12:32 +0400)] 
test: add test_check_af_unix_works()

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agodbus: add a few directory separator macros
Marc-André Lureau [Wed, 9 Feb 2022 07:54:52 +0000 (11:54 +0400)] 
dbus: add a few directory separator macros

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agodbus: move DBUS_IS_DIR_SEPARATOR to dbus-internals.h
Marc-André Lureau [Wed, 9 Feb 2022 07:52:51 +0000 (11:52 +0400)] 
dbus: move DBUS_IS_DIR_SEPARATOR to dbus-internals.h

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agodbus: move AF_UNIX code to server-socket
Marc-André Lureau [Thu, 17 Mar 2022 14:16:01 +0000 (18:16 +0400)] 
dbus: move AF_UNIX code to server-socket

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agodbus: handle unix server in a new function
Marc-André Lureau [Tue, 8 Feb 2022 13:55:49 +0000 (17:55 +0400)] 
dbus: handle unix server in a new function

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>
3 years agodbus: move AF_UNIX code to transport-socket
Marc-André Lureau [Thu, 17 Mar 2022 14:03:00 +0000 (18:03 +0400)] 
dbus: move AF_UNIX code to transport-socket

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agodbus: add _dbus_transport_open_unixexec()
Marc-André Lureau [Fri, 1 Apr 2022 19:00:28 +0000 (23:00 +0400)] 
dbus: add _dbus_transport_open_unixexec()

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>
3 years agodbus: handle unix transport in a new common function
Marc-André Lureau [Tue, 8 Feb 2022 09:04:33 +0000 (13:04 +0400)] 
dbus: handle unix transport in a new common function

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>
3 years agodbus: add function for Unix sockets on Windows
Marc-André Lureau [Tue, 8 Feb 2022 11:41:50 +0000 (15:41 +0400)] 
dbus: add function for Unix sockets on Windows

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agodbus: move _DBUS_MAX_SUN_PATH_LENGTH to sysdeps.h
Marc-André Lureau [Tue, 8 Feb 2022 10:25:08 +0000 (14:25 +0400)] 
dbus: move _DBUS_MAX_SUN_PATH_LENGTH to sysdeps.h

Share the same constant for all systems.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agobuild-sys: check for afunix.h
Marc-André Lureau [Wed, 9 Feb 2022 10:48:43 +0000 (14:48 +0400)] 
build-sys: check for afunix.h

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
3 years agodbus: move unix socket declarations to common sysdeps.h
Marc-André Lureau [Tue, 8 Feb 2022 12:23:27 +0000 (16:23 +0400)] 
dbus: move unix socket declarations to common sysdeps.h

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>
3 years agodbus: change unix socket functions to return DBusSocket
Marc-André Lureau [Tue, 8 Feb 2022 11:19:32 +0000 (15:19 +0400)] 
dbus: change unix socket functions to return DBusSocket

This will allow to abstract away for Windows Unix socket support.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>