Commit Graph

150 Commits

Author SHA1 Message Date
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
Zbigniew Jędrzejewski-Szmek d3eb60722d bootctl: emit extra warning if the default boot entry is broken
Let's make it more obvious for the user if something is badly borked.
It does the job, but I'm not too happy with this.
2019-04-05 13:51:30 +02:00
Zbigniew Jędrzejewski-Szmek 44e6a5ef82 bootctl: check if files specified by boot entry exist, and warn if not
Example output:
        title: Fedora 30 (Workstation Edition) (5.0.5-300.fc30.x86_64)
           id: 08a5690a2eed47cf92ac0a5d2e3cf6b0-5.0.5-bad-300.fc30.x86_64
       source: /boot/efi/loader/entries/08a5690a2eed47cf92ac0a5d2e3cf6b0-5.0.5-bad-300.fc30.x86_64.conf
      version: 5.0.5-300.fc30.x86_64
   machine-id: 08a5690a2eed47cf92ac0a5d2e3cf6b0
        linux: /08a5690a2eed47cf92ac0a/5.0.5-300.fc30.x86_64/linux (No such file or directory)
       initrd: /08a5690a2eed47cf92ac0a/5.0.5-300.fc30.x86_64/initrd (No such file or directory)
               /08a5690a2eed47cf92ac0a/5.0.5-300.fc30.x86_64/initrd2 (No such file or directory)
      options: ...
2019-04-05 13:51:19 +02:00
Zbigniew Jędrzejewski-Szmek ce4c4f8108 bootctl: replace "type" with "source" in output
I think this is more useful (because it's easy to stick the path into an editor command
when one wants to change the options or inspect the files), and more self-explanatory.

Example output:
        title: Fedora 30 (Workstation Edition) (4.20.16-200.fc29.x86_64)
           id: 08a5690a2eed47cf92ac0a5d2e3cf6b0-4.20.16-200.fc29.x86_64
       source: /boot/efi/loader/entries/08a5690a2eed47cf92ac0a5d2e3cf6b0-4.20.16-200.fc29.x86_64.conf
      version: 4.20.16-200.fc29.x86_64
          ...

        title: Fedora 30 (Workstation Edition)
           id: fedora-30
       source: /boot/efi/EFI/Linux/linux-5.0.5-300.fc30.x86_64-08a5690a2eed47cf92ac0a5d2e3cf6b0.efi
        linux: EFI/Linux/linux-5.0.5-300.fc30.x86_64-08a5690a2eed47cf92ac0a5d2e3cf6b0.efi
          ...

        title: Reboot Into Firmware Interface
           id: auto-reboot-to-firmware-setup
       source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
2019-04-05 13:50:34 +02:00
Zbigniew Jędrzejewski-Szmek bd44566c4d tree-wide: use SD_ID128_UUID_FORMAT_STR as appropriate 2019-04-05 13:48:38 +02:00
Lennart Poettering a7798cd81b tree-wide: use reallocarray() where appropriate 2019-04-02 14:54:42 +02:00
Zbigniew Jędrzejewski-Szmek e2600fd582 bootctl: use path_join() to join paths
We would say "/boot/efi//loader/entries"...
2019-03-14 08:28:18 +01:00
Zbigniew Jędrzejewski-Szmek 341890de86 bootctl: create $BOOT/<machine-id> when installing sd-boot 2019-03-12 09:45:16 +01:00
Lennart Poettering 93f14ce28d bootspec: move augmentation of loader-discovered entries into bootspec.c
Previously, bootctl would show boot loader entries discovered by the
boot loader which couldn't found locally separately in the output.

Let's move this code into bootspec.c, and beef it up a bit. This way we
can use it later on for logind, and correctly show automatically
discovered windows/macos entries too.
2019-03-05 16:50:58 +01:00
Lennart Poettering 4629499e7f bootctl: tweak 'list' output a bit
Let's suppress the final newline in the list if it's the last entry we
are outputting.
2019-03-05 16:50:58 +01:00
Zbigniew Jędrzejewski-Szmek cc5fc36aec
Merge pull request #11243 from poettering/nspawn-root-overlay
add systemd-nspawn --volatile=overlay support, as well as the same for host systems
2019-03-01 16:08:55 +01:00
Lennart Poettering adc6f43b14 copy: don't synthesize a 'user.crtime_usec' xattr on copy unless explicitly requested
Previously, when we'd copy an individual file we'd synthesize a
user.crtime_usec xattr with the source's creation time if we can
determine it. As the creation/birth time was until recently not
queriable form userspace this effectively just propagated the same xattr
on the source to the same xattr on the destination. However, current
kernels now allow to query the birthtime using statx() and we do make
use of that now. Which means that suddenly we started synthesizing these
xattrs much more regularly.

Doing this actually does make sense, but only in very few cases:
not for the typical regular files we copy, but certainly when dealing
with disk images. Hence, let's keep this kind of propagation, but let's
make it a flag and default to off. Then turn it on whenever we deal with
disk images, and leave it off otherwise.

