Commit graph

6811 commits

Author SHA1 Message Date
Ralf Habacker
041b236251 INSTALL: Re-word CMake build instructions
Originally part of commit
"README,INSTALL: remove references to the autotools build system"
in dbus!378.

Co-authored-by: Simon McVittie <smcv@collabora.com>
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-15 13:09:56 +01:00
Simon McVittie
4325a0fcc8 Continue to recommend CMake when building on Windows
In the longer term I'd like to move everything towards Meson so we only
have one primary build system, but at the moment Ralf would prefer to
keep recommending CMake for Windows builds (see dbus!378) so let's
stick with that for now.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-15 13:06:18 +01:00
Simon McVittie
0b685497a0 Merge branch 'spdx-mit' into 'master'
Add SPDX license tags for the MIT (Expat) license, where straightforward

See merge request dbus/dbus!427
2023-08-15 11:22:54 +00:00
Simon McVittie
3190b488e3 Add SPDX license tags for the MIT (Expat) license, where straightforward
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-14 17:18:04 +00:00
Simon McVittie
680ba5d4a7 Merge branch 'meson-special-builds' into 'master'
Use Meson for the 'reduced' and 'legacy' build variants

See merge request dbus/dbus!430
2023-08-14 17:17:29 +00:00
Ralf Habacker
5d1922784c Use Meson for the 'reduced' and 'legacy' build variants
There are some differences between Autotools and Meson here:

- Because we detect native atomic operations differently, we can no
  longer emulate a platform that doesn't have them, such as ARMv4;
  but modern OSs no longer support ARMv4 and all significant hardware
  platforms now have native atomic operations, so this is now less of
  a concern.

- Similarly, we can no longer emulate a platform that doesn't have the
  getrandom() library function, but that function is available in all
  relevant glibc versions (such as CentOS >= 8, Debian >= 10,
  Ubuntu >= 18.04) so testing the fallback path is less of a concern now.

We also no longer try to disable dnotify in the legacy build, but our
dnotify code path was removed in 2013, so --disable-dnotify didn't do
anything anyway.

[Separated from a larger commit on dbus!378 —smcv]

Co-authored-by: Simon McVittie <smcv@collabora.com>
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-14 17:38:17 +01:00
Simon McVittie
6fb74c76ee Merge branch 'spdx-misc' into 'master'
Improve SPDX license info slightly

See merge request dbus/dbus!428
2023-08-14 16:21:35 +00:00
Simon McVittie
b463b301b9 stats.h: Add missing copyright information
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-14 16:58:22 +01:00
Simon McVittie
7c4d0d6281 doc: Repeat a copyright notice in a form understood by SPDX tools
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-14 16:58:21 +01:00
Simon McVittie
ad44d655ba NEWS: Update
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-14 16:29:47 +01:00
Simon McVittie
1999ea0537 INSTALL: Rewrite extremely outdated list of dependencies
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-14 16:29:46 +01:00
Simon McVittie
24c4b60a59 release-checklist: Update for increased use of Meson
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-14 16:18:58 +01:00
Simon McVittie
7b7effc175 INSTALL: Remove generic Autotools installation instructions
Now that we are recommending Meson, let's de-emphasize Autotools.
Anyone who still needs Autotools will already know how it works, at
least generically.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-14 16:18:39 +01:00
Simon McVittie
f7005fbb40 README, INSTALL: Move build/install instructions into INSTALL
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-14 16:17:46 +01:00
Simon McVittie
9a47cca662 Merge branch 'time64' into 'master'
On 32-bit glibc, define _TIME_BITS to 64 if not already defined

Closes #465

See merge request dbus/dbus!416
2023-08-14 14:45:53 +00:00
Simon McVittie
3072109b11 On 32-bit glibc, define _TIME_BITS to 64 if not already defined
On older 32-bit architectures such as i386, this redefines time_t to be
64-bit, and correspondingly increases the size of all system data
structures that contain a time_t, such as struct timeval and struct stat.
This is necessary to allow timestamps beyond January 2038 to be
represented; as well as things that obviously deal with timestamps,
this affects functions like stat() (and therefore our wrapper
_dbus_stat()), which will fail with EOVERFLOW if asked to inspect a
file whose correct timestamp does not fit in time_t.

