systemd/.git
12 months agouserbdctl: show 'mapped' user range only inside of userns
Lennart Poettering [Fri, 22 Nov 2024 08:34:56 +0000 (09:34 +0100)]
userbdctl: show 'mapped' user range only inside of userns

Outside of userns the concept makes no sense, there cannot be users
mapped from further outside.

(cherry picked from commit e412fc5e042b8f642bcba42f5c175124583e05ae)

12 months agocryptenroll: it's called PKCS#11, not PKCS11
Lennart Poettering [Fri, 22 Nov 2024 09:11:04 +0000 (10:11 +0100)]
cryptenroll: it's called PKCS#11, not PKCS11

In the --help text we really should use the official spelling, just like
in the man page.

(cherry picked from commit cc6baba7200bd8171b6beff446b4009dad5c4230)

12 months agocore/service: service_add_fd_store() consumes passed fd
Yu Watanabe [Thu, 21 Nov 2024 20:15:49 +0000 (05:15 +0900)]
core/service: service_add_fd_store() consumes passed fd

Without this change, the fd is closed twice on failure.

Fixes a bug introduced by dff9808a628c31b7ecb1f1aba8fdc3be06ce8372.

Fixes #35288.

(cherry picked from commit d99198819caeff6f40a0a520364e59b8a0cbaa4f)

12 months agokillall: gracefully handle processes inserted into containers via nsenter -a
Lennart Poettering [Wed, 20 Nov 2024 11:02:46 +0000 (12:02 +0100)]
killall: gracefully handle processes inserted into containers via nsenter -a

"nsenter -a" doesn't migrate the specified process into the target
cgroup (it really should). Thus the cgroup will remain in a cgroup
that is (due to cgroup ns) outside our visibility. The kernel will
report the cgroup path of such cgroups as starting with "/../". Detect
that and print a reasonably error message instead of trying to resolve
that.

(cherry picked from commit f6793bbcf0e3f0a6daa77add96183b88d5ec2117)

12 months agocore/exec-invoke: suppress placeholder home only in build_environment()
Mike Yuan [Mon, 18 Nov 2024 18:41:07 +0000 (19:41 +0100)]
core/exec-invoke: suppress placeholder home only in build_environment()

Currently, get_fixed_user() employs USER_CREDS_SUPPRESS_PLACEHOLDER,
meaning home path is set to NULL if it's empty or root. However,
the path is also used for applying WorkingDirectory=~, and we'd
spuriously use the invoking user's home as fallback even if
User= is changed in that case.

Let's instead delegate such suppression to build_environment(),
so that home is proper initialized for usage at other steps.
shell doesn't actually suffer from such problem, but it's changed
too for consistency.

Alternative to #34789

(cherry picked from commit b718b86e1b8477f58461f3c456c944abb1428c0f)

12 months agocore/exec-invoke: minor cleanup for apply_working_directory() error handling
Mike Yuan [Mon, 18 Nov 2024 23:22:59 +0000 (00:22 +0100)]
core/exec-invoke: minor cleanup for apply_working_directory() error handling

Assign exit_status at the same site where error log is emitted,
for readability.

(cherry picked from commit d911778877c18827c64e21cc98e86c31dff9a627)

12 months agobasic/user-util: split out placeholder suppression from USER_CREDS_CLEAN into its...
Mike Yuan [Mon, 18 Nov 2024 18:30:02 +0000 (19:30 +0100)]
basic/user-util: split out placeholder suppression from USER_CREDS_CLEAN into its own flag

No functional change, preparation for later commits.

(cherry picked from commit eea9d3eb106a91d4479d859603463bdfe3d262eb)

12 months agobasic/user-util: introduce shell_is_placeholder() helper
Mike Yuan [Mon, 18 Nov 2024 18:24:57 +0000 (19:24 +0100)]
basic/user-util: introduce shell_is_placeholder() helper

(cherry picked from commit 579ce77ead476e3d5b9a774ab00ec3ec53933ab2)

12 months agounits: add initrd directory to list of conditions for systemd-confext
Luca Boccassi [Tue, 19 Nov 2024 23:34:00 +0000 (23:34 +0000)]
units: add initrd directory to list of conditions for systemd-confext

systemd-sysext has the same check, but it was forgotten for confexts.
Needed to activate confexts from the ESP in the initrd.

(cherry picked from commit fe077a1a582a43a6378ff29452a373cc7d393764)

12 months agoman/kernel-command-line: fix typo
Antonio Alvarez Feijoo [Tue, 19 Nov 2024 12:36:38 +0000 (13:36 +0100)]
man/kernel-command-line: fix typo

(cherry picked from commit a04d42821bb5350b0ffa82834e50e9b679279854)

12 months agondisc-option: use memcpy_safe() at one more place
Yu Watanabe [Mon, 18 Nov 2024 04:28:27 +0000 (13:28 +0900)]
ndisc-option: use memcpy_safe() at one more place

As 'len' may be 8.

Follow-up for a163404cc88914142ef8bbfaab0eb39d1a990c02.

(cherry picked from commit c8ddd5ff72453876b360e7580cc386945b79f5e9)

12 months agocryptenroll: show better log message if slot to wipe does not exist
Antonio Alvarez Feijoo [Tue, 19 Nov 2024 10:26:49 +0000 (11:26 +0100)]
cryptenroll: show better log message if slot to wipe does not exist

```
$ systemd-cryptenroll /dev/vda3
SLOT TYPE
   0 password
$ systemd-cryptenroll --wipe-slot 1 /dev/vda3
Failed to wipe slot 1, continuing: No such file or directory
```

(cherry picked from commit 2b251491debf9cab695f5f34da9908ca46f085fe)

12 months agossh-generator: silence "Binding to socket" messages
Mantas Mikulėnas [Tue, 12 Nov 2024 08:30:09 +0000 (10:30 +0200)]
ssh-generator: silence "Binding to socket" messages

(cherry picked from commit 2424a67c02913eac30b5d59f1e5ee39a846ca54b)

12 months agosystemctl: grey out tasks limit the same way we grey out the fd store limit in the...
Lennart Poettering [Mon, 18 Nov 2024 22:26:58 +0000 (23:26 +0100)]
systemctl: grey out tasks limit the same way we grey out the fd store limit in the output

