Commit Graph
1136 Commits
Author SHA1 Message Date
Mike Gilbert 7cd137e647 bootctl: avoid using __WORDSIZE macro
__WORDSIZE does not seem to be documented anywhere, and is probably
meant to be used internally by glibc headers.

In systemd, it was only being used in warning messages. We can avoid
using it by rewording the messages slightly.

Fixes a build error with musl libc.

Bug: https://bugs.gentoo.org/894430
2023-02-15 10:24:25 +09:00
Yu Watanabe 0b75493da0 tree-wide: fix typo and comment style update 2023-02-15 10:08:16 +09:00
Jan Janssen ec96dad2f4 boot: Ensure raise() is not dropped by LTO 2023-02-12 22:23:22 +01:00
Jan Janssen 5983306474 boot: Fix undefined reference to raise() on arm
This is just a workaround. Once we drop gnu-efi, the arm build system
for EFI binaries should be changed to use the arm-none-eabi toolchain,
which should not exhibit this behavior.
2023-02-09 21:55:40 +00:00
Daan De Meyer 77db9ef2ab boot: Make sure we take --root into account everywhere. 2023-02-09 14:46:17 +00:00
Daan De Meyer 3b42ffe590 bootctl: Add missing %m 2023-02-09 11:31:57 +00:00
Luca Boccassi 5b5aaf9a91 Merge pull request #26180 from ddstreet/tpm2_cleanup
Add struct tpm2_handle and use _cleanup_ instead of goto
2023-02-01 23:40:52 +00:00
Luca Boccassi e5cf396181 Merge pull request #26287 from medhefgo/mkosi-auto-enroll
ci: Test with secure boot enabled under mkosi
2023-02-01 21:51:04 +00:00
Dan Streetman 16e16b8c7b tpm2: add Tpm2Handle with automatic cleanup
This allows using _cleanup_ with the handles, which then allows removing the
use of goto in all functions that use the handles.
2023-02-01 12:52:08 -05:00
Dan Streetman 23e9ccc24a tpm2: use Tpm2Context* instead of ESYS_CONTEXT*
This is needed for later patches that use Tpm2Handle, which requires access
to the Tpm2Context.
2023-02-01 12:51:17 -05:00
Dan Streetman 68d084cee5 tpm2: use ref counter for Tpm2Context
This will be used by Tpm2Handle instances, which is added in later patches.

The refcounting allows the context to be retained until all Tpm2Handles have
been cleaned up, and the initial ref is released, before cleaning the context.
2023-02-01 12:51:17 -05:00
Dan Streetman bd860983a6 tpm2: rename struct tpm2_context to Tpm2Context
This aligns with systemd coding guidelines for struct naming
2023-02-01 12:51:17 -05:00
Dan Streetman 7bfe0a48d9 tpm2: rename tpm2 alg id<->string functions
The 'pcr_bank' functions operate on hash algs, and are not specific to the PCR
banks, while the 'primary_alg' functions operate on asymmetric algs, and are
not specific to primary keys.
2023-02-01 18:13:48 +01:00
Jan Janssen 1e8e7f4463 boot: Add if-safe mode for secure boot enrollment 2023-02-01 16:52:28 +01:00
Lennart Poettering 74e795ee55 id128: introduce ERRNO_IS_MACHINE_ID_UNSET() helper macro 2023-02-01 15:25:30 +01:00
Jan Janssen 2df8574af0 boot: Use aarch64 virtual counter
This should be used in VMs and should also yield the same value when
running on real devices. It is also what grub uses.

Fixes: #26224
2023-01-27 09:26:16 +01:00
Jan Janssen a083aed03f boot: Use unicode literals
No changes in behavior.
2023-01-25 15:24:10 +01:00
Jan Janssen 54d9ecc380 boot: Use unsigned for beep counting 2023-01-25 15:23:49 +01:00
Jan Janssen dede50a715 boot: Replace UINTN with size_t
No changes in behavior.
2023-01-25 15:22:41 +01:00
Yu Watanabe a0344b17dd bootctl-status: several follow-ups for unlink command
Follow-ups for 8702496bfb.

