1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-11 04:58:19 +03:00

66299 Commits

Author SHA1 Message Date
Daan De Meyer
a980b83fe0 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 f470dafddcd688c3ea6031d4bbcbf934fd094711)
2023-09-06 16:09:43 +02:00
Daan De Meyer
ce7dda2184 mkfs-util: Set FORK_REOPEN_LOG
We set FORK_CLOSE_ALL_FDS, so we should also set FORK_REOPEN_LOG to
reopen the log in the child process so we don't miss any logging
messages.

(cherry picked from commit fbc6a7557120fbb97d781a5d2c640a3c55c3000f)
2023-09-06 16:06:41 +02:00
Alvin Alvarado
cd66aed7d9 man: Fix typo in config file example for ukify
or else it would output 'Unknown config setting [UKI] SecureBootCerificate=' or just an error outright if not overrode.

(cherry picked from commit c766e05f292182b73e52db7044decc125c453d6f)
2023-09-06 16:06:41 +02:00
Lennart Poettering
5f09b13339 boot: explain why we refuse to edit kernel cmdline when we do so
(cherry picked from commit c4d281fa1a6a99208daef2b80f57bcad37a6eaab)
2023-09-06 16:06:41 +02:00
Lennart Poettering
bec4bb92e2 man: mention two more things logind does
Prompted by: #28902

(cherry picked from commit 1126841553a28f22eb6bc55eeed8af8d98610f71)
2023-09-06 16:06:41 +02:00
Daan De Meyer
a6bd20e3de 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 3c1c52f2c9e67fe60b36325be7292ff0baaf808b)
2023-09-06 16:06:41 +02:00
Lennart Poettering
93b886fcc2 tpm2-util: give PCR 6 a name too
The specs call this TCG PC Client Platform Firmware Profile
Specification says this PCR is owned by the Host Platform Manufacturer,
at various places. Hence let's give it that name.

(cherry picked from commit b060b9a492e161d0f59721b9a22cce528c967a40)
2023-09-06 16:06:41 +02:00
Mike Yuan
01b7520be4 core/socket: don't consider service active when in SERVICE_AUTO_RESTART_QUEUED
Follow-up for 09d04ad325473e05e23e6ba8382d7de1dd819bda

Fixes #28856

(cherry picked from commit c068650fcfc69aebb35be1c71f35dbc25b22030a)
2023-09-06 16:06:41 +02:00
Daan De Meyer
562a7fd8e5 repart: Make sure we keep trailing slashes in ExcludeFiles=
We conditionalize behavior based on whether these paths have trailing
slashes or not, so let's make sure we keep them intact.

(cherry picked from commit d10eccbd7717441538859e0a0c68ecc61289bb69)
2023-09-06 16:06:41 +02:00
Daan De Meyer
979b2abbdd parse-helpers: Add PATH_KEEP_TRAILING_SLASH
(cherry picked from commit ce60b3a40a89bb5d116003343c56c55a0da9f8fb)
2023-09-06 16:06:41 +02:00
Daan De Meyer
ff45789ea3 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 4541d045b2cc2834add853f06293d4474ac403e4)
2023-09-06 16:06:41 +02:00
Yu Watanabe
6b1346f1f0 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 57d2b6a96f997c23bed37d74c6da087fb06081d2)
2023-09-06 16:06:41 +02:00
Yu Watanabe
918f6a4627 Revert "mount: check right before invoking /bin/umount if it makes sense"
This reverts commit 1483892a421ca34bc841a8e8b1f385744c0407ed.

As the commit says, it does not solve the race. Moreover, it introduces
an regression #28410.

Also, checking by `path_is_mount_point()` may trigger automount. From
statx(2),
> AT_NO_AUTOMOUNT
>     Don't automount the terminal ("basename") component of pathname
>     if it is a directory that is an automount point.
Similar statements can be found in fstatat(2), which is used in the
fallback call for statx() in glibc, and name_to_handle_at(2), which is
used as the fallback when statx() failed.
So, `path_is_mount_point()` may _do_ trigger automount for parent paths.
That should be avoided especially on shutdown.

The original issue #25527 that is 'fixed' by the commit is not serious,
and should be fixed by making umount command handle path gracefully:
https://github.com/util-linux/util-linux/issues/2132

Fixes #28410.

(cherry picked from commit e323d2e463270ef556aeb753455bdf01a22af46d)
2023-09-06 16:06:41 +02:00
Daan De Meyer
9a95e81676 meson: Use rsync to copy test data directories
install_subdir() does not copy symlinks but copies the file they
point to. We also get a very ugly warning in the meson install
output:

"""
Warning: trying to copy a symlink that points to a file. This will copy the file,
but this will be changed in a future version of Meson to copy the symlink as is. Please update your
build definitions so that it will not break when the change happens.
"""

Let's fix both problems at once by using rsync which does the right
thing. Verified by running systemd-dissect --mtree on both the install
output before and after and all the symlinks are now correctly preserved.

(cherry picked from commit cc2a0d85d2733b0a3285e16ca8a869cad84a03ec)
2023-09-06 16:06:41 +02:00
Daan De Meyer
d38ba62059 hostname: Make sure we pass error to bus_verify_polkit_async()
Fixes #28943

(cherry picked from commit b56ee692334231f0312c2fd142b9f2a84da14ac9)
2023-09-06 16:06:41 +02:00
David Tardon
3f5e2f806d bus-polkit: don't propagate error from polkit
An error reply from polkit is a valid case and should not be propagated
as failure of async_polkit_callback(). It should only be saved here.
It'll be returned by bus_verify_polkit_async() later, when it's called
for the same method again.

Follow-up for #26365.

(cherry picked from commit 45b1c015b0eaff65b1f34e0ba8d072939eaa3926)
2023-09-06 16:06:41 +02:00
Lennart Poettering
7ddbacbaa5 polkit: move asserts up, so that they cover all reply codepaths
(cherry picked from commit c1b2e1a89a54dc5ec51f5f1c6257a2956782b296)
2023-09-06 16:06:41 +02:00
Emanuele Giuseppe Esposito
154b83bb6c systemd-stub: ignore EFI shell unauthenticated kernel command line if we are in confidential vms
(cherry picked from commit fab0eeb72bb5e1fdf3304cc6e01ebf5d7677c124)
2023-09-06 16:06:41 +02:00
Daan De Meyer
63b1a8f023 repart: Default to swap format for swap partitions
(cherry picked from commit 973d6be4026340e31fc8ceda8e98b7fc16df4b71)
2023-09-06 16:06:41 +02:00
Zbigniew Jędrzejewski-Szmek
063d67fe32 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 390902012c5177b6b01bc634b2e9c704073d9e7d and
ad21e542b20f0fb292d1958d3a759bf3403522c2.

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 5fa01ac0369f0f225ab1e1f90f6b7058cc4deaaf)
2023-09-06 16:06:41 +02:00
Luca Boccassi
6f28774f39 core: stage /run/host/os-release with a symlink to avoid possible race condition
If someone reads /run/host/os-release at the exact same time it is being updated, and it
is large enough, they might read a half-written file. This is very unlikely as
os-release is typically small and very rarely changes, but it is not
impossible.

Bind mount a staging directory instead of the file, and symlink the file
into into, so that we can do atomic file updates and close this gap.
Atomic replacement creates a new inode, so existing bind mounts would
continue to see the old file, and only new services would see the new file.
The indirection via the directory allows to work around this, as the
directory is fixed and never changes so the bind mount is always valid,
and its content is shared with all existing services.

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

Follow-up for 3f37a82545d461ab

(cherry picked from commit 663e27564ff4529b04da0ddc96804eb4e084a043)
2023-09-06 16:06:41 +02:00
Warren
117fa69b71 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 5007942477ecfb69702f542cb6770ea4b5bc1e57)
2023-09-06 16:06:41 +02:00
Michael A Cassaniti
e624bc4484 sysupdate: Use sector size for partition size calculations
(cherry picked from commit eeee4861594f2827fb80d748535489f46ec036a4)
2023-09-06 16:06:41 +02:00
Daan De Meyer
fcf1ecf814 dissect-image: Fix mount_point_is_available()
We call dir_is_empty() to check if the directory is empty but don't
take the result into account when returning from the function.

(cherry picked from commit e36c6210b7e1509206514dccedb73f7a1a5c4de1)
2023-09-06 16:06:41 +02:00
Mike Yuan
f2fad15239 sleep: clear EFI HibernateLocation if writing kernel config fails
Follow-up for f1f331a252d22c15f37d03524cce967664358c5c

(cherry picked from commit 031a399d87de5a47d395bb12b70e112c83b02c3f)
2023-09-06 16:06:41 +02:00
Rahil Bhimjiani
0baa4866d5 man: kernel-install(8) add uki.conf in FILES & add ukify(1) in SEE ALSO
Signed-off-by: Rahil Bhimjiani <rahil3108@gmail.com>
(cherry picked from commit f5263dd09e428df42c3d3b12f7e8ca95121ef3ee)
2023-09-06 16:06:41 +02:00
Yu Watanabe
9d0b12ef44 man/rules: update man rules for systemd-tmpfiles-setup-dev-early.service
Follow-up for bb7f485f4bddd57bbf50739bafa43d127bab59d6.