"systemctl status systemd-logind" otherwise looks a bit weird, since the
tasks and the fdstore lines are so close to each other but formatted
quite differently when it comes to coloring.

(cherry picked from commit 54646b1ca95373dfa3ebe5d6e7e27deeed9e77b0)

12 months agonspawn: --private-users-ownership= value is called 'chown', not 'own'
Lennart Poettering [Wed, 13 Nov 2024 11:14:53 +0000 (12:14 +0100)]
nspawn: --private-users-ownership= value is called 'chown', not 'own'

(cherry picked from commit bae936b418e08063b68c95f4df53c3cd4f70e881)

12 months agopid1: make clear that $WATCHDOG_USEC is set for the shutdown binary, noone else
Lennart Poettering [Thu, 14 Nov 2024 22:16:19 +0000 (23:16 +0100)]
pid1: make clear that $WATCHDOG_USEC is set for the shutdown binary, noone else

We use the $WATCHDOG_USEC variable for two very closely uses: as part of
the sd_watchdog_enabled() protocol for implementing service watchdogs.
And as part of the protocol between the service manager and
systemd-shutdown across the PID 1 execve() transition during shutdown.

Apparently some exitrds tools got confused by the latter use. Let's
address that by setting $WATCHDOG_PID to 1, in accordance to the
sd_watchdog_enabled() protocol to make clear this is only intended for
PID 1 and nothing else.

Replaces: #35135
(cherry picked from commit 4b20ae9a0e914e61d6bac095e5fc9664510ac03e)

12 months agoAdd proper dependencies to ukify target
Daan De Meyer [Fri, 15 Nov 2024 09:34:27 +0000 (10:34 +0100)]
Add proper dependencies to ukify target

Also remove the systemd-measure dependency from the mkosi target as
mkosi doesn't invoke systemd-measure itself.

(cherry picked from commit 1a077e05fbcbfffe548ef39f45e4f2ca1399715d)

12 months agomeson: bump version to 256.8 v256.8
Luca Boccassi [Thu, 14 Nov 2024 18:11:30 +0000 (18:11 +0000)]
meson: bump version to 256.8

12 months agotest: skip TEST-84-STORAGETM if running with bugged libnvme
Luca Boccassi [Thu, 14 Nov 2024 16:19:25 +0000 (16:19 +0000)]
test: skip TEST-84-STORAGETM if running with bugged libnvme

libnvme 1.11 appears to require a kernel built with NVME TLS
kconfigs, and fails hard if it is not, as the expected
privileged keyring '.nvme' is not present. We cannot just
create it from userspace, as privileged keyrings can only
be created by the kernel itself (those starting with '.').

Skip the test if the library exactly matches this version.

https://github.com/linux-nvme/nvme-cli/issues/2573

Fixes https://github.com/systemd/systemd/issues/35130

(cherry picked from commit 893aa45886ef84b1827445dc438e410ad89fbbbf)

12 months agonspawn: ignore failure in creating /dev/net/tun when --private-network is unspecified
Yu Watanabe [Wed, 13 Nov 2024 04:36:11 +0000 (13:36 +0900)]
nspawn: ignore failure in creating /dev/net/tun when --private-network is unspecified

Follow-up for efedb6b0f3cff37950112fd37cb750c16d599bc7.
Closes #35116.

(cherry picked from commit 985ea98e7f90c92fcc0b8441fafb190353d2feb8)
Really rewritten from scratch.

12 months agonetwork-generator: drop wrong warning for rd.peerdns without value
Yu Watanabe [Wed, 14 Aug 2024 06:39:12 +0000 (15:39 +0900)]
network-generator: drop wrong warning for rd.peerdns without value

(cherry picked from commit 2a774f064815573efc33d43dfe3548590e42e9c2)

12 months agonetwork-generator: ignore kernel command line without value
Yu Watanabe [Wed, 14 Aug 2024 06:36:22 +0000 (15:36 +0900)]
network-generator: ignore kernel command line without value

And drop duplicated log messages.

(cherry picked from commit 551b21eb0a5ea691d7bce0aff6b1281dd1f98819)

12 months agonetwork-generator: parse vlan ID from vlan interface name
Yu Watanabe [Wed, 7 Aug 2024 06:04:46 +0000 (15:04 +0900)]
network-generator: parse vlan ID from vlan interface name

Fixes #33954.

(cherry picked from commit e31a55edf136e777aabdf19894ee886eac47c20e)

12 months agonetwork-generator: allow to create bridge or friends without slave interfaces
Yu Watanabe [Fri, 9 Aug 2024 10:01:40 +0000 (19:01 +0900)]
network-generator: allow to create bridge or friends without slave interfaces

(cherry picked from commit c40ef3f8ff3fd212b88aa84b9e17d1d49aca4ddb)

12 months agonetwork-generator: vlan= can be specified multiple times
Yu Watanabe [Wed, 7 Aug 2024 06:03:59 +0000 (15:03 +0900)]
network-generator: vlan= can be specified multiple times

(cherry picked from commit 9eee6b1b3f00d46459eebefb70be50ea6af30ddb)

12 months agoshutdown: replace unbounded fsync() with bounded sync_with_progress()
Lennart Poettering [Mon, 9 Sep 2024 15:53:03 +0000 (17:53 +0200)]
shutdown: replace unbounded fsync() with bounded sync_with_progress()

Let's put a time-out on this syncing.

Inspired-by: #34289 #34283
(cherry picked from commit b4b66b26620bfaf5818c95d5cffafd85207694e7)

12 months agoshutdown: teach sync_with_progress() to optionally sync a specific fd only
Lennart Poettering [Mon, 9 Sep 2024 15:49:33 +0000 (17:49 +0200)]
shutdown: teach sync_with_progress() to optionally sync a specific fd only

This is preparation for reusing the logic for syncing DM and other
devices with a timeout applied.

(cherry picked from commit 13b5225d6278af15e84ebd1889f04cfe81b47787)

12 months agoshutdown: clean up sync_with_progress a bit
Mike Yuan [Wed, 5 Jun 2024 15:53:27 +0000 (17:53 +0200)]
shutdown: clean up sync_with_progress a bit

Also, ignore the error on caller's side.

(cherry picked from commit 758760a3610e3c6674de8a1d51b12b991eafef7c)

