Commit Graph
54021 Commits
Author SHA1 Message Date
Lennart Poettering 3777c6e65a udev: new "image_dissect" builtin that can be used to generate symlinks based on partition designators (#36631)
This replaces #36209 and implements this via a new builtin, rather than
by shelling out to systemd-dissect.

Replaces: #36209 
Replaces: #28894
Fixes: #34319 
Fixes: #33453 
Fixes: #27897
Fixes: #18035
2025-04-03 13:32:11 +02:00
Lennart Poettering 2caa462504 build-path: make invoke_callout_binary() honour $PATH as last resort
If we cannot find the callout we need in the build dir let's look for it
in $PATH as last resort.

This makes invoke_callout_binary() usable for all binaries we install
into $PATH (as opposed to /usr/lib/systemd), but has no effect
on callout binaries specified with full path.

This is useful, since we soon want to invoke journalctl as a callout.
2025-04-03 19:40:30 +09:00
Yu Watanabe f5729bbb1e generator: two minor tweaks to fsck code (#36970) 2025-04-03 19:19:54 +09:00
Yu Watanabe 23e724f23e two udev blkid builtin tweaks (#36968)
Fixes: #34319
2025-04-03 18:44:56 +09:00
ZIHCO 653b42c853 test: add a new unit test, src/test/test-binfmt-util.c 2025-04-03 18:32:23 +09:00
Lennart Poettering e5d2701bc2 gpt-auto-generator: write fsck override unit to "middle" generator dir
We generally let gpt-auto-generator write to the "late" generator dir,
so that the explicit fstab-generator can write to the "middle" one. And
I think we should leave it that way. But we also want to override the
generic systemd-fsck-root.service service potentially, and if we'd do
that in the "late" generator dir, it would be pointless, since that's
ordered *after* the static version hence would never be taken into
consdiration.

Hence clean this up: keep writing to the late dir for everything,
except for the fsck stuff.
2025-04-03 11:08:57 +02:00
Lennart Poettering 96386bb5a7 veritysetup: when we fail to unlock a disk with the root hash signature logic, retry without
Currently, there's no nice way to get a key into the dm-verity kernel
keyring unless recompiling the kernel, or enabling SB or buying into
shim. Neither sounds particularly attractive.

hence provide a reasonable fallback: if unlocking with signed roothash
doesn#t work, just try without. maybe the kernel policy allows this,
maybe not. It's worth a try.
2025-04-03 11:08:57 +02:00
Lennart Poettering bcd904d471 dissect-image: move extension release arguments of verity_dissect_and_mount() into a structure 2025-04-03 11:08:57 +02:00
Lennart Poettering 74cfd0921c gpt-auto-generator: parse systemd.image_filter= from kernel cmdline 2025-04-03 11:08:57 +02:00
Lennart Poettering f02868d296 builtin-dissect_image: add support for image filters 2025-04-03 11:08:57 +02:00
Lennart Poettering 743667e069 dissect-tool: expose image filtering via new --image-filter= parameter 2025-04-03 11:08:57 +02:00
Lennart Poettering f1395724f6 dissect-image: add a concept for "filtering" partitions we dissect
DDIs may contain multiple versions of the same OS, or even multiple
OSes. Hence it makes sense to not just pick the "newest", whatever that
might be, but only partitions associated with specific images, or in a
specific version.

Let's a concept for such filtering: a per-designator glob expression
that can be applied to the partition label string, and can be used for
such filtering.

Usecase: when picking UKI belonging to OS image X in version Y, make
sure we only pick a /usr/ partition belonging to X in version Y, and a
root and home partition belonging to X in any version.

This only adds the basic infrastructure, but doesn't actually expose it
anywhere.
2025-04-03 11:08:57 +02:00
Lennart Poettering fb008a7333 veritysetup: optionally pick up roothash/roothashsig from udev device db entry 2025-04-03 11:08:57 +02:00
Lennart Poettering 0a64b7ba6e gpt-auto-generator: add support for setting up verity partitions automatically
So far the gpt-auto-generator would only cover unprotected and encrypted
partitions. Teach it handling of verity too.
2025-04-03 11:08:57 +02:00
Lennart Poettering 7852e301e0 gpt-auto-generator: add support for mount.usr=dissect
So far, we did not support auto-discovery the /usr/ partition at boot.
Change that: on explicit request (i.e. mount.usr=dissect) automatically
discover the /usr/ partition based on our usual dissection logic.
2025-04-03 11:08:57 +02:00
Lennart Poettering c05a132fef generator: add root=off to explicitly turn search for rootfs off
This is useful when booting into storage target mode, where we do not
want to enter a root fs, we just want to stay forever in the initrd,
and hence there's value in not even generating and jobs to find the
rootfs
2025-04-03 11:08:57 +02:00
Lennart Poettering 198f7badaa gpt-auto-generator: optionally, set up root fs via dissection logic
This introduces root=dissect, which is a lot like root=gpt-auto, but
uses the image dissection logic to find the root partition. It's also
based on the GPT efi var telling us about the root disk, but instead of
just picking some suitable root disk manually it uses the dissection
logic.

This is a big step forward, since it means we can actually make
use of the image policy logic for the root fs too.
2025-04-03 11:08:57 +02:00
Lennart Poettering 1e6f03a45d dissect-image: relax image policy logic a bit
Previously if we found a verity signature partition in an image, and the
image policy required "verity" (but did not allow "signature") we'd
refuse the image. This is of course unnecessarily strict: if "verity" is
allowed, we can make use of the verity data, and ignore the signature
data.

hence, relax the rules here: when we pick up a partition and want to
test it against the policy, always consider all "weaker" uses too, maybe
they are allowed if the "stronger" users isn't.
2025-04-03 11:08:57 +02:00
Lennart Poettering e34c89897a dissect-image: guess verity root hash from the resources we found
When dissecting an image, let's make use of the Verity data even if we
got told no root hash explicitly: we can simply determine it by
concatenating the data partition uuid with the verity partition uuid.

Of course, on first thought this doesn't really add much: if the root
hash is not pinned from somewhere, this does not guarantee trust in
the image.

However, this is very useful for attestation: if we have the root hash
we can measure it before mounting things, even if we don't actually
authenticate it.

Hence, at best this helps us with attestation, at worst it doesn't improve
security but certainly doesn't hurt it.
2025-04-03 11:08:57 +02:00
Lennart Poettering 923eabf085 dissect-image: rework how we determine that we are ready to do verity/verity-sig
Previously, if during early enumeration of the partition table we
figured out we have a verity + verity-sig partition, we determined we are
"ready" to do verity/verity-sig, as reported by the "verity_ready" and
"verity_ready_sig" fields of DissectedImage.

Let's rework this: only determine we are ready in case the VeritySettings
structure is fully populated. Mark verity-sig/verity only as ready once
we actually *load* the verity sig metadata from the special partition.

This is conceptually more correct, as we consider things "ready" only if
we actually have all data for it loaded. It's also preparation for a
later commit that guesses the verity root hash based on what we discover.
2025-04-03 11:08:57 +02:00
Lennart Poettering a8b2302bc1 udev: add dissect_image builtin
Fixes: #33453 #27897 #18035
2025-04-03 11:08:57 +02:00
Lennart Poettering e71f60476b udev-builtin-blkid: skip GPT dissection unless we actually have partition support 2025-04-03 11:08:57 +02:00
Lennart Poettering 5d3243bd46 udev-builtin-blkid: look for ESP/XBOOTLDR only in initrd; afterwards just look at /
So far the gpt-auto symlinks would point to:

   1. the disk the ESP/XBOOTLDR is located on
   2. or to a loopback device whose filename field is set to "rootdisk"
      or "rootdisk.raw"

This makes sense in the initrd. But once we transition to the host this
is quite confusing, since the symlinks might point to a different place
than what we actually ended up transitioning too: the actual backing
device of the root file system might be different from what gpt-auto
found.

Let's clean this up: let's avoid any ambiguities here: let's extend the
rules above with one more rule:

   3. if we left the initrd, we'll make gpt-auto point to the selected
      root file system, if it otherwise would have been a candidate.

Or in other words, the ID_PART_GPT_AUTO_ROOT_DISK=1 udev property now
always makes sense: in the initrd it points to the future root disk, and
on the host to the actual root disk.

Fixes: #34319
2025-04-03 11:08:57 +02:00
Lennart Poettering e04c7a92cc generator: downgrade complaint about trying to fsck a non-block device 2025-04-03 10:22:46 +02:00
Lennart Poettering bed3ff8ebc generator: also suppress fsck early if we are adding a bind mount
There's no point in "fscking a bind mount". Let's not do it hence.
2025-04-03 10:22:46 +02:00
Lennart Poettering 7c23f95c2c udev-builtin-blkid: skip GPT dissection unless we actually have partition support 2025-04-03 10:04:03 +02:00
Lennart Poettering 2fad9fb769 udev-builtin-blkid: look for ESP/XBOOTLDR only in initrd; afterwards just look at /
So far the gpt-auto symlinks would point to:

   1. the disk the ESP/XBOOTLDR is located on
   2. or to a loopback device whose filename field is set to "rootdisk"
      or "rootdisk.raw"

This makes sense in the initrd. But once we transition to the host this
is quite confusing, since the symlinks might point to a different place
than what we actually ended up transitioning too: the actual backing
device of the root file system might be different from what gpt-auto
found.

Let's clean this up: let's avoid any ambiguities here: let's extend the
rules above with one more rule:

   3. if we left the initrd, we'll make gpt-auto point to the selected
      root file system, if it otherwise would have been a candidate.

Or in other words, the ID_PART_GPT_AUTO_ROOT_DISK=1 udev property now
always makes sense: in the initrd it points to the future root disk, and
on the host to the actual root disk.

Fixes: #34319
2025-04-03 10:01:49 +02:00
Yu Watanabe a345f47625 Two trivial cleanups (#36980) 2025-04-03 08:56:46 +09:00
Lennart Poettering 4dba936a03 dissect-image: after probing file systems, we still have the chance to not use a partition
Just because we found something we should still allow it to not be used,
hence include UNUSED in the found flags.
2025-04-03 06:09:01 +09:00
Yu Watanabe 9ec7d7ae90 tree-wide: replace unsigned int -> unsigned, long int -> long 2025-04-03 06:01:31 +09:00
Yu Watanabe dba777cf26 memfd-util: make memfd_add/get_seals() static 2025-04-03 06:01:31 +09:00
Yu Watanabe 101b248002 journald: two minor tweaks (#36966) 2025-04-03 04:31:55 +09:00
Yu Watanabe daaf66fb1b journald: split out varlink code into .c/.h file and add varlink documentation to it (#36965)
No real code changes.
2025-04-03 04:31:15 +09:00
Yu Watanabe c421abaf80 sd_journal_get_cursor() tweaks (#36964) 2025-04-03 04:11:35 +09:00
Yu Watanabe 8f9737bf7e prioq: minor tweaks (#36963) 2025-04-03 04:10:10 +09:00
Lennart Poettering b49ba39071 sd-event: don't consider no pending IO event a programming error in sd_event_source_get_io_revents() 2025-04-03 04:07:44 +09:00
Lennart Poettering a7d58b7d3d varlink: add common helper that refuse method calls from unpriv clients 2025-04-03 04:07:08 +09:00
Yu Watanabe 0f2373f214 Several cleanups for rc-local-generator (#36953) 2025-04-03 04:05:45 +09:00
Yu Watanabe 2e338f3ac1 logind: utmp fix (#36958)
Fixes: #36930
2025-04-03 02:41:26 +09:00
Yu Watanabe 8ebc5cf91d udevdm: use PidRef at one more place (#36959) 2025-04-03 02:26:42 +09:00
Yu Watanabe fd386a6a9d tree-wide: pass -EBADF to device_monitor_new_full()
Prompted by https://github.com/systemd/systemd/pull/36922#discussion_r2024940885.
2025-04-03 02:14:52 +09:00
Yu Watanabe 5833a3340c udev: use notify socket to send message from worker processes to manager process (#36922)
This replaces home-grown notification method from worker processes to
manager process with sd-notify. Then, we can reuse many library
functions commonly used by many components.
Hopefully, this does not change any effective functionalities.
2025-04-03 02:09:36 +09:00
Yu Watanabe abaa8bc7ca some selinux modernizations (#36955) 2025-04-03 01:30:03 +09:00
Yu Watanabe d4a6d44210 udev: introduce rm_rf_safep() and modernize udev_watch_restore() (#36923) 2025-04-03 01:28:34 +09:00
victor-ok 3365c40640 test: converted unittest in src/test/test-mkdir.c to use new ASSERT_OK() macros and friends 2025-04-03 01:21:18 +09:00
Lennart Poettering 808a751fac journald: do not schedule idle timer if our event loop is dying 2025-04-02 17:37:58 +02:00
Lennart Poettering ead537940c journald: rename stdout_stream_destroy() → stdout_stream_terminate() 2025-04-02 17:37:58 +02:00
Lennart Poettering 737bf89cca journald: document Varlink interface 2025-04-02 17:32:05 +02:00
Lennart Poettering 3e414aa7c9 journald: split out varlink code into a separate .c file
No actual code changes just splitting out code.
2025-04-02 17:32:05 +02:00
Lennart Poettering 98d6578335 sd-journal: make return parameter to sd_journal_get_cursor() optional 2025-04-02 17:29:04 +02:00