Commit graph

6528 commits

Author SHA1 Message Date
Jordan Williams
625366dd0e
Update NEWS 2022-07-25 14:14:57 -05:00
Jordan Williams
e62e42f84c
Add name to AUTHORS 2022-07-25 14:14:57 -05:00
Jordan Williams
fac146f44d
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.
2022-07-25 14:14:57 -05:00
Jordan Williams
ad5836cb0d
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.
2022-07-25 14:14:56 -05:00
Simon McVittie
8e0290fcc8 release-checklist: Add a reminder to update both Autotools and Meson
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-23 11:23:06 +01:00
Simon McVittie
3758e5b164 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>
2022-07-23 11:23:06 +01:00
Simon McVittie
702ca4d13c 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
2022-07-20 13:27:46 +00:00
Simon McVittie
98eff5513e 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>
2022-07-19 21:11:09 +01:00
Simon McVittie
36038fb126 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>
2022-07-19 21:11:09 +01:00
Simon McVittie
624efc0781 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>
2022-07-19 20:50:33 +01:00
Simon McVittie
a54ed9ffad 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>
2022-07-19 20:50:33 +01:00
Simon McVittie
bf30fe6d60 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>
2022-07-19 20:45:31 +01:00
Simon McVittie
6d46d43aab 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>
2022-07-19 20:45:24 +01:00
Simon McVittie
536b39a11c Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-19 20:27:29 +01:00
Simon McVittie
440aa8edf0 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
2022-07-18 13:06:58 +00:00
Simon McVittie
f49ff4f0ea 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>
2022-07-18 11:15:54 +00:00
Simon McVittie
bef88fd562 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>
2022-07-18 11:15:54 +00:00
Simon McVittie
11e6c92e95 test/bus: Factor out common setup/teardown code
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-18 11:15:54 +00:00
Simon McVittie
2cdd0d0f30 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
2022-07-18 11:15:17 +00:00
Simon McVittie
8b08dd3264 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>
2022-07-18 10:31:40 +00:00
Simon McVittie
a615db944c Merge branch 'issue-405' into 'master'
Escape socket path when building the D-Bus address

See merge request dbus/dbus!329
2022-07-18 09:27:44 +00:00
Marc-André Lureau
c7a98fd20b 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>
2022-07-18 11:11:11 +04:00
Simon McVittie
a3850d399c 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
2022-07-17 19:01:43 +00:00
Simon McVittie
a8006841ce 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>
2022-07-16 22:23:07 +00:00
Simon McVittie
ad72e3b9e3 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>
2022-07-16 22:23:07 +00:00
Simon McVittie
b3163746a9 Merge branch 'win32-uds' into 'master'
Add Unix socket support on Windows

See merge request dbus/dbus!249
2022-07-15 16:14:55 +00:00
Marc-André Lureau
b937c4aec1 spec: AF_UNIX now available on Windows as well
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
e6f2eed6f8 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>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
df6ab5924c dbus: extract out _dbus_server_new_for_dir()
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
85694b5bb3 gitlab: skip failing runtime directory check, add FIXME
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
12af359bb2 dbus/win: use SIO_AF_UNIX_GETPEERPID to lookup peer PID
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
d08973f6d3 test: enable AF_UNIX server-oom test on !unix
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
522cc62e02 test/server-oom: do not hardcode /tmp
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
01b293027e test: enable AF_UNIX relay tests on !unix
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
03dac62937 test/relay: do not hardcode /tmp on !unix
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
2be8c00a1d test: enable AF_UNIX loopback tests on !unix
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
c6d6a2c9e6 tests/loopback: do not hardcode /tmp for !unix
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
e05ff718a1 test: fix loopback AF_UNIX tests to work on Windows
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
b1213e3aee test: enable AF_UNIX corrupt test on !unix
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
a19d2e7f09 tests/corrupt: do not hardcode /tmp on !unix
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
58992c88bc test: add test_check_af_unix_works()
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
95f4cf53fe dbus: add a few directory separator macros
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:54 +01:00
Marc-André Lureau
dcdb992dd2 dbus: move DBUS_IS_DIR_SEPARATOR to dbus-internals.h
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:49 +01:00
Marc-André Lureau
d98c98d1e5 dbus: move AF_UNIX code to server-socket
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:18 +01:00
Marc-André Lureau
ee7c08afaf 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>
2022-07-15 16:26:18 +01:00
Marc-André Lureau
a508ab583d dbus: move AF_UNIX code to transport-socket
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:18 +01:00
Marc-André Lureau
d3dd8c5724 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>
2022-07-15 16:26:18 +01:00
Marc-André Lureau
ed838d4169 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>
2022-07-15 16:26:18 +01:00
Marc-André Lureau
655266f32e dbus: add function for Unix sockets on Windows
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-15 16:26:18 +01:00
Marc-André Lureau
0cf03ce49b 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>
2022-07-15 16:26:18 +01:00