Commit Graph
90212 Commits
Author SHA1 Message Date
dongshengyuan 2fbb73cb92 boot/random-seed: create \loader\ dir if missing when seeding
When the random seed file doesn't exist but we have good entropy
(seeded_by_efi=true), we attempt to create it. This requires a handle
to the \loader\ directory, which may not exist on systems using
UKI+EFISTUB without systemd-boot installed.

Obtain the directory handle by first trying a read-only open; if that
returns EFI_NOT_FOUND, create the directory. We deliberately avoid
requesting write access on an already-present directory because some
firmware implementations return EFI_INVALID_PARAMETER for a
WRITE|CREATE open on an existing directory — this would be logged at
LOG_ERR and abort seed creation on systems where \loader\ exists but
random-seed does not (the normal systemd-boot layout).

Once a handle to \loader\ is obtained, open the seed file relative to
that handle rather than using the full path from root.

Introduced-by: c0e7046c17 ("boot: log about RO I/O errors at debug level.")
Fixes: #42801
Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
2026-06-30 13:26:59 +01:00
Lennart Poettering 2dc228b127 update TODO 2026-06-30 13:51:55 +02:00
Ronan Pigott 7eed8858d7 run: do not munge user.slice with --slice-inherit
When using --slice-inherit, setting arg_slice would inadvertently munge
user.slice into the current user slice, usually producing a slice name
like user-1000-user.slice. This is treated as a user-UID slice by
user-.slice.d/10-defaults.conf, resulting in a strange description:
literally "User slice for UID user" (instead of an actual user UID).

Keep arg_slice empty when using --slice-inherit so that we actually
inherit from the relevant slice instead of a munged version.

Fixes: #42601
2026-06-30 09:51:05 +01:00
Luca Boccassi 8032290a98 luo-util: use new LIVEUPDATE_SESSION_GET_NAME ioctl to get session name if available
Added in kernel 7.2. Fallback can be removed once baseline
moves above. Ubuntu 26.04 uses 7.0.
2026-06-30 09:15:58 +01:00
Luca Boccassi ef5ef5544a Import linux/liveupdate.h UAPI header from 7.2-rc1 2026-06-30 09:15:58 +01:00
Syed Mohammed Nayyar 778c0e3a6c portable: leave room for trailing NUL in metadata receive buffer
receive_portable_metadata() reads each item into a stack buffer of
PATH_MAX + NAME_MAX + 2 bytes, passes the full sizeof() as the recv
iovec length, and then NUL-terminates with iov_buffer[n] = 0. recvmsg()
can return n equal to the buffer size, so the terminator is written one
byte past the end.

Grow the buffer by one byte and cap the iovec at sizeof - 1, so a full
record is still received and the trailing NUL always fits, matching the
coredump-receive.c reader.
2026-06-30 09:18:18 +02:00
dongshengyuan b0d48e096c man: document that $XDG_CONFIG_HOME affects environment.d lookup path
Align the documentation with the actual behavior: if $XDG_CONFIG_HOME is
set to an absolute path in the user service manager environment, it takes
precedence over the default ~/.config/ when locating environment.d files.
Also note the bootstrapping limitation that variables defined inside
environment.d files are not yet available when the generator runs.

Fixes: #42777
Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
2026-06-30 09:00:11 +02:00
Yu Watanabe 25714364a9 locale-util: drop libintl dependency
Both glibc and musl provides dgettext(). Hence it is not necessary to
use libintl.so provided by gettext.

This partially reverts 590e226437,
fully reverts commit e6e65dc261 and
bd19ffd9cb.

