1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-05 09:17:44 +03:00
Commit Graph

61506 Commits

Author SHA1 Message Date
Luca Boccassi
f381320760 boot: skip loading DTBs in type 1 when secure boot is enabled
The kernel loads the DTB from EFI before ExitBootServices():

https://github.com/torvalds/linux/blob/v6.5/drivers/firmware/efi/libstub/fdt.c#L245

DTBs can map and assign arbitrary memory ranges. The kernel refuses
to load one from the dtb= kernel command line parameter when secure
boot is enabled, as it's not safe. Let's do the same for type 1
entries, as they are unverified.

This only affects arm64 and riscv64, firmwares do not support DTB
on x86.

(cherry picked from commit 4b4d612d86)
(cherry picked from commit c1404fff32)
(cherry picked from commit 7844c655be)
2023-09-20 10:14:24 +01:00
Lennart Poettering
2d15dbc0a9 Revert "tree-wide: Mount file descriptors via /proc/<pid>/fd"
(cherry picked from commit 7b9da3861a)
(cherry picked from commit d5c180b96e)
2023-09-09 02:21:12 +01:00
Luca Boccassi
d3868a1ea0 packit: build on Fedora 38
Rawhide has moved too far ahead and uses incompatible options
2023-09-08 16:35:10 +01:00
Yu Watanabe
0531c47e96 wait-online: request that at least one managed online interface exists
Fixes a regression caused by ab3aed4a03.

I thought the commit does not cause any severe regression. However,
drivers for network interfaces may be loaded later. So, we should wait
if no network interface is found.

Fixes #27822.

(cherry picked from commit 2f96a29c2c)
(cherry picked from commit abbd24e8a5)
2023-09-08 16:35:10 +01:00
Yu Watanabe
5ad5807106 test-network: add testcase for no managed interface
(cherry picked from commit 56dfde0d54)
2023-09-08 16:35:10 +01:00
Yu Watanabe
8c9b36f1be test-network: split out wait-online related test case
(cherry picked from commit b09ec84700)
2023-09-08 16:35:10 +01:00
Yu Watanabe
f483155917 wait-online: exit with success when all interfaces are ready or unmanaged
Previously, when neither '--any' nor '--interface' options specified,
at least one of the interfaces must be in configured state.
This patch makes wait-online exit with success even if all interfaces
are in unmanaged state.

This may break backward compatibility in a rare situation. But in most
cases, this typically not change anything, as at least one interface
is managed by networkd.service when it is enabled.

This is mostly for making wait-online gracefully handle the case that
networkd.service and wait-online.service are enabled by mistake. In such
situation, all interfaces are typically not managed.

Fixes #25813.

(cherry picked from commit ab3aed4a03)
2023-09-08 16:35:10 +01:00
Yu Watanabe
2ea9d28c76 udev: set ID_PATH properties for all pci, usb, and platform devices
Before c43ff248f9, the following line in
60-drm.rules also sets ID_PATH for all pci, usb, and platform devices:
===
ACTION!="remove", SUBSYSTEM=="drm", SUBSYSTEMS=="pci|usb|platform", IMPORT{builtin}="path_id"
===
Unfortunately, some existing rules rely on the unexpected behavior.
To keep the backward compatibility, let's set ID_PATH for them.

Fixes #28411.

(cherry picked from commit 6636b2b6bf)
(cherry picked from commit 971ff12380)
2023-09-08 16:35:10 +01:00
Daan De Meyer
f2ada831e4 fd-util: Use /proc/pid/fd instead of /proc/self/fd
Currently, we mount via file descriptors using /proc/self/fd. This
works, but it means that in /proc/mounts and various other files,
the source of the mount will be listed as /proc/self/fd/xxx. For other
software that parses these files, /proc/self/fd/xxx doesn't mean anything,
or worse, it means the completely wrong thing, as it will refer to one of
their own file descriptors instead.

