1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-31 01:47:15 +03:00

55412 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
527c9002b5 bootctl: split out the check whether sd-boot is installed
(cherry picked from commit d9f048b5d113b85b65093f582a8153f79110c49e)
2022-01-11 20:31:34 +01:00
lincoln auster
9a109a9a11 sd-bus/man: document EBUSY error in bus_message_read (#21954)
* sd-bus/man: document EBUSY error in bus_message_read

The EBUSY error can be returned from sd_bus_exit_container(), and, if
that happens, it will be propogated upwards towards bus_message_read. In
terms of documentation, this means that bus_message_read's man page
can't just include the error text for sd_bus_message_read_basic, as
reading basic types exclusively doesn't have the potential for this
error.

sd_bus_message_read_basic's error documentation isn't incorrect when
applied to sd_bus_message_read, it's just incomplete.  While EBUSY is
documented in sd_bus_message_open_container.xml,
it's explanation is unique to the sd_bus_message_exit_container function
and makes for poor documentation of the general read API.

(cherry picked from commit a1a03fa54bfb45315eefaa49ceb38a21aceafde8)
2022-01-11 20:30:50 +01:00
Jan Janssen
e9a0404b76 boot: Fix readdir_harder() on VirtualBox
Fixes: #22073
(cherry picked from commit ed3abbfbde674bd163cb1c64d9e31dd24e352f85)
2022-01-11 20:30:40 +01:00
Julia Kartseva
617c67a039 bpf: fix bpf_can_link_lsm_program condition
Since bpf_can_link_lsm_program return value is boolean, the expression
`r < 0` is always false.

(cherry picked from commit ccfc534deed2f3873c967851497af10d8a1ee01c)
v250.2
2022-01-10 21:47:30 +01:00
Julia Kartseva
f9370f9188 bpf: check if lsm link ptr is libbpf error
BPF_RAW_TRACEPOINT_OPEN is expected to work only on x86 and x86_64,
since BPF trampoline is implemented only on these architectures.

Attach probing by bpf_program__attach_lsm already happens in
`bpf_lsm_supported`. The resulting pointer can store libbpf error and
that is the case for unsupported architectures.
Add libbpf error check to `bpf_lsm_supported` so execution does not
reach the point where unit startup fails.

(cherry picked from commit f409aa5c6363144c9711226319614f3b248d9828)
2022-01-10 21:47:21 +01:00
Zbigniew Jędrzejewski-Szmek
911516e161 shared/rm-rf: loop over nested directories instead of instead of recursing
To remove directory structures, we need to remove the innermost items first,
and then recursively remove higher-level directories. We would recursively
descend into directories and invoke rm_rf_children and rm_rm_children_inner.
This is problematic when too many directories are nested.

Instead, let's create a "TODO" queue. In the the queue, for each level we
hold the DIR* object we were working on, and the name of the directory. This
allows us to leave a partially-processed directory, and restart the removal
loop one level down. When done with the inner directory, we use the name to
unlinkat() it from the parent, and proceed with the removal of other items.

Because the nesting is increased by one level, it is best to view this patch
with -b/--ignore-space-change.

This fixes CVE-2021-3997, https://bugzilla.redhat.com/show_bug.cgi?id=2024639.
The issue was reported and patches reviewed by Qualys Team.
Mauro Matteo Cascella and Riccardo Schirone from Red Hat handled the disclosure.

(cherry picked from commit 5b1cf7a9be37e20133c0208005274ce4a5b5c6a1)
2022-01-10 21:47:03 +01:00
Zbigniew Jędrzejewski-Szmek
664529efa9 shared/rm_rf: refactor rm_rf() to shorten code a bit
(cherry picked from commit 84ced330020c0bae57bd4628f1f44eec91304e69)
2022-01-10 21:47:00 +01:00
Zbigniew Jędrzejewski-Szmek
47741ff9ea shared/rm_rf: refactor rm_rf_children_inner() to shorten code a bit
(cherry picked from commit 3bac86abfa1b1720180840ffb9d06b3d54841c11)
2022-01-10 21:46:56 +01:00
Ludwig Nussel
1d5687278c systemctl: Fix --show timestamp
(cherry picked from commit 2dbb54788ee8d4c3d84e1af309335ad3c3885f1a)
2022-01-10 21:46:34 +01:00
Jan Janssen
3c5c13f82c boot-timestamps: Discard firmware init time when running in a VM
Fixes: #22060
(cherry picked from commit f699bd81e8e18da2d2fc11e7fb7dce95f8bb3f9e)
2022-01-09 21:27:07 +01:00
Zbigniew Jędrzejewski-Szmek
8ec64d0778 bpf: actually skip RestrictFileSystems= when not supported
Units would fail to start, incl. systemd-journald.service and systemd-udevd.service.
Since unit->manager->restrict_fs will be set if and only if we can use it,
we can just check for that and remove the other checks.
Follow-up for 299d9417238e0727a48ebaabb5a9de0c908ec5c8.

(cherry picked from commit 46004616a12dcdaf11020b8d58f956a006c9d9cf)
2022-01-09 21:26:58 +01:00
Luca Boccassi
76e23c1cbe test: store empty files rather than symlinks for test-fstab-generator
Dangling symlinks get pruned when packaging up the installation
directory. Just store empty files instead, and compare the names
rather than the content for .requires/.wants - the filename is
what is important anyway, the content is ignored.

Fixes #22059

(cherry picked from commit e683878c0f03a4ffa123e37b27933fbf7e144901)
2022-01-09 21:26:13 +01:00
Zbigniew Jędrzejewski-Szmek
d1612a7163 man: add missing example title in systemd.network(5)
Also rename the file to match the example being extended.

(cherry picked from commit 55ac274ef4c1661f3053ae3a709202c918365f3b)
2022-01-09 21:25:17 +01:00
Zbigniew Jędrzejewski-Szmek
d08f6ff204 seccomp: move arch_prctl to @default
It was reported as used by the linker:

> [It is] called in the setup of ld-linux-x86-64.so.2 from _dl_sysdep_start.
> My local call stack (with LTO):
>
> #0 init_cpu_features.constprop.0 (/usr/lib64/ld-linux-x86-64.so.2)
> #1 _dl_sysdep_start (/usr/lib64/ld-linux-x86-64.so.2)
> #2 _dl_start (/usr/lib64/ld-linux-x86-64.so.2)
> #3 _start (/usr/lib64/ld-linux-x86-64.so.2)
>
> Looking through the source, I think it's this (links for glibc 2.34):
> - First dl_platform_init calls _dl_x86_init_cpu_features, a wrapper for init_cpu_features.
> - Then init_cpu_features calls get_cet_status.
> - At last, get_cet_status invokes arch_prctl.

Fixes #22033.

(cherry picked from commit 5f02870a74aa3a758115cc9bd6d68f239caf8453)
2022-01-07 17:41:17 +01:00
Yu Watanabe
7dbfdefca3 test: add test cases for fstab-generator
(cherry picked from commit 8cc8a073a834f3882b17115cd3e9a81f6a105898)
2022-01-07 16:03:06 +01:00
Yu Watanabe
c6e4d8d9bd meson: install test-network-generator-conversion.sh even if networkd is not enabled
Follow-up for 987dd89c775815831ae21736fe60aef59cb7a6fa.

(cherry picked from commit b322e683acf3ca3c86ea38be8a8b20a29459ec5f)
2022-01-07 16:03:03 +01:00
Yu Watanabe
41134e766a fstab-generator: also skip other network filesystems and live image
(cherry picked from commit 155e1bb4e7cf87191007488cf6a68a558a16eca1)
2022-01-07 16:02:50 +01:00
Yu Watanabe
7ca41c509e fstab-generator: skip root directory handling when nfsroot is requested
Fixes RHBZ#2037233 (https://bugzilla.redhat.com/show_bug.cgi?id=2037233).

(cherry picked from commit 77b8e92de8264c0b656a7d2fb437dd8d598ab597)
2022-01-07 16:02:46 +01:00
Adam Williamson
d0e98b7a12 kernel-install: prefer /boot over /boot/efi for $BOOT_ROOT
This restores the preference order from before 9e82a74. The code
previous to that change 'preferred' /boot over /boot/efi; that
commit changed it to check /boot/efi before checking /boot.
Changing this precedence could (and did, for me) have unexpected
effects - it seems safer to leave it how it was.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
(cherry picked from commit a5307e173bf86d695fe85b8e15e91126e8618a14)
2022-01-07 16:00:24 +01:00
Markus Weippert
11f3040d0a homed: stop before stopping dbus
Otherwise, systemd-homed-active.service will fail to deactivate all
homes because homectl can no longer talk to homed if dbus stops first.
As a result, /home cannot be umounted.

Doing this on systemd-homed-active.service instead works as well, but
systemd-homed will exit 1 if dbus is already shut down.

(cherry picked from commit e00a25a7b41bd45ab73b47cbd94b3af909b8f8a1)
2022-01-07 16:00:18 +01:00
Yu Watanabe
7a003166fb udev-util: ignore USB-C ports in power source mode when detecting system is running on AC power
Fixes #21988.

(cherry picked from commit 795e86b4f1e8a1fd440f8c817621779c6aedbdb5)
2022-01-07 15:59:30 +01:00
Yu Watanabe
dbfaed242e udev-util: re-implement on_ac_power() with sd-device
(cherry picked from commit 01d4ad3bde9efbbc5856846fea328ee9bbcef87e)
2022-01-07 15:59:25 +01:00
Yu Watanabe
435bd3077a util: move on_ac_power() from util.c -> udev-util.c
(cherry picked from commit 06795b02e386763ca919bb4cd03990b9036e2e0a)
2022-01-07 15:59:23 +01:00
Julia Kartseva
95a43a476f bpf: do not freeze if bpf lsm fails to set up
BPF LSM is cgroup unaware and it's set up is happening in core manager.
It occures that the current implementation is too restrictive and causes
pid 1 to freeze.
Instead:
* in bpf_lsm_setup set manager->restrict_fs pointer last,
so it is an indicator that the set up was successful
* check for manager->restrict_fs before applying unit options

(cherry picked from commit 299d9417238e0727a48ebaabb5a9de0c908ec5c8)
2022-01-07 15:59:13 +01:00
Zbigniew Jędrzejewski-Szmek
428425ddc6 core/bpf: tighten handling of return values, improve messages
The code was written unidiomatically, using r as a boolean value, and
confusing errno and r in some places. AFAICS, there wasn't any actual
problem: even in the one place where errno was used instead of r, it would
almost certainly be initialized.

It seems that some libbpf functions set errno, while others return the
error, possibly encoded. Since there are almost no docs, the only way to
know is to read the code of the function. To make matters worse, there is
a global libbpf_mode which can be set to change the convention. With
LIBBPF_STRICT_DIRECT_ERRS in libbpf_mode, some functions set errno while others
return a negative error, and the only way to know is to read the code, except
that the split is now different. We currently don't set
LIBBPF_STRICT_DIRECT_ERRS, but even the possibility makes everything harder
to grok.

This is all very error-prone. Let's at least add some asserts to make sure that
the returned values are as expected.

(cherry picked from commit b7cba81553d0d958f23182ba9ab1739842ff9f5a)
2022-01-07 15:59:10 +01:00
Zbigniew Jędrzejewski-Szmek
75dac89443 core/bpf: avoid unnecessary initialization of variables, tighten scope
No funtional change.

(cherry picked from commit 92698b0f9e34d69bc97e9ed8830eafaa06f41a46)
2022-01-07 15:59:07 +01:00
Pigmy-penguin
c33d10d230 userdbctl: fix "Password OK" shown even when password is empty or locked (#21308)
userdbctl: fix "Password OK" shown even when password is empty or locked
(cherry picked from commit cd933f14bd70d8311799972ca71280a733eb1d6a)
2022-01-07 15:55:31 +01:00
Mike Gilbert
4c0ed19c52 test-watchdog: mark as unsafe
If something goes wrong with this test it may result in an unsafe
system restart. Let's avoid running it automatically.

See https://github.com/systemd/systemd/issues/22001.

(cherry picked from commit 70652c2a6fa9c06c7faac62f41c72e2e4eaa9340)
2022-01-07 15:54:12 +01:00
Zbigniew Jędrzejewski-Szmek
fb9bbbee6a logind: do not propagate error in delayed action
If the action failed, we should log about the issue, and continue.
Exiting would bring the graphical session down, which of course is not
appreciated by users.

As documented in previous commits, a non-negative return from the callback
doesn't matter, so the callback is simplified a bit.

Fixes #21991.

(cherry picked from commit 8207b8321bbbcbd19a345deb77d455d98e6ffb84)
2022-01-07 15:53:45 +01:00
Frantisek Sumsal
3af61b9224 test: use full date & time when checking for coredumps
Otherwise we might hit a window where the coredump happens before
midnight, but we check for it after midnight, which yields no results.

E.g.:

```
$ coredumpctl --no-legend --no-pager --file system.journal
Wed 2022-01-05 01:00:06 CET 359 0 0 SIGABRT journal /usr/bin/udevadm n/a
$ coredumpctl --since 23:59:55 --no-legend --no-pager --file system.journal
No coredumps found.
$ coredumpctl --since "2022-01-04 23:59:59" --no-legend --no-pager --file system.journal
Wed 2022-01-05 01:00:06 CET 359 0 0 SIGABRT journal /usr/bin/udevadm n/a
```

(cherry picked from commit 1b51599f29d245f2214349498bf2c1f0aa36873f)
2022-01-07 15:53:20 +01:00
Daan De Meyer
c86461782f journal: Log filename when we fail to write an entry
(cherry picked from commit 5b4a634a03c54a4d18b01686ac86b1133b54a939)
2022-01-07 15:53:17 +01:00
Daan De Meyer
bdaa1b2dda journal: Log a better message when we're rotating because a file is full
The previous message was confusing errors. When we're rotating because
we've reached the file size limit, let's log a better message.

Fixes #22007.

(cherry picked from commit eff79e4e22e7c745fea259c4414f685363d9f16a)
2022-01-07 15:53:12 +01:00
Yu Watanabe
b4c57e1b1c backlight: ignore error if the backlight device is already removed
Fixes #21997.

(cherry picked from commit f0f65087834198d4dabf8b389ddc34223400aab7)
2022-01-07 15:52:33 +01:00
Yu Watanabe
80f1b9ab54 test-repart: append /sbin and /usr/sbin to $PATH= to make sfdisk can be found
Fixes #21972.

(cherry picked from commit 329a5b91d9ec780b2ce84ee336448291a568ae0d)
2022-01-07 15:52:26 +01:00
Yu Watanabe
6f1f99a35d test-repart: disable pager
(cherry picked from commit 31cf58864d3f437c7e3f0497df0fef85130f159d)
2022-01-07 15:52:25 +01:00
Yu Watanabe
0e29d6ef44 sd-boot: select newest kernel entry matching with the default glob pattern
This fixes a bug introduced by 0c674ce5f24a6e52561ec6520e43a1ca45d90f01.

Fixes #22004.

(cherry picked from commit e37d30f334830fab4decd52ef3c17fa09b7b0d92)
2022-01-07 15:51:51 +01:00
Yu Watanabe
7b2f8845cd resolve: add missing initialization of libgcrypt
Fixes #21951.

(cherry picked from commit e28df39269e03d49f540ebfe6b2e507d0f26c844)
2022-01-07 15:51:46 +01:00
Bastien Nocera
fe16ab6b39 hwdb: Allow end-users root-less access to TL866 EPROM readers
As is currently done in the upstream minipro tool:
https://gitlab.com/DavidGriffith/minipro/-/tree/master/udev

(cherry picked from commit f097f4ab896ea81e76b5764e218d7c644bfda199)
2022-01-07 15:37:08 +01:00
Zbigniew Jędrzejewski-Szmek
5c14fde3ba hwdb: make usb match patterns uppercase
Those patterns were always supposed to be uppercase.

(cherry picked from commit cc1746bbedb3c508cb39ce9c299f4f098bebb1a8)
2022-01-07 15:36:46 +01:00
Zbigniew Jędrzejewski-Szmek
697ec43fc5 hwdb: fix check for uppercasedness of match patterns
The check was added in 77547d5313ea916d2fb64ca5a8812734e9b50f92, but
it doesn't work as expected. Because the second part is wrapped in Optional(),
it would silently "succeed" when the lowercase digits were in the second part:

>>> from parse_hwdb import *
>>> g = 'v' + upperhex_word(4) + Optional('p' + upperhex_word(4))
>>> g.parseString('v04D8pE11C*')
(['v', '04D8', 'p', 'E11C'], {})
>>> g.parseString('v04D8pe11c*')
(['v', '04D8'], {})

The following matches are OK:
usb:v0627p0001:*QEMU USB Keyboard*
usb:v0627p0001:*
usb:v0627p0001*
usb:v0627*

(cherry picked from commit 1a37237e2ffe6dfe142224a9d9e8b24135e93244)
2022-01-07 15:36:36 +01:00
Marco Scardovi
402280118f make HP 15s-eq0xxx changes specific to sku9MG38EA#ABZ
Signed-Off-By: Marco Scardovi <marco@scardovi.com>
(cherry picked from commit 7bd3d6e35a6de8b1bf93e2fae28a64f0c7ffd2ac)
v250.1
2022-01-04 17:11:10 +01:00
Zbigniew Jędrzejewski-Szmek
0776365d77 meson: generate better arch defines for clang bpf compilation
The code assume that meson's cpu_family can be mapped directly to
'-D__<cpu_family>__'. This works in a surprising number of cases, but not for a
few architectures. PPC uses "powerpc", and RISC-V omits the trailing underscores.
ARM and RISC-V require a second define too.

Fixes #21900.

(I don't think this matters too much: we need *something* so that gnu/stubs.h
can be successfully included. But we don't actually call syscalls or depend too
much on the host environment, so things should be fine as long as we don't get
a compilation error.)

(cherry picked from commit e897b07f97cf25e092a4cc8e1144e06564b45d53)
2022-01-04 16:28:31 +01:00
Zbigniew Jędrzejewski-Szmek
cd686fe4c7 basic/log: allow errno values higher than 255
When the support for "synthetic errno" was added, we started truncating
the errno value to just the least significant byte. This is generally OK,
because errno values are defined up to ~130.

The docs don't really say what the maximum value is. But at least in principle
higher values could be added in the future. So let's stop truncating
the values needlessly.

The kernel (or libbpf?) have an error where they return 524 as an errno
value (https://bugzilla.redhat.com/show_bug.cgi?id=2036145). We would
confusingly truncate this to 12 (ENOMEM). It seems much nicer to let
strerror() give us "Unknown error 524" rather than to print the bogus
message about ENOMEM.

(cherry picked from commit 5f74fcd41cb1a1b26c23e0f2ab405ae9cf6bcc93)
2022-01-04 16:27:57 +01:00
Zbigniew Jędrzejewski-Szmek
e4d4c5f9ee coredump: do not crash if we failed to acquire exe path
The COREDUMP_EXE attribute is "optional", i.e. we continue to process the
crash even if we didn't acquire it. The coredump generation code assumed
that it is always available:

 #5 endswith at ../src/fundamental/string-util-fundamental.c:41
 [ endswith() is called with NULL here, and an assertion fails. ]
 #6 submit_coredump at ../src/coredump/coredump.c:823
 #7 process_socket at ../src/coredump/coredump.c:1038
 #8 run at ../src/coredump/coredump.c:1413

We use the exe path for loop detection, and also (ultimately) pass it to
dwfl_core_file_report(). The latter seems to be fine will NULL, so let's just
change our code to look at COMM, which should be more reliable anyway.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2036517.

(cherry picked from commit c790632cabf5691b0910fc6b7a5c6af31a7786aa)
2022-01-04 16:27:51 +01:00
Yu Watanabe
bdcc3b0713 elf-util: add missing assertion
(cherry picked from commit 80b241f2ec98509cbc89d2fb1626403167a832fb)
2022-01-04 16:27:41 +01:00
Yu Watanabe
72f95a1342 elf-util: executable argument for parse_elf() may be NULL
Fixes assertion triggered by parse_package_metadata() and json_build().

(cherry picked from commit d090049c01d9939b12989a74b1edc5fee75c1710)
2022-01-04 16:27:14 +01:00
Yu Watanabe
9f5372ce4c hostname-util: drop GET_HOSTNAME_ALLOW_NONE flag and always refuse "(none)"
The flag is now only used in test-sysctl-util.c, and it should be
replaced with uname(), because of the same reason as the previous
commit.

(cherry picked from commit 9383fa08bd263277d9a17a8999c3497458f273e3)
2022-01-04 16:25:46 +01:00
Yu Watanabe
7c78994860 hostname-setup: gracefully handle kernel with empty CONFIG_DEFAULT_HOSTNAME
Previously, sethostname_idempotent_full() calls gethostname_full() with
GET_HOSTNAME_ALLOW_NONE and GET_HOSTNAME_ALLOW_LOCALHOST flags. That
intended to get any values set by kernel. But, that does not work, as
the hostname may be empty.

Let's simplify the logic. The function sethostname_idempotent_full()
intends to set the requested hostname only when the current hostname
is different from the requested one. So, no check in getostname_full()
is required. Hence, simply use the result of uname() here.

Fixes #21896.

(cherry picked from commit d8d6b2275f7b7a5b58c6b0d89b78c927333c6af9)
2022-01-04 16:25:42 +01:00
Jan Janssen
1c4c566d86 boot: Do not warn if an initializing driver returns EFI_ABORTED
Fixes: #21965
(cherry picked from commit 8fb16fee96a1563738e7fa784fc45d152b8c2694)
2022-01-04 16:25:33 +01:00
Yu Watanabe
c563e3ef77 seccomp-util: include missing_syscall_def.h to make __SNR_foo mapped to __NR_foo
Fixes #21969.

(cherry picked from commit e83156c264d149e8f92f05b4d777317824a430f1)
2022-01-04 16:24:48 +01:00