Commit Graph
76187 Commits
Author SHA1 Message Date
Maanya Goenka 25d1b96880 src/sysext: Use versioned names when logging extensions used for merge operation
If this is not done, and there are two images, image_1.raw and image_2.raw under
an image.raw.v folder, then the log will say "Using extensions image" instead of
using "Using extensions image_2.raw" which is the desired behavior for v-picked extensions.
2024-09-11 06:44:38 +02:00
Lennart Poettering 408ab988db tmpfiles: add separate fragment for stuff we copy from .extra/ into /run/systemd
Let's move copying out the PCR signature/key into its own tmpfiles
snippet.

And then let's add support for copying out the profile + os-release
information systemd-stub now places in the invoked initrd.

That way these four pieces of information are available even after the
initrd→host transition.
2024-09-11 04:47:44 +09:00
Lennart Poettering 41a9a502a1 meson: increase default number of available sections for the stub
Now that we have multi-profile UKIs people likely want to stick more PE
sections into them than before. Hence, bump the number of available PE
section slots to 30 (up from 15). Also, make this configurable at build
time since some folks probably want even more, and others don't want
this at all.

(pre-allocating too many shouldn't matter too much btw, I'd advise
everyone to overshoot, except maybe on the tiniest of embedded boards)
2024-09-11 04:47:00 +09:00
Luca Boccassi 59e6059513 doc-sync: strip point release from version before uploading
We create subdirectories for each major release, but not for point releases
so strip the suffix if it is present
2024-09-10 20:20:01 +02:00
Lennart Poettering d794c10d96 cryptsetup: use the new crypt_token_set_external_path() API if available
Let's make use of libcryptsetup's new crypt_token_set_external_path()
API in place of the interposition stuff we have been doing before. Let's
kill it entirely, given that this was a developer feature only anyway
(and guarded by an appropriate ifdef).

Fixes: #30098
2024-09-11 02:56:55 +09:00
Lennart Poettering 34ed064f67 homectl: when chainloading a shell, prefix "-" rather than overriding first char
Login shells are supposed to marked via a dash as first char. We follow
that logic, but right now we simply overwrite the first char of the
shell. That might not be the right choice, given that this turns
"zsh" into "-sh", which suggests some bourne shell process.

Hence, let's correct things, and instead prefix a dash, which should be
safer.

