Commit Graph

38652 Commits

Author SHA1 Message Date
Lennart Poettering ccc45964a4 update TODO 2019-03-01 12:41:32 +01:00
Lennart Poettering 3da2b703d9 man: document XBOOTLDR partition logic in bootctl's man page 2019-03-01 12:41:32 +01:00
Lennart Poettering c5fcaed881 man: document XBOOTLDR search logic for sd-boot 2019-03-01 12:41:32 +01:00
Lennart Poettering aa4c06844d man: extend systemd-gpt-auto-generator with XBOOTLDR info 2019-03-01 12:41:32 +01:00
Lennart Poettering 82dad52818 docs: enclose all uuids in `` 2019-03-01 12:41:32 +01:00
Lennart Poettering 2cb45cdc4d meson: sort header list again 2019-03-01 12:41:32 +01:00
Lennart Poettering 1b14a4b097 mkosi: let's update the boot loader also in /efi
This is after all where we preferable mount the ESP today.
2019-03-01 12:41:32 +01:00
Lennart Poettering 8312d69409 bootspec: stat() on an autofs mount point doesn't trigger it, let's hence do it explicitly 2019-03-01 12:41:32 +01:00
Lennart Poettering c8b32d06bd stub: don't override LoaderDevicePartUUID EFI var
We document and all our code assumes that LoaderDevicePartUUID is
initialized to the ESP's UUID. Let's hence not override the variable if
it is already set, in order to not confuse userspace if the kernel's EFI
image is run from a different partition than the ESP.

