Alan Coopersmith [Sun, 13 Oct 2024 19:33:06 +0000 (12:33 -0700)]
test: Move fd limit check into test_flood
Other tests have different requirements for fds (and already check for
them), so move this check into the specific test (mirroring what those
other tests already do) instead of blocking the whole test program,
incorrectly using autoconf test return codes instead of TAP protocol,
as discussed in #176.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Alan Coopersmith [Sun, 13 Oct 2024 19:24:09 +0000 (12:24 -0700)]
test: raise fd limit to maximum before running fdpass tests
Many of these tests require more than the default fd limit on some systems,
so raise the limit, if we can, to give them a better chance of being able
to run.
Closes #176 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Needed when building with support for Solaris audit API, otherwise
linking fails with:
Undefined first referenced
symbol in file
adt_export_session_data dbus/libdbus-1.so.3.38.1.p/dbus-sysdeps-unix.c.o
adt_start_session dbus/libdbus-1.so.3.38.1.p/dbus-sysdeps-unix.c.o
adt_end_session dbus/libdbus-1.so.3.38.1.p/dbus-sysdeps-unix.c.o
adt_set_from_ucred dbus/libdbus-1.so.3.38.1.p/dbus-sysdeps-unix.c.o
Fixes: cd2e3826 ("Add Meson build system") Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
spec: recommend searching for system-services in /etc/ and /run/
This is useful when an asset manager wants to install a system
service while /usr/ is read-only (e.g.: portable services running
on a different namespaced image). Also recommend searching in /run/
following the now-standard pattern, for ephemeral services.
bus: search for system-services in /etc/ and /run/ by default
Tthis is useful when an asset manager wants to install a system
service while /usr/ is read-only (e.g.: portable
services running on a different namespaced image). Unlike other
directories, enforce strict naming and do not set up an inotify,
as the directories might not even exist until much later. Also
search in /run/ for ephemeral services that will disappear after
a reboot.
Jordan Williams [Wed, 6 Mar 2024 14:32:34 +0000 (08:32 -0600)]
Handle missing user when installing setuid in meson_post_install.py
The logic that sets the dbus-daemon-launcher-helper setuid does not
handle the case where the group named the same as the dbus_user does not
exist.
This makes the assumption that the primary group of the dbus_user
has the same name as the dbus_user.
This may not be the case.
To remedy these issues, obtain the group id for dbus_user instead of
attempting to retrieve the group id by name.
To avoid a failure when the user does not exist, handle the KeyError
exception from the pwd.getpwnam function by printing a warning and
skipping the logic to set the binary setuid.
Perform an additional check to ensure that the dbus_user's primary group
has only a single member.
Fail similarly if it has more than one member.
Resolves: #492 Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 25 Sep 2024 16:58:42 +0000 (17:58 +0100)]
spec: Add a reminder of how to access Properties
Readers of the message bus specification might be encountering Properties
for the first time, so for the basic properties in the o.fd.DBus
interface, link to the interface definition.
I'm not intending to add similar text for extension interfaces like
Containers.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 25 Sep 2024 16:56:18 +0000 (17:56 +0100)]
spec: Have a sect2 per interface documented for the message bus
Previously, we arbitrarily divided o.fd.DBus into "messages"
(methods and signals), in one sect2, and Properties, in another sect2;
and for the only extended interface that is documented so far,
o.fd.DBus.Monitoring, we included its single method in the list of
o.fd.DBus methods.
This is putting too much weight on implementation details of how the
D-Bus protocol is implemented (with Properties being "less core" than
methods and signals), and not enough weight on how interfaces are
conceptually structured. It's more usual to group together all aspects
of an interface into one document or section, and the current arbitrary
separation is going to look more and more odd as we start documenting
more interfaces like Containers (dbus!449), Stats and Verbose.
Instead, repurpose the "Message Bus Messages" section to become the
documentation for the o.fd.DBus interface, and introduce a separate
section for each other interface that the message bus provides.
Each one contains a full list of methods, signals and properties (if any)
if it is specific to the message bus, or a cross-reference to a more
generic interface description if it is equally applicable to the message
bus and its clients.
Prompted by discussion on dbus!449.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 25 Sep 2024 14:39:49 +0000 (15:39 +0100)]
meson: Substitute DBUS_APIDOC_LINK
doc/index.html.in is common to the Meson and CMake build systems, so
every time a new variable gets substituted into it, both the Meson and
CMake build systems need to provide a value for that variable.
Fixes: b58ca0e1 "cmake: Inclusion of a link in html overview file corrected" Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Tue, 1 Oct 2024 12:17:41 +0000 (13:17 +0100)]
meson: Install Doxygen docs as api/html/*.html
This ensures that the Doxygen-built documentation has the same layout
in the installed files that it does in the build tree and on the
website. If we don't keep the same layout, then there is no value for
the `DBUS_APIDOC_LINK` in index.html that would be correct for both
the build tree and the installed tree. The build tree effectively has
a html subdirectory hard-coded, because that's how Doxygen lays out
its outputs.
This commit is the Meson equivalent of
commit 522633b4 "cmake: install api docs in html subdir" in the CMake
build system (dbus!473, dbus#519).
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 25 Sep 2024 17:11:32 +0000 (18:11 +0100)]
spec: Don't expect clients to support obsolete message buses
The newest release of the reference message bus that did not support
GetConnectionCredentials was 1.6.30, almost a decade ago.
It's entirely reasonable for new code to assume that
GetConnectionCredentials will succeed, and not implement a fallback.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 25 Sep 2024 17:08:19 +0000 (18:08 +0100)]
spec: Improve flow of text when cross-referencing methods, etc.
`<xref>` will typically be replaced by something like
"the section called “Foo”", so if we want to name a specific method
in running text, we need to use `<link>`.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Tue, 1 Oct 2024 13:28:56 +0000 (14:28 +0100)]
CI: Only configure wine as an exe_wrapper if we are going to run tests
This choice of exe_wrapper doesn't appear to work on Debian 12, causing
a build failure while checking that the output of the C++ compiler is
executable.
Another advantage of this is that if we're not running the test suite,
we can do a more traditional cross-build where running host-architecture
executables is impossible, which doubles as a way to prove that this
still works.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Tue, 1 Oct 2024 13:06:12 +0000 (14:06 +0100)]
CI: Don't run test suite under Wine on Debian
This has been noted to be unreliable (dbus#509) and we now have more
realistic test coverage on actual Windows.
I'm marking these CI jobs to do the build but not run the tests,
instead of skipping them completely, because having coverage for a
successful build on mingw-w64 (32-bit, 64-bit) bit × (release, debug)
does still seem like a useful thing for us to have.
Signed-off-by: Simon McVittie <smcv@collabora.com>
CMake has previously installed the api documentation in the api/
subdirectory, but api/html is required to correspond to the link
in the generated index file (index.html).
Simon McVittie [Wed, 25 Sep 2024 13:41:48 +0000 (14:41 +0100)]
test: Always initialize an "out" parameter
check_valid_fd() does not touch its second parameter if the fd is not,
in fact, a valid fd. Initialize the "out" parameter to the opposite
of the value we are hoping for, so that both assertions will fail if
there is a problem.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 25 Sep 2024 13:40:16 +0000 (14:40 +0100)]
sysdeps-unix: Always initialize flags for syslog()
If passed an invalid DBusSystemLogSeverity, the default case for the
switch construct is to crash out with an assertion failure, but the
assertion failure itself is not compiled in if we are doing a production
build without assertions.
Detected by compiling with gcc 14, which does some static analysis
by default.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 25 Sep 2024 13:36:13 +0000 (14:36 +0100)]
sysdeps: Avoid passing possibly null port-number string to printf %s
gcc 14 detects that port can be NULL here, which is technically invalid
to pass to printf (although many implementations print it as "(null)").
Becuase we're using getaddrinfo(), we treat a NULL service (port number
string) as a request to listen on "port 0", meaning we ask the kernel to
assign an arbitrary nonzero port for us; when printing addresses in
error messages, treating that as port 0 seems reasonable.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Alyssa Ross [Mon, 22 Jul 2024 08:08:05 +0000 (10:08 +0200)]
dbus-sysdeps-unix: don't add (uid_t)-1 to creds
If I set a breakpoint on the call to _dbus_credentials_add_unix_uid
further down in this function and run the loopback test, I can see
that sometimes it's getting called with a uid of 4294967295. This is
not intended, but happens because the -1 value returned from
SO_PEERCRED is interpreted as a uid of 4294967295, because if uid_t is
unsigned, it won't be sign extended when assigned to uid_read.
As far as I can tell, every other API used in this function to get
uid/gid on some system returns an error when there's no credential
information (e.g. on a non-unix socket), rather than returning -1, so
they shouldn't have to do this check.
Alyssa Ross [Sun, 28 Jul 2024 10:50:37 +0000 (12:50 +0200)]
test: use "tty" group rather than "bin"
Unlike "bin", "tty" actually means something on modern Linux distros,
and is used by a default udev rule, so it's more likely to exist on
distros than a group that just exists for historical compatibility
with who knows what.
"tty" exists on macOS, Debian, and Fedora (the criteria used for
choosing "bin" in f2905def ("policy tests: Use bin rather than
nogroup, wheel, or root")), but also fixes running the bus test for me
on NixOS, which has "tty" but not "bin".
Closes: https://gitlab.freedesktop.org/dbus/dbus/-/issues/514 Signed-off-by: Alyssa Ross <hi@alyssa.is>
Alyssa Ross [Sun, 21 Jul 2024 12:24:13 +0000 (14:24 +0200)]
meson: fix name of DBUS_ENABLE_LAUNCHD macro
This is the name used previously by autoconf, and still used by the C
code. Presumably this meant that the launchd ended up never being
built with Meson, even if launchd support was enabled.
Signed-off-by: Alyssa Ross <hi@alyssa.is> Fixes: cd2e3826 ("Add Meson build system")
Simon McVittie [Wed, 23 Aug 2023 11:04:33 +0000 (12:04 +0100)]
sysdeps: Remove _dbus_string_append_int()
It's a wrapper around snprintf(), so we are not gaining any efficiency
versus _dbus_string_append_printf(), and might as well use the more
general function instead. Doing it this way might even be a little *more*
efficient, since it reduces reallocations; it's certainly more concise.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 23 Aug 2023 10:57:44 +0000 (11:57 +0100)]
sysdeps: Remove _dbus_string_append_uint()
It's a wrapper around snprintf(), so we are not gaining any efficiency
versus _dbus_string_append_printf(), and might as well use the more
general function instead.
Signed-off-by: Simon McVittie <smcv@collabora.com>
gitlab.fd.o/bustle/bustle points to the old archived project. The new
version has been rewritten in Rust and is now hosted at
gitlab.gnome.org/World/bustle
Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
sysdeps-win: Fix autolaunch: regression on Windows
Commit f20a05f60f6f included in dbus-1.15.0 broke autolaunch: on
Windows. autolaunch_custom_command_line_parameter shall be initalized
to null as it is later used in only one place in the code, with this
ternary:
hongjinghao [Thu, 4 Jan 2024 07:15:53 +0000 (15:15 +0800)]
Do not crash when reloading configuration with > 128 dirs
When `dbus-daemon` sets more than 128 directories for `XDG_DATA_DIRS`,
none of the elements in `new_dirs` will be `NULL`, which resulted in
these loops reading out-of-bounds (undefined behaviour). In practice
this led to a crash.
To avoid this, make sure to stop iteration at the end of the array.
instead of using has_header use check_header to confirm the header
works. This is necessary to get the meson build to work with Visual
Studio 2022. It has <stdatomic.h> but it does not actually work when
compiling a C program. A minimal C program that include <stdatomic.h>
fails with the following errors:
Simon McVittie [Fri, 1 Dec 2023 19:10:50 +0000 (19:10 +0000)]
CI: Set language environment variables to safe values
Recent versions of glibc support C.UTF-8 natively, and both Debian and
openSUSE (which we use for our CI) have been patching it into our glibc
versions for several years before that.
Helps: https://gitlab.freedesktop.org/dbus/dbus/-/issues/488 Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 1 Dec 2023 19:03:49 +0000 (19:03 +0000)]
CI: Don't re-run the tests when preparing to build as a subproject
After running the test suite, we don't need (or want) to re-run the test
suite as a side-effect of producing a dist tarball. Historically, this
test-case used Autotools `make dist`, not `make distcheck`, but when
we removed the Autotools build system, it was replaced with
`meson dist` (similar to Autotools `make distcheck`). Change that to
`meson dist --no-tests`, which is more like Autotools `make dist` as
originally intended.
In particular, when we re-ran the test suite, we weren't filtering out
the time-consuming and timeout-prone tests that emulate malloc()
failures, which we don't normally intend to run in CI.
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/489 Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 1 Dec 2023 19:00:20 +0000 (19:00 +0000)]
CI: Remove meson-dist and cmake-dist build systems
Before we removed the Autotools build system, these meant: do a
`make dist` with Autotools, then unpack the resulting tarball, and build
it with Meson or CMake (as appropriate). This was important because the
contents of an Autotools `make dist` differed significantly from what's
in git: only the files that were explicitly declared as sources in the
Autotools build system were distributed, and Autotools would also add its
own generated cruft.
Now that we're doing releases with Meson, the official source release
artifact is basically `git archive`, so there's much less need to
distinguish between official source releases and what's in git, and these
variant build systems became simple aliases for meson and cmake.
Remove those aliases from tools/ci-build.sh, and stop using them in
.gitlab-ci.yml.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Ralf Habacker [Mon, 21 Aug 2023 21:34:10 +0000 (23:34 +0200)]
Remove autotools support from CI jobs
The 'debian mingw32 autotools debug' job was replaced with a corresponding
meson related job named 'debian mingw32 meson debug' and the remaining
autotools related jobs were removed.
The drop in replacement job for 'debian mingw64 autotools' is
'debian mingw32 meson' and is now build by default.
time: use dbus_int64_t for seconds instead of long
On 32 bit systems long will overflow in 2038, causing complete breakage.
This is confirmed by running dbus's test suite on a 32 bit system
with system time set to 2040 (and configured to use 64 bit time_t of course).
Note that both timespec and timeval are specified with time_t for the
seconds component. This should propagate everywhere where that data is
passed and stored, but previously _dbus_get_monotonic_time() and
_dbus_get_monotonic_time() would truncate it to long.
Also add a function for parsing dbus_int64_t from
files, as existing functions can only handle long.
Signed-off-by: Alexander Kanavin <alex@linutronix.de>