In particular, if the modification or access timestamp on
/etc/machine-id has somehow been set to a post-2038 time, libdbus will
consider the inability to stat() that file to be an installation error,
and when using the deprecated dbus_get_local_machine_id(), that can
cause third-party i386 software such as the Steam client to crash.
Using 64-bit timestamps avoids that failure mode.

Using 64-bit timestamps in glibc is an opt-in and not the default,
because if done carelessly it can change libraries' ABIs. However,
libdbus is careful not to include system headers and system data
types in its own headers, with the only exceptions being extremely
basic ISO C headers like <stddef.h> and <stdarg.h>; so we can safely
do this without it breaking our ABI. This is similar to the reasoning
for why commit 96ffc2a0 "configure.ac: support large-file for stat64"
was a safe change.

This change only affects glibc. Some non-GNU operating system libraries
(such as musl) are less concerned with binary backwards compatibility
than glibc, and therefore have incompatibly changed their ABI on 32-bit
platforms to switch to 64-bit timestamps throughout; no action is needed
on those platforms. If other non-GNU OS libraries have taken a route
similar to GNU's, then maintainers of those operating systems are
welcome to send tested merge requests similar to this one.

An extra subtlety here is that _TIME_BITS=64 requires
_FILE_OFFSET_BITS=64. In the Meson build, Meson unconditionally enables
_FILE_OFFSET_BITS=64 where appropriate, and in the Autotools build,
we already had that via AC_SYS_LARGEFILE, but in the CMake build we
did not necessarily have this; so we also define _FILE_OFFSET_BITS=64
there if necessary, as a continuation of commit 96ffc2a0
"configure.ac: support large-file for stat64".

On newer 32-bit architectures like x32, time_t is always 64-bit and so
this has no practical effect.

On 64-bit, setting these would have no practical effect, but to minimize
risk I'm only doing this for 32-bit architectures.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/465
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-14 14:18:25 +00:00
Simon McVittie
91b59ea792 Merge branch 'pidfd' into 'master'
Use PID FD if available from SO_PEERPIDFD, and return it via GetConnectionCredentials()

See merge request dbus/dbus!398
2023-08-08 11:45:34 +00:00
Luca Boccassi
7a4c47a929 bus: return ProcessFD in GetConnectionCredentials()
Allows to track a process by pinning to a file descriptor,
which unlike a PID cannot be reused.

root@image:~# busctl call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus GetConnectionCredentials "s" org.freedesktop.systemd1
a{sv} 3 "ProcessID" u 1 "UnixUserID" u 0 "ProcessFD" h 4

Signed-off-by: Luca Boccassi <bluca@debian.org>
2023-08-08 12:24:20 +01:00
Luca Boccassi
8883f0dd01 _dbus_asv_add_unix_fd: add
Add a new helper to add unix FDs to arrays. Will be used for
GetConnectionCredentials().

Signed-off-by: Luca Boccassi <bluca@debian.org>
2023-08-08 12:24:20 +01:00
Luca Boccassi
80d523dcc8 DBusCredentials: add support for PID FDs via SO_PEERPIDFD
The new socket option SO_PEERPIDFD allows to pin the process on the
other side of the socket by file descriptor, which closes a race
condition where a PID can be reused before we can pin it manually.
Available since Linux v6.5.

When storing credentials, pin the process by FD from the PID.
When querying the PID, if the PID FD is available, resolve
it from there first if possible.

Ensure the DBusCredentials object only returns the PID FD if it was
obtained by this call, so that we know for sure we can rely on it
being safe against PID reuse attacks.

Signed-off-by: Luca Boccassi <bluca@debian.org>
2023-08-08 12:24:20 +01:00
Simon McVittie
5f9c3da486 Merge branch 'ci-fixes' into 'master'
CI: cleanup setting build directory

See merge request dbus/dbus!424
2023-08-08 11:10:03 +00:00
Ralf Habacker
1b10f4f89c tools/ci-build.sh: cleanup setup and usage of ci_builddir
The order and arrangement of the initialization of the build directories
has been improved: the deletion of special directories have been moved to
the associated part, the rest have been merged and there is a default
value if not specified as an environment variable, making it easier to
execute on the command line.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2023-08-07 19:59:16 +02:00
Ralf Habacker
5ddb3b67bf CI: add prefix 'ci_' to env var 'builddir'
This customization simplifies their use, e.g. when outputting the command
line used. Because of FreeBSD, 'awk' is used instead of 'gawk' to make
sure that the tool is available.
2023-08-07 19:49:53 +02:00
Simon McVittie
8cd3ebabf6 Merge branch 'cmake-using-meson-variables' into 'master'
Let cmake retrieve version and variable information from meson build system

