Commit Graph

34 Commits

Author SHA1 Message Date
Yu Watanabe
cdf3339c56 bootctl: fix typo
Follow-up for bbeeea4362.
2025-04-19 04:49:29 +09:00
Daan De Meyer
93a1f7921a basic: Stop including log.h in macro.h
Now that the necessary functions from log.h have been moved to macro.h,
we can stop including log.h in macro.h. This requires modifying source
files all over the tree to include log.h instead.
2025-04-18 14:19:15 +02: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
Daan De Meyer
69369fd322 bootctl: adjust feature message (#36372) 2025-03-21 11:17:00 +01:00
Zbigniew Jędrzejewski-Szmek
6012a52aba bootctl: do not print special glyphs to the log
The log line looked like this:
  bootctl[1457]: ! Mount point '/efi' which backs the random seed file is world accessible, which is a security hole! !
which doesn't look nice.

Also upgrade the message to error. This is something to fix.
2025-03-15 14:40:52 +01:00
Zbigniew Jędrzejewski-Szmek
1ae9b0cfa8 basic/glyph-util: rename "special glyph" to just "glyph"
Admittedly, some of our glyphs _are_ special, e.g. "O=" for SPECIAL_GLYPH_TOUCH ;)
But we don't need this in the name. The very long names make some invocations
very wordy, e.g. special_glyph(SPECIAL_GLYPH_SLIGHTLY_UNHAPPY_SMILEY).
Also, I want to add GLYPH_SPACE, which is not special at all.
2025-03-15 14:40:39 +01:00
Zbigniew Jędrzejewski-Szmek
16fa8dbbe9 bootctl: fix boolean logic in id128 comparisons
There were too many levels of negation there. Add a comment to explain the
reasoning at a high level.
2025-03-14 12:21:45 +01:00
Zbigniew Jędrzejewski-Szmek
f25e4e5af0 bootctl: stop printing "Stub/Boot loader set partition information"
... and "Stub/Boot loader set network boot URL information".

This reverts 26bfd97216
('bootctl: also shown whether stub loader partition data was passed'),
and one line from bfcf48b842
('bootctl: show stub partition data too in "status" too'),
and two lines from e15d18b4c6
('sd-stub: if we are http booted, query source URL and write to EFI variable').

As discussed in https://github.com/systemd/systemd/pull/36372, those are not
"features", but optional pieces of information that may or may not be set, also
depending on how the boot loader and stub were loaded. We already prominently
show this information right below: either we print the device path or "n/a" or
skip the output. The user already has all the information, and the status
output should be dense, so it doesn't make sense to repeat this twice.

               ✓ Boot loader set partition information
    Partition: /dev/disk/by-partuuid/3f003ec5-5673-5b4f-b9a4-cbac1ca4461a
OR
               - Boot loader set partition information
    Partition: n/a

               ✓ Stub loader set partition information
    Partition: /dev/disk/by-partuuid/3f003ec5-5673-5b4f-b9a4-cbac1ca4461a
OR
               - Stub loader set partition information
    Partition: n/a
2025-03-13 12:30:59 +01:00
Lennart Poettering
a462280c9a bootctl: tweak status output when operating on --image= files
Let's not claim the system was not booted with UEFI if we use --image=.
The system wasn't booted at all, after all. Hence supress the whole
section altogether in this case.
2025-03-13 10:49:53 +01: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
Daan De Meyer
a5bfd056c1 bootctl-install: Use i2d_PKCS7() instead of i2d_PKCS7_SIGNED()
For a detached signature, these are equivalent so let's use i2d_PKCS7()
like we do everywhere else.
2025-02-25 09:49:53 +00:00
Lennart Poettering
1089d0f89e boot: add new 'uki-url' bls type #1 menu items for booting remote UKIs
Companion BLS spec PR:

https://github.com/uapi-group/specifications/pull/135
2025-02-21 10:04:15 +01:00
Lennart Poettering
e2a3d56218 boot: add new bls type #1 stanza "uki"
This one is between "efi" and "linux": we'll recognize such entries as
linux, but we'll just invoke them as EFI binaries.

This creates a high-level concept for invoking UKIs via indirection of a
bls type #1 entry, for example to permit invocation from a non-standard
path or for giving entries a different name.

Companion BLS spec PR:

https://github.com/uapi-group/specifications/pull/135