(cherry picked from commit cf5d2df98665b4b11bd291d2dc5bd91a58ec5fd6)
2023-09-06 16:06:41 +02:00
Yu Watanabe
4e639ca0f1 units: introduce systemd-tmpfiles-setup-dev-early.service
This makes tmpfiles, sysusers, and udevd invoked in the following order:
1. systemd-tmpfiles-setup-dev-early.service
   Create device nodes gracefully, that is, create device nodes anyway
   by ignoring unknown users and groups.
2. systemd-sysusers.service
   Create users and groups, to make later invocations of tmpfiles and
   udevd can resolve necessary users and groups.
3. systemd-tmpfiles-setup-dev.service
   Adjust owners of previously created device nodes.
4. systemd-udevd.service
   Process all devices. Especially to make block devices active and can
   be mountable.
5. systemd-tmpfiles-setup.service
   Setup basic filesystem.

Follow-up for b42482af904ae0b94a6e4501ec595448f0ba1c06.

Fixes #28653.
Replaces #28681 and #28732.

(cherry picked from commit bb7f485f4bddd57bbf50739bafa43d127bab59d6)
2023-09-06 14:45:40 +02:00
Luca Boccassi
dbda80049d core: copy os-release with COPY_TRUNCATE
Otherwise if the os-release file shrinks between updates, there
will be a merge of the two.
Also remove redundant ENOENT check.

Follow-up for 3f37a82545d461ab

(cherry picked from commit bf85c2395e3ed5628b58f86a478e99132288130d)
2023-09-06 14:45:17 +02:00
Lennart Poettering
9d87299a67 man: don't claim BindPaths= file systems would remain "in memory", they are just kept "mounted"
Follow-up for: 947d836a6e86f1936250ff8e3c67fa33b92a597f

(I guess in the original patch authors usecase the root fs actually
*does* remain in memory, but that's a special case and does not belong
in the man pages this way).

(cherry picked from commit 579fbe5b789cbee10546f6274c39be311e71e49c)
2023-09-06 14:45:17 +02:00
Michael A Cassaniti
7bfe3c6215 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 c2dfcbd48e780e49bfc11f1c34077f6c98891e40)
2023-09-06 14:45:17 +02:00
Franck Bui
5c3fa0cfee 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 487ae08b85048f86e72e86d6c601d4c558b6cb8a)
2023-09-06 14:45:17 +02:00
Lennart Poettering
470be7a153 vconsole-setup: use "@kernel" rather than "kernel" as special string to leave keymap untouched
This is a magic string, and we should avoid stepping into the territory
of normal keymap names with that, given that users can pick names
otherwise freely.

Hence, prefix the name with a special char to avoid any namespace
issues.

Follow-up for: #28660

(cherry picked from commit bf77d59772722e96508df91bd24e1b6940b3edfb)
2023-09-06 14:45:17 +02:00
Lennart Poettering
10304c2787 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 946dc7c635f050129896d1515c08a81504af2421)
2023-09-06 14:45:17 +02:00
Lennart Poettering
5f72468e3c file-io: let's use offsetof() rather than sizeof() for determining EFI_FILE_INFO prefix size
The gnu-efi definition of the struct uses [1], our local one [0] to size
the filename array. Let's avoid an ambiguity and use offsetof() so that
this difference doesn't matter. Also, doing it this way makes very clear
to the read what happens here: it's a structure with a variable size
suffix.

(cherry picked from commit 490b4486a752d8d2a10eb4c10d5af523ea539f5e)
2023-09-06 14:45:17 +02:00
Lennart Poettering
a5d9940957 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 85ec1b6efadf3466bd1d265950f3d967a43cb1d0)
2023-09-06 14:45:17 +02:00
Franck Bui
9f0efc2047 test: testsuite-35.sh needs manual/test-session-properties to be installed on SUSE
(cherry picked from commit 372d40fb0315887ecffe163438b6ca0955618948)
2023-09-06 14:45:17 +02:00
Lennart Poettering
045ff3b47a man: let's tone down the recommendation to use Type=exec a bit
This is a follow-up for #28596.

I think the suggestion to use Type=exec uses too strong wording:
Type=exec has non-trivial drawbacks over Type=simple, and they deserve
to be mentioned.

Hence drop the <emphasis> and turn this around so that Type=exec is
*recommended*, but Type=simple is not expressly discouraged, because
there are plenty reasons to use it.

Add a brief discussion where Type=simple might be preferable.

Also, fix the outright unruth that Type=exec was the "simplest and
fastest", because it certainly is a lot, but not that.

