diff --git a/0019-Add-fw_path-variable-revised.patch b/0019-Add-fw_path-variable-revised.patch new file mode 100644 index 0000000000000000000000000000000000000000..a8491e8c083d23bd27540ff1e5e16db2509a2579 --- /dev/null +++ b/0019-Add-fw_path-variable-revised.patch @@ -0,0 +1,81 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Paulo Flabiano Smorigo +Date: Wed, 19 Sep 2012 21:22:55 -0300 +Subject: [PATCH] Add fw_path variable (revised) + +This patch makes grub look for its config file on efi where the app was +found. It was originally written by Matthew Garrett, and adapted to fix the +"No modules are loaded on grub2 network boot" issue: + +https://bugzilla.redhat.com/show_bug.cgi?id=857936 + +Signed-off-by: Paulo Flabiano Smorigo +Signed-off-by: Robbie Harwood +--- + grub-core/kern/main.c | 13 ++++++------- + grub-core/normal/main.c | 25 ++++++++++++++++++++++++- + 2 files changed, 30 insertions(+), 8 deletions(-) + +diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c +index 73967e2f5b0..d1de9fa6873 100644 +--- a/grub-core/kern/main.c ++++ b/grub-core/kern/main.c +@@ -128,16 +128,15 @@ grub_set_prefix_and_root (void) + + grub_machine_get_bootlocation (&fwdevice, &fwpath); + +- if (fwdevice) ++ if (fwdevice && fwpath) + { +- char *cmdpath; ++ char *fw_path; + +- cmdpath = grub_xasprintf ("(%s)%s", fwdevice, fwpath ? : ""); +- if (cmdpath) ++ fw_path = grub_xasprintf ("(%s)/%s", fwdevice, fwpath); ++ if (fw_path) + { +- grub_env_set ("cmdpath", cmdpath); +- grub_env_export ("cmdpath"); +- grub_free (cmdpath); ++ grub_env_set ("fw_path", fw_path); ++ grub_free (fw_path); + } + } + +diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c +index 70614de1565..62571e6dfcc 100644 +--- a/grub-core/normal/main.c ++++ b/grub-core/normal/main.c +@@ -339,7 +339,30 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), + /* Guess the config filename. It is necessary to make CONFIG static, + so that it won't get broken by longjmp. */ + char *config; +- const char *prefix; ++ const char *prefix, *fw_path; ++ ++ fw_path = grub_env_get ("fw_path"); ++ if (fw_path) ++ { ++ config = grub_xasprintf ("%s/grub.cfg", fw_path); ++ if (config) ++ { ++ grub_file_t file; ++ ++ file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG); ++ if (file) ++ { ++ grub_file_close (file); ++ grub_enter_normal_mode (config); ++ } ++ else ++ { ++ /* Ignore all errors. */ ++ grub_errno = 0; ++ } ++ grub_free (config); ++ } ++ } + + prefix = grub_env_get ("prefix"); + if (prefix) diff --git a/0028-use-fw_path-prefix-when-fallback-searching-for-grub-.patch b/0028-use-fw_path-prefix-when-fallback-searching-for-grub-.patch new file mode 100644 index 0000000000000000000000000000000000000000..6b1580bb49c690b1ffa4aad1f94e3b1bc180bbed --- /dev/null +++ b/0028-use-fw_path-prefix-when-fallback-searching-for-grub-.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Fedora Ninjas +Date: Wed, 19 Feb 2014 15:58:43 -0500 +Subject: [PATCH] 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 +--- + 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 7ca2e5400b1..02577502116 100644 +--- a/grub-core/normal/main.c ++++ b/grub-core/normal/main.c +@@ -347,7 +347,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); +@@ -370,7 +370,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; diff --git a/grub.patches b/grub.patches index 5b690a9a6aac8cda8be064d11d0a084c6750d955..176b486de7cd771f0b8ac7b8b099cf17daed914e 100644 --- a/grub.patches +++ b/grub.patches @@ -206,5 +206,7 @@ Patch205: disable-some-unsupported-filesystems.patch Patch206: remove-the-items-of-unsupported-filesystems-in-fs.ls.patch Patch207: backport-Read-etc-default-grub.d-.cfg-after-etc-default-grub.patch Patch208: modify-klist-in-10_linux.in.patch +Patch209: 0019-Add-fw_path-variable-revised.patch +Patch210: 0028-use-fw_path-prefix-when-fallback-searching-for-grub-.patch #Patch208: add-TPCM-support-with-ipmi-channel.patch #Patch209: skip-verification-when-not-loading-grub.cfg.patch diff --git a/grub2.spec b/grub2.spec index 0ad59924bb5226e123b5dc1ad38c0494ee26dc64..788a64384e6a58f6ea747140eef9451084df98b0 100644 --- a/grub2.spec +++ b/grub2.spec @@ -14,7 +14,7 @@ Name: grub2 Epoch: 1 Version: 2.12 -Release: 2 +Release: 3 Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -449,6 +449,12 @@ fi %{_datadir}/man/man* %changelog +* Fri Mar 8 2024 zhangqiumiao - 1:2.12-3 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:look for grub.cfg on efi where the app was found + * Thu Mar 7 2024 zhangqiumiao - 1:2.12-2 - Type:bugfix - CVE:NA