Let's improve the situation by using /proc/pid/fd instead. This allows
processes parsing /proc/mounts to do the right thing more often than not.
One scenario where even this doesn't work if when containers are involved,
as with the pid namespace unshared, even /proc/pid/fd will mean the wrong
thing, but it's no worse than /proc/self/fd which will always means the wrong
thing.

This also doesn't work if we mount via file descriptor and then exit, as the pid will
be gone, but it does work as long as the process that did the mount is alive, which
makes it useful for systemd-dissect --with for example if the program we run in the
image wants to parse /proc/mounts.

(cherry picked from commit 4419735822)
(cherry picked from commit 8046167dc2)
(cherry picked from commit edf4a86f3d)
2023-09-08 16:35:10 +01:00
Daan De Meyer
ad54019a1d tree-wide: Always include <net/if.h> before related linux headers
Otherwise, we get redefinition errors if <net/if.h> is included later
on by another header.

(cherry picked from commit 2af02e6165)
(cherry picked from commit 49a3ecd71d)
(cherry picked from commit 299e6cd33b)
2023-09-08 16:35:10 +01:00
Daan De Meyer
bd7859a126 debug-generator: Use generator_add_symlink()
(cherry picked from commit bd6c95c00b)
(cherry picked from commit 0d1198a79c)
(cherry picked from commit 3621e136ad)
2023-09-08 16:35:10 +01:00
Lennart Poettering
1e8ebd9e7e logind: give better error messages when failing to attach devices to seats
When the user tries to attach a device lacking ID_FOR_SEAT they
currently get a very cryptic error message. Let's improve the situation
a bit. Still a bit cryptic maybe, but much less so.

Inspired-by: https://lists.freedesktop.org/archives/systemd-devel/2023-September/049469.html
Inspired-by: https://lists.freedesktop.org/archives/systemd-devel/2023-September/049484.html
Also-see: https://lists.freedesktop.org/archives/systemd-devel/2023-September/049470.html
Also-see: https://lists.freedesktop.org/archives/systemd-devel/2023-September/049489.html
(cherry picked from commit 08237f062e)
(cherry picked from commit 3126a5a5aa)
(cherry picked from commit 98584e89ad)
2023-09-08 16:35:10 +01:00
Yu Watanabe
29c801d2d7 icmp6-util: make icmp6_receive() accept the null source address
Fixes #29050.

(cherry picked from commit 4961f56646)
(cherry picked from commit fabdb2832d)
(cherry picked from commit 262ba9bba6)
2023-09-08 16:35:10 +01:00
Yu Watanabe
4ebd2c664d icmp6-util: several cleanups for icmp6_receive()
- Rename the argument for storing the sender address,
- allow to call it with NULL for ret_xyz,
- reduce needless copy of timestamp when the message does not have
  timestamp.

(cherry picked from commit 5121163832)
(cherry picked from commit 811edcef2d)
(cherry picked from commit bd96e3ace7)
2023-09-08 16:35:10 +01:00
Yu Watanabe
4efd9743f9 sd-ndisc,sd-radv: fix use of uninitialized value
When icmp6_receive() fails, then the source address is not initialized yet.

(cherry picked from commit 4674f407b2)
(cherry picked from commit 9dec95c8c5)
(cherry picked from commit 9f545c1aea)
2023-09-08 16:35:10 +01:00
Frantisek Sumsal
11d5deb7d3 shell-completions: code cleanup
(cherry picked from commit 05ebcbd5c5)
(cherry picked from commit 307a5e8ef4)
(cherry picked from commit 2cf4bbd373)
2023-09-08 16:35:10 +01:00
Christian Hergert
466bb430a4 oomd: avoid unnecessary wake-ups for ManagedOOMSwap
If there are no "ManagedOOMSwap" entries to monitor, then the event source
can be completely disabled. This scenario appears to be common and avoiding
the wake-ups can save idle energy consumption.