Inspired by findings on https://github.com/systemd/systemd/issues/34153#issuecomment-2338104907
2024-09-10 17:24:21 +02:00
Lennart Poettering 3a2a8585e6 Merge pull request #34339 from poettering/uki-with-many-boot
sd-boot: synthesize one menu entry for each profile of multi-profile UKIs
2024-09-10 16:25:34 +02:00
Lennart Poettering 5446e39e0e hwdb: death to tabs!
Some tabs snuck in here, but we don't like tabs in our codebase. Fix
them.
2024-09-10 16:24:32 +02:00
Yu Watanabe 08491c0cdf Merge pull request #34331 from yuwata/network-netdev-cleanups
network/netdev: several cleanups for attaching/detaching netdev, and setting/getting ifindex from netdev
2024-09-10 22:05:55 +09:00
Tomas Bzatek 34e56246b1 udev/ata_id: export read look-ahead values
Indicates whether the ATA read look-ahead feature is supported
and enabled.

Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
2024-09-10 22:04:30 +09:00
Lennart Poettering 8c0d7222b4 boot: don't hardcode drop-in paths at multiple places
Instead, let's define them once, and pass them through as parameters
everywhere.
2024-09-10 14:38:11 +02:00
Lennart Poettering 382e4da4a5 boot: synthesize a separate menu entry from each .profile section
This iterates through the .profile sections a UKI provides and uses it
to generate multiple menu entries from them, one for each .profile
section.
2024-09-10 14:38:11 +02:00
Yu Watanabe 8f28d34246 test-network: add test more cases for assigned units for each interface 2024-09-10 19:30:17 +09:00
Yu Watanabe f49c8e6553 network/state-file: save assigned .netdev file even if the interface is unmanaged
Follow-up for 2cf9b1a0ee.
2024-09-10 19:30:17 +09:00
Yu Watanabe d0899c6a55 network/vxcan: also manage peer interface name by manager
Then, the Link object for the peer interface can have a reference to the
corresponding NetDev object.
2024-09-10 19:30:17 +09:00
Yu Watanabe 971c0ce85c network/vxcan: refuse when peer and the main interface names are equivalent 2024-09-10 19:30:17 +09:00
Yu Watanabe 2d5f58cf41 network/l2tp: manage l2tp session name by Manager
Then, Link object for an L2TP session can have reference to the
corresponding NetDev object.
2024-09-10 19:30:17 +09:00
Yu Watanabe 121d32b09c network/l2tp: refuse duplicated session name 2024-09-10 19:30:17 +09:00
Yu Watanabe c480e4cd66 network/l2tp: downgrade log level of several messages
Also, use log_section_warning_errno() where applicable.
2024-09-10 19:30:17 +09:00
Yu Watanabe 909acd37b8 network/veth: also manage peer name by Manager
Then, the Link object for the peer interface can have a reference to the
corresponding NetDev object.
2024-09-10 19:30:17 +09:00
Yu Watanabe 98fbb3b5b0 network/veth: refuse when peer and the main interface names are equivalent 2024-09-10 19:30:17 +09:00
Yu Watanabe c60cd572bd network/netdev: add attach(), detach(), set_ifindex(), and get_ifindex() to netdev vtable
Currently no vtable sets these functions, but will be used later.
2024-09-10 19:30:17 +09:00
Yu Watanabe 36ca0164ab network/netdev: allow to register the same NetDev object with multiple names
Preparation for later commits.
2024-09-10 19:30:17 +09:00
Yu Watanabe 5dc20e1acd network/netdev: split out netdev_set_ifindex_internal() and _impl()
No functional change, just refactoring and preparation for later
commits.
2024-09-10 19:30:13 +09:00
Yu Watanabe bfacb8fe1d network/netdev: split out netdev_attach() and netdev_attach_name() from netdev_load_one()
No functional change, just refactoring and preparation for later
commits.
2024-09-10 19:29:05 +09:00
Yu Watanabe 0dc71b9584 network/netdev: use hashmap_remove_value() on detaching NetDev from manager
Then, it is not necessary to free NetDev.ifname when a conflicting
.netdev file is already loaded.

This also split out netdev_detach_name() and netdev_detach_impl().

No functional change, just refactoring.
2024-09-10 19:29:05 +09:00
Yu Watanabe bc0d3f3842 network/netdev: downgrade log level in netdev_set_ifindex()
This also makes netdev_enter_failed() called on caller side.

No functional change, just refactoring.
2024-09-10 19:29:05 +09:00
Yu Watanabe 5d7de25052 network/netdev: check family of received NEWLINK message
For safety. No functional change, just refactoring and preparation for
later commits.
2024-09-10 19:28:56 +09:00
Yu Watanabe 72fd133dca network/route: use NetDev object assigned to Link 2024-09-10 16:38:07 +09:00
Yu Watanabe 1788c34628 network/netdev: also check ifindex, iftype, and kind when assigning NetDev to Link
Even when a NetDev object with the same name found, its iftype or kind
may be different. For safety, let's also check them.
2024-09-10 16:38:06 +09:00
Lennart Poettering ea8aa2ea85 boot: only open type2 ukis once when parsing 2024-09-10 09:14:02 +02:00
Lennart Poettering f2129f1d8c Merge pull request #34294 from poettering/uki-with-many-core
multi-profile UKIs (systemd-stub hookup)
2024-09-10 08:59:53 +02:00
Yu Watanabe 6d449bc71f Merge pull request #34318 from YHNdnzj/networkctl-edit-if-netdev
networkctl: support editing netdev files by link and cat ":all"
2024-09-10 14:32:28 +09:00
Yu Watanabe 214c2508f3 Merge pull request #34336 from yuwata/nspawn-fuse-follow-ups
nspawn: follow-ups for FUSE support
2024-09-10 14:32:09 +09:00
Lennart Poettering a632d8dd9f stub: add ability to place multiple alternative PE sections of a specific type in the same UKI ("Multi-Profile UKIs")
This adds a ability to add alternative sections of a specific type in
the same UKI. The primary usecase is for supporting multiple different
kernel cmdlines that are baked into a UKI.