Then, introduce minimal libintl.h for musl build, to avoid using
libintl.h by gettext, which is typically installed on musl-based
build systems.
2026-06-29 23:22:41 +09:00
Luca Boccassi 04c0b735a7 test: make TEST-07-PID1.issue-14566 more robust (#42798)
e.g.:
https://artifacts.dev.testing-farm.io/f5150e83-eccf-4d84-aa8b-ff25cd7a3cb4/
2026-06-29 15:16:39 +01:00
Luca Boccassi 2d567f7db8 shared/varlink: fix license of varlink-io.systemd.Udev.c
Sources in src/shared need to be licensed LGPL-2.1-or-later, not
GPL-2.0-or-later, which is the license for src/udev. Fix it.

Follow-up for 2f0aa9a804
2026-06-29 13:03:20 +01:00
Luca Boccassi 58d6d403ce test: drop ASAN workaround in TEST-07-PID1.issue-14566
https://bugzilla.redhat.com/show_bug.cgi?id=2098125 was marked as
fixed some years ago, so it should be safe to run this test again
now.

Follow-up for 11562ee585
2026-06-29 12:06:33 +01:00
Luca Boccassi 682a42891f test: use /run/ for temporary files in TEST-07-PID1.issue-14566
And delete the file before starting, to be safe against reruns

Follow-up for c1566ef0d2
2026-06-29 12:03:57 +01:00
Luca Boccassi e9482b9ebb test: make TEST-07-PID1.issue-14566 more robust
The test slept a fixed 4s after starting the service, then read the
child PID from /leakedtestpid. On a loaded host the executor had not
exec'd the script yet:

[ 1571.079978] TEST-07-PID1.sh[17329]: + systemctl start issue14566-repro
[ 1571.079978] TEST-07-PID1.sh[17329]: + sleep 4
[ 1571.079978] TEST-07-PID1.sh[17329]: + systemctl status issue14566-repro
[ 1562.350438] systemd[1]: init.scope: Child 17296 belongs to init.scope.
[ 1571.081084] TEST-07-PID1.sh[17333]: ● issue14566-repro.service - Issue 14566 Repro
[ 1571.081084] TEST-07-PID1.sh[17333]:      Loaded: loaded (/usr/lib/systemd/tests/testdata/TEST-07-PID1.units/issue14566-repro.service; static)
[ 1571.081084] TEST-07-PID1.sh[17333]:     Drop-In: /usr/lib/systemd/system/service.d
[ 1571.081084] TEST-07-PID1.sh[17333]:              └─10-timeout-abort.conf
[ 1571.081084] TEST-07-PID1.sh[17333]:      Active: active (running) since Mon 2026-06-29 06:19:07 UTC; 4s ago
[ 1571.081084] TEST-07-PID1.sh[17333]:  Invocation: b3356aa5fff24eee85e302250ecb06b1
[ 1571.081084] TEST-07-PID1.sh[17333]:    Main PID: 17331 (9)
[ 1571.081084] TEST-07-PID1.sh[17333]:       Tasks: 1 (limit: 4468)
[ 1571.081084] TEST-07-PID1.sh[17333]:      Memory: 768K (peak: 768K)
[ 1571.081084] TEST-07-PID1.sh[17333]:         CPU: 1ms
[ 1571.081084] TEST-07-PID1.sh[17333]:      CGroup: /system.slice/issue14566-repro.service
[ 1571.081084] TEST-07-PID1.sh[17333]:              └─17331 systemd-executor --deserialize 66 --log-level debug,console:info --log-target journal
[ 1562.350492] systemd[1]: Child 17297 ((sd-close)) died (code=exited, status=0/SUCCESS)
[ 1571.082379] TEST-07-PID1.sh[17334]: ++ cat /leakedtestpid
[ 1571.082379] TEST-07-PID1.sh[17334]: cat: /leakedtestpid: No such file or directory

Make the service Type=notify and notify readiness after writing the PID
file, and wait for the service to go inactive in a timeout loop instead
of fixed sleeps.

Follow-up for c1566ef0d2
2026-06-29 12:03:40 +01:00
Luca Boccassi 14d0b77287 mkosi: fix license of mkosi.finalize
Every mkosi file/script is LGPL-2.1-or-later, but this one is CC-0,
fix it

Follow-up for 858e59c82c
2026-06-29 11:54:19 +01:00
wangzhaohui 104750fd60 shell-completion: add missing commands and options to timedatectl zsh
The zsh completion for timedatectl was missing three commands ('show',
'ntp-servers', 'revert') and five options (--monitor, -p/--property=,
-a/--all, --value, -P) that are already present in the bash completion,
documented in the man page, and implemented in the binary.

Fixes #16507
2026-06-29 10:35:13 +01:00
dongshengyuan e0e62a33bb logind: fix typo in reboot-to-boot-loader-entry path
SetRebootToBootLoaderEntry on non-EFI systems wrote the boot loader
entry name to /run/systemd/reboot-boot-to-loader-entry (wrong order),
while the getter and unlink both use the correct path
/run/systemd/reboot-to-boot-loader-entry.

The written value was never read back, silently breaking the feature
on non-EFI systems.

Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
2026-06-29 17:46:03 +09:00
dongshengyuan 99b3bbb4c0 journal-verify: fix offset reported for tail hash mismatch
After walking a hash chain, the loop exits with p == 0. The error()
call for a tail_hash_offset mismatch passed p as the file offset,
printing 0000000000000000 instead of the actual last data object.

Pass 'last' instead, which holds the offset of the final chain entry.

Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
2026-06-29 17:46:03 +09:00
Arif Budiman 82577b363a po: Translated using Weblate (Indonesian)
Currently translated at 100.0% (286 of 286 strings)

Co-authored-by: Arif Budiman <arifpedia@gmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/id/
Translation: systemd/main
2026-06-29 09:29:06 +01:00
Yu Watanabe 8b8d819944 Revert "mkosi: Grow the root partition on boot"
This reverts commit 7f33ee8bb4.

The file is located outside mkosi/ subdirectory, hence currently unused.
If this is moved to mkosi/ subdirectory, the config conflicts with
TEST-58-REPART. Let's remove it at least now, and reintroduce it later
at correct place with test adjustment if this is really useful.
2026-06-28 10:25:43 +01:00
Lennart Poettering 339dcb2af2 cryptenroll: add interactive mode and Varlink IPC API (#42380)
Replaces: #31096
Fixes: #36298
2026-06-28 08:47:27 +02:00
Ronan Pigott 313e2a38ab run: make custom slice imply XDG_SESSION_CLASS=none
--slice and --slice-inherit are intended to make the new service unit
part of a specific slice. Logind is incompatible with that goal, as a
session of any kind will prompt logind to immediately yoink the new
command from the service unit into a new session scope, which does not
inherit from run0's own slice. The use can still explicitly request a
session with --setenv=XDG_SESSION_CLASS=<class>.

Also make --slice and --slice-inherit conflict with --lightweight and
--area, which depend on logind to be effective.
2026-06-28 13:48:02 +09:00
dongshengyuan c99674a408 numa: add support for preferred-many and weighted-interleave policies
Add support for two newer NUMA memory policies:

- MPOL_PREFERRED_MANY (Linux 5.15): like MPOL_PREFERRED but accepts
  a set of nodes instead of a single node, falling back to all nodes
  if preferred nodes cannot satisfy the allocation.

- MPOL_WEIGHTED_INTERLEAVE (Linux 6.9): like MPOL_INTERLEAVE but
  distributes pages across nodes proportionally to per-node weights
  configured via /sys/kernel/mm/mempolicy/weighted_interleave/.

On kernels that do not support the requested policy, set_mempolicy()
returns EINVAL. We convert EINVAL to EOPNOTSUPP only for the two new
policies (MPOL_PREFERRED_MANY, MPOL_WEIGHTED_INTERLEAVE), so that a
bad NUMAMask= for already-supported policies still fails the service
rather than being silently ignored.

The NUMA subsystem being absent (ENOSYS) continues to be handled
silently at debug level, as before.

Varlink serialization uses json_underscorify() on an owned copy of
the policy name string to convert hyphenated names to the underscore
form declared in the IDL enum, avoiding mutation of the read-only
static string table.

Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
2026-06-28 13:40:07 +09:00
Jouke Witteveen 5a03efc9c1 Correct allocation size computation in xescape_full
Amends 17260a9 (#42524).

Since there is no return path with an incomplete write, the effect of
the memset block was unobservable, so drop it.
2026-06-28 12:52:47 +09:00
Frantisek Sumsal 7804fd182c vmspawn: complain loudly if we can't prepare a unix socket for virtiofsd
I couldn't convince vmspawn to start a VM on a Fedora image I just
downloaded, and it was pretty light on any useful details:

$ build/systemd-vmspawn --image ~/Downloads/Fedora-Server-Guest-Generic-Rawhide-20260627.n.0.x86_64.qcow2 --image-format=qcow2 --bind-ro=/tmp/bar; echo $?
░ Spawning VM Fedora-Server-Guest-Generic-Rawhide-20260627.n.0.x8664.qcow2 on /home/mrc0mmand/Downloads/Fedora-Server-Guest-Generic-Rawhide-20260627.n.0.x86_64.qcow2.
░ Press Ctrl-] three times within 1s to kill VM.
1

Turns out that the unix socket path vmspawn generates for the virtiofsd
socket is too long. Let's relay this information to the user as well to
make debugging this a little less painful:

$ build/systemd-vmspawn --image ~/Downloads/Fedora-Server-Guest-Generic-Rawhide-20260627.n.0.x86_64.qcow2 --image-format=qcow2 --bind-ro=/tmp/bar
░ Spawning VM Fedora-Server-Guest-Generic-Rawhide-20260627.n.0.x8664.qcow2 on /home/mrc0mmand/Downloads/Fedora-Server-Guest-Generic-Rawhide-20260627.n.0.x86_64.qcow2.
░ Press Ctrl-] three times within 1s to kill VM.
Failed to prepare unix socket '/run/user/1000/systemd/vmspawn/Fedora-Server-Guest-Generic-Rawhide-20260627.n.0.x8664.qcow2/sock-9594581dcf598992': File name too long
2026-06-28 12:52:02 +09:00
Yu Watanabe dc416f5825 journal: replace libgcrypt with openssl (#42695) 2026-06-28 03:45:22 +09:00
Lennart Poettering 2868b61746 update TODO 2026-06-27 17:28:39 +02:00
Lennart Poettering 65079c0a39 shell-completion: catch up with cryptenroll command line 2026-06-27 17:28:39 +02:00
Lennart Poettering 2d691049ae test: cover the io.systemd.CryptEnroll Varlink interface
Extend the existing systemd-cryptenroll test with varlinkctl invocations
equivalent to the command line ones: enrolling a recovery key and passwords
(unlocking via a key file by path and via a passed file descriptor), listing
slots, combining enrollment with a type-based wipe, and the negative cases
(ListSlots without 'more', and the pkcs11/tpm2 mechanisms that are not part of
the EnrollMechanism allowlist).
2026-06-27 17:28:39 +02:00
Lennart Poettering 47dc8abf8b cryptenroll: refuse reading a key longer than 4 MiB
If we open this up to external processes let's tighten rules and refuse
reading more than 4 MiB as key, after all this is locked memory.
2026-06-27 17:28:39 +02:00
Lennart Poettering 0089a46b6b cryptenroll: add interactive --firstboot enrollment wizard
Add a --firstboot mode that interactively walks the user through enrolling a
passphrase, a recovery key, or a FIDO2 token, with one menu entry per suitable
token currently plugged in (driven by a new fido2_enumerate_devices() helper).
Pressing enter at the top-level menu leaves the volume unchanged; for each
already-enrolled credential type the wizard offers to wipe it as part of the
operation. It populates the same EnrollContext the command line and Varlink
paths use, so the actual enrollment goes through the shared enroll_now() path.

A companion --prompt-suppress= option takes a list of slot types: if a slot of
any listed type already exists, the wizard does nothing and exits successfully.
This lets it be hooked into the boot process while staying quiet once the
system has been set up.

The accompanying systemd-cryptenroll-firstboot.service runs this from the
initrd, after systemd-repart has created the encrypted volume but before we
transition to the host, suppressing itself once a password, recovery key or
FIDO2 token is enrolled. To make that work, determine_default_node() now looks
below /sysroot/ when running in the initrd, since the host file systems aren't
at their final location yet.

While the wizard is active it draws the same installer-style chrome (blue bars
at the top and bottom of the terminal) as systemd-sysinstall, using the shared
prompt_loop_yes_no() helper for its wipe confirmations.

Honours the systemd.firstboot= kernel command line option.

Fixes: #36298
2026-06-27 17:28:39 +02:00
Lennart Poettering e298331876 cryptenroll: add --unlock-headless as a new pseudo-unlock mechanism
THis simply tries TPM2 if available, and falls back to empty password.
2026-06-27 17:28:39 +02:00
Lennart Poettering 5f2d4fb623 cryptenroll: add --unlock-empty to unlock via an empty password 2026-06-27 17:28:39 +02:00
Lennart Poettering 2bbcf6c66f cryptenroll: move load_volume_key_keyfile() to cryptenroll-password.c
Conceptually a keyfile and a password are pretty much the same thing,
hence put them in the same file.
2026-06-27 17:28:39 +02:00
Lennart Poettering 0df41e9329 cryptenroll: expose enrollment as an io.systemd.CryptEnroll Varlink service
Add a Varlink interface for systemd-cryptenroll, building on the EnrollContext
introduced previously. A single Enroll method covers password, recovery-key and
FIDO2 enrollment; PKCS#11 and TPM2 are not exposed for now (they are not
part of the EnrollMechanism allowlist, so the generic InvalidParameter error
applies). A ListSlots method enumerates the currently enrolled keyslots.

The dispatcher populates the same EnrollContext the command line uses and then
runs the shared enroll_now()/prepare_luks()/wipe_slots() paths, so both
front-ends behave identically. FIDO2 enrollment that requires user presence
reports an imminent touch via a non-terminating "state":"touch" reply when the
caller passes 'more'. Credential material (password, FIDO2 PIN, recovery key)
is handled as sensitive, and key files may be passed either by path or as an
fd index.

The server is allocated root-only plus caller's-own-UID, with the listening
socket created in 0644 mode.

Replaces: #31096
2026-06-27 17:28:39 +02:00
Lennart Poettering fd3fb3a85c cryptenroll: add an "unlock_password" field to ExecContext
This is preparation for the Varlinkification, as then we want to pass
the password in via IPC instead of prompting the user.

Note that this only adds the field, and applies it, but never actually
sets it. That's for the varlinkification later.
2026-06-27 17:28:39 +02:00
Lennart Poettering 39d08de81b cryptenroll: collect all enrollment parameters in an EnrollContext
Introduce an EnrollContext structure that carries everything the enrollment
and unlocking helpers need, and route all enroll_*()/load_volume_key_*()/
wipe_slots() calls through it. The command line still populates the existing
arg_* globals as before; once parsing is complete they are copied into a
self-contained EnrollContext (which owns its strings/arrays) and the rest of
the code only ever reads from the context.

This is preparation for the upcoming varlinkification of systemd-cryptenroll:
a Varlink dispatcher (and later an interactive first-boot wizard) can populate
the very same EnrollContext without going through the arg_* parsing layer.

To support non-interactive (e.g. Varlink) callers, the context carries an
'interactive' flag: when false, every credential prompt is disabled and the
helpers fail with -ENOPKG (the established "querying disabled via headless"
code) instead of blocking on a tty. Passwords, FIDO2 PINs and PKCS#11 PINs are
all covered, and an optional FIDO2 PIN can be supplied directly via the
context. enroll_recovery() additionally grows a quiet mode that returns the
recovery key instead of printing it.

This also adds one new field to EnrollContext which didn't exist before:
the unlock_password is useful for the Varlink hookup later.

No change in command line behaviour.
2026-06-27 17:28:39 +02:00
Lennart Poettering 846b0efb04 mute-console: allow NULL being passed 2026-06-27 17:28:39 +02:00
Lennart Poettering 77ee077dfe shared: add a generic prompt_loop_yes_no() helper
Factor a yes/no variant of prompt_loop() out into prompt-util.[ch], so the
various interactive tools can share a single implementation, and convert
systemd-sysinstall's installation confirmation question over to it.
2026-06-27 17:28:39 +02:00
Yu Watanabe ca5100dbad gcrypt-util: drop several unused definitions 2026-06-28 00:26:56 +09:00
Yu Watanabe 6461c1b017 tree-wide: drop gcrypt dependency from all binaries except for unit tests
With this change, gcrypt dependency is not mandatory. Hence, allow to build
systemd even when -D gcrypt=enabled but gcrypt devel package is not installed.
2026-06-28 00:26:56 +09:00
Yu Watanabe 005e94da17 journal: replace gcrypt with openssl 2026-06-28 00:26:56 +09:00
Yu Watanabe 7fae5c5bcc fsprg-openssl: rewrite fsprg with OpenSSL
This introduce OpenSSL port of fsprg, which is implemented by using libgcrypt.
2026-06-28 00:26:56 +09:00
Yu Watanabe 2b2ca3d7cb crypto-util: load several more functions from libcrypto.so
They will be used in later commits.
2026-06-28 00:26:56 +09:00
Yu Watanabe 73568eb5b5 crypto-util: sort symbols 2026-06-28 00:26:29 +09:00
Yu Watanabe d956568160 test-fsprg: add unit test for FSPRG 2026-06-28 00:20:38 +09:00
Yu Watanabe e8d21b76f0 test-journal-verify: replace HAVE_GCRYPT ifdef with journal_auth_supported() 2026-06-28 00:00:11 +09:00
Yu Watanabe a09feb7958 sd-journal: allow to verify sealed journals even when sealing support is disabled
Of course, if disabled, seal tags cannot be verified, hence the check is skipped.
2026-06-28 00:00:11 +09:00
Yu Watanabe 2e077b57a7 sd-journal: allow to read sealed journal files when sealing is not supported 2026-06-28 00:00:11 +09:00
Yu Watanabe 24c4729198 sd-journal: drop libgcrypt dependency from libsystemd
This introduce a vtable for journal tagging feature in sd-journal,
and makes libgcrypt dependent features loaded by users (journald,
journalctl, journal-remote, and unit tests) when necessary.
2026-06-28 00:00:11 +09:00
Yu Watanabe 14236c019b journal-authenticate: save mmaped size rather than file size field in the file 2026-06-28 00:00:11 +09:00