Commit Graph
88101 Commits
Author SHA1 Message Date
Lennart Poettering 853d0649d5 find-esp: return pinned fd to ESP/XBOOTLDR
The reworks the ESP/XBOOTLDR logic to pin the ESP/XBOOTLDR via an fd,
and return that as optional return parameter.

So far we only pinned the parent dir of the ESP/XBOOTLDR, which was
useful when verifying that ESP/XBOOTLDR is actually a mount point by
comparing mount ids. This however became obsolete with
a98a6eb95c. Hence, let's clean this up,
and pin the inode we really care about and return it.
2026-04-20 17:19:27 +02:00
Lennart Poettering 4712d70669 chase: tighten flags checks in chase_and_unlinkat()
Some flags don't reasonably apply to chase_and_unlinkat() (because we
open the parent inode of an inode to delete, which is always a dir),
hence let's catch these flags when misused.

(I ran into this, and it was very confusing to debug, hence let's make
it easier)
2026-04-20 17:19:27 +02:00
Lennart Poettering 54ed5c5806 btrfs-util: make sure btrfs_get_block_device_at() works when called without path 2026-04-20 17:19:27 +02:00
Lennart Poettering a4256a9b31 sd-path: expose XDG 'projects' user dir
As per:

https://blog.tenstral.net/2026/04/hello-projects-directory.html
2026-04-20 15:01:17 +01:00
Frantisek Sumsal c955e24916 test: re-enable sync in TEST-25-IMPORT
Newer tar started using openat2() via open_subdir() to address
CVE-2025-45582 [0]. Now, gnulib, that tar uses, provides the openat2()
syscall in two ways [1]:

1) If glibc doesn't provide openat2(), it provides its own version in
   openat2.c, that tries to call openat2() syscall first, and if it
   returns ENOSYS, it emulates the function in userspace.

2) If glibc provides openat2(), it uses that directly, without providing
   any fallback on ENOSYS.

Quite recently our test suite started calling nspawn with
--suppress-sync=yes. This means that we call seccomp_suppress_sync(),
which eventually calls block_open_flag(), that blocks the openat2()
syscall completely and refuses it with ENOSYS as this syscall can't be
sensibly filtered (see the openat2()-relevant comments in
block_open_flag() and seccomp_restrict_sxid()). And when glibc provides
openat2(), there's no fallback, so the ENOSYS bubbles up to the user as:

TEST-25-IMPORT.sh[163]: + tar xzf /var/tmp/scratch.tar.gz
TEST-25-IMPORT.sh[163]: tar: ./adirectory/athirdfile: Cannot open: Function not implemented
TEST-25-IMPORT.sh[163]: tar: Exiting with failure status due to previous errors

Let's mitigate this by re-enabling sync for TEST-25-IMPORT, at least for
now.

[0] https://cgit.git.savannah.gnu.org/cgit/tar.git/commit/?id=75b03fdff48916bd0654677ed21379bdb0db016d
[1] https://cgit.git.savannah.gnu.org/cgit/gnulib.git/commit/?id=0b97ffdf32bdab909d02449043447237273df75e
2026-04-20 14:33:36 +01:00
Lennart Poettering 3a2d828e72 update TODO 2026-04-20 12:35:12 +02:00
Lennart Poettering ad18f634b6 parse-util: rework safe_atou64() as wrapper around safe_atou64_full()
Follow-up for: 023f88a6ab

Claude complained...
2026-04-20 12:02:54 +02:00
Lennart Poettering 11879c717f Json underscorify even more (#41636) 2026-04-20 12:02:30 +02:00
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
Lennart Poettering 112f5317d1 resolved: let's generate enum fields properly too
AFAICS none of the enums here uses dashes, hence this should not
actually have any effect except for being more correct.
2026-04-20 09:36:09 +02:00
Lennart Poettering 40ab0df557 networkd: gnerate proper underscored enums in varlink interface
AFAICS none of the states actually user dashes/underscores, but let's
prepare for the future and be fully correct here.
2026-04-20 09:36:09 +02:00
Lennart Poettering f5575d9eb5 mountfsd: generate properly underscored designator json strings
Let's make sure we generate data that will actually pass the IDL checks,
and use underscores for designator names.

(This is a bugfix)
2026-04-20 09:36:09 +02:00
Lennart Poettering ab6feb11ed sd-json: add JSON_BUILD_PAIR_STRING_NON_EMPTY_UNDERSCORIFY() helper
it's the combination of JSON_BUILD_PAIR_STRING_NON_EMPTY
and JSON_BUILD_PAIR_STRING_UNDERSCORIFY
2026-04-20 09:36:06 +02:00
Lennart Poettering a77a95665f sd-json: make sure SD_JSON_BUILD_STRING_UNDERSCORIFY() can deal with NULL strings
SD_JSON_BUILD_STRING() and everything else can deal with it, make sure
SD_JSON_BUILD_STRING_UNDERSCORIFY() can too.
2026-04-20 09:36:06 +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