The mechanism is relatively simple (I think), in order to make it robust.

1. A new PE section ".profile" is introduced, that is a lot like
   ".osrel", but contains information about a specific "profile" to
   boot. The ".profile" section can appear multiple times in the same
   PE, and acts as delimiter indicating where a new profile starts.
   Everything before the first ".profile" is called the "base profile",
   and is shared among all other profiles, which can then override or
   add addition PE sections on top.

2. An UKI's command line can be prefixed with an argument such as "@0" or
   "@1" or "@2" which indicates the "profile" to boot. If no argument is
   specified the default is profile 0. Also, a UKI that lacks any
   .profile section is treated like one with only a profile 0, but with
   no data in that profile section.

3. The stub will first search for its usual set of PE sections
   (hereafter called "base sections"), and stop at the first .profile PE
   section if any. It will then find the .profile matching the selected
   profile by its index, and any sections found as part of that profile
   on top of the base sections.

And that's already it.

Example: let's say a distro wants to provide a single UKI that can be
invoked in one of three ways:

1. The regular profile that just boots the system
2. A profile that boots into storagetm
3. A profile that initiates factory reset and reboots.

For this it would define a classic UKI with sections .linux, .initrd,
.cmdline, and whatever else it needs. The .cmdline section would contain
the kernel command line for the regular profile.

It would then insert one ".profile" section, with a contents like the
following:

    ID=regular

This is the profile for profile 0. It would immediately afterwards add
another ".profile" section:

    ID=storagetm
    TITLE=Boot into Storage Target Mode

This would then followed with a .cmdline section that is just like the
basic one, but with "rd.systemd.unit=storage-target-mode.target"
suffixed. Then, another .profile section would be added:

    ID=factory-reset
    TITLE=Factory Reset

Which is then followed by one last PE section: a .cmdline one with
"systemd.unit=factory-reset.target" suffixed to te regular command line.

i.e. expressed in tabular form the above would be:

    The base profile:
          .linux
          .initrd
          .cmdline
          .osrel
    The regular boot profile:
          .profile
    The storagetm profile:
          .profile
          .cmdline
    The factory reset profile:
          .profile
          .cmdline

You might wonder why the first .cmdline in the list above is placed in
the base profile rather than in the regular boot profile, given that it
is overriden in all other profiles anyway. And you are right. The only
reason I'd place it in the base profile is that it makes the UKI more
nicely extensible if later profiles are added that want to replace
something else instead of the .cmdline, for example .ucode or so. But it
really doesn't matter much.

While the primary usecase is of course multiple alternative command
lines, the concept is more powerful than that: for various usecases it
might be valuable to offer multiple choices of devicetree, ucode or
initrds.

The .profile contents is also passed to the invoked kernel as a file in
/.extra/profile (via a synthetic initrd). Thus, this functionality can
even be useful without overriding any section at all, simply by means of
reading that file from userspace.

Design choices:

1. On purposes I used a special command line marker (i.e. the "@" thing,
   which maybe we should call the "profile selector"), that doesn't look
   like a regular kernel command line option.  This is because this is
   really not a regular kernel command line option – we process it in
   the stub, then remove it as prefix, and measure the unprefixed
   command line only after that. The kernel will not see the profile
   selector either. I think these special semantics are best
   communicated by making it look substantially different from regular
   options.

2. This moves around measurements a bit. Previously we measured our UKI
   sections right after finding them. Now we first parse the profile
   number from the command line, then search for the profile's sections,
   and only then measure the sections we actually end up using for this
   profile. I think that this logic makes most sense: measure what we
   are using, not what we are overriding. Or in other words, if you boot
   profile @3, then we'll measure .cmdline (assuming it exists) of
   profile 3, and *not* measure .cmdline of the base profile. Also note
   that if the user passes in a custom kernel command line via command
   line arguments we'll strip off the profile selector (i.e. the initial
   "@X" thing) before we pass it on.

3. The .profile stuff is supposed to be generic and extensible. For
   example we could use it in future to mark "dangerous" options such as
   factory reset, so that boot menus can ask for confirmation before
   booting into it. Or we could introduce match expressions against
   SMBIOS or other system identifiers, to filter out profiles on
   specific hw.

