Commit Graph
88420 Commits
Author SHA1 Message Date
Lennart Poettering acdaececf0 bootspec: add boot_config_selected_entry() helper 2026-05-01 07:10:31 +02:00
Luca Boccassi 630f5a1fc4 mkosi: update debian commit reference to 1302f123d9ab65bbaff5d95935eabfd659456550
* 1302f123d9 Restrict wildcard for new files
* a6d0098d10 Install new files for upstream build
* ce07fd7616 d/t/boot-and-services: use coreutils tunable in apparmor test (LP: #2125614)
2026-04-30 20:30:22 +01:00
Yaping Li f78ba86d26 report: report user and system CPU time per cgroup
Extend io.systemd.CGroup.CpuUsage from a single per-unit nanosecond
counter to three rows distinguished by a "type" field of "total",
"user", or "system". The values come from cpu.stat's usage_usec,
user_usec and system_usec keys, read in a single keyed-attribute
fetch and cached on each CGroupInfo so each scrape only opens
cpu.stat once per cgroup.
2026-04-30 20:08:39 +02:00
Zbigniew Jędrzejewski-Szmek 4ce8cd17da fundamental: drop now-unused macro
Followup for 9d2f5b4611.
2026-04-30 19:26:08 +02:00
Lennart Poettering 99ce7a0770 options: get rid of "on_error" parameter to FOREACH_OPTION
I am really not a fan of full code lines passed to macros as parameters.
Let's get rid of the 3rd parameter of FOREACH_OPTION() hence:

1. Let's return errors just as a regular value (though a negative one),
   that can be handled via a OPTION_ERROR case statement for the switch.
   This normalizes handling of the error, just like any other event
   returned by the option parser.

2. In order to avoid exploding the amount of boilerplate in each use
   (that just propagates the error on OPTION_ERROR), let's then
   introduce an explicit FOREACH_OPTION_OR_RETURN(), that returns from
   the calling function on its own (and makes that clear in the name).

Together this cleans up, normalizes the logic and shortens the code.
2026-04-30 11:12:33 +01:00
Frantisek Sumsal 7671b43cb8 sd-json: limit the number of env variables to something reasonable
Let's start with 1024, as that should be plenty for all sane use cases.
2026-04-30 09:46:46 +02:00
Frantisek Sumsal 1c534452e9 dns-question: limit the number of questions per query
Let's cap the number of question each query can have to something
reasonable - 128 questions per query should be more than enough for any
real-world scenario.
2026-04-30 09:43:55 +02:00
Daan De Meyer 9d2f5b4611 fundamental/cleanup: add CLEANUP_ELEMENTS() and DEFINE_POINTER_ARRAY_CLEAR_FUNC()
DEFINE_POINTER_ARRAY_CLEAR_FUNC() generates a helper of the form
helper_array_clear(T *array, size_t n) that drops each element but does
not free the array itself, parallel to DEFINE_POINTER_ARRAY_FREE_FUNC()
for cases where the array has automatic storage duration.

CLEANUP_ELEMENTS() pairs with these helpers to provide a _cleanup_-like
attribute for fixed-size arrays: the bound is taken from ELEMENTSOF(),
and the helper is invoked across the elements at scope exit. Compared to
CLEANUP_ARRAY(), the storage is neither freed nor zeroed.

Migrate various logic across the tree over to the new macros.

sd-device: use DEFINE_POINTER_ARRAY_CLEAR_FUNC() for sd_device_unref_array_clear()

Replace the local device_unref_many() helper with the macro-generated
equivalent.

format-table: switch help-table arrays to CLEANUP_ELEMENTS()

Generate table_unref_array_clear() via DEFINE_POINTER_ARRAY_CLEAR_FUNC()
and convert the help-table arrays in bootctl, cryptenroll, nspawn,
repart and vmspawn to CLEANUP_ELEMENTS(). The arrays no longer need a
trailing NULL slot, so the size matches ELEMENTSOF() of the groups
array.

firewall-util: switch netlink message arrays to CLEANUP_ELEMENTS()

Generate sd_netlink_message_unref_array_clear() via
DEFINE_POINTER_ARRAY_CLEAR_FUNC() in place of the NULL-terminated
sd_netlink_message_unref_many(), and convert the two stack arrays of
sd_netlink_message pointers to CLEANUP_ELEMENTS().
2026-04-30 09:15:34 +02:00
Dan Anderson cd7aceeaa3 Improve error logging for fstat failure
Small hygiene fix.  r must be >= 0 as per the prior statement (otherwise we would have returned).  This is really only going to be r == 0, which means return r; is return 0;  I'm updating this to use log_debug_errno
2026-04-30 08:05:54 +02:00
Lennart Poettering a69f0b8b28 repart: hide read-only block devices from candidates
If they are read-only they are no candidates, since we cannot write to
them.
2026-04-30 08:04:55 +02:00
Samuel Dainard 3f2189ca25 binfmt-util: handle ELOOP/EACCES from automount in read-only bind mounts
When /proc is bind-mounted read-only (common in mock/Koji buildroots,
containers, and other sandboxed environments), opening
/proc/sys/fs/binfmt_misc returns ELOOP if it is an automount point
that cannot be triggered in the read-only context.

Currently binfmt_mounted_and_writable() only handles ENOENT, so ELOOP
propagates as an error. This causes test-binfmt-util to fail with
SIGABRT and disable_binfmt() to log a spurious warning at shutdown.

Treat ELOOP and EACCES the same as ENOENT: binfmt_misc is not usably
available, return false.

Note: PR #37006 (merged April 2025) addressed ELOOP in the xstatfsat()
path, but the open() call in binfmt_mounted_and_writable() remained
unhandled.

Fixes #38070
2026-04-29 21:39:24 +01:00
Luca Boccassi 33ac56f462 man: add section about systemd-boot Type#1 sidecars
Follow-up for 6b1324fb86

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 17:57:26 +01:00
Christian Brauner 994f016a7f blockdev-list: fix per-element leak in block_device_array_free() (#41869)
FOREACH_ARRAY declares 'i' as the iterator but the body passed 'd' (the
array base) to block_device_done(). Since mfree() leaves the field NULL
after the first call, element 0 is freed repeatedly while elements
1..N-1 leak their node, symlinks strv, model, vendor and subsystem.

The bug predates the sanitizer-instrumented callers. PR #41776's new
systemd-storage-block daemon runs blockdev_list() under ASan/LSan in
TEST-87-AUX-UTILS-VM and exposes it (15 allocs / 804 bytes leaked per
ListVolumes request). The fix also benefits repart and blockdev_list's
internal CLEANUP_ARRAY cleanup.

Follow-up for 9f6b2745ea
2026-04-29 17:28:16 +01:00
Zbigniew Jędrzejewski-Szmek a234840e3e Convert remaining udev progs to option macros (#41856) 2026-04-29 17:23:18 +02:00
Zbigniew Jędrzejewski-Szmek 61811433bb follow-up for recently merged PRs (#41870)
Just small stuff.
2026-04-29 16:41:35 +02:00
Frantisek Sumsal 82614a4c6f sd-json,user-record: store the strv size when extending it
So strv_push_with_size() doesn't have to recalculate the size every
time.
2026-04-29 16:33:46 +02:00
Lennart Poettering fd035af9bf update TODO
This is mostly stuff discussed in #41776.
2026-04-29 16:06:03 +02:00
Lennart Poettering 32a291abe9 sd-boot: minor tweaks as follow-up for #41863
This addresses some trivial points made by @keszybz in the PR review.
2026-04-29 15:53:21 +02:00
Lennart Poettering e4e3ec811a volume: add an "io.systemd.StorageProvider" IPC API that is supposed to be used by vmspawn/nspawn/pid1 to provide storage volumes in a generic fashion (#41776)
BindPath= in unit files, and --bind= in nspawn/vmspawn doesn't really
cut it to connect arbitrary storage infra to it. Let's do something
about it, and implement a simple, light-weight API for acquiring an fd
to a storage volume. Benefits:

1. the interface can be implemented by anyone, connecting anything to
vmspawn/nspawn/service management
2. very lose coupling: just bind a socket into a well-known dir, done
3. mounting can happen on-demand
2026-04-29 15:51:52 +02:00
Zbigniew Jędrzejewski-Szmek 13f6feda78 udevadm: convert verb dispatch to VERB macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 15:28:05 +02:00
Zbigniew Jędrzejewski-Szmek fcfd42a30c udev-builtin-hwdb: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 15:28:05 +02:00
Zbigniew Jędrzejewski-Szmek ab9acf8c8c shared/options: add new helper option_parser_get_arg
option_parser_next_arg() is renamed to option_parser_peek_next_arg()
to match option_parser_consume_next_arg().

A new helper is added option_parser_get_arg(…, n). It is a common pattern
to only need a single arg, and getting an array and extracting a single
item from it is too verbose.
2026-04-29 15:28:05 +02:00
Zbigniew Jędrzejewski-Szmek 53f7c1a8cc sd-boot related work from #41543 (add "extra" stanza to bls type 1) (#41863)
This implements the "extra" stanza for type 1 entries in systemd-boot,
see:


https://github.com/uapi-group/specifications/commit/bde167a46c866c44e1240120695f70f0bf70aadc

It comes with a really thorough test suite matching our currently level
of testing of systemd-boot (read: there is none, I ask you to trust me,
Claude, and your review on this one)...

Split out of #41543
2026-04-29 15:25:38 +02:00
Zbigniew Jędrzejewski-Szmek a79c4fdf93 Small cleanups in sd-varlink and sd-json (#41861) 2026-04-29 15:03:00 +02:00
Zbigniew Jędrzejewski-Szmek 6c7726193e sd-bus: store the strv size when extending it (#41864)
So strv_push_with_size() doesn't have to recalculate the size every
time.
2026-04-29 15:01:12 +02:00
Zbigniew Jędrzejewski-Szmek 408d18f4d2 udev-builtin-blkid: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek c86ba4e037 udevadm-info: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 222b417494 udevadm-trigger: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 5656636a41 udevadm-wait: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 0257deff36 udevadm-control: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek a00de0b648 udevadm-lock: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek ed2b92e205 udevadm-settle: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 5a2144f9bc udevadm-monitor: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek a517a6297e udevadm-test: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 12e5e0e903 udevadm-verify: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 5751647799 udevadm-test-builtin: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek ce4746f228 udevadm-hwdb: convert to OPTION macros
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 5893cf3dcf udev: convert udev-config.c to OPTION macros
--timeout-signal is now documented (fixup for
e209926778).

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek bfc07f83da udev: fix stale optarg use
Fixup for 8623980980. This didn't
cause any problems until the conversion away from getopt_long().
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 765fc4125b shared/options: add OPTION_COMMON_RESOLVE_NAMES 2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek 07fc22cd03 udevadm-cat: convert to OPTION macros 2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek c2c9887852 udevadm: convert option parsing to the new option parser
Verb dispatch is left untouched for now.

Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 14:00:41 +02:00
Zbigniew Jędrzejewski-Szmek fb0143f1ce shared/options: add option_parser_get_help_table_ns() helper
It'll be used in the next commit.
2026-04-29 14:00:41 +02:00
Lennart Poettering 6b1324fb86 man: add a brief note about type 1 extra lines 2026-04-29 13:36:56 +02:00
Lennart Poettering a3d0e761d4 boot: downgrade log level for an error we ignore 2026-04-29 13:36:56 +02:00
Lennart Poettering d5572aca2c boot: load extra files for UKIs into memory and register as initrds
This generates on-the-fly cpio initrds from 'extra' resources declared
in Type #1 entries and installs them via the Linux initrd protocol so
that they get passed to the Linux kernel.

Replaces: #39286
2026-04-29 13:36:56 +02:00
Lennart Poettering feba5dcc5f boot: parse 'extra' type 1 stanza too
This loads the new 'extra' stanza, but doesn't actually do anything with
it yet. That's added in a later commit.

Replaces: #39286

Implements: https://github.com/uapi-group/specifications/pull/212
2026-04-29 13:36:56 +02:00
Lennart Poettering c3ace5621b cpio: move TPM PCR info into CpioTarget
The PR to measure into is closely associated with where we place a
resource in the initrd cpios. Hence, let's also track it in CpioTarget,
thus simplifying our function parameter lists that way.

No change in behaviour.
2026-04-29 13:36:47 +02:00
Frantisek Sumsal 51a88ac723 core: limit the number of units that can be requested over ListUnitsByNames 2026-04-29 12:58:58 +02:00
Frantisek Sumsal 0d71d58da0 sd-bus: store the strv size when extending it
So strv_push_with_size() doesn't have to recalculate the size every
time.
2026-04-29 12:58:22 +02:00