]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootspec: introduce SYSTEMD_ESP_PATH for overriding where to look for the ESP (#10834)
authorLennart Poettering <lennart@poettering.net>
Tue, 20 Nov 2018 03:37:01 +0000 (04:37 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 20 Nov 2018 03:37:01 +0000 (12:37 +0900)
docs/ENVIRONMENT.md
src/shared/bootspec.c

index 654f7d25cff6e3a234b490f7008f19fe8b9e6269..3e61ea51e7068725beb0e621d0caa7ab87c74eea 100644 (file)
@@ -125,6 +125,12 @@ bootctl and other tools that access the EFI System Partition (ESP):
   is a FAT file system are turned off, as are checks that the path is located
   on a GPT partition with the correct type UUID.
 
+* `$SYSTEMD_ESP_PATH=…` — override the path to the EFI System Partition. This
+  may be used to override ESP path auto detection, and redirect any accesses to
+  the ESP to the specified directory. Not that unlike with bootctl's --path=
+  switch only very superficial validation of the specified path is done when
+  this environment variable is used.
+
 systemd itself:
 
 * `$SYSTEMD_ACTIVATION_UNIT` — set for all NSS and PAM module invocations that
index df15b660ecd72df3f22dbe3d7a7774adfffc3a86..9ba6978962729ebbea10b9080608fd9801121b5a 100644 (file)
@@ -16,6 +16,7 @@
 #include "fd-util.h"
 #include "fileio.h"
 #include "parse-util.h"
+#include "path-util.h"
 #include "stat-util.h"
 #include "string-util.h"
 #include "strv.h"
@@ -590,6 +591,18 @@ int find_esp_and_warn(
                 goto found;
         }
 
+        path = getenv("SYSTEMD_ESP_PATH");
+        if (path) {
+                if (!path_is_valid(path) || !path_is_absolute(path)) {
+                        log_error("$SYSTEMD_ESP_PATH does not refer to absolute path, refusing to use it: %s", path);
+                        return -EINVAL;
+                }
+
+                /* Note: when the user explicitly configured things with an env var we won't validate the mount
+                 * point. After all we want this to be useful for testing. */
+                goto found;
+        }
+
         FOREACH_STRING(path, "/efi", "/boot", "/boot/efi") {
 
                 r = verify_esp(path, true, unprivileged_mode, ret_part, ret_pstart, ret_psize, ret_uuid);