(cherry picked from commit e5e900edcd3b245499379201072cbb69346e9798)
2023-09-06 14:45:17 +02:00
Lennart Poettering
9ab0cc68e8 bootctl: don't advertise systemd-efi-options in --help/man anymore
The command is deprecated, as per NEWS of 254. Let's go one step further
and remove it from the help text and man page, so that people are not
inspired to use it at this time anymore.

This is how we usually have done this before: remove it from visibility,
but support it for a while still.

(cherry picked from commit 0de0ed6e89823c8834a94682bfd5e366aee9930b)
2023-09-06 14:01:13 +02:00
Daan De Meyer
550cd149c1 tree-wide: Fix -Wmaybe-uninitialized compilation warnings
(cherry picked from commit 7e48f3ba71614604e2b7fbb5bcfdb1c848600e89)
2023-09-06 13:58:06 +02:00
Mike Yuan
699666e94d vconsole: support KEYMAP=kernel for preserving kernel keymap
Follow-up for #26089 and #28505

Currently, if default-keymap is not empty, there's no way
to ask vconsole-setup to retain the kernel keymap. Let's
accept a special value "kernel" for that purpose.

Addresses the problem mentioned in https://github.com/systemd/systemd/pull/28505#issuecomment-1663681665

(cherry picked from commit ef7f5baae8224960f78651e8a3cf4c1f1b870a31)
2023-09-06 13:54:29 +02:00
Maxim Mikityanskiy
208a21833b 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 fa8216e20605ff42054ee316201a13ac6cdd4cd1)
v254.1
2023-08-09 13:51:00 +02:00
Yu Watanabe
257c6f91b8 resolve: initialize 'current' when SD_RESOLVED_NO_STALE is set
Otherwise, the check below is always fail.
```
if (FLAGS_SET(query_flags, SD_RESOLVED_NO_STALE) && j->until_valid < current)
```

Follow-up for 5ed91481abea382dc486507556e5cdf0f36b796f.

(cherry picked from commit 6756b61626afc343f8b6824f41bef67bb442f1d7)
2023-08-09 13:51:00 +02:00
Yu Watanabe
507c4c7968 Revert "Revert "tmpfiles.d: adjust /dev/vfio/vfio access mode""
This reverts commit 33b91308c26ca5d512e43b6b32d596a2c9237d04.

The commit b42482af904ae0b94a6e4501ec595448f0ba1c06 dropped
'--exclude-prefix=/dev' from systemd-tmpfiles-setup.service. So, the
possibly later invocation of the service changes the permission set by
udevd.

As commmented in the head of this file, settings should be consistent
with udev rules. Only missing entry here is vfio. Let's re-add the
entry for the device.

Addresses https://github.com/systemd/systemd/pull/28681#issuecomment-1666949888.

(cherry picked from commit ca15b59f1f37cad54e82edb3042e8a035fc6ab18)
2023-08-09 13:51:00 +02:00
Yu Watanabe
6ed278526d udev: decrease devlink priority for encrypted partitions
Decrease devlink priority for encrypted partitions, and make the priority for
decrypted DM devices relatively higher. This is for the case that an encrypted
partition and its decrypted DM device have the same label.

(cherry picked from commit c4521fc17bb33d10bf5aca3f87f6a394dfecf423)
2023-08-09 13:51:00 +02:00
Yu Watanabe
4bb0d3cf56 veritysetup-generator: fix ordering of generated units
Fixes a bug introduced by 08b04ec7e72b7327b4803809732b1b8fce8dd069 and
953006dcb0a37a57aed0e762ff6289700e8689e8.

Fixes #28725.

(cherry picked from commit 685e0dd1924cce44327040b08a8980af2192bf59)
2023-08-09 13:51:00 +02:00
Yu Watanabe
7483f75fa6 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 809da721f0167f88234e55a342e82023019e2341)
2023-08-09 13:51:00 +02:00
Yu Watanabe
08c1aff483 resolve: ignore nameserver= and domain= kernel command line options without value
Otherwise, manager_parse_dns_server_string_and_warn() or
manager_parse_search_domains_and_warn() will trigger assertion.

(cherry picked from commit 91acee9906e973365109b1b1d5e880ced9aeae65)
2023-08-09 13:51:00 +02:00
mordner
b4b4caf09f man: fix typo in journalctl
(cherry picked from commit 653c90ec0e6f4d68b68938a20bd8cff492e7a666)
2023-08-09 13:51:00 +02:00
Fabian Vogt
72da03631a 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 327cd2d3db703555f8d572b4cd055fbe55e1068b)
2023-08-09 13:51:00 +02:00