Commit Graph
31 Commits
Author SHA1 Message Date
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 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 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
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 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
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
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
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
Antonio Alvarez Feijoo 5a70aa5315 bootctl: clarify that --secure-boot-auto-enroll requires a boolean value 2025-09-08 12:31:27 +02:00
Antonio Alvarez Feijoo 992716c9ab bootctl: fix reference to non-existent option in error log 2025-09-08 12:30:35 +02:00
Mike Yuan 1bc82e0c97 bootctl: make sure install verb also honors implied --graceful
Follow-up for bcc73cafdb
2025-09-05 04:45:33 +09:00
Antonio Alvarez Feijoo 13358b7ce2 bootctl: specify that kernel image commands require a kernel image argument 2025-08-13 11:28:22 +01:00
Luca Boccassi bcc73cafdb bootctl: automatically set --graceful when running in chroot
Installing stuff in a chroot should not fail because efivars are
not available. When running in a container touching efivars is
completely disabled, but there are some cases (recovery) where
it is needed to touch them in a chroot, so don't disable them but
avoid failing the run instead.
2025-07-25 20:44:03 +01:00
Yu Watanabe 83a047fe23 tree-wide: include sys/stat.h where necessary
These source files uses symbols provided by sys/stat.h, e.g. struct stat,
S_IFREG, S_IFBLK, and so on. Let's explicitly include sys/stat.h where
necessary.

Glibc's fcntl.h includes bits/stat.h, which provides these symbols, so
these symbols can be used without explicitly including sys/stat.h. But,
based on the discussion in #37922, we should explicitly include relevant
headers, and should not rely on the indirect inclusion.

Similar to 4f18ff2e29, but for sys/stat.h.
2025-07-07 12:44:10 +09:00
Daan De Meyer f712008289 bootctl: Clean up includes
Split out of #37344.
2025-05-22 02:14:09 +09:00
Igor Opaniuk 2857a83975 bootctl: configure a sysfail entry
You can configure the sysfail boot entry using the bootctl command:
$ bootctl set-sysfail sysfail.conf

The value will be stored in the `LoaderEntrySysFail` EFI variable.

The `LoaderEntrySysFail` EFI variable would be unset automatically
during next boot by `systemd-boot-clear-sysfail.service` if no
system failure occured, otherwise it would be kept as it is and a system
failure reason will be saved to `LoaderSysFailReason` EFI variable.

Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
2025-05-12 15:37:47 +02:00
Yu Watanabe cdf3339c56 bootctl: fix typo
Follow-up for bbeeea4362.
2025-04-19 04:49:29 +09:00
Lennart Poettering bbeeea4362 bootctl: replace --no-variables by --variables=BOOL
I think the current behaviour of not doing EFI variables when we are run
in a container makes a ton of sense, but in some cases it's useful to
do EFI var setup even when a set of namespaces is set up for us, for
example to recover a hosed installation from a rescue disk.

While we are at it, let's remove some duplicate checks, and
systematically output information why we skip various operations.

Fixes: #36174 #35005
2025-04-16 13:39:12 +02:00
Lennart Poettering 742e26ba20 bootctl: make sure bootctl --image= works on image with /usr/ but without /
Let's make sure we can use the tool on ParticleOS images. They have no
root fs by default (until they are instantiated), but always have /usr/.
Hence add DISSECT_IMAGE_USR_NO_ROOT which has the desired effect.
2025-03-13 10:49:33 +01:00
Lennart Poettering 14871a6529 efivars: kill SystemdOptions efi var support
This has been depracted since v254 (2023). Let's kill it for
good now, it has been long enough with 2y. Noone has shown up who wants
to keep it. And given it doesn't work in SB world anyway, and is not
measured is quite problematic security wise.
2025-02-26 17:28:43 +01:00
Lennart Poettering 37252381d2 bootctl,kernel-install: suffix some paths referring to dirs in log messages with / 2025-02-10 01:15:52 +01:00
Lennart Poettering 7249651bff bootctl: move print block device path calls to command section of its own 2025-01-28 16:25:15 +00:00
Zbigniew Jędrzejewski-Szmek fd409ff0e0 various: set info on varlink server object
The values that were previously hardcoded in sd-varlink.c are now defined
in new varlink_set_info_systemd() and that function is called everywhere
where we create a server.
2024-12-10 10:51:56 +01:00
Daan De Meyer a1d46e3078 tree-wide: Introduce --certificate-source= option
This allows loading the X.509 certificate from an OpenSSL provider
instead of a file system path. This allows loading certficates directly
from hardware tokens instead of having to export them to a file on
disk first.
2024-11-07 20:30:47 +01:00
Zbigniew Jędrzejewski-Szmek 0b676aab33 Move bootctl to its own source subdirectory
It's been split into a bunch of files and deserves its own subdirectory
similarly to systemctl.
2024-11-07 14:15:00 +01:00