(Let's rename LOADER_UNIFIED_LINUX to LOADER_TYPE2_UKI at the same time
to reduce confusion what is what)
2025-02-21 10:04:15 +01:00
Lennart Poettering
e15d18b4c6 sd-stub: if we are http booted, query source URL and write to EFI variable
This way userspace can read the field, and use it to retrieve more
resources from the same place.
2025-02-21 10:03:32 +01:00
Lennart Poettering
fd2a114061 bootctl: fix potential uninitialized memory access (#36329) 2025-02-10 15:34:38 +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
af5b961ad8 bootctl: minor reordering of fields in output
Let's move the currently used/default/oneshot entry output after the
basic info about the boot loader itself, since conceptually these are
objects kinda "one level down" from the boot loader perspective. Hence,
let's *first* show all info about the boot loader itself before we
display the objects it manages.

This is just a trivial change in output, just swaps th elines for these
fields with the ones showing where the boot loader is installed.
2025-02-09 23:34:29 +01:00
Lennart Poettering
df418fa234 bootctl: suppress output of empty partition info if we also have no idea about EFI binary path
So far we'd output both the partition and the binary path always, even
if we didn't know either (but in that case show empty information).
Let's address this, and show partition info only if we know it, or if we
know the EFI binary path, but suppress both if we know neither.

Note that we'll show the partition info if we don't know it still if we
know the EFI binary path used for boot, since it is relative to the
partition of course, and hence it's really strange to know one but not
the other, hence it deserves some mentioning in the output.
2025-02-09 23:23:38 +01:00
Lennart Poettering
26bfd97216 bootctl: also shown whether stub loader partition data was passed
Let's make the stub and loader output sections more alike, and say in
both cases whether we recieved that data from the boot phase or not the
same way.
2025-02-09 23:21:14 +01:00
Lennart Poettering
df28afe9b2 bootctl: fix potential uninitialized memory access
And while we are at it, let' get rid of have_xyz_partition_uuid
variables, to simplify things.
2025-02-09 23:19:46 +01:00
Lennart Poettering
f90efd2d13 bootctl: improve output regarding random seed if we cannot access ESP 2025-02-09 09:14:21 +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
Yu Watanabe
c1bfee0bdb bootctl: use hash ops with destructor
This also makes the hashmap allocated when necessary.
2025-01-23 18:19:28 +09:00
Yu Watanabe
901bfcd8c1 tree-wide: rely on sd_varlink_dispatch() for validating zero-argument method calls, too
Follow-ups for a7cc7038ac.
2025-01-20 00:21:31 +09:00
Lennart Poettering
d66894a7a5 ask-password-api: add new "hup_fd" field to AskPasswordReq
This new field allows specification of an fd on which the password
prompt logic will look for POLLHUP events for, and if seen will abort
the query.

The usecase for this is that when we query for a pw on behalf of a
Varlink client we can abort the query automatically if the client dies.
2025-01-02 16:38:44 +01:00
Lennart Poettering
c4a02a526d ask-password-api: move timeout into AskPasswordRequest structure too 2025-01-02 16:38:25 +01:00
Lennart Poettering
72068d9d25 ask-password-api: move tty_fd into AskPasswordRequest structure, too 2025-01-02 16:38:12 +01: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
Adrian Vovk
f2751d757f bootspec: Look at /loader/addons in XBOOTLDR
The bootspec util-lib's handling of global addons didn't previously
match the behavior of sd-stub, and this commit corrects that.

First, bootspec didn't load global addons from the XBOOTLDR dir, but the
stub does. So, bootspec now enumerates addons in XBOOTLDR, not just ESP

Second, the stub only loads resources (including addons) from the
partition that it was found on. Thus, we must keep track of which
partition the global addons come from, and which partition each boot
entry comes from. In other words: global addons found on the ESP will
NOT apply to UKIs found in XBOOTLDR, and bootspec now reflects that.
2024-11-26 22:25:29 -05:00
Daan De Meyer
f2ac4458f0 bootctl: Only create loader/keys/auto if required
systemd-boot uses the existance of loader/keys/auto to determine
whether to auto-enroll secure boot or not so only create the directory
if we're actually going to put auto-enroll signature lists in it.
2024-11-15 18:36:53 +00: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
Daan De Meyer
4047b99c00 bootctl: Validate private key path 2024-11-07 20:24:59 +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