Commit graph

6159 commits

Author SHA1 Message Date
Simon McVittie
7ee72a2795 spawn-unix: Don't log an error if unable to reset Linux OOM score
We cannot safely log between fork() and exec() because it isn't an
async-signal-safe operation (in particular it might allocate memory).

We also don't want to treat a failure here as a real problem, because
it might legitimately not work: in a system dbus-daemon that has dropped
privileges from root, the pseudo-file representing this process parameter
remains owned by root and cannot be altered by the unprivileged user.

For the main use-case for this operation, the system dbus-daemon, we
have another opportunity to do this in the dbus-daemon-launch-helper
(see the previous commit).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-22 19:30:30 +00:00
Simon McVittie
2efb462466 dbus-daemon-launch-helper: Reset Linux OOM score adjustment here
Previously, we were relying on the system bus being able to reset
its OOM score adjustment after it forks, but before it execs the
dbus-daemon-launch-helper. However, it can't actually do that (leading
to dbus#378), because the system bus typically starts as root, uses its
root privileges to adjust resource limits, and then drops privileges
to the `@DBUS_USER@`, typically `dbus` or `messagebus`. This leaves the
pseudo-files in /proc for its process parameters owned by root, and the
`@DBUS_USER@` is not allowed to open them for writing.

The dbus-daemon-launch-helper is setuid root, so it can certainly
alter its OOM score adjustment before exec'ing the actual activated
service. We need to do this before dropping privileges, because after
dropping privileges we would be unable to write to this process
parameter.

This is a non-async-signal-safe context, so we can safely log errors
here, unlike the fork-and-exec code paths.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/378
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-22 19:26:58 +00:00
Simon McVittie
c42bb64457 spawn-unix: On Linux, don't try to increase OOM-killer protection
The oom_score_adj parameter is a signed integer, with increasingly
positive values being more likely to be killed by the OOM-killer,
and increasingly negative values being less likely.

Previously, we assumed that oom_score_adj would be negative or zero,
and reset it to zero, which does not require privileges because it
meant we're voluntarily giving up our OOM-killer protection.
In particular, bus/dbus.service.in has OOMScoreAdjust=-900, which
we don't want system services to inherit.

However, systemd >= 250 has started putting a positive oom_score_adj
on user processes, to make it more likely that the OOM killer will kill
a user process rather than a system process. Changing from a positive
oom_score_adj to zero is increasing protection from the OOM-killer,
which only a privileged process is allowed to do, resulting in warnings
whenever we carry out traditional (non-systemd) service activation
on the session bus.

To avoid this, do the equivalent of:

    if (oom_score_adj < 0)
        oom_score_adj = 0;

which is always allowed.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/374
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-22 19:26:55 +00:00
Simon McVittie
f3ffe9a873 sysdeps-unix: Factor out _dbus_reset_oom_score_adj
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-22 19:21:14 +00:00
Simon McVittie
715a1a920d spawn-unix: Correct indentation
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-22 19:21:12 +00:00
Simon McVittie
9b7bea10c2 Merge branch 'integration-test' into 'master'
tests: Ensure session bus has started before integration test

See merge request dbus/dbus!256
2022-02-22 17:05:05 +00:00
Simon McVittie
47a4bdfaf8 tests: Ensure session bus has started before integration test
The session dbus-daemon won't necessarily be run immediately on login
if we are using systemd socket activation for it, and the transient
services directory $XDG_RUNTIME_DIR/dbus-1/services isn't created until
it's actually run. Ping the dbus-daemon to make sure it's available.

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug-Debian: https://bugs.debian.org/1005889
2022-02-21 18:09:22 +00:00
Ralf Habacker
d1ad22c93d Merge branch 'cmake-fixes' into 'master'
cmake: remove obsolete variable DBUS_SOURCE_DIR

See merge request dbus/dbus!254
2022-02-21 14:50:14 +00:00
Ralf Habacker
b6dd487d43 cmake: remove obsolete variable DBUS_SOURCE_DIR
This issue has been reported at #377

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-02-21 14:14:27 +00:00
Simon McVittie
25909d16c1 Merge branch 'xml-catalog' into 'master'
doc: Introduce XML catalog

