Allow configuration to override the default ENV_FILE_NAME
and FAT_ENV_FILENAME to support scenarios with multiple
distributions or architectures.

For multiple distributions, https://wiki.debian.org/UEFI explains:

> Debian installs grub-efi for its EFI bootloader, as:
>
> Architecture Path
> amd64        \EFI\debian\grubx64.efi
> i386         \EFI\debian\grubia32.efi
> arm64        \EFI\debian\grubaa64.efi
> armhf        \EFI\debian\grubarm.efi

Other distributions use their own directories (eg \EFI\fedora, etc).

EFI Boot Guard (EBG) looks for a specific data file (normally BGENV.DAT)
which contains a single kernel configuration entry. Using the new
--with-env-file-name option, each distribution builds and configures
its own instance of EBG, which can find its corresponding
data file (eg BGENV-DEBIAN.DAT, or EFI\debian\BGENV.DAT, etc). This
also has the benefit of decoupling the distributions at boot so that
a breaking EBG change to one distribution will not affect another.

Signed-off-by: Earl Chew <earl_c...@yahoo.com>
---
 configure.ac      | 14 ++++++++++++++
 include/envdata.h |  2 --
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 20fcf32..eea1845 100644
--- a/configure.ac
+++ b/configure.ac
@@ -156,6 +156,19 @@ AC_ARG_WITH([env-backend],
 
 AC_SUBST([env_api_file], [${ENV_API_FILE}])
 
+AC_ARG_WITH([env-file-name],
+           AS_HELP_STRING([--with-env-file-name=STRING],
+                           [override the boot environment file name]),
+           [
+               ENV_FILE_NAME="$withval"
+           ],
+           [ ENV_FILE_NAME="BGENV.DAT" ])
+
+AC_DEFINE_UNQUOTED(
+       [ENV_FILE_NAME], [L"${ENV_FILE_NAME}"], [Boot environment file name])
+AC_DEFINE_UNQUOTED(
+       [FAT_ENV_FILENAME], ["${ENV_FILE_NAME}"], [Boot environment FAT file 
name])
+
 AC_ARG_WITH([boot-delay],
            AS_HELP_STRING([--with-boot-delay=INT],
                           [specify the additional boot delay in seconds, 
defaults to 3]),
@@ -268,6 +281,7 @@ AC_MSG_RESULT([
        efi libs:                ${GNUEFI_LIB_DIR}
 
        environment backend:     ${ENV_API_FILE}.c
+       environment file name:   ${ENV_FILE_NAME}
        number of config parts:  ${ENV_NUM_CONFIG_PARTS}
        reserved for uservars:   ${ENV_MEM_USERVARS} bytes
        boot delay:              ${ENV_BOOT_DELAY} seconds
diff --git a/include/envdata.h b/include/envdata.h
index 9c4ad44..da41dda 100644
--- a/include/envdata.h
+++ b/include/envdata.h
@@ -16,8 +16,6 @@
 
 #include <stdint.h>
 
-#define ENV_FILE_NAME L"BGENV.DAT"
-#define FAT_ENV_FILENAME "BGENV.DAT"
 #define ENV_STRING_LENGTH 255
 
 #define USTATE_OK 0
-- 
2.39.1

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to efibootguard-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/20240428155415.3604986-1-earl_chew%40yahoo.com.

Reply via email to