- add missing error cause in logging,
- add several missing assertions,
- drop an unnecessary initialization,
- make boot_config_find_in() return negative errno if nothing found,
- and several coding style fixlets.
2023-01-25 10:51:50 +00:00
Yu Watanabe 1b7586df97 bootctl-uki: several follow-ups for inspect_osrel()
Follow-ups for #26124 and #26158.

- use os_release_pretty_name(),
- constify the buffer passed to inspect_osrel(),
- propagate errors in inspect_osrele(), and ignore them in the caller
  side,
- and several coding style fixlets.
2023-01-25 10:51:38 +00:00
Zbigniew Jędrzejewski-Szmek 2f6c52b919 shared/efi-loader: fix compilation with !ENABLE_EFI, improve messages
When compiled without ENABLE_EFI, efi_stub_measured() was not defined, so
compilation would fail. But it's not enough to add a stub that returns
-EOPNOTSUPP. We call this function in various places and usually print the error
at warning or error level, so we'd print a confusing message. We also can't add
a stub that always returns 0, because then we'd print a message like "Kernel
stub did not measure", which would be confusing too. Adding special handling for
-EOPNOTSUPP in every caller is also unattractive. So instead efi_stub_measured()
is reworked to log the warning or error internally, and such logging is removed
from the callers, and a stub is added that logs a custom message.
2023-01-24 23:07:21 +00:00
Jan Janssen 4a7ee0a521 meson: Do not include headers in source lists
Meson+ninja+compiler do this for us and are better at it.

https://mesonbuild.com/FAQ.html#do-i-need-to-add-my-headers-to-the-sources-list-like-in-autotools
2023-01-24 22:04:03 +01:00
Yu Watanabe 5b532e14e3 bootctl-uki: several coding style fixlets
Mostly follow-ups for #26082.
2023-01-24 16:32:34 +01:00
Gerd Hoffmann 2d4260482c bootctl: kernel-inspect: print os info 2023-01-24 16:32:16 +01:00
Luca Boccassi 780b9ae133 Merge pull request #26110 from medhefgo/boot-no-gnu-efi
boot: Stop linking against libefi.a
2023-01-23 23:51:49 +00:00
Callum Farmer 9c100c4e70 boot: Use objcopy with arm64
Binutils 2.38 added support for efi-app-aarch64
Still use binary mode if we have an older objcopy
Add check for incompatible gnu-efi crt0 containing the header section
which gets added by objcopy and if used results in duplicate header
and subsequently a broken binary

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
2023-01-23 22:52:07 +00:00
Jan Janssen cd4300f30f meson: Move bootctl sources defintion to its own file
The root meson.build file is already large enough.
2023-01-23 14:41:26 +01:00
Jan Janssen 1d278ad7d4 boot: Stop linking against libefi.a
libefi.a just provided the c helper API that was slowly removed. As we
do not depend on anything provided by it anymore, it is safe to drop
now.

Since the ST/BS/RT pointers are very convenient and needed everywhere,
they are retained and initialized by us.
2023-01-20 21:02:16 +01:00
Jan Janssen 31a131bb32 boot: Introduce DEFINE_EFI_MAIN macro 2023-01-20 21:01:08 +01:00
Jan Janssen 831b6a7fb0 boot: Simplify debug hook 2023-01-20 20:55:11 +01:00
Jan Janssen 19f08504c5 boot: Rework GUID handling
This stops using global GUID variables provided by gnu-efi. The globals
presumably exist to make EFI calls easier. But these GUIDs are just
128bits, so it's cheap to just put them on the stack when needed. C99
compound literals makes this even easier.

This also adds a convenience macro to create GUID pointers and uses it
everywhere. Not forcing a GUID definition to be a compound literal makes
them easier to use when assigning them to variables:
    EFI_GUID before = *SOME_CONST_GUID;
    EFI_GUID after = SOME_GUID;

