Commit graph

5974 commits

Author SHA1 Message Date
Ralf Habacker
2148a5a803 cmake: install dbus-daemon-launch-helper on Unix
Previously it was built on Unix platforms, but not installed. This
would prevent traditional activation on the system bus (on Linux
without systemd or non-Linux, or for services without SystemdService),
which requires the activation helper.

Because the executable is an internal implementation detail of how
traditional activation is implemented on Unix, it is not exported to
the generated cmake support files.

Resolves: dbus#310
2020-09-22 11:22:40 +02:00
Simon McVittie
e8dc63c041 Merge branch 'spec-cookie-timeouts' into 'master'
spec: Update recommendations for DBUS_COOKIE_SHA1 timeouts

See merge request dbus/dbus!171
2020-09-21 11:23:25 +00:00
Simon McVittie
3f8b2ce52e spec: Update recommendations for DBUS_COOKIE_SHA1 timeouts
This had two issues that could damage interoperability.

First, the spec wording suggested that any cookie that had not been
deleted was suitable for use in authentication. However, this introduces
a race condition, which is called out in comments in both the reference
implementation and GDBus: the newest cookie might be less old than the
arbitrary lifetime when authentication *begins*, but older than the
lifetime at the time authentication *ends*. As a result, we need a grace
period during which an old cookie will still be accepted, but a newer
cookie exists and will be used for new authentication operations.

Second, the spec wording implied that the arbitrary timeouts were
completely up to the implementor. However, GLib bug
https://gitlab.gnome.org/GNOME/glib/-/issues/2164 indicates that they
need to be reasonably compatible: in particular, GDBus servers
historically didn't allocate new cookies until 10 minutes had passed,
but libdbus clients would decline to use a cookie older than 5 minutes,
causing authentication to fail if the gdbus-server test-case (in which
GDBus and libdbus clients connect to a GDBus server) happened to take
longer than 5 minutes to run.

While I'm here, also be consistent about calling the secrets "cookies"
(consistent with the name of the mechanism) rather than "keys" (which
is what they are called in libdbus' dbus-keyring.c).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-09-07 11:03:00 +00:00
Simon McVittie
58d71b797d Merge branch 'glib-tests-on-freebsd' into 'master'
tests: On Unix, include <netinet/in.h> for IPPROTO_TCP

See merge request dbus/dbus!167
2020-08-19 14:28:04 +00:00
Simon McVittie
f0e526bca8 tests: On Unix, include <netinet/in.h> for IPPROTO_TCP
Otherwise, dbus doesn't compile on FreeBSD if the GLib-based tests
are enabled (which suggests that no FreeBSD user has run those tests
successfully).

We already include <netinet/in.h> in other places with no conditions
or checks other than "is Unix", so apparently it's portable enough that
specifically testing for its presence is not necessary. POSIX requires it
to exist.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-08-14 17:02:46 +01:00
Simon McVittie
c91ca6edad v1.13.18
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-07-02 11:09:48 +01:00
Simon McVittie
00e7beaac2 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-07-02 10:24:55 +01:00
Simon McVittie
e75c67a28f Merge branch 'issue305' into 'master'
userdb: Reference-count DBusUserInfo, DBusGroupInfo

Closes #305

See merge request dbus/dbus!166
2020-07-01 13:29:39 +00:00
Simon McVittie
2b7948ef90 userdb: Reference-count DBusUserInfo, DBusGroupInfo
Previously, the hash table indexed by uid (or gid) took ownership of the
single reference to the heap-allocated struct, and the hash table
indexed by username (or group name) had a borrowed pointer to the same
struct that exists in the other hash table.

However, this can break down if you have two or more distinct usernames
that share a numeric identifier. This is generally a bad idea, because
the user-space model in such situations does not match the kernel-space
reality, and in particular there is no effective kernel-level security
boundary between such users, but it is sometimes done anyway.

In this case, when the second username is looked up in the userdb, it
overwrites (replaces) the entry in the hash table that is indexed by
uid, freeing the DBusUserInfo. This results in both the key and the
value in the hash table that is indexed by username becoming dangling
pointers (use-after-free), leading to undefined behaviour, which is
certainly not what we want to see when doing access control.

An equivalent situation can occur with groups, in the rare case where
a numeric group ID has two names (although I have not heard of this
being done in practice).

Solve this by reference-counting the data structure. There are up to
three references in practice: one held temporarily while the lookup
function is populating and storing it, one held by the hash table that
is indexed by uid, and one held by the hash table that is indexed by
name.

Closes: dbus#305
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-07-01 13:21:23 +01:00
Simon McVittie
6ee66ff7bc userdb: Make lookups return a const pointer
This makes it more obvious that the returned pointer points to a
struct owned by the userdb, which must not be freed or have its
contents modified, and is only valid to dereference until the next
modification to the userdb's underlying hash tables (which in practice
means until the lock is released, because after that we have no
guarantees about what might be going on in another thread).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-30 19:13:17 +01:00
Simon McVittie
ce9682ecc3 Merge branch 'illumos_cmsg' into 'master'
Solaris and derivatives do not adjust cmsg_len on MSG_CTRUNC

