Commit Graph
88088 Commits
Author SHA1 Message Date
Felix Pehla 89d705a892 man/fstab-generator: fix option list and make formatting consistent
Add "overlay", which is already mentioned further down below, to the
list of possible options.

Consistently use <literal> for possible values of systemd.volatile=,
rather than <param> or no special formatting.

Use yes/no rather than true/false as boolean since that is what's used
everywhere else and I'm already touching the lines anyway.
2026-04-20 09:39:35 +02:00
mukunda katta 5159388230 nspawn,shared/nsresource: fix copy-paste errno logging args
In nspawn.c's run_container() the child_netns_fd = receive_one_fd(...)
failure path logged 'r' instead of the negative errno returned in
child_netns_fd, so the actual error from receive_one_fd was being
overwritten by whatever 'r' happened to hold. The other receive_one_fd
call sites in the same function use the returned fd variable directly
(mntns_fd, etc.), so align this one.

In shared/nsresource.c's nsresource_add_cgroup() the cgroup_fd_idx =
sd_varlink_push_dup_fd(...) failure path logged userns_fd_idx, which
is the previous successful push's index, not the negative errno we
just got from pushing cgroup_fd. Log cgroup_fd_idx instead.

Both were flagged by static analysis (#41709) and match the immediately
preceding userns_fd-path pattern that was presumably copy-pasted.

Refs #41709.
2026-04-20 09:37:52 +02:00
Frantisek Sumsal 3297add538 compress: simplify the condition a bit
Simply mirror the format we've already established in
decompress_blob_zstd().
2026-04-20 09:37:13 +02:00
Frantisek Sumsal 35eb598af2 compress: gracefully handle a truncated ZSTD frame
If a journal file contains a truncated ZSTD frame (i.e. a frame with
Frame_Content_Size > 0, but with not enough data in Data_Block),
ZSTD_decompressStream() would return a non-zero, non-error value. This
would then skip the error path in the ZSTD_isError() branch and we'd hit
the following assert:

$ build-local/journalctl -o cat --file zstd-truncated.journal
Assertion 'output.pos >= prefix_len + 1' failed at src/basic/compress.c:1236, function decompress_startswith_zstd(). Aborting.
Aborted                    (core dumped) build-local/journalctl -o cat --file zstd-truncated.journal

Let's handle this situation gracefully and return EBADMSG instead.

Also, add another journalctl invocation to the corrupted-journals test
that goes through the sd_journal_get_data() -> decompress_startswith_zstd()
code path which, among other things, covers the issue when run on the
provided journal file.
2026-04-20 09:37:13 +02:00
Frantisek Sumsal e869c83367 test: append .journal to unpacked corrupted journals
Otherwise `journalctl --directory=` skips over them in the second part of
the test.
2026-04-20 09:37:13 +02:00
Christian Brauner 6548da06fc nspawn: avoid passing NULL to log_syntax() (#41712)
And a couple of other cosmetic tweaks.
2026-04-20 08:48:17 +02:00
Frantisek Sumsal 6182d0c666 import: fix an always-true assert() 2026-04-19 14:06:30 +02:00
Frantisek Sumsal 774a9f440b strxcpyx: add a paranoia check for vsnprintf()'s return value
vsnprintf() can, under some circumstances, return negative value, namely
during encoding errors when converting wchars to multi-byte characters.
This would then wreak havoc in the arithmetics we do following the
vsnprintf() call. However, since we never do any wchar shenanigans in
our code it should never happen.

Let's encode this assumption into the code as an assert(), similarly how
we already do this in other places (like strextendf_with_separator()).
2026-04-19 14:06:15 +02:00
Yu Watanabe 809a4139a6 iovec-wrapper: fix memleak, rename functions for consistency, and introduce several helper functions (#41689) 2026-04-19 07:29:03 +09:00
Yu Watanabe f71dcac4dc iovec-wrapper: introduce several more helper functions 2026-04-19 06:15:54 +09:00
Yu Watanabe 6d14614f4d iovec-wrapper: rename iovw_append() to iovw_extend()
The naming is consistent with strv_extend().

This also
- introduces tiny iovw_extend_iov() wrapper,
- refuse when the source and target points to the same object,
- check the final count before extending in iovw_extend_iovw().
2026-04-19 06:02:48 +09:00
Yu Watanabe d49c509d9b iovec-wrapper: introduce iovw_concat()
This is similar to iovw_to_cstring(), but allows embedded NUL, as this
just concat multiple iovec, the result may not be a string.

Now, iovw_to_cstring() internally uses iovw_concat().
2026-04-19 05:51:05 +09:00
Yu Watanabe a4e0f04157 iovec-wrapper: introduce iovw_compare() and iovw_equal() 2026-04-19 05:51:01 +09:00
Yu Watanabe ce81c7dd74 iovec-wrapper: fix memleak in iovw_consume() when len == 0
This makes even when len == 0, the input buffer is freed.
The behavior is consistent with strv_consume() and friends.
2026-04-19 03:45:08 +09:00
Yu Watanabe 043358d852 iovec-util: introduce IOVEC_SHIFT() macro and friends 2026-04-19 03:27:35 +09:00
Yu Watanabe 366e1d264a sd-dhcp-client: fix memleak of sd_dhcp_client.timeout_ipv6_only_mode
This also drops unnecessary zero assignments.
2026-04-19 03:25:27 +09:00
Sebastian Bernardt c8f5a56408 mailmap: name change 2026-04-18 14:24:47 +01:00
Nandakumar Raghavan fa6eb2e016 repart: add EncryptKDF= option for LUKS2 partitions
systemd-repart currently creates LUKS2 encrypted partitions using
libcryptsetup's default KDF (Argon2id), which requires ~1GB of memory
during key derivation. This is too much for memory-constrained
environments such as kdump with limited crashkernel memory, where
luksOpen fails due to insufficient memory.

Add an EncryptKDF= option to repart.d partition definitions that allows
selecting the KDF type. Supported values are:

- "argon2id" — Argon2id with libcryptsetup-benchmarked parameters
- "pbkdf2"  — PBKDF2 with libcryptsetup-benchmarked parameters
- "minimal" — PBKDF2 with SHA-512, 1000 iterations, no benchmarking,
  matching the existing cryptsetup_set_minimal_pbkdf() behaviour used
  for TPM2-sealed keys

When not specified, the libcryptsetup default (argon2id) is used,
preserving existing behaviour.

The KDF type is applied via sym_crypt_set_pbkdf_type() after
sym_crypt_format() and before any keyslots are added.
2026-04-18 11:03:52 +01:00
Luca Boccassi 2a6e40c2f5 bootspec: two smaller tweaks to bootspec.c (#41690)
The first commit is prep work for #41543 but I think it makes a ton of
sense on its own as it cleans up logging a bit.
2026-04-18 11:02:35 +01:00
Yu Watanabe b51c133a4e random-util: introduce random_bytes_allocate_iovec() helper function
It is similar to crypto_random_bytes_allocate_iovec(), but possibly
insecure.
2026-04-18 09:56:38 +02:00
Lennart Poettering a08ff701f0 bootspec: improve documentation around id/file BootEntry fields 2026-04-18 09:51:12 +02:00
Lennart Poettering 03cf3c4ff9 bootspec: make boot_filename_extract_tries() ready for use outside of bootspec.c 2026-04-18 09:51:12 +02:00
Lennart Poettering 4368cc8164 Various useful helpers (#41684)
Split out of #41543.

These don't make too much sense on their own, but they also don't really
hurt. They are preparation for #41543, but in order to make things
either to review I split these four commits out, since they are not
directly part of what the PR shall achieve
2026-04-18 09:50:19 +02:00
Lennart Poettering 9879a19222 boot: minor clean-ups in initrd_unregister() 2026-04-18 09:48:42 +02:00
Lennart Poettering e705c842f7 bootctl: minor tweaks (#41695)
This is split out of #41543, but makes sense on its own.
2026-04-18 08:41:46 +02:00
Lennart Poettering 587064b3f3 boot: switch initrd_register() to use _cleanup_free_ and other tweaks 2026-04-18 08:40:58 +02:00
Tobias Stoeckmann 4d2847dcc2 man: Fix NOTES formatting
The NOTES section in os-release(5) contains an unusual formatting.
Switch function and ulink tags and remove a newline within ulink text to
keep the entry formatting in sync with others. Also, this preserves the
formatting within the text itself.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-04-17 21:12:16 +01:00
Zbigniew Jędrzejewski-Szmek 1b42c9e06e network/json: two trivial cleanups (#41693) 2026-04-17 19:25:17 +02:00
Yu Watanabe 8bb669712e string-util: make make_cstring() take void* rather than char*
It is typically used for making C string embedded in a binary data.
Hence, the input pointer may not be char*.
2026-04-17 19:24:53 +02:00
Yu Watanabe f46ad8b4ba mountpoint-util: initialize mnt_id for name_to_handle_at(AT_HANDLE_MNT_ID_UNIQUE)
Suppress the following message:
```
$ sudo valgrind --leak-check=full build/networkctl dhcp-lease wlp59s0
==175708== Memcheck, a memory error detector
==175708== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==175708== Using Valgrind-3.26.0 and LibVEX; rerun with -h for copyright info
==175708== Command: build/networkctl status wlp59s0
==175708==
==175708== Conditional jump or move depends on uninitialised value(s)
==175708==    at 0x4BC33D1: inode_same_at (stat-util.c:610)
==175708==    by 0x4BF1972: inode_same (stat-util.h:86)
==175708==    by 0x4BF48FE: running_in_chroot (virt.c:817)
==175708==    by 0x4B16643: running_in_chroot_or_offline (verbs.c:37)
==175708==    by 0x4B175CE: _dispatch_verb_with_args (verbs.c:136)
==175708==    by 0x4B17868: dispatch_verb (verbs.c:160)
==175708==    by 0x407CBB: networkctl_main (networkctl.c:249)
==175708==    by 0x407D06: run (networkctl.c:263)
==175708==    by 0x407D39: main (networkctl.c:266)
==175708==
```
Not sure if it is an issue in valgrind or glibc, but at least there is
nothing we can do except for working around it.
2026-04-17 19:05:41 +02:00
Zbigniew Jędrzejewski-Szmek 08b2d65cab A small batch of conversions to the new option+verbs macros (#41671)
Those are all relatively straightforward.
2026-04-17 19:04:04 +02:00
Zbigniew Jędrzejewski-Szmek 34b9dfe1be sleep: convert to "verbs", using the new option+verb macros
We had verb-like dispatch, but done in a manual way. We have a fairly
heavy preperation steps that wraps all operations in the same way, so we
don't want to call the operation implementation functions directly. But
let's use the generic verb machinery and pass the state directly using
the userdata pointer and the recently added verb data pointer.

--help output is substantially the same, but options are now in a new
section below the verbs.
2026-04-17 19:02:42 +02:00
Zbigniew Jędrzejewski-Szmek b332dfb033 Rework ssh-issue to be verb-based and convert to the new verb+option parsing (#41668)
This is a bit involved because the old interface was documented, so
compat glue needed to be added.
But I think it's an improvement overall.
2026-04-17 19:01:01 +02:00
Lennart Poettering b54af7ce9a bootctl: make bootspec-util.c independent of bootctl.c
This changes boot_config_load_and_select() to also take the root path as
input, just like the ESP and XBOOTLDR path.

This has the benefit of making the whole file independent of bootctl.c,
which means we can link it into a separate test, and is preparatory work
for a follow-up commit.
2026-04-17 18:52:35 +02:00
Lennart Poettering f85415498c bootctl: drop redundant log message
If unprivileged_mode is false then verify_esp() will treat access errors
like any other and log about them. Here we set it to false, hence
there's no point to log a 2nd time.
2026-04-17 18:52:35 +02:00
Yu Watanabe 1c8158412f network/json: drop unnecessary return value assignment 2026-04-18 01:35:17 +09:00
Yu Watanabe 7756f0434c network/json: fix error handling 2026-04-18 01:35:17 +09:00
Lennart Poettering 7e8882a96f stat-util: add vfs_free_bytes()
The casts and the right fields to multiply aren't entirely trivial,
let's add a helper for it.
2026-04-17 18:32:21 +02:00
Lennart Poettering d7b6d89d90 string-util: add minor optimization to strrstr() 2026-04-17 18:32:21 +02:00
Lennart Poettering 2561159d39 string-util: add new strrstr_no_case() call 2026-04-17 18:32:20 +02:00
Lennart Poettering 023f88a6ab parse-util: add safe_atou64_full() 2026-04-17 18:32:20 +02:00
Lennart Poettering c40f254cca boot: gracefully handle LoadFile() implementations that return EFI_SUCCESS with a NULL buffer
LoadFile() with a NULL buffer is supposed to return the file size
without acquiring the data and return EFI_BUFFER_TOO_SMALL.

However it appears some firmware returns EFI_SUCCESS in case the file is
empty, i.e. the file size returned is zero. And I guess that's even
fine.

Let's handle this gracefully hence.
2026-04-17 18:23:51 +02:00
Lennart Poettering a93fa2c6b4 boot: never auto-boot a menu entry with the non-default profile
When figuring out which menu entry to pick by default, let's not
consider any with a profile number > 0. This reflects that fact that
additional profiles are generally used for
debug/recovery/factory-reset/storage target mode boots, and those should
never be auto-selected. Hence do a simple check: if profile != 0, simply
do not consider the entry as a default.

We might eventually want to beef this up, and add a property one can set
in the profile metadata that controls this behaviour, but for now let's
just do a this simple fix.
2026-04-17 17:54:47 +02:00
Lennart Poettering c83c21a054 man: drop redundant word from varlinkctl man page 2026-04-17 15:11:37 +01:00
Frantisek Sumsal c859d41232 namespace: don't log misleading error in the r > 0 path
fd_is_fs_type() returns < 0 for errors, 0 for false, and > 0 for true, so
in the r > branch we'd most likely report EPERM together with the error
message which is misleading.
2026-04-17 15:54:44 +02:00
Luca Boccassi e6fbf51fd6 Revert "ci: Switch PR review workflow to Opus 4.7 via Mantle endpoint"
This reverts commit 0112338585.
2026-04-17 15:35:45 +02:00
Luca Boccassi 2e79f8aa41 systemctl: add --kernel-cmdline= argument
Allows appending kernel command line arguments, like
kexec-tool does. This is especially needed for the integration
tests, as mkosi adds a bunch of options that are needed for the
test suite to work, and it breaks without them.
2026-04-17 13:58:05 +01:00
Luca Boccassi 73aeb1b538 Followups for recent changes to basic/iovec-wrapper (#41676) 2026-04-17 13:55:51 +01:00
Frantisek Sumsal d651df8283 nspawn: avoid passing NULL to log_syntax()
If range is NULL (i.e. when PrivateUsers= doesn't contain ':'),
both later error paths will then pass NULL to log_syntax():

~# cat foo.nspawn
[Exec]
PrivateUsers=9999999999999999999

~# SYSTEMD_LOG_LEVEL=debug systemd-nspawn -D foo |& grep foo.nspawn
Found settings file: /root/foo.nspawn
/root/foo.nspawn:2: UID/GID shift invalid, ignoring: (null)

or

~# cat foo.nspawn
[Exec]
PrivateUsers=4294967294

~ # SYSTEMD_LOG_LEVEL=debug systemd-nspawn -D foo |& grep foo.nspawn
Found settings file: /root/foo.nspawn
/root/foo.nspawn:2: UID/GID shift and range combination invalid, ignoring: (null)

Let's just use rvalue in both of these cases instead.
2026-04-17 14:55:29 +02:00
Zbigniew Jędrzejewski-Szmek 45c20448d5 basic/iovec-wrapper: use iovw_append in one more place 2026-04-17 12:25:58 +02:00