And MAKE_GUID_PTR() makes it more explicit what is happening. It was
easy to confuse the old code as a cast:
    before(&(EFI_GUID) SOME_GUID);
    after(MAKE_GUID_PTR(SOME));
2023-01-20 20:55:11 +01:00
Jan Janssen 888b678f9f boot: Drop use of ValueToString 2023-01-20 20:55:11 +01:00
Jan Janssen edb73ee742 boot: Drop use of GuidToString 2023-01-20 20:55:11 +01:00
Lennart Poettering e684d2d5f8 bootctl: remove space that should not be there 2023-01-20 18:42:25 +01:00
Lennart Poettering eab7061898 bootctl: split out boot loader spec + boot loader interface commands in --help text
grub (at least on fedora) nowadays implements the boot loader spec, but
not the boot loader interface. Hence let's split out the commands
specific to each in two groups in the --help text. This way the first
group just covers boot lodaer spec stuff (i.e. stuff on disk in the
ESP/XBOOTLDR partition). And the other covers talking to the boot loader
via EFI var.
2023-01-20 18:42:25 +01:00
Lennart Poettering 5bbf72bb9e bootctl: realign column in --help text
for some reason the descriptions of the switches and the commands
weren't aligned, one space off. Fix that.
2023-01-20 18:30:47 +01:00
Lennart Poettering 1e7d6cc072 bootctl: change section title for kernel image commands
Let's call them kernel *images*, not just *kernels*.
2023-01-20 18:30:06 +01:00
Lennart Poettering 2b197967bf bootctl: drop full stop at end of --help texts
We never do that, don't do so here either.
2023-01-20 18:29:15 +01:00
Jan Janssen 4c0a83a434 boot: Properly strip EFI binaries
Removing debugging related sections is apparently not enough to truely
strip a (PE) binary.
Better late than never. It gets rid of this pesky warning from sbsign:
    warning: data remaining[174080 vs 193173]: gaps between PE/COFF sections?
2023-01-20 17:28:35 +01:00
Gerd Hoffmann 24a3b37f12 bootctl: add kernel-inspect to --help text 2023-01-20 14:17:51 +00:00
Yu Watanabe d09df6b94e tree-wide: fix typo 2023-01-20 15:32:16 +09:00
Ludwig Nussel 8702496bfb bootctl: unlink and cleanup functions
The unlink command removes an entry from the ESP including
referenced files that are not referenced in other entries. That is
useful eg to have multiple entries that use the same kernel with
different options.

The cleanup command removes all files that are not referenced by any
entry.
2023-01-19 14:24:43 +01:00
Luca Boccassi 41d125614c Merge pull request #23706 from medhefgo/efi-clang
boot: Add printf functions
2023-01-18 22:24:39 +00:00
Lennart Poettering a56182ddac Merge pull request #26082 from kraxel/uki
bootctl: add is-uki command
2023-01-18 18:10:30 +01:00
Jan Janssen 9220b2c46b boot: Drop use of Print
The custom print helpers have been replaced with explicit checks at the
call site to keep this in line with the way it is done in userspace. Any
calls where the check has been ommited should not need them as the value
is expected to alawys be around.
2023-01-18 17:47:57 +01:00
Jan Janssen 2f3c3b0bee boot: Drop use of xpool_print/SPrint 2023-01-18 17:47:57 +01:00
Jan Janssen 5966c54df4 boot: Add log_trace debugging helper 2023-01-18 16:50:04 +01:00
Jan Janssen 6ac54809de boot: Introduce log_wait
Instead of stalling for every log message as it appears we now wait for
several messages at strategic locations.
2023-01-18 16:50:04 +01:00
Jan Janssen c2c6203556 boot: Use printf for error logging
This also drops the _stall suffix in anticipation of the next commit.
2023-01-18 16:50:04 +01:00