Note btw, that PE allows defining multiple sections that point to the
same offsets in the file. This allows sharing payload under different
names. For example, if profile @4 and @7 shall carry the same .ucode
section, they can define .ucode in each profile and then make it point to
the same offset.

Also note that that one can even "mask" a base section in a profile, by
inserting an empty section. For example, if the base .dtb section should
not be used for profile @4, then add a section .dtb right after the
fourth .profile with a zero size to the UKI, and you will get your wish
fulfilled.

This code only contains changes to sd-stub. A follow-up commit will
teach sd-boot to also find this profile PE sections to synthesize
additional menu entries from a single UKI.

A later commit will add support for gnerating this via ukify.

Fixes: #24539
2024-09-10 06:49:08 +02:00
Lennart Poettering f4e081051d efi: teach PE parsing support for ".profile" sections
This adds helpers for:

1. Returning the PE section table of open PE files or memory

2. Scanning PE section tables for the sections that belong to a specific
   profile
2024-09-10 06:49:08 +02:00
Lennart Poettering 52dd7c8131 efi: add free_and_xstrdup16() helper modelled after free_and_strdup() in userspace 2024-09-10 06:48:38 +02:00
Lennart Poettering 9f6f3bd2fb Merge pull request #34297 from poettering/shell-prompt-extra
shell: define three system credentials we can propagate into shell prompts and welcome msgs
2024-09-10 06:42:31 +02:00
Lennart Poettering 89cdd4866a Merge pull request #34328 from poettering/analyze-help-text
analyze: --help text improvements
2024-09-10 06:42:03 +02:00
Lennart Poettering b4199a97e6 Merge pull request #34330 from poettering/shutdown-async-sync
shutdown: make all fsync()s asynchronous and apply timeout
2024-09-10 06:41:46 +02:00
Mike Yuan 0d3787deac networkctl: support editing netdev files by link and cat ":all"
Also, don't abuse RET_GATHER in verb_cat(), where the failures
are most likely unrelated to each other.

Closes #34281
2024-09-09 23:20:42 +02:00
Mike Yuan c9837c17d5 networkctl-status-link: show netdev files associated with link 2024-09-09 23:20:42 +02:00
Mike Yuan 4591c89a15 sd-network: introduce sd_network_link_get_netdev_file{,_dropins} 2024-09-09 23:20:42 +02:00
Mike Yuan 2cf9b1a0ee network: store netdev drop-in paths and dump into state file 2024-09-09 23:20:41 +02:00
Mike Yuan 4c8dc66438 networkd-state-file: use ASSERT_PTR where appropriate 2024-09-09 21:45:42 +02:00
Yu Watanabe da7fb6dad7 nspawn: use ERRNO_IS_NEG_NOT_SUPPORTED() at one more place
Follow-up for dc3223919f.
Addresses https://github.com/systemd/systemd/pull/34067#discussion_r1748061156.

Error codes other than ENOSYS may not come here, but if it comes, still
there is nothing we can do here, so let's not log the failure loudly.
2024-09-10 04:38:33 +09:00
Yu Watanabe b86b90cec5 nspawn: sync DeviceAllow= setting with systemd-nspawn@.service
Follow-up for dc3223919f.
Addresses https://github.com/systemd/systemd/pull/34067#discussion_r1748592958.

Otherwise, containers started with and without --keep-unit option run in
different device policies.
2024-09-10 04:38:11 +09:00
Lennart Poettering b4b66b2662 shutdown: replace unbounded fsync() with bounded sync_with_progress()
Let's put a time-out on this syncing.

Inspired-by: #34289 #34283
2024-09-09 19:12:31 +02:00
Lennart Poettering 13b5225d62 shutdown: teach sync_with_progress() to optionally sync a specific fd only
This is preparation for reusing the logic for syncing DM and other
devices with a timeout applied.
2024-09-09 19:12:31 +02:00
Lennart Poettering a8ea7c1940 meson: tweak meson conditionalization for ssh{d,}_config drop-ins
Let's make sure "no" is an acceptable setting for these paths.
2024-09-09 19:03:48 +02:00