12 months agoboot: allocate cleanup pages below 4GiB only on x86
andre4ik3 [Wed, 13 Nov 2024 14:53:25 +0000 (18:53 +0400)]
boot: allocate cleanup pages below 4GiB only on x86

Outside of x86, some machines (e.g. Apple silicon, AMD Opteron A1100) have
physical memory mapped above 4GiB, meaning this allocation will fail, causing
the entire boot process to fail on these machines.

This commit makes it so that the below-4GB address space allocation requirement
is only set on x86 platforms, and not on other platforms (that don't have the
specific Linux x86 boot protocol), thereby fixing boot on those that have no
memory mapped below 4GiB in their address space.

Tested on an Apple silicon M1 laptop and an AMD x86_64 desktop tower.

Fixes: #35026

Manual backport of 6e207b370e91e681efb08c497a6c8ad78e3c8d83.

12 months agoportable: do not use SYNTHETIC_ERRNO for sd_bus_error_set_errno()
Mike Yuan [Wed, 13 Nov 2024 16:45:53 +0000 (17:45 +0100)]
portable: do not use SYNTHETIC_ERRNO for sd_bus_error_set_errno()

The concept of synthetic errnos is about logging, which
is irrelevant irt bus error and we don't do any special
treatment in sd-bus for them, meaning the value propagated
would be spurious.

(cherry picked from commit 2f2058da0b88535cb3a95fc98e7b2f1ae4d35601)

12 months agohwdb: update to main@{2024-11-12}
Luca Boccassi [Tue, 12 Nov 2024 23:35:54 +0000 (23:35 +0000)]
hwdb: update to main@{2024-11-12}

git restore -s origin/main hwdb.d/ test/hwdb.d

12 months agomkosi: update opensuse commit reference
Luca Boccassi [Mon, 21 Oct 2024 13:26:05 +0000 (14:26 +0100)]
mkosi: update opensuse commit reference

It was force-pushed again

(cherry picked from commit 3034dc001394bba6d94d16a2a9c7a8cefd53035e)

12 months agomkosi: update opensuse commit reference and switch branch
Luca Boccassi [Fri, 18 Oct 2024 10:35:56 +0000 (11:35 +0100)]
mkosi: update opensuse commit reference and switch branch

'factory' was reset to 8 years ago

(cherry picked from commit 77579c66ef4b8aec1e723f9ed6c63efd10fb2688)

12 months agoTEST-17-UDEV: check if udev database file is removed on remove event
Yu Watanabe [Sun, 13 Oct 2024 16:28:23 +0000 (01:28 +0900)]
TEST-17-UDEV: check if udev database file is removed on remove event

(cherry picked from commit 49c46fbaf15b95a8264d01213539914e15fdc6fe)

12 months agoudev: do not re-create database on remove event
Yu Watanabe [Sun, 13 Oct 2024 15:55:43 +0000 (00:55 +0900)]
udev: do not re-create database on remove event

Fixes a bug introduced by f6bda694f908cc227b002570b893029aa4c9e173 (v256).

With the offending commit, on remove event, database file for a device is once
removed in event_execute_rules_on_remove(), but later re-created here.
This fixes the issue, and makes the database file not re-created on remove event.

(cherry picked from commit 5b2dce150d5eadcd33d620e095c9c1e2de51dd24)

12 months agocore/namespace: honor MountEntry.read_only, .options, and so on in static entries
Yu Watanabe [Sat, 19 Oct 2024 05:38:08 +0000 (14:38 +0900)]
core/namespace: honor MountEntry.read_only, .options, and so on in static entries

Otherwise, ProtectHome=tmpfs makes /home/ and friends not read-only.
Also, mount options for /run/ specified in MountAPIVFS=yes are not
applied.

The function append_static_mounts() was introduced in
5327c910d2fc1ae91bd0b891be92b30379c7467b, but at that time, there were
neither .read_only nor .options in the struct. But, when later the
struct is extended, the function was not updated and they were not
copied from the static table.
The fields has been used in static tables since
e4da7d8c796a1fd11ecfa80fb8a48eac9e823f06, and also in
94293d65cd4125347e21b3e423d0e245226b1be2.

Fixes #34825.

(cherry picked from commit 0cc496b2d21f73d0a03414ce40eceb9e3af76e22)

12 months agonetwork/tunnel: allow Local=/Remote=any for all tunnel types
Yu Watanabe [Tue, 29 Oct 2024 17:51:18 +0000 (02:51 +0900)]
network/tunnel: allow Local=/Remote=any for all tunnel types

It seems there is no restriction for local and remote addresses.

Fixes #34930.

(cherry picked from commit 5e48fd0506ed6212c9db2276d5845ab77aa9bce4)

12 months agoman/systemd.special: fix a typo
Štěpán Němec [Mon, 11 Nov 2024 19:31:43 +0000 (20:31 +0100)]
man/systemd.special: fix a typo

(cherry picked from commit 62ec4798f28ccf02926c2ae53d2a772b088383ee)

12 months agoman: fix incorrect volume numbers in internal man page references
Štěpán Němec [Mon, 11 Nov 2024 19:10:00 +0000 (20:10 +0100)]
man: fix incorrect volume numbers in internal man page references

Some ambiguity (e.g., same-named man pages in multiple volumes)
makes it impossible to fully automate this, but the following
Python snippet (run inside the man/ directory of the systemd repo)
helped to generate the sed command lines (which were subsequently
manually reviewed, run and the false positives reverted):

from pathlib import Path

import lxml
from lxml import etree as ET

man2vol: dict[str, str] = {}
man2citerefs: dict[str, list] = {}

for file in Path(".").glob("*.xml"):
    tree = ET.parse(file, lxml.etree.XMLParser(recover=True))
    meta = tree.find("refmeta")
    if meta is not None:
        title = meta.findtext("refentrytitle")
        if title is not None:
            vol = meta.findtext("manvolnum")
            if vol is not None:
                man2vol[title] = vol
            citerefs = list(tree.iter("citerefentry"))
            if citerefs:
                man2citerefs[title] = citerefs

for man, refs in man2citerefs.items():
    for ref in refs:
        title = ref.findtext("refentrytitle")
        if title is not None:
            has = ref.findtext("manvolnum")
            try:
                should_have = man2vol[title]
            except KeyError:  # Non-systemd man page reference?  Ignore.
                continue
            if has != should_have:
                print(
                    f"sed -i '\\|<citerefentry><refentrytitle>{title}"
                    f"</refentrytitle><manvolnum>{has}</manvolnum>"
                    f"</citerefentry>|s|<manvolnum>{has}</manvolnum>|"
                    f"<manvolnum>{should_have}</manvolnum>|' {man}.xml"
                )