See merge request dbus/dbus!202
2022-02-21 14:11:02 +00:00
Jan Tojnar
2ac9a348f0 doc: Introduce XML catalog
This adds a nice way of loading the DTD files based on the identifier
in the DOCTYPE declaration, no matter where the DTDs are installed.
See also ‘XML catalog’ Wikipedia entry and update-xmlcatalog(8).
2022-02-21 14:01:20 +00:00
Simon McVittie
7488756a0c Merge branch 'add-confidential-mr-doc' into 'master'
CONTRIBUTING.md: creation of "confidential" merge requests added

See merge request dbus/dbus!252
2022-02-21 13:55:18 +00:00
Ralf Habacker
55f79f882d CONTRIBUTING.md: creation of "confidential" merge requests added
See #368
2022-02-21 13:54:38 +00:00
Simon McVittie
817e1c6e5d Merge branch 'fix-issue-377' into 'master'
cmake: fix for ninja phony cycle related configuring errors

Closes #377

See merge request dbus/dbus!253
2022-02-17 14:57:23 +00:00
Ralf Habacker
673d48c7c9 cmake: fix for ninja phony cycle related configuring errors
A prefix has been added to the custom target names in docbook-related
macros to fix the reported error:

  ninja: error: build.ninja:xxx: multiple rules generate
  doc/dbus-xxx.1.html [-w dupbuild=err]

Fixes #377

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-02-17 14:12:09 +01:00
Ralf Habacker
a3937715ae cmake: drop obsolete dependencies for generated docbook source files
The docbook source files are already dependencies of the generated
docbook files.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-02-17 14:12:09 +01:00
Ralf Habacker
8d97452051 cmake: let macro docbook handle all requested formats in one call
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-02-17 14:12:09 +01:00
Ralf Habacker
4bb89044df cmake: in macro generate_docbook_file use easier to read parameter names
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-02-17 14:12:09 +01:00
Simon McVittie
4f62953a12 Merge branch 'dbus-server-signal-config-reloaded' into 'master'
dbus-daemon: Inform dbus clients about configuration changes

Closes #376

See merge request dbus/dbus!250
2022-02-16 14:08:48 +00:00
Ralf Habacker
564056e21e dbus-daemon: Implement signal 'ActivatableServicesChanged'
After any reload of the activatable service files the mentioned signal is
emitted to the current bus to inform clients.

The calls to signal emmission have not been implemented in the platform
specific functions _dbus_daemon_report_reloaded() to avoid duplicate
implementations.

Fixes #376
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-02-16 14:00:13 +01:00
Ralf Habacker
5efc97f03c dbus-specification: Add signal 'ActivatableServicesChanged' and related bus feature
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-02-16 14:00:13 +01:00
Simon McVittie
758d37b1f8 Merge branch 'address-escape-doc' into 'master'
spec: add * to optionally-escaped bytes set

See merge request dbus/dbus!248
2022-02-16 12:22:21 +00:00
Kir Kolyshkin
87070a615a spec: add * to optionally-escaped bytes set
Commit ee71e1ff60 added * to the list of optionally escaped bytes
set, but did not update the documentation. I guess this happened because
the change is not backward compatible.

It seems that the period of 14+ years should be enough to not cause any
backward compatibility issues, so let's document this.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-01-31 20:34:00 -08:00
Simon McVittie
37b76d1373 Merge branch 'ci-fix' into 'master'
docker/windows: fix bad path from MR !218

See merge request dbus/dbus!247
2022-01-27 19:57:34 +00:00
Marc-André Lureau
94f8689417 docker/windows: fix bad path from MR !218
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-27 23:07:18 +04:00
Ralf Habacker
7f5469d7dc Merge branch 'win-ci' into 'master'
CI: add Windows native builds

See merge request dbus/dbus!218
2022-01-27 16:10:34 +00:00
Marc-André Lureau
84e60c55e4 gitlab-ci: add cmake Windows builds with VS and mingw-ucrt
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-21 21:16:45 +04:00
Marc-André Lureau
98c903656d gitlab-ci: build a Windows docker image, with VS15 & msys
Based on GStreamer & Mesa freedesktop gitlab CI, use the Windows 1809
runner provided by the GStreamer Foundation.