This was discovered while using Sysprof for various GNOME 45 performance
tuning. systemd-oomd goes from waking up a few times a second to no
wake-ups helping keep a laptop in deep(er) sleep.

Signed-off-by: Christian Hergert <chergert@redhat.com>
(cherry picked from commit b63beb4d28)
(cherry picked from commit 08d0b94e36)
(cherry picked from commit 6a163f1557)
2023-09-08 16:35:10 +01:00
msizanoen
cd6f8a9c87 login: Properly handle -EIO in session_leave_vt
session_leave_vt may be called after the VT device was hung up, which
will cause vt_release to fail with -EIO. This is known to cause an issue
with GNOME 44 on Fedora where gdm-session-worker sometimes freezes when
trying to switch to VT 1 after a `loginctl terminate-user` operation.

Fix this by reopening the VT in session_leave_vt if we get an -EIO.

(cherry picked from commit 99d4ad71b7)
(cherry picked from commit 1bfe066deb)
(cherry picked from commit c70dc59688)
2023-09-08 16:35:10 +01:00
Chris Patterson
e433c1e985 99-systemd.rules.in: tag PTP devices with systemd
Chronyd and similar time services, when using PTP devices, may need
the BindsTo/After directives to ensure the devices are available
before starting.  Tag PTP devices with systemd to allow for wider
adoption.

Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
(cherry picked from commit 23cbe90d7d)
(cherry picked from commit e3a69bdbc0)
(cherry picked from commit e94ddb830b)
2023-09-08 16:35:10 +01:00
Michael Vasseur
9f173a4692 pkg.m4 macro needs brackets
See documentation at: https://manpages.debian.org/testing/pkgconf/pkg.m4.7.en.html

Without this the macro was not always correctly resolved so the correct command was not used in the rest of the snippet.

(cherry picked from commit c91d636fad)
(cherry picked from commit 01841ae829)
(cherry picked from commit 1ab8d21988)
2023-09-08 16:35:10 +01:00
Zbigniew Jędrzejewski-Szmek
dd6d4d3530 man/gpt-auto-generator: avoid saying "negative" for boolean
Fixes #28928.

(cherry picked from commit 7abb0eef8f)
(cherry picked from commit 9d43d9e8c5)
(cherry picked from commit 41a3e30b12)
2023-09-08 16:35:10 +01:00
Daan De Meyer
f60488f72e Limit rlim_max in rlimit_nofile_safe() to nr_open
We might inherit a max rlim value that's larger than the kernel's
maximum (nr_open). This will cause setrlimit() to fail as the given
maximum is larger than the kernel's maximum. To get around this,
let's limit the max rlim we pass to rlimit() to the value of nr_open.

Should fix #28965

(cherry picked from commit f470dafddc)
(cherry picked from commit a980b83fe0)
(cherry picked from commit 30ce78cb1a)
2023-09-08 16:35:10 +01:00
Lennart Poettering
eb53438941 boot: explain why we refuse to edit kernel cmdline when we do so
(cherry picked from commit c4d281fa1a)
(cherry picked from commit 5f09b13339)
(cherry picked from commit b94677ee3d)
2023-09-08 16:35:10 +01:00
Lennart Poettering
cdc909df51 man: mention two more things logind does
Prompted by: #28902

(cherry picked from commit 1126841553)
(cherry picked from commit bec4bb92e2)
(cherry picked from commit 4e51e336c8)
2023-09-08 16:35:10 +01:00
Daan De Meyer
85600241d2 install: Drop install_info_may_process() from unit_file_get_default()
This currently makes unit_file_get_default() fail if the default
target is transient which shouldn't make us fail to get the default
unit.