See merge request dbus/dbus!382
2023-08-07 14:59:34 +00:00
Ralf Habacker
e665f96c76 Let cmake retrieve version and variable information from meson build system
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2023-08-07 16:10:21 +02:00
Ralf Habacker
dbb4e0ea90 cmake: reorder include header and function checks to match meson build system 2023-08-07 16:10:21 +02:00
Simon McVittie
fcf889e7bd Merge branch 'systemd_user' into 'master'
systemd: start as the D-Bus user/group, rather than root

See merge request dbus/dbus!399
2023-08-04 14:52:07 +00:00
Luca Boccassi
760cb1e418 systemd: start as the D-Bus user/group, rather than root
When starting as root files in /proc/self/fdinfo/ will be owned as root
and set to 400, so we cannot read them. Nowadays it is not necessary to
start as root when running under systemd, so just add User/Group with
the configured user to the system unit.

If libaudit support is enabled, add AmbientCapabilities=CAP_AUDIT_WRITE
so that we can still write to the audit log.

Signed-off-by: Luca Boccassi <bluca@debian.org>
2023-08-03 09:13:30 +00:00
Ralf Habacker
053003014b Revert "CI: Only run "opensuse mingw64 meson debug" if triggered manually"
This reverts commit 0f902faa38.

See https://gitlab.freedesktop.org/dbus/dbus/-/issues/469
2023-08-03 11:00:00 +02:00
Simon McVittie
a2b1f7edf7 Merge branch 'pid_fd_spec' into 'master'
spec: add ProcessFD to GetConnectionCredentials()

See merge request dbus/dbus!420
2023-08-02 15:14:46 +00:00
Luca Boccassi
baac5ce171 spec: add ProcessFD to GetConnectionCredentials()
Make D-Bus implementations return a file descriptor
pinning the process as part of the credentials on
platforms that implement such concept, like Linux.

Pinning the process allows to defend against PID
reuse attacks, making authentication by
service/cgroup possible.

Signed-off-by: Luca Boccassi <bluca@debian.org>
2023-08-01 19:31:33 +00:00
Simon McVittie
3444466f9f Merge branch 'master' into 'master'
dbus-daemon: Avoid known options being interpreted as optional arguments

Closes #467

See merge request dbus/dbus!421
2023-08-01 18:39:16 +00:00
Xin Shi
86a89967f2 dbus-daemon: Avoid known options being interpreted as optional arguments
The man page and --help imply that

    dbus-daemon --print-address --print-pid

is a valid/useful thing to do, but because --print-address takes an
optional argument, it is ambiguous whether --print-pid is meant to
be the argument for --print-address (same as --print-address=--print-pid)
or a new option (same as --print-address=1 --print-pid). In fact,
before this commit, the dbus-daemon would interpret --print-pid as
the optional argument to --print-address, and then fail to parse it
because it isn't an integer.

Because none of our options are syntactically valid as arguments for
any option that takes an optional argument, we can avoid the ambiguity
by delaying parsing of optional arguments until all known options
have been tried.

Resolves: dbus/dbus#467

Signed-off-by: Xin Shi <shixin21@huawei.com>
2023-08-01 18:25:07 +00:00
Simon McVittie
7ab384de57 Merge branch 'empty-group-list' into 'master'
dbus-sysdeps-unix: Handle empty supplementary group list

See merge request dbus/dbus!422
2023-08-01 18:23:09 +00:00
cptpcrd
49dd4aba42 dbus-sysdeps-unix: Check socklen_t is unsigned when getting group list
After the change to handle an empty list properly, the function now
assumes that is true.
2023-08-01 18:09:26 +00:00
cptpcrd
f8a7bffd5e dbus-sysdeps-unix: Handle empty supplementary group list
It is valid for getsockopt(SO_PEERGROUPS) to return len=0; that
indicates the process has no supplementary groups. Rather than failing,
simply use the returned empty list (and add the primary GID to it).