https://www.freedesktop.org/wiki/Infrastructure/

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-21 21:16:45 +04:00
Marc-André Lureau
f8067a07c3 gitlab-ci: move "before_script" and "cache" to .debian-build
As we are introducing Windows builds next, move out Unix-specific
job definitions to the base job.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-21 21:16:45 +04:00
Marc-André Lureau
e0deb95b31 gitlab-ci: factorize build jobs with "extends"
It is easier to read and modify than anchors. And we are going to move
more Debian-specific to the base ".debian-build" next.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-21 21:16:45 +04:00
Marc-André Lureau
a58d46b789 bus/signal: fix compilation when only -Dembedded-tests
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-21 21:16:45 +04:00
Marc-André Lureau
2a5f1cfda7 cmake: add -fno-common when !MSVC
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-21 21:16:45 +04:00
Marc-André Lureau
b0d418a51b cmake: fix warnings variables
Do not use strings for compiler flags.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-21 21:16:45 +04:00
Simon McVittie
d90ad99648 Merge branch 'badoom' into 'master'
auth: fix a no-memory case

See merge request dbus/dbus!246
2022-01-21 15:53:58 +00:00
Marc-André Lureau
cfdfac9169 auth: fix a no-memory case
Jumping to "out" will call _dbus_string_zero() unconditionally on tmp
string variables. Do not attempt to zero what wasn't even initialized.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-01-21 16:05:09 +04:00
Ralf Habacker
eef6e75978 Merge branch 'cmake-msvc-fixes' into 'master'
cmake: do not use gcc specific warning when building with msvc

See merge request dbus/dbus!245
2022-01-03 10:17:17 +00:00
Ralf Habacker
98ef5e22f7 cmake: do not use gcc specific warning when building with msvc 2022-01-03 10:31:24 +01:00
Simon McVittie
3de360aa4b NEWS: Mention CMake 3.4 dependency
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-12-17 15:54:08 +00:00
Simon McVittie
31b5e0ff8b Bump version number for continued development
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-12-17 15:50:15 +00:00
Simon McVittie
8afc535770 doc: Uninstall *.svg generated by Doxygen
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-12-17 13:08:08 +00:00
Simon McVittie
f013f991fa Prepare v1.13.20
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-12-17 13:07:48 +00:00
Simon McVittie
7e155b8531 Update AUTHORS from git log
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-12-17 12:49:09 +00:00
Simon McVittie
308a1aa48c Merge branch 'fix-issue-365' into 'master'
Fix memory leaks in _dbus_get_install_root_as_hash in case of OOM condition

Closes #365

See merge request dbus/dbus!239
2021-12-16 11:28:02 +00:00
Ralf Habacker
8a6a8a794f In _dbus_get_autolaunch_address() avoid uninitialized mutex
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2021-12-16 10:05:50 +01:00
Ralf Habacker
9e35022436 Cleanup zero string length case condition in Windows helper functions
This cleanup has been processed in _dbus_daemon_publish_session_bus_address()
_dbus_get_install_root_as_hash() and _dbus_get_address_string().

The zero length condition has been catched in each function calling
the mentioned functions.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2021-12-16 10:04:47 +01:00
Ralf Habacker
1bbc135234 Fix "out of memory" handling in _dbus_get_install_root_as_hash()
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2021-12-16 09:46:46 +01:00
Ralf Habacker
d9e404c03a Fix "out of memory" handling in _dbus_get_address_string()
To avoid partial strings, appending to the returned string
is only done if fully successful.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2021-12-16 09:46:46 +01:00
Ralf Habacker
dbc8f2a818 _dbus_get_install_root_as_hash() now expects an initialized DBusString instance as a parameter
Since the _dbus_get_address_string() function is affected by the change,
the code calling the mentioned function been adapted.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2021-12-16 09:46:46 +01:00
Ralf Habacker
1f0331be72 _dbus_get_address_string() now expects an initialized DBusString instance as a parameter
The mentioned function now expects an initialized DBusString instance as
parameter for the return of a string to have a clear responsibility
regarding initialization and usage and thus simplify the "out of memory"
management.

Since the _dbus_get_shm_name() and _dbus_get_mutex_name() functions are
affected by the change, the related documentation has been adapted.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2021-12-16 09:46:36 +01:00
Ralf Habacker
58b9dcd6ee Indentation correction of Windows specific utility functions
The corrections refer to the following commits, so that they are not mixed
up with blank changes.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2021-12-16 08:13:39 +00:00