Closes #304

See merge request dbus/dbus!165
2020-06-15 13:16:51 +00:00
Andy Fiddaman
b96ef23e40 Solaris and derivatives do not adjust cmsg_len on MSG_CTRUNC 2020-06-12 21:18:36 +00:00
Simon McVittie
18336ba46a Merge branch 'cmake-fix-install' into 'master'
cmake: Fix installed files

See merge request dbus/dbus!155
2020-06-10 18:22:48 +00:00
Ralf Habacker
927a5f4d75 cmake: add support for user session semantic on Linux operating systems
Systemd user support is controlled by the cmake variable ENABLE_USER_SESSION,
which and WITH_SYSTEMD_USERUNITDIR to specify a custom installation
location. If WITH_SYSTEMD_USERUNITDIR is not specified, the related install
path is determined from an installed systemd package, if present.

This was added to the Autotools build system as part of fd.o#61301,
but until now was not possible to enable when building with CMake.
2020-06-10 18:13:47 +00:00
Ralf Habacker
97bdefd4e2 cmake: Add support for systemd integration on Linux operating systems
Previously, only the Autotools build system could do this. This commit
includes most of the same features as in the Autotools build, although
not the user-session semantics, which will be added separately.

Systemd support is controlled by the cmake variable ENABLE_SYSTEMD, which can
have the values OFF, ON and AUTO, the latter enabling support by default if
the required libraries are available.

With WITH_SYSTEMD_SYSTEMUNITDIR a custom installation location can be specified.
If it is not specified, the related install path is determined from the installed
systemd package, if present.
2020-06-10 18:13:47 +00:00
Ralf Habacker
eb6d4a1439 cmake: Add macro check_auto_option() as an addition to add_auto_option()
check_auto_option() checks the values given to an auto-option and prints
a fatal error in case of invalid combinations.
2020-06-10 18:13:47 +00:00
Ralf Habacker
ab404c5ffb cmake: rename tristateoption() to add_auto_option() and make signature compatible to option() 2020-06-10 18:13:47 +00:00
Ralf Habacker
3f3368b490 cmake: Use CMAKE_INSTALL_FULL_<dir> for configuration and state
This means we apply GNUInstallDirs' various special cases when
the prefix is /, /usr or something starting with /opt; these are
not applied when installing to CMAKE_INSTALL_<dir>. See
https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html#special-cases
2020-06-10 18:13:47 +00:00
Ralf Habacker
d5fd3d76f7 cmake: fix installation of example files 2020-06-10 18:13:47 +00:00
Simon McVittie
f94696eb4f Merge branch 'normalize-trailing-newlines' into 'master'
Normalize C source files to end with exactly one newline