(cherry picked from commit 3c1c52f2c9)
(cherry picked from commit a6bd20e3de)
(cherry picked from commit d651df3ab8)
2023-09-08 16:35:10 +01:00
Daan De Meyer
3d6ca6f524 parse-helpers: Add PATH_KEEP_TRAILING_SLASH
(cherry picked from commit ce60b3a40a)
(cherry picked from commit 979b2abbdd)
(cherry picked from commit d8cd17d109)
2023-09-08 16:35:10 +01:00
Daan De Meyer
fb9c443bd7 path-util: Add path_simplify_full()
Sometimes its useful to keep a trailing slash in the path so let's
add path_simplify_full() and a flag to do just that.

(cherry picked from commit 4541d045b2)
(cherry picked from commit ff45789ea3)
(cherry picked from commit c1b5f5b081)
2023-09-08 16:35:10 +01:00
Yu Watanabe
7bd90e5047 core/mount: disable timer event source when USEC_INFINITY
Setting USEC_INFINITY to timer event source should not cause any
problem. But, disabling timer event source should be preferable.

[zjs: simplify the call to sd_event_source_set_enabled()]

(cherry picked from commit 57d2b6a96f)
(cherry picked from commit 6b1346f1f0)
(cherry picked from commit 6d25022e36)
2023-09-08 16:35:10 +01:00
Daan De Meyer
c685e2c8e8 hostname: Make sure we pass error to bus_verify_polkit_async()
Fixes #28943

(cherry picked from commit b56ee69233)
(cherry picked from commit d38ba62059)
(cherry picked from commit 6691b54958)
2023-09-08 16:35:10 +01:00
Zbigniew Jędrzejewski-Szmek
55b733528d manager: fix error handling after failure to set up child
exec_child() is supposed to set *exit_status when returning failure.
Unfortunately, we didn't do that in two cases. The result would be:
- a bogus error message "Failed at step SUCCESS spawning foo: …",
- a bogus success exit status.

Bugs introduced in 390902012c and
ad21e542b2.

The code is reworked to add some asserts and not set exit_status in the caller
so that it's clearer (also to the compiler) that it needs to be set.