Without this change, calling GetConnectionCredentials on a bus name
owned by a process with no supplementary groups does not return the
UnixGroupIDs field, even though it is easy to determine that the process
only has one GID (the primary GID).
2023-08-01 18:09:26 +00:00
Simon McVittie
1d45d1c3f6 Merge branch 'adduser' into 'master'
Fix CI failures

Closes #468

See merge request dbus/dbus!423
2023-08-01 18:02:33 +00:00
Simon McVittie
0f902faa38 CI: Only run "opensuse mingw64 meson debug" if triggered manually
Mitigates: dbus/dbus#469
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-01 18:48:30 +01:00
Simon McVittie
8d14293458 CI: Make user creation idempotent
adduser --system exits successfully if the user already exists, but
ordinary adduser doesn't.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/468
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-01 18:30:14 +01:00
Simon McVittie
b230cf03b0 Merge branch 'override_dep_name' into 'master'
meson: Override "dbus-1" dependency name

See merge request dbus/dbus!415
2023-06-13 18:53:14 +00:00
Barnabás Pőcze
67036a2fdf meson: Override "dbus-1" dependency name
Since meson 0.54.0, it is possible to override a dependency name,
so do that to make it easy to use dbus as a subproject. After this
change, simply

  dependency('dbus-1')

will fall back to the subproject automatically and there is no need
for using `fallback` keyword argument. Of course this assumes that
the dbus source tree is at subprojects/dbus-1 and not subprojects/dbus
but it is easy to achieve that.

If the dbus source tree for some reason needs to be at subprojects/dbus,

  dependency('dbus-1', fallback: 'dbus')

may be used, which still has the advantage of not needing to
depend on the variable names in the dbus build definitions.
2023-06-13 18:12:26 +02:00
Simon McVittie
0a440c93db Merge branch 'wip/work-around-462' into 'master'
CI: Don't run windows-meson-mingw-ucrt64 by default

See merge request dbus/dbus!414
2023-06-13 13:16:30 +00:00
Simon McVittie
f8767c8e4a CI: Enable "debian mingw64 meson debug" by default
This gives us coverage for Meson mingw-w64 by default, but
cross-compiling from Debian with MSVCRT rather than a native compilation
on Windows with UCRT. When combined with "windows msys64 ucrt64 cmake",
this fills in most of the missing coverage caused by disabling
windows-meson-mingw-ucrt64 to work around dbus#462.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-13 13:59:21 +01:00
Simon McVittie
2c11190b6a CI: Don't run windows-meson-mingw-ucrt64 by default
Workaround for dbus#462: if this doesn't run reliably as a result of
external factors, then we shouldn't be using it as a CI gate.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-13 13:57:25 +01:00
Simon McVittie
d219c8af45 Merge branch 'issue-455' into 'master'
CI: Fix problem with configuration when cross building with cmake

Closes #455

See merge request dbus/dbus!413
2023-06-13 11:58:07 +00:00
Ralf Habacker
a2ae66ff1a CI: restore cross building with cmake 2023-06-12 21:37:05 +02:00
Ralf Habacker
4e45eb06b1 CI: Fix problem with configuration when cross building with cmake
Due to an adaptation of an rpm macro for cross-compiling with cmake, there
was a problem with the previous method of using the current directory as
the build directory. Instead, the command line options provided by cmake
are now used to define the source and build directories, which provide more
stable behavior.

Fix #455
2023-06-12 21:36:41 +02:00
Simon McVittie
4a1f6a0c2c Merge branch 'wip/meson-warnings' into 'master'
meson: Disable some warnings when asserts/checks are disabled

See merge request dbus/dbus!412
2023-06-07 12:26:30 +00:00
Simon McVittie
ba515347cf meson: Disable some warnings when asserts/checks are disabled
Some labels are only used when checks are enabled, and some variables
are only used when assertions and/or checks are enabled. Instead of
cluttering the code with extra #ifdefs, we silence those warnings:
they're harmless in this case. We already do this in Autotools.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-07 12:09:31 +00:00
Simon McVittie
2ca68e9544 Merge branch 'wip/issue453' into 'master'
cmake: Define _GNU_SOURCE before checking for any symbols

Closes #453

See merge request dbus/dbus!411
2023-06-07 12:08:04 +00:00