Commit Graph
113 Commits
Author SHA1 Message Date
Mike Yuan 192954ac68 bootctl: declare missing arg_* in header
Follow-up for 90cf998875
2026-03-04 14:32:15 +01:00
Yu Watanabe 4b4eba1666 tree-wide: use _contains() rather than _get()/_find() 2026-03-02 23:10:22 +09:00
Zbigniew Jędrzejewski-Szmek 04897fbbee bootctl: override is_efi_boot() check by --variables= option (#40413)
Fixes #40392.
2026-02-25 15:42:53 +01:00
Mike Yuan 577e5e9a5e parse-argument: make parse_tristate_argument() do something useful
I expressed the issue I have with parse_tristate_argument()
in #37751: it doesn't add any value to direct use of parse_tristate();
on the contrary, it doesn't support means to reset the arg to "auto"/-1 state.
The mere reason it existed is that we need a int type ret param.

Since the previous attempt to address this mess failed, let's
try to make the function more useful by making it accept "auto".
I figure this is useful on its own.

As requested in
https://github.com/systemd/systemd/pull/40652#discussion_r2831833996,
the function name is suffixed with _with_auto() to establish
that "auto" is handled internally.
2026-02-20 21:20:45 +01:00
r-vdp 450e0dce02 systemd-boot: add a preferred setting that's similar to default but avoids booting known-bad entries
Motivation:
Currently, when setting the default boot pattern, boot assessment status
is not taken into account. This means that with boot assessment enabled,
when an explicit boot entry is configured as the default entry using an
EFI var, as is common for instance in A/B boot schemes, the configured
entry will be booted indefinitly, regardless of the entry's boot
assessment status.
In order to allow for this use case in combination with boot assessment,
we introduce a new `preferred` keyword, both in the config file and in the
bootctl CLI, that acts very similar to the existing `default` keyword but
takes boot assessment into account and never selects any entries that
have been marked as bad.
If the preferred pattern does not resolve to any bootable entry, and a
default pattern is also specified, then the default pattern will be
considered next, and we may then still select a known-bad entry to be
booted.

Fixes: https://github.com/systemd/systemd/issues/31215
Fixes: https://github.com/systemd/systemd/issues/40192
2026-02-18 03:28:12 +09:00
Yu Watanabe ed6a2eaa31 ask-password-api: several modernizations for ask_password_agent(); use CLEANUP_TMPFILE_AT more (#40631) 2026-02-16 20:07:32 +09:00
Mike Yuan 09388a6b9e tree-wide: drop redundant check for SD_VARLINK_METHOD_MORE flag
If the IDL declares the method requires 'more' yet the call doesn't
have it set, varlink_idl_validate_method_call() should have rejected
it and the callback shouldn't be reached.
2026-02-16 09:44:54 +01:00
Yu Watanabe 07f147d544 bootctl: do not use the EFI path as XBOOTLDR path
When running in a container, EFI and XBOOTLDR partition check is
relaxed, hence /boot may be recognized as both EFI and XBOOTLDR
partition.

Before:
```
$ run0 systemd-nspawn -xD / --private-network --bind=/sys/firmware/efi/efivars --bind=/boot -E SYSTEMD_LOG_LEVEL=debug -- build/bootctl --variables=yes --no-pager -x
Failed to check file system type of "/efi": No such file or directory
Using EFI System Partition at /boot.
Using XBOOTLDR partition at /boot as $BOOT.
/boot
```

After:
```
$ run0 systemd-nspawn -xD / --private-network --bind=/sys/firmware/efi/efivars --bind=/boot -E SYSTEMD_LOG_LEVEL=debug -- build/bootctl --variables=yes -x
Failed to check file system type of "/efi": No such file or directory
Using EFI System Partition at /boot.
Didn't find an XBOOTLDR partition, using the ESP as $BOOT.
/boot
```
2026-02-13 16:11:33 +09:00
Yu Watanabe 9bc1336abd bootctl: do not show an empty () for ESP partition
Before:
```
$ run0 systemd-nspawn -xD / --private-network --bind=/sys/firmware/efi/efivars --bind=/boot -- build/bootctl --variables=yes --no-pager
(snip)
Boot Loader Entry Locations:
          ESP: /boot ()
       config: /boot//loader/loader.conf
     XBOOTLDR: /boot ($BOOT)
        token: fedora
(snip)
```

After:
```
run0 systemd-nspawn -xD / --private-network --bind=/sys/firmware/efi/efivars --bind=/boot -- build/bootctl --variables=yes --no-pager
(snip)
Boot Loader Entry Locations:
          ESP: /boot
       config: /boot//loader/loader.conf
     XBOOTLDR: /boot ($BOOT)
        token: fedora
(snip)
```

This also moves spurious position of new line in each output.
2026-02-13 16:11:33 +09:00
Yu Watanabe 340c82c454 bootctl: make list command take --variables= option 2026-02-13 16:11:33 +09:00
Yu Watanabe 865f0fe28f bootctl: make status command take --variables= option 2026-02-13 16:11:33 +09:00
Yu Watanabe 6cd57ebcef bootctl: make reboot-to-firmware command take --variables= option 2026-02-13 16:11:33 +09:00
Yu Watanabe 1fa1e88ead bootctl: override is_efi_boot() check if --variables= option is specified
Fixes #40392.
2026-02-13 16:11:33 +09:00
Yu Watanabe 28fa318b16 bootctl: move arg_touch_variables checkers to bootctl-util.c
No functional change, just refactoring.
2026-02-13 16:11:30 +09:00
Yu Watanabe 3c5ed73030 bootctl: refuse --variables=yes when EFI support is disabled 2026-02-13 16:08:23 +09:00
Daan De Meyer 4f5d44ef53 tree-wide: Migrate to varlink_set_sentinel() 2026-02-11 14:25:36 +01:00
Mike Yuan 41615d59fa various: port manual goto cleanup to CLEANUP_TMPFILE_AT 2026-02-11 02:39:26 +01:00
Lennart Poettering 8b736d94cd bootctl: decouple "list", "unlink", "cleanup"
These operations to quite different things, they just share 2 common
funcs. Let's split them out into separate files.

This also splits up verb_list() into separate calls for the three
operations. This actually fixes issues, as for status/list we want
"unpriv" ESP discovery logic, but for the other two we really should
have privileged discovery logic.

This is preparation for adding "bootctl link" later, but this makes
sense either way, I am sure.
2026-02-10 19:43:04 +00:00
Lennart Poettering 51480b56c8 bootctl: rearrange if branches in vl_method_install() 2026-02-10 11:56:26 +01:00
Lennart Poettering 10268261a8 bootctl: toughen fd validation in Install() handler
Let's also check the fd flags. Just in case.
2026-02-10 11:56:26 +01:00
Lennart Poettering a537c5e4b8 bootctl: add comments emphasizing that certain functions do not touch the file read pointer 2026-02-06 23:17:02 +01:00
Lennart Poettering 9b29d38c33 bootctl: return recognizable Varlink error when we cannot determine the boot entry token
When running "bootctl install" on an empty --root= dir, we don't know
which token to use, and the operation will fail. Make sure to return an
explicit error about this.

This introduces a recognizable low-level error for this (EUNATCH), and
then turns this into a recognizable Varlink error.

(I made sure that the old low-level error EINVAL wasn't load-bearing,
and it is safe to change this.)
2026-02-06 23:16:50 +01:00
Lennart Poettering 91b3620b07 bootctl: optionally include backing disk name in efi boot option description 2026-02-06 23:16:49 +01:00
Lennart Poettering 7ee2f6657f bootctl: parse install source via our usual string table helpers 2026-02-06 23:16:00 +01:00
Lennart Poettering aea76373b2 bootctl: add Install() varlink API
Fixes: #11221
2026-02-06 23:15:49 +01:00
Lennart Poettering 38433a6d06 bootctl: rework bootctl-install.c in preparation of varlinkification
This primarily introduces a context object for each operation, so that
we later can instantiate one for each varlink op we execute, and can
safely lifecycle all operation parameters for each subequent call.

This also reworks the root dir handling to be fd based.

This drops explicit CHASE_TRIGGER_AUTOFS from a bunch of chase() calls
that operate within the ESP/XBOOTLDR, while it keeps them in place for the
chase() calls that find the top-level ESP/XBOOTLDR inode. This reflects
the fact that we explicitly support autofs for the ESP/XBOOTLDR itself,
but below it expect no further mounts, just plain VFAT.

This changes behaviour of the interaction of $KERNEL_INSTALL_CONF_ROOT
and --root=: the former will now be taken relative to the host root, and
will no longer be affected by --root=. This follows similar behaviour in
kernel-install, where it is very explicitly documented in the man page
(the bootclt man page does not document this). This is strictly speaking
a compat breakage, but i think a very minor, niche one, and I think the
pain afflicted by this change is probably neglible compare to the
unsystematic behaviour comapred to kernel-install.
2026-02-06 23:15:47 +01:00
Mike Yuan f6edc81230 bootctl,sbsign: fix $SOURCE_DATE_EPOCH parsing
This fixes two things:

* $SOURCE_DATE_EPOCH is previously treated as usec, while it's in seconds
* >= 0 is passed to log_debug_errno(), triggering assertion

Replaces #40403
2026-01-20 15:54:55 +01:00
Yu Watanabe 2c751f3420 Tweak setting of boot timeout variables (#40125) 2026-01-05 06:50:49 +09:00
Zbigniew Jędrzejewski-Szmek 1d26e7c1d5 bootctl: round the timeout up
I think this is better: if I specify 0.5s, I'd be suprised if the
menu didn't show up at all.
2026-01-04 13:58:37 +01:00
Zbigniew Jędrzejewski-Szmek abd17aa3f4 bootctl: rework setting of menu timeout variables
menu-force and menu-hidden were added in 97f077df05,
menu-disable was added in 6efdd7fec5, a year later.
So we can assume that if the feature flag is set, the other string values are
supported too. The comment that there's no way check that was added later in
5b45fad4fc, but it was incorrect even at that
time.

Fixes https://github.com/systemd/systemd/issues/39167. As described in the
issue, we documented various string values in the BLI, but bootctl didn't use
the string values. At the time menu-force and menu-hidden were added, using
numerical values for compatibility made sense. But that stopped being needed
when a string value that didn't have a strictly equivalent numerical value and
a feature flag were added.

When converting a large number to menu-force, message is downgraded to debug,
since the severity of the issue is very minor. Debug messages are added in
other places when the requested setting is modified too.
2026-01-04 13:55:44 +01:00
DaanDeMeyer 11f47cb700 bootctl-install: Fix OpenSSL UI
Follow up for a86a366eb0.
2025-12-24 18:04:57 +01:00
Luca Boccassi b262ded0bd Boot loader menu docs and tweaks (#39842) 2025-12-17 23:00:59 +00:00
Zbigniew Jędrzejewski-Szmek 3cdd80d3e0 sd-boot: correct typos 2025-12-17 22:55:38 +01:00
Yu Watanabe 93378148d4 tree-wide: normalize comment style 2025-12-15 08:50:13 +09:00
Yu Watanabe 5963cdf498 tree-wide: add missing '#pragma once' 2025-11-05 05:16:34 +09:00
jouyouyun 49ca2d8778 bootctl: fix typo 2025-11-03 11:30:42 +01:00
Yu Watanabe 219a67c131 bootctl: return earlier when secure boot auto-enrollment is requested but OpenSSL support is disabled 2025-11-02 16:07:46 +09:00
Yu Watanabe 1b48b63b51 bootctl: move conditions into corresponding functions 2025-11-02 16:07:46 +09:00
Daan De Meyer f102bc3e5f tree-wide: Introduce sd-forward.h and shared-forward.h headers
Let's not leak details from src/shared and src/libsystemd into
src/basic, even though you can't actually do anything useful with
just forward declarations from src/shared.

The sd-forward.h header is put in src/libsystemd/sd-common as we
don't have a directory for shared internal headers for libsystemd
yet.

Let's also rename forward.h to basic-forward.h to keep things
self-explanatory.
2025-10-16 17:00:29 +02:00
Felix Pehla 4a94a1b83f shared/bootspec: parse 'uki' boot entry option
Commit e2a3d56218 (as part of #36314)
makes sd-boot recognize a 'uki' stanza in a boot loader entry and
uapi-group/specifications@3f2bd8236d adds
it to the BLS, but bootctl and other components parsing said config do
not know about it, leading to the error message
`Unknown line 'uki', ignoring.` when attempting to parse the same entry.

This commit makes it get parsed the same way that that 'efi' is.
2025-09-29 22:59:49 +02:00
Lennart Poettering d71f2899bd meson: drop libblkid dep from components not using it directly 2025-09-24 18:11:12 +02:00
Lennart Poettering a86a366eb0 bootctl: split out auto-enroll cert load code into function of its own 2025-09-20 00:47:46 +09:00
Lennart Poettering 407139ae92 bootctl: output a more precise log message when updating existing EFI vars 2025-09-20 00:47:46 +09:00
Lennart Poettering 7dd55c83b8 bootctl: don't update $ESP/EFI/BOOTX64.EFI twice
We update BOOTX64.EFI explicitly once (because we know that it's the
main entry point of UEFI) and then a second time when we update
everything in $ESP/EFI/*.EFI. That's redundant and pretty ugly/confusing
in the log output. Hence exclude the file we already updated explicitly
from the 2nd run.
2025-09-20 00:47:46 +09:00
Lennart Poettering b6f4f85c39 bootctl: downgrade messages about foreign EFI files
Given that we iterate through $ESP/EFI/BOOT/*.EFI these days this is a
pretty common case, hence it's not really noteworthy, hence downgrade
these log messages from LOG_NOTICE to LOG_INFO.
2025-09-20 00:47:46 +09:00
Lennart Poettering c95d72913a bootctl: split out varlink setup into a helper call of its own 2025-09-20 00:47:46 +09:00
Lennart Poettering 83d0b6597c bootctl: normalize some enum definitions 2025-09-20 00:47:46 +09:00
Lennart Poettering f757022294 bootctl: use RET_GATHER() all over the place 2025-09-20 00:47:46 +09:00
Lennart Poettering 5c396a0110 bootctl: switch a few getenv() calls to secure_getenv()
Following the rule that we should always prefer the secure flavour over
the regular one unless there's a clear reason for the regular one, let's
switch this over. Better safe than sorry.
2025-09-20 00:47:46 +09:00
Yu Watanabe bed2723caa bootctl: drop unnecessary verb_unlink()
It is a trivial wrapper for verb_list(). Let's directly use verb_list()
and drop verb_unlink().

Follow-up for 8702496bfb.
2025-09-17 14:35:45 +02:00