File: use-fw_path-prefix-when-fallback-searching-for-grub-config.patch

package info (click to toggle)
grub2 2.14~git20250718.0e36779-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 60,688 kB
  • sloc: ansic: 541,811; asm: 68,074; sh: 9,803; cpp: 2,095; makefile: 1,895; python: 1,518; sed: 446; lex: 393; yacc: 268; awk: 85; lisp: 54; perl: 31
file content (41 lines) | stat: -rw-r--r-- 1,557 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From: Mark Salter <msalter@redhat.com>
Date: Mon, 9 Jan 2023 18:30:39 -0500
Subject: use fw_path prefix when fallback searching for grub config

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>
---
 grub-core/normal/main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index 51bce0e..ecf977e 100644
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -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;