This is particularly relevant as overlayfs combining a real fs, and a
tmpfs on top will result in EOPNOTSUPP when it is attempted to open a
file with xattrs for writing, as tmpfs does not support xattrs, and
hence the copy-up cannot work. Hence, let's avoid synthesizing this
needlessly, to increase compat with overlayfs.
2019-03-01 14:11:07 +01:00
Lennart Poettering 0d73a81611 bootctl: properly handle readdir() errors 2019-03-01 12:41:32 +01:00
Lennart Poettering 882b3bd6c5 bootctl: let's make sure we always add empty line after EFI binary output
Let's make sure we output another "\n", even if we fail this function,
so that the output we started is separated properly from what is
following.
2019-03-01 12:41:32 +01:00
Lennart Poettering 81fed855d9 bootctl: output where we found $BOOT 2019-03-01 12:41:32 +01:00
Lennart Poettering fbf45d22da bootctl: teach bootctl the new partition type 2019-03-01 12:41:32 +01:00
Lennart Poettering a2f8664e9a bootspec: load entries from both the ESP and XBOOTLDR partitions
Let's simply search in both.
2019-03-01 12:41:32 +01:00
Lennart Poettering c4ba5b516d bootctl: safety check for regular file when reading EFI images 2019-03-01 12:41:32 +01:00
Lennart Poettering 78d5d4ed77 bootctl: use SYNTHETIC_ERRNO() where appropriate 2019-03-01 12:41:32 +01:00
Lennart Poettering 9a6f746fb6 locale-util: prefix special glyph enum values with SPECIAL_GLYPH_
This has been irritating me for quite a while: let's prefix these enum
values with a common prefix, like we do for almost all other enums.

No change in behaviour, just some renaming.
2018-12-14 08:22:54 +01:00
Chris Down e92aaed30e tree-wide: Remove O_CLOEXEC from fdopen
fdopen doesn't accept "e", it's ignored. Let's not mislead people into
believing that it actually sets O_CLOEXEC.

From `man 3 fdopen`:

> e (since glibc 2.7):
> Open the file with the O_CLOEXEC flag. See open(2) for more information. This flag is ignored for fdopen()

As mentioned by @jlebon in #11131.
2018-12-12 20:47:40 +01:00
Lennart Poettering e4de72876e util-lib: split out all temporary file related calls into tmpfiles-util.c
This splits out a bunch of functions from fileio.c that have to do with
temporary files. Simply to make the header files a bit shorter, and to
group things more nicely.

No code changes, just some rearranging of source files.
2018-12-02 13:22:29 +01:00
Zbigniew Jędrzejewski-Szmek baaa35ad70 coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.

I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
2018-11-22 10:54:38 +01:00
Zbigniew Jędrzejewski-Szmek 294bf0c34a Split out pretty-print.c and move pager.c and main-func.h to shared/
This is high-level functionality, and fits better in shared/ (which is for
our executables), than in basic/ (which is also for libraries).
2018-11-20 18:40:02 +01:00
Yu Watanabe 608f8ec92e bootctl: use static destructor and DEFINE_MAIN_FUNCTION() macro 2018-11-20 16:48:21 +01:00
Lennart Poettering 80641a81b6 bootctl: display loader features in a pretty way. 2018-11-16 15:52:22 +01:00
Zbigniew Jędrzejewski-Szmek 0221d68a13 basic/pager: convert the pager options to a flags argument
Pretty much everything uses just the first argument, and this doesn't make this
common pattern more complicated, but makes it simpler to pass multiple options.
2018-11-14 16:25:11 +01:00
Yu Watanabe 7709ef3a70 bootctl: include error cause in log message 2018-10-20 00:52:45 +09:00
Lennart Poettering bd2865caf6 bootctl: include boot entries discovered by the boot loader but not in $BOOT in the "list" output
Let's use the new LoaderEntries efi var for this, and show all entries
we couldn't find via the config snippets.
2018-10-08 21:40:44 +02:00
Lennart Poettering d88c96ffe5 bootctl: add new verbs for setting the default boot/oneshot entry
Fixes: #5739 #8574
2018-10-08 21:40:44 +02:00
Lennart Poettering 57db6f18d4 bootctl: add auto-paging 2018-10-08 21:40:44 +02:00
Lennart Poettering ba85725324 bootctl: highlight various title/product fields in output 2018-10-08 21:40:44 +02:00
Lennart Poettering 20a28174c5 bootctl: unify the code which we use to show boot loader entries 2018-10-08 21:40:44 +02:00
Lennart Poettering 48184e4391 bootctl: downgrade to log messages that aren't actually errors 2018-10-08 21:40:44 +02:00
Lennart Poettering 7fd66f3c3d bootctl: reword status/list section headers a bit
This is really confusing, let's try to clean this up a bit, in
particular as there are two very similar concepts:

1. The boot loaders, i.e. the category you find systemd-boot, the
   Windows and Apple boot loaders in. These may typically be listed in the
   firmware's EFI variables.

2. The boot loader entries, as defined by the Boot Loader Spec. In this
   category you find the various Linux kernels that are installed, i.e.
   the stuff systemd-boot shows on screen. To make things confusing, the
   Windows and Apple boot loaders can appear both as boot loaders and as
   boot loader entries.

This tries to establish the following nomenclature: "boot loaders" and
"boot loader entries" for these two concepts.
2018-10-08 21:40:44 +02:00
Lennart Poettering a099e0352c bootctl: show 'Default Boot Entry' header only when we found something 2018-10-08 21:40:44 +02:00
Lennart Poettering 21f7a622d5 bootspec: remove redundant logging
boot_loader_read_conf(), boot_entries_find(), boot_entries_load_config()
all log their errors internally, hence no need to log a second or third
time about the same error when they return.
2018-10-08 21:40:44 +02:00
Lennart Poettering a36b411ea2 bootctl: tiny shortification 2018-10-08 21:40:44 +02:00
Lennart Poettering e0e8d177c8 bootctl: let's be paranoid and synchronize the ESP in full after all changes
We already synchronize all files we write individually, as well as the
directories they are stored in. Let's also synchronize the ESP as a
whole after our work, just in case.
2018-10-08 21:40:44 +02:00