(cherry picked from commit 597c6cc1195a986e8f89921aa89505b0eacf8181)

12 months agologin: fix session_kill(..., KILL_LEADER,...) (#35105)
12paper [Sun, 10 Nov 2024 02:13:39 +0000 (03:13 +0100)]
login: fix session_kill(..., KILL_LEADER,...) (#35105)

`loginctl kill-session --kill-whom=leader <N>` (or the D-Bus equivalent)
doesn't work because logind ends up calling `KillUnit(..., "main", ...)`
on a scope unit and these don't have a `MainPID` property. Here, I just
make it send a signal to the `Leader` directly.

(cherry picked from commit 8254755091847105c33e473c62cdc7621ed275bc)

12 months agoudev: skipping empty udev rules file while collecting the stats
Lidong Zhong [Thu, 7 Nov 2024 06:41:11 +0000 (14:41 +0800)]
udev: skipping empty udev rules file while collecting the stats

To keep align with the logic used in udev_rules_parse_file(), we also
should skip the empty udev rules file while collecting the stats during
manager reload. Otherwise all udev rules files will be parsed again whenever
reloading udev manager with an empty udev rules file. It's time consuming
and the following uevents will fail with timeout.

(cherry picked from commit 2ae79a31b7c7947e2c16e18eb85ac5607ebc40b6)

12 months agoman: drop whitespace from final <programlisting> lines
Zbigniew Jędrzejewski-Szmek [Thu, 7 Nov 2024 15:47:48 +0000 (16:47 +0100)]
man: drop whitespace from final <programlisting> lines

In the troff output, this doesn't seem to make any difference. But in the
html output, the whitespace is sometimes preserved, creating an additional
gap before the following content. Drop it everywhere to avoid this.

(cherry picked from commit fe45f8dc9bf1e9be8de4e14838bc2d7befcf946b)

12 months agodocs: add reminder to run update-man-rules before tagging a release
Luca Boccassi [Wed, 6 Nov 2024 19:21:14 +0000 (19:21 +0000)]
docs: add reminder to run update-man-rules before tagging a release

(cherry picked from commit 088793239ebc9c3a26c562be82dd5f4467162b26)

12 months agodocs: remove 'v' prefix from meson.version
Luca Boccassi [Wed, 6 Nov 2024 19:20:00 +0000 (19:20 +0000)]
docs: remove 'v' prefix from meson.version

It is actually v-less

(cherry picked from commit 94a46c20dacd8859a6fa3f807b0d134f800a1e90)

12 months agopid1: stop refusing to boot with cgroup v1
Zbigniew Jędrzejewski-Szmek [Sat, 2 Nov 2024 16:07:22 +0000 (17:07 +0100)]
pid1: stop refusing to boot with cgroup v1

Since v256 we completely fail to boot if v1 is configured. Fedora 41 was just
released with v256.7 and this is probably the first major exposure of users to
this code. It turns out not work very well. Fedora switched to v2 as default in
F31 (2019) and at that time some people added configuration to use v1 either
because of Docker or for other reasons. But it's been long enough ago that
people don't remember this and are now very unhappy when the system refuses to
boot after an upgrade.

Refusing to boot is also unnecessarilly punishing to users. For machines that
are used remotely, this could mean somebody needs to physically access the
machine. For other users, the machine might be the only way to access the net
and help, and people might not know how to set kernel parameters without some
docs. And because this is in systemd, after an upgrade all boot choices are
affected, and it's not possible to e.g. select an older kernel for boot. And
crashing the machine doesn't really serve our goal either: we were giving a
hint how to continue using v1 and nothing else.

If the new override is configured, warn and immediately boot to v1.
If v1 is configured w/o the override, warn and wait 30 s and boot to v2.
Also give a hint how to switch to v2.

https://bugzilla.redhat.com/show_bug.cgi?id=2323323
https://bugzilla.redhat.com/show_bug.cgi?id=2323345
https://bugzilla.redhat.com/show_bug.cgi?id=2322467
https://www.reddit.com/r/Fedora/comments/1gfcyw9/refusing_to_run_under_cgroup_01_sy_specified_on/

The advice is to set systemd.unified_cgroup_hierarchy=1 (instead of removing
systemd.unified_cgroup_hierarchy=0). I think this is easier to convey. Users
who are understand what is going on can just remove the option instead.

The caching is dropped in cg_is_legacy_wanted(). It turns out that the
order in which those functions are called during early setup is very fragile.
If cg_is_legacy_wanted() is called before we have set up the v2 hierarchy,
we incorrectly cache a true answer. The function is called just a handful
of times at most, so we don't really need to cache the response.

(cherry picked from commit d0ab0e5fa5434cac67e51dbeb1d873c6ac6f20cd)

12 months agoman/udev: fix typo
Yu Watanabe [Wed, 6 Nov 2024 10:05:12 +0000 (19:05 +0900)]
man/udev: fix typo

Follow-up for df8f9b88bd41320653fe1c51ea515a2d03a349df.

(cherry picked from commit 9dcf5c226e582cb664b6f14d5efbeed2350ba3bc)

12 months agoman: convert multiple left-over "See Also" sections to <simplelist>
Lennart Poettering [Tue, 5 Nov 2024 13:47:32 +0000 (14:47 +0100)]
man: convert multiple left-over "See Also" sections to <simplelist>

These were forgotten during the initial conversion, probably because
most of them consisted only of a single entry.

Fix that.

(cherry picked from commit df8f9b88bd41320653fe1c51ea515a2d03a349df)

12 months agoman: link up D-Bus API docs from daemon man pages
Lennart Poettering [Tue, 5 Nov 2024 13:20:01 +0000 (14:20 +0100)]
man: link up D-Bus API docs from daemon man pages

Let's systematically make sure that we link up the D-Bus interfaces from
the daemon man pages once in prose and once in short form at the bottom
("See Also"), for all daemons.

Also, add reverse links at the bottom of the D-Bus API docs.

Fixes: #34996
(cherry picked from commit 607d2974870e9769f44ee179dcaf26cbec64cb20)

12 months agoman: point people from sd-bus man page to busctl
Lennart Poettering [Tue, 5 Nov 2024 13:08:16 +0000 (14:08 +0100)]
man: point people from sd-bus man page to busctl

(cherry picked from commit 2f69ad26ca21d4da7f875bdea77594a115e2deee)

12 months agoman: tone down claims on processes having exited already in ExecStop=
Lennart Poettering [Tue, 5 Nov 2024 12:51:00 +0000 (13:51 +0100)]
man: tone down claims on processes having exited already in ExecStop=

Processes can easily survive the first kill operation we execute, hence
we shouldn't make strong claims about them having exited already. Let's
just say "likely" hence.

Fixes: #15032
(cherry picked from commit ac804bc2f8d814d2afcdccd88f7469ac320da1c8)

12 months agoman: document that .path units don't care for hidden files
Lennart Poettering [Tue, 5 Nov 2024 12:36:19 +0000 (13:36 +0100)]
man: document that .path units don't care for hidden files

Fixes: #32751
(cherry picked from commit 5adc4337996f561df43c617e37ef4b157073b2e6)

12 months agoman: document that PrivateTmp= is unaffected by ProtectSystem=strict
Lennart Poettering [Tue, 5 Nov 2024 12:33:53 +0000 (13:33 +0100)]
man: document that PrivateTmp= is unaffected by ProtectSystem=strict

Fixes: #33130
(cherry picked from commit b71173709651102081c9d8c6d6e3d2a6ef5cf17e)

12 months agoman: don't claim SELinuxContext= only worked in the system service manager
Lennart Poettering [Tue, 5 Nov 2024 12:15:36 +0000 (13:15 +0100)]
man: don't claim SELinuxContext= only worked in the system service manager

Fixes: #34840
(cherry picked from commit ecbe9ae5a0952d968c57e59dda4a42b72e5b5e6d)

12 months agoman: document the timeout applied to /usr/lib/systemd/system-shutdown/ drop-in binaries
Lennart Poettering [Tue, 5 Nov 2024 12:12:20 +0000 (13:12 +0100)]
man: document the timeout applied to /usr/lib/systemd/system-shutdown/ drop-in binaries

Fixes: #34949
(cherry picked from commit af080967bad2524d2fa2fef6ba5e9fcf18d3017e)

12 months agotest: delete /swapfile after swapoff
Luca Boccassi [Tue, 5 Nov 2024 18:15:36 +0000 (18:15 +0000)]
test: delete /swapfile after swapoff

[   23.608342] TEST-55-OOMD.sh[689]: + btrfs filesystem mkswapfile -s 64M /swapfile
[   23.651930] TEST-55-OOMD.sh[704]: ERROR: cannot create new swapfile: File exists

(cherry picked from commit 78b032d727e8f9e925c10c6617a1e409307ffc24)

12 months agorun: handle gracefully if we can't find binary client-side due to perms
Lennart Poettering [Tue, 5 Nov 2024 10:54:14 +0000 (11:54 +0100)]
run: handle gracefully if we can't find binary client-side due to perms

Fixes: #35022
(cherry picked from commit 9810899ef2f28fbb42cf659e6892b1a5074cfc83)

12 months agoresolved: log error messages for openssl/gnutls context creation
Zbigniew Jędrzejewski-Szmek [Sun, 3 Nov 2024 11:58:12 +0000 (12:58 +0100)]
resolved: log error messages for openssl/gnutls context creation

In https://bugzilla.redhat.com/show_bug.cgi?id=2322937 we're getting
an error message:
Okt 29 22:21:03 fedora systemd-resolved[29311]: Could not create manager: Cannot allocate memory
I expect that this actually comes from dnstls_manager_init(), the
openssl version. But without real logs it's hard to know for sure.

Use EIO instead of ENOMEM, because the problem is unlikely to be actually
related to memory.

(cherry picked from commit ee95e86ae163e436384f1b782a77a7e18deba890)

12 months agoci: add coverage for builds without sd-boot
Luca Boccassi [Mon, 4 Nov 2024 19:43:02 +0000 (19:43 +0000)]
ci: add coverage for builds without sd-boot

This should catch compilation issues such as:
https://github.com/systemd/systemd/pull/35014

(cherry picked from commit 8a3ac7afa6be8447061dc6cbd98830bb332fed28)

12 months agotest: set nullglob to avoid failure when building without sd-boot
Luca Boccassi [Mon, 4 Nov 2024 20:26:34 +0000 (20:26 +0000)]
test: set nullglob to avoid failure when building without sd-boot

2024-11-04T20:13:17.3258095Z + for loader in build/src/boot/efi/*{.efi,.efi.stub}
2024-11-04T20:13:17.3258275Z ++ sbverify --list 'build/src/boot/efi/*.efi'
2024-11-04T20:13:17.3258525Z + [[ Error reading file build/src/boot/efi/*.efi: No such file or directory
2024-11-04T20:13:17.3258952Z Can't open image build/src/boot/efi/*.efi != \N\o\ \s\i\g\n\a\t\u\r\e\ \t\a\b\l\e\ \p\r\e\s\e\n\t ]]
(cherry picked from commit 441922336baf4e302e3b88849c5a08c73b602044)

12 months agotest: fix tool name in comment
Luca Boccassi [Mon, 4 Nov 2024 20:22:01 +0000 (20:22 +0000)]
test: fix tool name in comment

(cherry picked from commit c53df275d512a219806a181de3bd57f02dc38dab)

12 months agopcrlock: Pad pe hash to a multiple of 8 bytes
Daan De Meyer [Sun, 3 Nov 2024 20:45:29 +0000 (21:45 +0100)]
pcrlock: Pad pe hash to a multiple of 8 bytes

All other tools (sbsigntools, osslsigncode, sbctl, goblin) do this
as well so let's follow suite.

(cherry picked from commit e37701a8cd2db1e67d28bcf337467d8efc6de41e)

12 months agotest-dhcp-client: utilize log_info instead of printf
Colin Foster [Fri, 1 Nov 2024 20:39:11 +0000 (15:39 -0500)]
test-dhcp-client: utilize log_info instead of printf

log_info appears to be the preferred method to convey information from
tests. Convert all the printfs to log_info to follow this standard.

(cherry picked from commit 38557d9ffbc6351b8980faf90d54619790436d43)

12 months agoudev-builtin-path_id: SAS wide ports must have num_phys > 1
Martin Wilck [Wed, 30 Oct 2024 15:57:39 +0000 (16:57 +0100)]
udev-builtin-path_id: SAS wide ports must have num_phys > 1

Some kernel SAS drivers (e.g. smartpqi) expose ports with num_phys = 0. udev
shouldn't treat these ports as wide ports.  SAS wide ports always have
num_phys > 1. See comments for sas_port_add_phy() in the kernel sources.

Sample data from a smartpqi system to illustrate the issue below.
Here the phy device is attached to port 0:0, which has no end devices attached
and the SAS end device (where sda is attached) is associated with SAS
port 0:1, which has no associated phy device. Thus num_phys for port-0:1 is 0.
This is arguably wrong, but it's how smartpqi has always set up its devices in
sysfs.

/sys/class/sas_phy/phy-0:0 -> ../../devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/phy-0:0/sas_phy/phy-0:0
/sys/devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/port-0:0/phy-0:0 -> ../phy-0:0
/sys/devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/phy-0:0/port -> ../port-0:0

/sys/class/sas_device/end_device-0:1 -> ../../devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/port-0:1/end_device-0:1/sas_device/end_device-0:1
/sys/class/block/sda -> ../../devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/port-0:1/end_device-0:1/target0:0:0/0:0:0:0/block/sda

Signed-off-by: Martin Wilck <mwilck@suse.com>
(cherry picked from commit 7f6674624eedc95db2a9877edc6ff424f4453531)

12 months agoTEST-64-UDEV-STORAGE: Don't hardcode device name in long-sysfs-path test
Daan De Meyer [Fri, 1 Nov 2024 20:27:52 +0000 (21:27 +0100)]
TEST-64-UDEV-STORAGE: Don't hardcode device name in long-sysfs-path test

There's no guarantee our device will be named /dev/vda, so give it
a serial so we can query for its devname inside the test.

(cherry picked from commit 2ec809dd3baf39b83b8f581e7ea837b9732f9964)

12 months agoTEST-17-UDEV: Don't hardcode root device name
Daan De Meyer [Fri, 1 Nov 2024 20:27:08 +0000 (21:27 +0100)]
TEST-17-UDEV: Don't hardcode root device name

There's no guarantee the root device will be /dev/sda, so let's use
bootctl to get the actual path instead of harcoding it.

(cherry picked from commit 29a8e71d9c0858aef502f091a0ef58d5569b1c70)

12 months agopam: quiet a spurious debug message
Ronan Pigott [Sat, 2 Nov 2024 02:44:18 +0000 (19:44 -0700)]
pam: quiet a spurious debug message

This singular debug message gets printed even if debug is not enabled.
Quiet this message when debug is not enabled for consistency.

(cherry picked from commit f4092cb9745cc2fc1f889eeaffa5cb5133969d85)

12 months agoposix_spawn_wrapper: do not set POSIX_SPAWN_SETSIGDEF flag
Mike Gilbert [Thu, 24 Oct 2024 16:24:35 +0000 (12:24 -0400)]
posix_spawn_wrapper: do not set POSIX_SPAWN_SETSIGDEF flag

Setting this flag is a noop without a corresponding call to
posix_spawnattr_setsigdefault.

If we call posix_spawnattr_setsigdefault with a full signal set,
it causes glibc's posix_spawn implementation to call sigaction 63 times,
once for each signal. That seems wasteful.

This feature is really only useful for signals which have their
disposition set to SIG_IGN. Otherwise the dispostion gets set to
SIG_DFL automatically, either by clone(CLONE_CLEAR_SIGHAND) or the
subsequent execve.

As far as I can tell, systemd does not have any signals set to SIG_IGN
under normal operating conditions.

(cherry picked from commit ff94426f8a2d6cd4ea2e370835db152917a1684e)

12 months agocore: make mount(8) and swapon(8) inherit SMACK label from systemd
Łukasz Stelmach [Tue, 29 Oct 2024 14:53:45 +0000 (15:53 +0100)]
core: make mount(8) and swapon(8) inherit SMACK label from systemd

By default mount(8), umount(8), swapon(8) and swapoff(8) should run with
with the SMACK label inherited from systemd rather than the default one
meant for services.

Fixes: aa5ae9711ef3cd0c69b7fcfbd65bca05fb704a8a
Follow-up-for: 20bbf5ee4c6c80599a91e7a4b7474e931a27db4a
(cherry picked from commit 8144537a81c7a815af3d4c63cd8545ee17b2715d)

12 months agotest-network: add test for DHCPv4 address removal on stop
Yu Watanabe [Wed, 23 Oct 2024 20:25:41 +0000 (05:25 +0900)]
test-network: add test for DHCPv4 address removal on stop

For issue #34837.

(cherry picked from commit 58a011ba4865d083bffdebe33126637bc5bba511)

12 months agonetwork: process queued remove requests before networkd is stopped
Yu Watanabe [Wed, 23 Oct 2024 19:40:45 +0000 (04:40 +0900)]
network: process queued remove requests before networkd is stopped

This makes networkd process all queued remove requests when a
terminating or restarting signal is received. Otherwise, e.g. DHCPv4
address will not be removed on stop, especially when
KeepConfiguration=no.

Fixes a bug introduced by 85a6f300c14d75d161cbfdb3eaf5af9594400ecd and
its subsequent commits.

Fixes #34837.

Co-authored-by: Will Fancher <elvishjerricco@gmail.com>
(cherry picked from commit db68e990467ffea2b6655e4726856ca7eb32b38d)

12 months agotest-sbat: separate the two sbat sections
Zbigniew Jędrzejewski-Szmek [Wed, 30 Oct 2024 14:19:24 +0000 (15:19 +0100)]
test-sbat: separate the two sbat sections

(cherry picked from commit 07000101eb9529c2d6b5f5402c9fe643c5f98420)

12 months agocryptenroll,homectl,journalctl: adjust messages before qrcodes
Zbigniew Jędrzejewski-Szmek [Mon, 28 Oct 2024 12:59:05 +0000 (13:59 +0100)]
cryptenroll,homectl,journalctl: adjust messages before qrcodes

Users will generally know what a qrcode is, so let's not treat them as dumb and
explain that it can be scanned. OTOH, we should say what the qrcode contains
and it is useful to give a hint why the users would want to scan it. Reword
messages accordingly.

(Also, don't say "to your phone", when somebody might be using a stolen phone,
or something else then a phone.)

(cherry picked from commit 10faa40ba781cf499258a3b37de02dd643822dc6)

12 months agobsod: make message for qrcode more useful
Zbigniew Jędrzejewski-Szmek [Mon, 28 Oct 2024 12:51:25 +0000 (13:51 +0100)]
bsod: make message for qrcode more useful

People know what a qrcode is. We don't need to tell them to scan it.
Instead, we should say what the code contains.

While at it, rename "stream" to "f" in line with the usual style.

(cherry picked from commit abf1cae0a75ca07f09afbb4eaa9f11fc429b1d02)

12 months agodocs: Align some comments in HACKING.md
Daan De Meyer [Wed, 30 Oct 2024 10:16:13 +0000 (11:16 +0100)]
docs: Align some comments in HACKING.md

(cherry picked from commit a33f453702e40f4b52226c6be1a01200aee69470)

12 months agoanalyze: Add times in seconds for Activating and Activated in tooltip
hugo303 [Fri, 25 Oct 2024 10:15:02 +0000 (12:15 +0200)]
analyze: Add times in seconds for Activating and Activated in tooltip

Print the times in seconds in the tooltip to remove the need to count
and trying to follow the lines in the svg diagram in order to see at
what times these events happen.

(cherry picked from commit f172dfddde3379319ee3a02666a7ecf11a5711f4)

12 months agoTEST-80-NOTIFYACCESS: don't specify --pid= if MAINPID= is provided explicitly
Mike Yuan [Tue, 29 Oct 2024 17:35:50 +0000 (18:35 +0100)]
TEST-80-NOTIFYACCESS: don't specify --pid= if MAINPID= is provided explicitly

Otherwise, with recent additions, the MAINPIDFDID= generated by
systemd-notify would mismatch with overridden MAINPID=.

(cherry picked from commit c3ecb747f1e35f609f15fc94ad4d5e5ca0bda4a2)

12 months agoqrcode-util: avoid memleak in error path
Zbigniew Jędrzejewski-Szmek [Mon, 28 Oct 2024 12:45:40 +0000 (13:45 +0100)]
qrcode-util: avoid memleak in error path

(cherry picked from commit 439306da8b3962f683f5359c461d1669c070f377)

12 months agotest-terminal-util: print value of colors_enabled()
Zbigniew Jędrzejewski-Szmek [Mon, 28 Oct 2024 12:39:36 +0000 (13:39 +0100)]
test-terminal-util: print value of colors_enabled()

This makes it easier to diagnose why colors are disabled.

(cherry picked from commit b137b2979868e2de5fb5c26e90bacee33597b8e7)

12 months agobsod: do not check for color support
Zbigniew Jędrzejewski-Szmek [Mon, 28 Oct 2024 12:38:58 +0000 (13:38 +0100)]
bsod: do not check for color support

When invoked on a running system, bsod would not print the qrcode.
The check for "color support" on stdout is pointless, since we're not
printing to stdout but to a terminal fd that is opened separately.

(cherry picked from commit 5a64c86936477ecea5cc1fb8dbc79faf522cf370)

12 months agoqrcode-util: add debug message to show why a qrcode wasn't printed
Zbigniew Jędrzejewski-Szmek [Mon, 28 Oct 2024 12:15:32 +0000 (13:15 +0100)]
qrcode-util: add debug message to show why a qrcode wasn't printed

(cherry picked from commit f0764b98e5c136cb948a8034949064f610acca24)

12 months agosysv-generator: break long message into lines
Zbigniew Jędrzejewski-Szmek [Fri, 18 Oct 2024 17:41:25 +0000 (19:41 +0200)]
sysv-generator: break long message into lines

The journal handles multi-line messages nicely, and they are easier
to read. Drop the recycling symbol, there is no circular process here,
we go from a to b and never back to a again.

(cherry picked from commit bb56c27fc81da2777cd7064a0b88ca011eced509)

12 months agosd-id128: mark functions as const, not pure
Zbigniew Jędrzejewski-Szmek [Mon, 28 Oct 2024 08:20:32 +0000 (09:20 +0100)]
sd-id128: mark functions as const, not pure

We would need to use pure if the funtion was getting pointers and
dereferencing them. But sd128_t is a structure and those functions
only access the parameters of the call.

(cherry picked from commit dc32b09b70c9bb20821df92ac82ace83d8a968e2)

12 months agosd-common: add __const__
Zbigniew Jędrzejewski-Szmek [Mon, 28 Oct 2024 08:13:10 +0000 (09:13 +0100)]
sd-common: add __const__

const is stronger than pure, see
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute
and
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute.

(cherry picked from commit 955c51c087f1fb6d0b7a0091db943ad05ba3095e)

12 months agomeson: add loongarch64's definition to cpu_arch_defines
Zhou Qiankang [Mon, 28 Oct 2024 04:47:20 +0000 (12:47 +0800)]
meson: add loongarch64's definition to cpu_arch_defines

The default definition to add is `-D__loongarch64__`, which is not searched in [bpf_tracing.h](https://github.com/libbpf/libbpf/blob/09b9e83102eb8ab9e540d36b4559c55f3bcdb95d/src/bpf_tracing.h#L68)

This may avoid `error: Must specify a BPF target arch via __TARGET_ARCH_xxx` in loongarch64

Signed-off-by: Zhou Qiankang <wszqkzqk@qq.com>
(cherry picked from commit 85d0aff84c83182875bc564e295978efd76ab905)

12 months agocore/service: use log_unit_* where appropriate
Mike Yuan [Sat, 26 Oct 2024 15:38:06 +0000 (17:38 +0200)]
core/service: use log_unit_* where appropriate

(cherry picked from commit 1e8f0beee4272ddc8b25dfa9af8e54bafc4c061a)

12 months agosd-event: fix memleak when built without assertion
Yu Watanabe [Fri, 25 Oct 2024 18:25:26 +0000 (03:25 +0900)]
sd-event: fix memleak when built without assertion

Fixes a bug introduced by baf3fdec27f0b3a1f3d39c7def2a778824cbee51.

This also adds several assertions at the beginning of the function.

Fixes #34899.

(cherry picked from commit 5dc0668802cd07cdca2dc5bda52cc1e63b57f145)

12 months agotest: add quick test to verify the PAM stack really ran in all run0 modes of operation
Lennart Poettering [Thu, 24 Oct 2024 20:51:49 +0000 (22:51 +0200)]
test: add quick test to verify the PAM stack really ran in all run0 modes of operation

(cherry picked from commit f515ea1cd4981ceb1a2c85d676f279db2972283f)

12 months agocore: make sure that if PAMName= is set we always do the full user changing even...
Lennart Poettering [Thu, 24 Oct 2024 08:52:56 +0000 (10:52 +0200)]
core: make sure that if PAMName= is set we always do the full user changing even if no user is specified explicitly

When PAMName= is set this should be enough to go through our entire user
changing story, so that PAM is definitely run, and environment variables
definitely pulled in and so on.

Previously, it would happen that under some circumstances we might no do
this when transitioning from root to root itself even though PAM was
enabled.

Fixes: #34682
(cherry picked from commit e4b4d9cc7adf245950e8676be0e0f4a813069500)

12 months agoman/veritysetup-generator: document veritytab kernel command line option
Antonio Alvarez Feijoo [Thu, 24 Oct 2024 08:07:28 +0000 (10:07 +0200)]
man/veritysetup-generator: document veritytab kernel command line option

(cherry picked from commit e98e3f856d56bfb8dd8883f9e570bb56c4b1e3b2)

12 months agoman: fix links to veritysetup(8)
Antonio Alvarez Feijoo [Thu, 24 Oct 2024 07:54:48 +0000 (09:54 +0200)]
man: fix links to veritysetup(8)

(cherry picked from commit dcbfc7872e96c20b4d29b527d3467f547f6971d0)

12 months agocore: don't forget about fallback_smack_process_label
Łukasz Stelmach [Wed, 23 Oct 2024 10:58:36 +0000 (12:58 +0200)]
core: don't forget about fallback_smack_process_label

Call setup_smack() also when only fallback_smack_process_label is set.

Fixes: 75689fb2d41f
(cherry picked from commit 20bbf5ee4c6c80599a91e7a4b7474e931a27db4a)

12 months agologind: allow read/write to char-hvc devices
Luca Boccassi [Tue, 22 Oct 2024 16:04:41 +0000 (17:04 +0100)]
logind: allow read/write to char-hvc devices

virtio console uses /dev/hvc* so we need access to write wall
messages

(cherry picked from commit 5ff6841c2378ed83e645681cbd4ee145f68d72b7)

12 months agoTEST-02-UNITTESTS: reuse $TEST_MATCH_SUBTEST to specify unit tests to be run
Yu Watanabe [Tue, 22 Oct 2024 06:32:12 +0000 (15:32 +0900)]
TEST-02-UNITTESTS: reuse $TEST_MATCH_SUBTEST to specify unit tests to be run

Then, we can easily test specific unit tests in qemu or container.

(cherry picked from commit aa7507ea4a57508da0f2a7d1ae6e139793c5694a)

12 months agotest-execute: update permission of credstore
Yu Watanabe [Mon, 5 Jun 2023 05:18:47 +0000 (14:18 +0900)]
test-execute: update permission of credstore

Follow-up for 40fb9eebbc075ce1e63100386d2c5f177ad7d738.

(cherry picked from commit c443f6924fa3b02113da2536dd816a15ee708510)

12 months agotest: CET/EET are deprecated, use Europe/Berlin and Kyiv
Luca Boccassi [Mon, 21 Oct 2024 16:31:09 +0000 (17:31 +0100)]
test: CET/EET are deprecated, use Europe/Berlin and Kyiv

The links moved to the legacy dataset so they won't be available by
default, so stop using them and just use the city ones instead

(cherry picked from commit aa077884c13769ae3bd6aa98978b4ac9e64b5365)

12 months agotest-dhcp6: terminate fqdn option
Ronan Pigott [Thu, 25 Jan 2024 00:53:35 +0000 (17:53 -0700)]
test-dhcp6: terminate fqdn option

The encoded fqdn in this option must be properly terminated. We will
soon validate that this field is correctly encoded, so correct it in the
test.

(cherry picked from commit 2d9822b634680f1be1d20920aceddac76de110eb)

12 months agopcrlock: Take VirtualSize > SizeOfRawData into account
Daan De Meyer [Mon, 7 Oct 2024 15:39:27 +0000 (17:39 +0200)]
pcrlock: Take VirtualSize > SizeOfRawData into account

If VirtualSize > SizeOfRawData, measure extra zeros to take into
account the extra zeros also measured by the stub.

(cherry picked from commit b53f2d5ed8ad0e537e9086daf84f9c2bf69fb72b)

12 months agotest: exercise bypass mode on the sd-resolved stub
Ronan Pigott [Fri, 11 Oct 2024 05:40:03 +0000 (22:40 -0700)]
test: exercise bypass mode on the sd-resolved stub

A basic test will verify that we provide the right flags.

(cherry picked from commit b7b1c50c6afd2ab8c2c779df9b73c6dbbc773f70)

12 months agoresolved: when adding names to packet fails, remove them from label compression hash...
Lennart Poettering [Thu, 12 Sep 2024 15:05:24 +0000 (17:05 +0200)]
resolved: when adding names to packet fails, remove them from label compression hash table again

let's make sure we undo any pollution of the label compression hash
table.

Fixes: #33671
(cherry picked from commit 360105f1e748148ba17bdb3f47525f01aba4127f)

12 months agodns-domain: tweak hash table comparison function for DNS names
Lennart Poettering [Thu, 12 Sep 2024 15:00:04 +0000 (17:00 +0200)]
dns-domain: tweak hash table comparison function for DNS names

Currently, when comparing two DNS names when storing them in a
hashtable, and the DNS names are not actually valid we'll compare the
error codes.

This is not very smart however, since this means two invalid DNS names
that happen to be equally "invalid" will be considered identical, even
if their strings are entirely different.

Let's find a better solution for this niche case: let's simple compare
the domains as strings.

This matters in case of DNS label compression: if we already added added
an invalid DNS name into the label compression hash table, and lookup
any other invalid DNS name, this lookup will likely return what the
earlier one already returned, and that's confusing.

(cherry picked from commit 8ed2c62d46f93c2117d65a908c316a381073af16)