This matches behaviour for all other variables set by the EFI stub, in
particular the closely related LoaderImageIdentifier variable.
2019-03-01 12:41:32 +01:00
Lennart Poettering 8118fb3c83 stub: don't ask for variable data we actually don't care about
Let's take benefit of the fact that efivar_get_xyz() take NULL pointers
for the return data: let's shorten the code a bit.
2019-03-01 12:41:32 +01:00
Lennart Poettering 0d957ef6cf stub: fix GUID to check EFI vars in
Our own variables are in the the "loader" GUID namespace, but our code
so far checked the "global" GUID namespace (i.e. EFI's own), before
setting the variables. Correct that, so that we always check the right
namespace for existing variables before we write them.
2019-03-01 12:41:32 +01:00
Lennart Poettering b9e452423c efi: beef up efivar_get_xyz() to accept NULL return values 2019-03-01 12:41:32 +01:00
Lennart Poettering 5d87589732 sd-boot: don't print error string where there's no error code known 2019-03-01 12:41:32 +01:00
Lennart Poettering fa2a3bbdd8 sd-boot: also look for boot loader entries in the XBOOTLDR partition
The specification always said so, let's actually implement this.

Unfortunately UEFI's own APIs don't allow us to search for partition
type GUID, hence we have to implement a minimal GPT parser ourselves.
2019-03-01 12:41:32 +01:00
Lennart Poettering 17ad0f0f4b sd-boot: don't dereference NULL ptr if loaded_image_path is NULL
In a follow-up commit we'd like to invoke config_entry_add_from_file()
on partitions that are not the ESP, let's prepare fpr that and allow
loaded_image_path to be passed as NULL.
2019-03-01 12:41:32 +01:00
Lennart Poettering c8ad5996b0 sd-boot: pass device handle to config_entry_add_linux()
This makes the code a bit simpler (after all the call is not interested
in the loaded image, just where it is found), and more like
config_load_entries() which takes the same arguments.

This also makes things easier for us later on, when we add support for
discovering images in $XBOOTLDR partitions.
2019-03-01 12:41:32 +01:00
Lennart Poettering dd2bf34cd0 bootspec: only sort entries list once
Instead of re-sorting entries list each time we loaded enrties from a
specific source, let's just sort them once at the end.
2019-03-01 12:41:32 +01:00
Lennart Poettering 5e146a75b3 bootspec: also look for boot loader spec type 2 entries (i.e. unified kernel images)
sd-boot reads them, and hence we should from our userspace side too
2019-03-01 12:41:32 +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 4a4994b68d bootspec: use verify_fsroot_dir() in verify_xbootldr() too
Let's share some code between verify_xbootldr() and verify_esp().
2019-03-01 12:41:32 +01:00
Lennart Poettering 85d021023f bootspec: also optoinally validate XBOOTLDR partition with udev insteado of blkid 2019-03-01 12:41:32 +01:00
Lennart Poettering 18ae9ef1a5 bootspec: split out code that validates whether directory is top-level dir of fs
Let's add a new function that checks whether some directory is the
top-level directory inside an fs, splitting out the code for this from
verify_esp().

While we are at it, let's slightly improve the code, so that we can
correctly work if we have no priviliges but the ESP is mounted
unaccessible: if we can't stat() the path "$ESP/.." then manually remove
the last component of $ESP and check that instead. Which is very similar
in behaviour, and hopefully good enough in the unprivileged case.
2019-03-01 12:41:32 +01:00
Lennart Poettering cedb9eec76 bootspec: if unprivileged validate partition data with udev rather than blkid directly
udev metadata access works unprivileged, which the blkid stuff doesn't
(as that needs raw device node access). Hence let's use udev if we lack
privs, and raw device access only if root.
2019-03-01 12:41:32 +01:00
Lennart Poettering ad95aa44d6 bootspec: also split out XBOOTLDR partition blkid code into its own function 2019-03-01 12:41:32 +01:00
Lennart Poettering 575d437032 bootspec: split out ESP blkid validation into function of its own
This makes it easier to add an alternative implementation for this that
uses sd-device instead of blkid directly.
2019-03-01 12:41:32 +01:00
Lennart Poettering 23953a3ef8 bootspec: add comment explaining verify_esp() return codes 2019-03-01 12:41:32 +01:00
Lennart Poettering a7afbd60e3 bootspec: use SYNTHETIC_ERRNO() where appropriate 2019-03-01 12:41:32 +01:00
Lennart Poettering 2f88b2a081 boot-bless: port over to new $BOOT discovery calls 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 9fc32cd9b3 systemctl: add missing OOM checks 2019-03-01 12:41:32 +01:00
Lennart Poettering 8a1ef3bf8d systemctl: use SYNTHETIC_ERRNO() where appropriate 2019-03-01 12:41:32 +01:00
Lennart Poettering 947fbaea8b systemctl: drop arg_esp_path variable from systemctl
It's not set ever (and there's no real need to make it settable, since
users can as well set $SYSTEMD_ESP_PATH to configure this.
2019-03-01 12:41:32 +01:00
Lennart Poettering 43b736a84b bootspec: store 'root' field in each bootspec entry we load
This 'root' field contains the root path of the partition we found the
snippet in. The 'kernel', 'initrd', 'efi', … fields are relative to this
path.

This becomes particularly useful later when we add support for loading
snippets from both the ESP and XBOOTLDR, but already simplifies the code
for us a bit in systemctl.
2019-03-01 12:41:32 +01:00
Lennart Poettering 15cb6c9897 bootspec: add internal APIs to discover the XBOOTLDR partition 2019-03-01 12:41:32 +01:00
Lennart Poettering 9f1cb0c1fa gpt-auto: also load the boot loader partition during regular boots 2019-03-01 12:41:32 +01:00
Lennart Poettering d9223c07f5 dissect: when mounting an image mount the XBOOTLDR partition to /boot
Previously, we'd mount the ESP to /efi if that existed and was empty,
falling back to /boot if that existed and was empty.

With this change, the XBOOTLDR partition is mounted to /boot
unconditionally. And the EFI is mounted to /efi if that exists (but it
doesn't have to be empty — after all the name is very indicative of what
this is supposed to be), and to /boot as a fallback but only if it
exists and is empty (we insist on emptiness for that, since it might be
used differently than what we assume).

The net effect is that $BOOT should be reliably found under /boot, and
the ESP is either /efi or /boot.

(Note that this commit only is relevant for nspawn and suchlike, i.e.
the codepaths that mount an image without involving udev during boot.)
2019-03-01 12:41:32 +01:00
Lennart Poettering a8c47660bb dissect: automatically detect boot loader spec $BOOT partition
The boot loader spec supports two places to store boot loader
configuration: the ESP and a generic replacement for it in case the ESP
is not available or not suitable. Let's look for both.
2019-03-01 12:41:32 +01:00
Lennart Poettering 7b5de29569 gpt: add definition for boot loader spec partition
As listed in the boot loader spec since a long time:

https://systemd.io/BOOT_LOADER_SPECIFICATION#technical-details
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 59ba6d0c17 dissect: use SYNTHETIC_ERRNO() where appropriate 2019-03-01 12:41:32 +01:00
Lennart Poettering 46bba8a51c bootspec: use SYNTHETIC_ERRNO() at one more place 2019-03-01 12:41:32 +01:00
Lennart Poettering feb41f1ffe bootspec: update log message, to indicate the error is ignored 2019-03-01 12:41:32 +01:00
Lennart Poettering 71f514169b fs-util: add new helper syncfs_path() 2019-03-01 12:41:32 +01:00
Lennart Poettering 57d2db22de env-file: (void)ify an unlink() call 2019-03-01 12:41:32 +01:00
Lennart Poettering 96be0e89f2 json: don't call va_end() twice in json_build()
This was apparently left-over when json_buildv() was added, and
json_build() just became a wrapper for it.
2019-03-01 12:19:19 +01:00
Martin Pitt 59273a0c53
semaphoreci: Run subset of autopkgtests in LXC (#11814)
Run build/test in LXC for now, as full nested QEMU is too brittle right
now: https://github.com/semaphoreci/semaphore/issues/37
But this at least runs some tests. It ensures that systemd generally
works in containers, as well as provides some backup results if the main
Ubuntu CI is down.
2019-03-01 10:01:09 +01:00