use fw_path prefix when fallback searching for grub config
authorMark Salter <msalter@redhat.com>
Mon, 9 Jan 2023 23:30:39 +0000 (18:30 -0500)
committerFelix Zielcke <fzielcke@z-51.de>
Wed, 11 Jun 2025 15:42:34 +0000 (17:42 +0200)
When PXE booting via UEFI firmware, grub was searching for grub.cfg in
the fw_path directory where the grub application was found.  If that
didn't exist, a fallback search would look for config file names based
on MAC and IP address.  However, the search would look in the prefix
directory which may not be the same fw_path.  This patch changes that
behavior to use the fw_path directory for the fallback search.  Only if
fw_path is NULL will the prefix directory be searched.

Signed-off-by: Mark Salter <msalter@redhat.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Gbp-Pq: Topic network
Gbp-Pq: Name use-fw_path-prefix-when-fallback-searching-for-grub-config.patch

grub-core/normal/main.c

index b1947c7af8a16cf2c689c7636d4b8670117d4bde..c0255a9f7d0b9a7e3d37fb7f49c83c35f5228869 100644 (file)
@@ -322,7 +322,7 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
       char *config;
       const char *prefix, *fw_path;
 
-      fw_path = grub_env_get ("fw_path");
+      prefix = fw_path = grub_env_get ("fw_path");
       if (fw_path)
        {
          config = grub_xasprintf ("%s/grub.cfg", fw_path);
@@ -345,7 +345,8 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
            }
        }
 
-      prefix = grub_env_get ("prefix");
+      if (!prefix)
+        prefix = grub_env_get ("prefix");
       if (prefix)
         {
           grub_size_t config_len;