See merge request dbus/dbus!162
2020-06-10 10:56:26 +00:00
Simon McVittie
eeef787418 Normalize C source files to end with exactly one newline
Some editors automatically remove trailing blank lines, or
automatically add a trailing newline to avoid having a trailing
non-blank line that is not terminated by a newline. To avoid unrelated
whitespace changes when users of such editors contribute to dbus,
let's pre-emptively normalize all files.

Unlike more intrusive whitespace normalization like removing trailing
whitespace from each line, this seems unlikely to cause significant
issues with cherry-picking changes to stable branches.

Implemented by:

    find . -name '*.[ch]' -print0 | \
    xargs -0 perl -0777 -p -i -e 's/\n+\z//g; s/\z/\n/g'

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-10 10:47:31 +00:00
Simon McVittie
55911d3ca9 Merge branch 'misc-comment' into 'master'
dbus-protocol.h: fix DBUS_ERROR_SPAWN_NO_MEMORY comment

See merge request dbus/dbus!163
2020-06-10 10:46:42 +00:00
Marc-André Lureau
a6454e4291 dbus-protocol.h: fix DBUS_ERROR_SPAWN_NO_MEMORY comment
Although this error seems to be unused (DBUS_ERROR_NO_MEMORY is used
instead), let's correct the comment.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-06-10 14:26:03 +04:00
Simon McVittie
41dfee5c32 Start 1.13.18 development
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-02 21:07:31 +01:00
Simon McVittie
fc2ee9f73b Prepare 1.13.16
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-02 12:18:05 +01:00
Simon McVittie
fc0f296583 fdpass test: Assert that we don't leak file descriptors
Reproduces: dbus#294
Reproduces: CVE-2020-12049
Reproduces: GHSL-2020-057
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-02 10:42:54 +01:00
Simon McVittie
872b085f12 sysdeps-unix: On MSG_CTRUNC, close the fds we did receive
MSG_CTRUNC indicates that we have received fewer fds that we should
have done because the buffer was too small, but we were treating it
as though it indicated that we received *no* fds. If we received any,
we still have to make sure we close them, otherwise they will be leaked.

On the system bus, if an attacker can induce us to leak fds in this
way, that's a local denial of service via resource exhaustion.

Reported-by: Kevin Backhouse, GitHub Security Lab
Fixes: dbus#294
Fixes: CVE-2020-12049
Fixes: GHSL-2020-057
2020-06-02 10:42:07 +01:00
Simon McVittie
9a651fa7e6 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-01 10:46:27 +01:00
Simon McVittie
e61611c544 Merge branch 'ci-run-cross-compiled-tests' into 'master'
CI: run cross compiled tests

Closes #296

See merge request dbus/dbus!158
2020-05-29 14:56:15 +00:00
Ralf Habacker
fa763da827 CI: for cmake show the used command lines when compiling and linking
This helps to detect incorrect settings.
2020-05-29 16:43:52 +02:00
Ralf Habacker
d64316a676 CI: Add running test cases for cross builds
Before building a wine prefix is created and search pathes
for binaries are configured in the wine prefix.

This commit adds a new shell variable 'ci_runtime' for specifing
the type of compiler support library which defaults to static for now.
2020-05-29 16:43:45 +02:00
Simon McVittie
45e8c5f338 Merge branch 'wine-symbol-support' into 'master'
Let Wine display the correct file name and line numbers for backtraces

See merge request dbus/dbus!104
2020-05-28 19:08:29 +00:00
Ralf Habacker
9738a48a3f cmake: Let Wine display the correct file name and line numbers for backtraces
Wine currently only supports the symbol formats STABS and DWARF 2,
but not the other versions, with STABS providing the most information
and being the first choice.

Since we already use the cmake variable DBUS_USE_WINE for running tests
under Wine, we also use it to activate the special symbol format.