(cherry picked from commit 5fa01ac036)
(cherry picked from commit 063d67fe32)
(cherry picked from commit 33d1a10c6d)
2023-09-08 16:35:10 +01:00
Warren
8140bee6b0 p11kit: check the flags associated with the slot instead of flags associated with the token
The logic around checking PKCS11 tokens (used by systemd-cryptenroll) contains a bug.
The code is checking the flags field of a pkcs11 token_info structure against a set of flags defined for the pkcs11 slot_info structure. This PR changes the check so that the correct structure's flag field is being checked.
(Reference to the PKCS#11 spec:http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/os/pkcs11-base-v2.40-os.html, section CK_SLOT_INFO).

(cherry picked from commit 5007942477)
(cherry picked from commit 117fa69b71)
(cherry picked from commit c03d5f1ddb)
2023-09-08 16:35:10 +01:00
Mike Yuan
9c469166e3 sleep: clear EFI HibernateLocation if writing kernel config fails
Follow-up for f1f331a252

(cherry picked from commit 031a399d87)
(cherry picked from commit f2fad15239)
(cherry picked from commit 1a77552257)
2023-09-08 16:35:10 +01:00
Michael A Cassaniti
440e776d1f file-io: Fix copying sparse files
This change makes sure a data copy using copy_bytes() does not exceed the
max_bytes value when using COPY_HOLES and max_bytes stops before the next
data section.

(cherry picked from commit c2dfcbd48e)
(cherry picked from commit 7bfe3c6215)
(cherry picked from commit b923225dec)
2023-09-08 16:35:10 +01:00
Franck Bui
f3094f810d test-mountpoint-util: /root might be mounted
On openSUSE with BTRFS, /root has to be mounted as dedicated subvolume to avoid
restoring it when a rollback of the system happens.

(cherry picked from commit 487ae08b85)
(cherry picked from commit 5c3fa0cfee)
(cherry picked from commit c0a45a591c)
2023-09-08 16:35:10 +01:00
Lennart Poettering
e7d44dc462 coredump: fix error path
We must go through finish, to undo the destruction of the final elements
of the iovw properly.

(cherry picked from commit 946dc7c635)
(cherry picked from commit 10304c2787)
(cherry picked from commit 3a25191361)
2023-09-08 16:35:10 +01:00
Lennart Poettering
7cc3d1e341 coredump: explicitly document that in order to process a coredump we have to write it to disk first
Prompted by: #28740

(cherry picked from commit 85ec1b6efa)
(cherry picked from commit a5d9940957)
(cherry picked from commit 495f887e55)
2023-09-08 16:35:10 +01:00
Daan De Meyer
62c62cb2ae tree-wide: Fix -Wmaybe-uninitialized compilation warnings
(cherry picked from commit 7e48f3ba71)
(cherry picked from commit 550cd149c1)
(cherry picked from commit 8a5b93fbe6)
2023-09-08 16:35:10 +01:00
Maxim Mikityanskiy
37a8c57211 hwdb: Mute SW rfkill keys on MSI Wind U100
Kernel patch [1] fixed bugs in rfkill handling on MSI Wind U100. Now
that the HW rfkill reports the correct state, and the SW rfkill is
controllable from userspace, it's necessary to mute KEY_WLAN and
KEY_BLUETOOTH generated on HW rfkill state changes. Otherwise, the
userspace will react to these keys and toggle the SW rfkill as well,
which is not desired, because the user may end up with non-functional
radios if HW and SW rfkills are out of sync.

Blocking these keycodes doesn't impair user experience, because the
desktop environment can still react to HW rfkill events and act
accordingly (for example, show notifications).

While at it, use "unknown" instead of "reserved" to mute keys, to avoid
the "atkbd serio0: Unknown key pressed" flood in dmesg.

[1]: https://lore.kernel.org/all/20230721145423.161057-1-maxtram95@gmail.com/

(cherry picked from commit fa8216e206)
(cherry picked from commit 208a21833b)
(cherry picked from commit 883aab2e80)
2023-08-10 09:43:05 +01:00
Yu Watanabe
60eb6438ec veritysetup-generator: fix ordering of generated units
Fixes a bug introduced by 08b04ec7e7 and
953006dcb0.

Fixes #28725.

(cherry picked from commit 685e0dd192)
(cherry picked from commit 4bb0d3cf56)
(cherry picked from commit 0563c5ddd9)
2023-08-10 09:43:05 +01:00
Yu Watanabe
391528fb66 sd-dhcp-server: propagate error on parsing DHCP packet
Otherwise, we silently ignore the received packet and that makes hard to
debug issue.

(cherry picked from commit 809da721f0)
(cherry picked from commit 7483f75fa6)
(cherry picked from commit 132229d87a)
2023-08-10 09:43:05 +01:00
mordner
c3ec635648 man: fix typo in journalctl
(cherry picked from commit 653c90ec0e)
(cherry picked from commit b4b4caf09f)
(cherry picked from commit 6b1a3e05d0)
2023-08-10 09:43:05 +01:00
Fabian Vogt
6a6c5f6b50 units/initrd-parse-etc.service: Conflict with emergency.target
If emergency.target is started while initrd-parse-etc.service/start is queued,
the initrd-parse-etc job did not get canceled. In parallel to the emergency
units, it eventually runs the service, which starts initrd-cleanup.service,
which in turn isolates initrd-switch-root.target. This stops the emergency
units and effectively starts the initrd boot process again, which likely
fails again like the initial attempt. The system is thus stuck in an endless
loop, never really reaching emergency.target.

With this conflict added, starting emergency.target automatically cancels
initrd-parse-etc.service/start, avoiding the loop.

(cherry picked from commit 327cd2d3db)
(cherry picked from commit 72da03631a)
(cherry picked from commit 23b5306412)
2023-08-10 09:43:05 +01:00
Ronan Pigott
80be287dba zsh: reintroduce pattern argument to uncached verbs
The systemctl completion previously made use of PREFIX as a pattern
argument to list-unit-files and list-units. This had the problem of
erroneously filtering the results that were stored in the cache, and
erroneously filtering results that might have been requested according
to the users configuration (e.g. _correct completer, certain
matcher-lists or tag-orders, etc.).

Unfortunately, the runtime of list-unit-files increases when no pattern
argument is provided, and systemctl show, used to filter those units,
can become unacceptably slow when provided with too many units to
describe.

Let's re-introduce the pattern argument to list-unit-files and
list-units where necessary in order to alleviate these bottlenecks
without poisining the cache. A 'use-pattern' style is introduced that
may be used to disable this behavior if it is undesired. We can still
expect that certain completions, like `systemctl start <TAB>` will be
slow, like before. To fix this we will need systemd to learn a more
efficient way of filtering the units than parsing systemctl show.

(cherry picked from commit 2cbda74862)
(cherry picked from commit dfc0445cb8)
(cherry picked from commit 7ca3cae97b)
2023-08-10 09:43:05 +01:00
Ronan Pigott
af20c4f05c zsh: use sys_really_all_units for non-template names
The systemctl invocations used for these completions match the ones used
for the _sys_really_all_units parameter, so we should really just use
the cached parameter rather than recomputing the result.

(cherry picked from commit c8e2cd79c1)
(cherry picked from commit 9814972198)
(cherry picked from commit f664081482)
2023-08-10 09:43:05 +01:00
Daan De Meyer
4ed6a3191f test-user-util: Drop tty check in gid_to_name() test
The tty user is not guaranteed to exist, so let's remove the dependency
from the test.

(cherry picked from commit a1fedc613f)
(cherry picked from commit 865f0d6e76)
(cherry picked from commit a99dfdca88)
2023-08-10 09:43:05 +01:00
Daan De Meyer
9ae6c41c40 tmpfiles: Consider ENOPKG as information not available
We already handle the case where /etc/machine-id is empty. Let's make
sure we also handle the case where /etc/machine-id is "uninitialized".

(cherry picked from commit 5dd814d7cd)
(cherry picked from commit faaa0ee5e9)
(cherry picked from commit d0a3467f47)
2023-08-10 09:43:05 +01:00
Luca Boccassi
5090681624 portablectl: fix regression when using --force without extension parameters
c18f4eb9e9 made it possible to use --force with various verbs, by
going through the newer D-Bus methods. Except it didn't, as it regressed
during PR review refactorings, and nobody noticed because there were no
tests for it. Fix it, and add tests.

Follow-up for c18f4eb9e9

(cherry picked from commit bdfa3f3a5c)
(cherry picked from commit 0f27d7b9f9)
(cherry picked from commit 8f3ec30c46)
2023-08-10 09:43:05 +01:00
Mike Yuan
d6068860d9 man/systemd.unit: DefaultTimeoutStartSec= -> DefaultDeviceTimeoutSec=
for device unit job timeouts

Follow-up for #24044

(cherry picked from commit 83d373d213)
(cherry picked from commit a5e5d6d64e)
(cherry picked from commit 4d79082c00)
2023-08-10 09:43:05 +01:00
Antonio Alvarez Feijoo
1db9a188e9 man/systemd-fsck@.service: clarify passno and noauto combination in /etc/fstab
Fixes #28657

(cherry picked from commit 000680a68d)
(cherry picked from commit 9c1b5911af)
(cherry picked from commit af6c953148)
2023-08-10 09:43:05 +01:00
Khem Raj
2adcfe6d11 include missing sys/file.h for LOCK_EX
(cherry picked from commit ac8db36cbc)
(cherry picked from commit 6b03b53bcc)
(cherry picked from commit af9df5f778)
2023-08-10 09:43:05 +01:00