Commit Graph

188 Commits

Author SHA1 Message Date
Endre Szabo 9e516e4c05
A typo fix in bootctl.c (#18106) 2020-12-30 12:10:24 +09:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Дамјан Георгиевски c4b843473a bootctl: add @current/@oneshot/@default targets to set-default/set-oneshot
Using `bootctl set-default @current` will set the default loader entry
to the currently booted entry as read from the `LoaderEntrySelected` EFI
variable.

Also `bootctl set-oneshot @current` will set the oneshot loader entry to
the current booted entry.

Correspondingly `@default` and `@oneshot` can be used to read from the
LoaderEntryDefault and LoaderEntryOneshot EFI variables.
2020-10-20 15:02:58 +02:00
Lennart Poettering 64a7fcc5cd bootctl: separate boot loader specific commands in man and --help
bootctl implements three types of operation: those that work with an EFI
boot loader, those which work with any EFI boot loader that implements
the boot loader spec + interface, and finally those specific to sd-boot.
Previously the --help text and the man page mixed them all up. Let's put
them clearly in three separate sections however, to communicate clearly
what is supposed to work everywhere, and what is specific to
systemd-boot or boot loaders implementing the two specs.

This adjusts wording here and there, but is mostly just about
re-ordering existing docs, and putting them under new sections.
2020-10-14 19:40:39 +02:00
Lennart Poettering ad0b610b0c bootctl: handle if LoaderSystemToken is invalid for some reason
This points to some firmware issue, but we should still be able to
correct things if this happens. Hence log about this and fix it.

Fixes: #17041
2020-09-14 21:33:31 +02:00
Lennart Poettering c1b9708c10 bootctl: don't accidentally propagate errors in "bootctl status"
Fixes: #16989
2020-09-10 12:45:54 +02:00
fangxiuning c53aafb7b5
tree-wide: drop pointless zero initialization (#16884)
tree-wide: drop pointless zero initialization
2020-08-28 17:45:54 +02:00
Daan De Meyer 31e57550b5 bootctl: Remove dependency on machine-id.
The machine-id is used to create a few directories and setup a default
loader entry in loader.conf. Having bootctl create the directories
itself is not particularly useful as it does not put anything in them
and bootctl install is not guaranteed to be called before an initramfs
tool like kernel-install so other programs will always need to have
logic to create the directories themselves if they happen to be called
before bootctl install is called.

On top of this, when using unified kernel images, these are installed to
$BOOT/EFI/Linux which removes the need to have the directories created
by bootctl at all. This further indicates that these directories should
be created by the program that puts something in them rather than by
bootctl.

Removing the machine-id dependency allows bootctl install to be called
even when there's no machine-id in the image. This is useful for image
builders such as mkosi which don't have a machine-id when
installing systemd-boot (via bootctl) because it should only be
generated by systemd when the final image is booted.

The default entry in loader.conf based on the machine-id in loader.conf
is also removed which shouldn't be a massive loss in usability overall.

This commit reverts commit 341890d.
2020-08-10 19:55:57 +01:00
Lennart Poettering 002914e688 bootctl: add simple, low-level reboot-to-firmware verb for controlling the flag 2020-05-29 15:41:50 +02:00
Lennart Poettering 8a96369e0b bootctl: show reboot-to-firmware info, too 2020-05-29 15:41:46 +02:00
Lennart Poettering d4bd786d69 efi: cache LoaderEntries EFI variable
Based-on:

https://github.com/systemd/systemd/issues/14828#issuecomment-634202054
2020-05-29 15:40:01 +02:00
Zbigniew Jędrzejewski-Szmek 6b8664cb5b tree-wide: fix bad errno checks 2020-05-20 18:10:58 +02:00
Zbigniew Jędrzejewski-Szmek 162392b75a tree-wide: spellcheck using codespell
Fixes #15436.
2020-04-16 18:00:40 +02:00
Lennart Poettering c46db6c0a2 bootctl: fix assert issue
Follow-up for b46c3e4913
2020-04-09 11:22:40 -07:00
Vito Caputo b46c3e4913 *: use _cleanup_close_ with fdopen() where trivial
Also convert these to use take_fdopen().
2020-03-31 06:48:03 -07:00
Zbigniew Jędrzejewski-Szmek 607ebf2bd2 bootlctl: show LoaderDevicePartUUID information in status 2019-11-30 17:42:13 +01:00
Lennart Poettering 351de38e4b bootctl: make 'random-seed' handle inability to write system token EFI variable gracefully
Apparently some firmwares don't allow us to write this token, and refuse
it with EINVAL. We should normally consider that a fatal error, but not
really in the case of "bootctl random-seed" when called from the
systemd-boot-system-token.service since it's called as "best effort"
service after boot on various systems, and hence we shouldn't fail
loudly.

Similar, when we cannot find the ESP don't fail either, since there are
systems (arch install ISOs) that carry a boot loader capable of the
random seed logic but don't mount it after boot.

Fixes: #13603
2019-11-21 19:55:17 +01:00
Zbigniew Jędrzejewski-Szmek 2536752dda Rename "system-options" to "systemd-efi-options"
This makes the naming more consistent: we now have
bootctl systemd-efi-options,
$SYSTEMD_EFI_OPTIONS
and the SystemdOptions EFI variable.

(SystemdEFIOptions would be redundant, because it is only used in the context
of efivars, and users don't interact with that name directly.)

bootctl is adjusted to use 2sp indentation, similarly to systemctl and other
programs.

Remove the prefix with the old name from 'bootctl systemd-efi-options' output,
since it's redundant and we don't want the old name anyway.
2019-11-18 20:20:58 +01:00
Zbigniew Jędrzejewski-Szmek b289de2b06 bootctl: update --help text 2019-11-18 20:20:58 +01:00
Lennart Poettering 353b2baa20 tree-wide: clean up --help texts a bit
This cleans up and unifies the outut of --help texts a bit:

1. Highlight the human friendly description string, not the command
   line via ANSI sequences. Previously both this description string and
   the brief command line summary was marked with the same ANSI
   highlight sequence, but given we auto-page to less and less does not
   honour multi-line highlights only the command line summary was
   affectively highlighted. Rationale: for highlighting the description
   instead of the command line: the command line summary is relatively
   boring, and mostly the same for out tools, the description on the
   other hand is pregnant, important and captions the whole thing and
   hence deserves highlighting.

2. Always suffix "Options" with ":" in the help text

3. Rename "Flags" →  "Options" in one case

4. Move commands to the top in a few cases

5. add coloring to many more help pages

6. Unify on COMMAND instead of {COMMAND} in the command line summary.
   Some tools did it one way, others the other way. I am not sure what
   precisely {} is supposed to mean, that uppercasing doesn't, hence
   let's simplify and stick to the {}-less syntax

And minor other tweaks.
2019-11-18 15:14:43 +01:00
Lennart Poettering a4a55e9ace bootctl: create leading dirs when "bootctl random-seed" is called if needed
Prompted by: #13603
2019-11-04 14:26:53 +01:00
Yu Watanabe 1405cb653a tree-wide: drop stdio.h when stdio-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe e30e8b5073 tree-wide: drop stat.h or statfs.h when stat-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe adb29d588e tree-wide: drop blkid.h when blkid-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe 996f7e1cd0 tree-wide: drop dirent.h when dirent-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe 455fa9610c tree-wide: drop string.h when string-util.h or friends are included 2019-11-04 00:30:32 +09:00
Zbigniew Jędrzejewski-Szmek e1fac8a68a Move the Commands section above Options section
For executables which take a verb, we should list the verbs first, and
then options which modify those verbs second. The general layout of
the man page is from general description to specific details, usually
Overview, Commands, Options, Return Value, Examples, References.
2019-10-08 18:21:26 +02:00
Zbigniew Jędrzejewski-Szmek 4e5aa79185 bootctl: add "system-options" verb 2019-09-16 18:08:54 +02:00
Zbigniew Jędrzejewski-Szmek 0bb2f0f10e util-lib: split shared/efivars into basic/efivars and shared/efi-loader
I want to use efivars.[ch] in proc-cmdline.c, but most of the efivars stuff is
not needed in basic/. Move the file from shared/ to basic/, but then move back
most of the higher-level functions to the new shared/efi-loader.c file.
2019-09-16 18:08:53 +02:00
Yu Watanabe f8a2b09a18 bootctl: arg_dolloar_boot_path() may return NULL 2019-08-12 16:14:07 +09:00
Yu Watanabe a2ae0d4969 bootctl: clear arg_xbootldr_path when acquire_xbootldr() succeeds 2019-08-12 00:04:44 +09:00
Zbigniew Jędrzejewski-Szmek a4d208018c bootctl: log message tweaks
Follow-up for e44c3229f2.
2019-07-26 15:05:18 +02:00
Lennart Poettering a2aa605d22 bootctl: add is-installed verb
Fixes: #9428
2019-07-25 18:31:20 +02:00
Lennart Poettering d6e9a347a5 bootctl: show random seed state 2019-07-25 18:20:50 +02:00
Lennart Poettering e44c3229f2 bootctl: add new verb for initializing a random seed in the ESP 2019-07-25 18:20:50 +02:00
Lennart Poettering 22c5ff5132 bootctl: add new feature flag for indicating random seed management support 2019-07-25 17:10:51 +02:00
Lennart Poettering b461576de4 bootctl: drop const from non-pointer function argument 2019-07-25 17:10:51 +02:00
Lennart Poettering 5509f91261 bootctl: use the fact that startswith() returns the suffix 2019-07-25 17:10:51 +02:00
Lennart Poettering d90f2add54 bootctl: show correct error code 2019-07-24 08:56:54 +09:00
Yu Watanabe 8cec0a5c32 tree-wide: drop duplicated blank lines
```
$ for i in */*.[ch] */*/*.[ch]; do sed -e '/^$/ {N; s/\n$//g}' -i $i; done
$ git checkout HEAD -- basic/linux shared/linux
```
2019-07-15 18:41:27 +02:00
Zbigniew Jędrzejewski-Szmek 3a76fbe01c bootctl,sd-boot: define EFI_LOADER_FEATURE_XBOOTLDR
It was added back in fa2a3bbdd8, but we
forgot to add the feature define.
2019-07-10 15:02:33 +02:00
Lennart Poettering 05b2ace147
Merge pull request #12870 from yuwata/tree-wide-further-path-join-cleanups
tree-wide: further path_join() and path_joina() cleanups
2019-06-25 09:27:01 +02:00
Zbigniew Jędrzejewski-Szmek 9dae4c8a26 bootctl: fix display of options with embedeed newlines
I have an .efi image with embedded newlinews. Now I don't even remember if it
was created for testing or by accident, but it doesn't really matter. We should
display such files correctly.

(This isn't a problem with normal BLS entries, because input is split into lines
so newlines are consumed.)
2019-06-25 10:30:58 +09:00
Yu Watanabe 270384b2d4 tree-wide: replace strjoina() with prefix_roota() 2019-06-25 01:31:26 +09:00
Yu Watanabe 042526868a
Merge pull request #12508 from keszybz/no-root-checks
Drop many root checks
2019-06-06 21:31:19 +09:00
Zbigniew Jędrzejewski-Szmek aa467bcae1 bootctl: do not allow -x and -p to be used together
-x already prints the path to ESP in some circumstances, and allowing
both to be printed seems confusing.
2019-05-19 12:01:32 +02:00
Zbigniew Jędrzejewski-Szmek fba4e94506 bootctl: add -x shortcut for --print-boot-path
It's a quite useful option, let's match -p.
2019-05-19 11:55:36 +02:00
Zbigniew Jędrzejewski-Szmek 405b104df6 bootclt: add missing column
This got broken somehow in 44e6a5ef82.
2019-05-19 11:31:19 +02:00
Zbigniew Jędrzejewski-Szmek 7c3ce8b5a9 bootctl: drop must_be_root() checks
The reasoning is the same as in previous cases. We get an error like
"Failed to update EFI variable: Operation not permitted" anyway, so
the check is not very useful.
2019-05-08 11:51:51 +02:00
Zbigniew Jędrzejewski-Szmek cce9457c70 bootctl: urlify .conf files
Just because we can ;)
2019-04-05 14:01:35 +02:00