Closes dbus/dbus/#133
2020-05-16 15:25:01 +00:00
Ralf Habacker
74717a9c0c .gitlab-ci.yml: Use x86_64 build chain to cross build 64bit executables
This error was discovered when working with the merge request
dbus/dbus!158.
2020-05-16 17:18:05 +02:00
Ralf Habacker
e32e2c0eb5 cmake: Fix setting default value for DBUS_BUILD_TESTS too late
This prevented setting cross compile support required for !158.
2020-05-04 09:12:09 +02:00
Ralf Habacker
df7d444fdb Merge branch 'cmake-build-missing-tools' into 'master'
Build missing tools with cmake

See merge request dbus/dbus!154
2020-04-30 00:31:04 +00:00
Ralf Habacker
08eb885be6 cmake: build and install dbus-cleanup-sockets on non Windows platforms 2020-04-29 17:35:08 +00:00
Ralf Habacker
f88ca3b853 cmake: build and install dbus-uuidgen on non Windows platforms 2020-04-29 17:35:08 +00:00
Ralf Habacker
681efdde5d Merge branch 'qthelp-docs-support' into 'master'
Add support to generate the api documentation in Qt help format

See merge request dbus/dbus!150
2020-04-29 15:32:32 +00:00
Ralf Habacker
6e8d75834e Add support to generate the api documentation in Qt help format
Qt help files are used by Qt Creator and KDevelop, for example, to support
the development of Qt-based applications and libraries.

Generating api documentation in Qt help format is controlled by two
user specific options named --enable-qt-help and --with-qchdir (autotools)
and -DENABLE_QT_HELP and -DINSTALL_QCH_DIR (cmake).
2020-04-29 15:23:23 +00:00
Ralf Habacker
dc9a0af697 cmake: remove component 'dev' as we never used that consistently
Marking targets with a component would only be useful if we
marked every target with a component in a consistent way,
but because we don't do that, it's pointless to have it
in just a few places.
2020-04-29 15:23:23 +00:00
Simon McVittie
7cc3ba0e25 Merge branch 'fix-dbus_poll-buffer-overflow' into 'master'
_dbus_poll(): Prevent buffer overflow in Windows verbose logging

See merge request dbus/dbus!125
2020-04-29 10:59:08 +00:00
Ralf Habacker
2658b2571c Fix return type and usage of WSAWaitForMultipleEvents()
The former int type leads to warnings.
2020-04-29 10:52:23 +00:00
Ralf Habacker
b09ba846aa Add debug output functions for _dbus_poll_xx() functions 2020-04-29 10:52:22 +00:00
Ralf Habacker
96b8295831 Fix bug not detecting out of memory condition in _dbus_poll_events ()
For cleaning purpose the event list members are initialized with
WSA_INVALID_EVENT. The cleanup code detects and handles the
case that the event list has been created from calloc ().
2020-04-29 10:52:22 +00:00
Ralf Habacker
0d714aed9d Separate the event based implementation for _dbus_poll() from the fd based one
The function _dbus_poll() has been split into two functions,
_dbus_poll_events() and _dbus_poll_select(), each containing the
corresponding implementation.

_dbus_poll() now calls the corresponding function.
2020-04-29 10:52:22 +00:00
Ralf Habacker
becf2e3feb dbus_poll(): Remove debug output to make room for a better implementation 2020-04-29 10:52:22 +00:00
Simon McVittie
0e8017b85a Merge branch 'shell-test-tap' into 'master'
shell-test: Print diagnostics to stderr

See merge request dbus/dbus!157
2020-04-28 11:00:29 +00:00
Félix Piédallu
362b22605c shell-test: Print diagnostics to stderr
Some of the command-lines that we print as diagnostics contain newlines,
which will cause warnings or errors under a strict TAP parser (and one of
them wasn't correctly prefixed with '#' anyway). TAP parsers only parse
stdout, not stderr, so we can use stderr for these diagnostic messages.

[smcv: Expand commit message]

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-04-28 11:50:23 +01:00
Ralf Habacker
35974233e2 Merge branch 'coverity-354884' into 'master'
Free allocated buffer in test_content() to avoid a resource leak

See merge request dbus/dbus!146
2020-04-27 15:15:10 +00:00