From 535e7e1f80c91c5fba2fb37afdaadb402f0bfae7 Mon Sep 17 00:00:00 2001 From: yueyuankun Date: Mon, 1 Jul 2024 18:18:46 +0800 Subject: [PATCH] Export all variables from the initial context when creating a submenu. (cherry picked from commit ffc10c83b2bb50085e13b652a35e39d3fdedfe3f) --- ...bles-from-the-initial-context-when-c.patch | 44 +++++++++++++++++++ grub.patches | 1 + grub2.spec | 8 +++- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 backport-Export-all-variables-from-the-initial-context-when-c.patch diff --git a/backport-Export-all-variables-from-the-initial-context-when-c.patch b/backport-Export-all-variables-from-the-initial-context-when-c.patch new file mode 100644 index 0000000..4e32260 --- /dev/null +++ b/backport-Export-all-variables-from-the-initial-context-when-c.patch @@ -0,0 +1,44 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 22 Jan 2019 15:40:25 +0100 +Subject: [PATCH] Export all variables from the initial context when creating a + submenu + +When a submenu is created, only the exported variables are copied to the +new menu context. But we want the variables to be global, so export lets +export all variables to the new created submenu. + +Also, don't unset the default variable when a new submenu is created. + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/normal/context.c | 2 +- + grub-core/normal/menu.c | 2 -- + 2 files changed, 1 insertion(+), 3 deletions(-) + +diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c +index ee53d4a68e5..87edd254c44 100644 +--- a/grub-core/normal/context.c ++++ b/grub-core/normal/context.c +@@ -99,7 +99,7 @@ grub_env_new_context (int export_all) + grub_err_t + grub_env_context_open (void) + { +- return grub_env_new_context (0); ++ return grub_env_new_context (1); + } + + int grub_extractor_level = 0; +diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c +index 4a02aadb01c..fe2e77a43e2 100644 +--- a/grub-core/normal/menu.c ++++ b/grub-core/normal/menu.c +@@ -375,8 +375,6 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot) + + if (ptr && ptr[0] && ptr[1]) + grub_env_set ("default", ptr + 1); +- else +- grub_env_unset ("default"); + + grub_script_execute_new_scope (entry->sourcecode, entry->argc, entry->args); + diff --git a/grub.patches b/grub.patches index fdf4fd2..cb56119 100644 --- a/grub.patches +++ b/grub.patches @@ -234,3 +234,4 @@ Patch233: LoongArch-Add-back-compatibility-for-linux-kernel.patch Patch234: Fix-that-patch-28dcf48482-introduced-old-code.patch Patch235: backport-CVE-2021-46848-lib-libtasn1-Fix-ETYPE_OK-off-by-one-array.patch Patch236: backport-disk-mdraid1x_linux-Prevent-infinite-recursion.patch +Patch237: backport-Export-all-variables-from-the-initial-context-when-c.patch diff --git a/grub2.spec b/grub2.spec index 7d216e4..a6e5088 100644 --- a/grub2.spec +++ b/grub2.spec @@ -14,7 +14,7 @@ Name: grub2 Epoch: 1 Version: 2.12 -Release: 20 +Release: 21 Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -454,6 +454,12 @@ fi %{_datadir}/man/man* %changelog +* Fri Jun 28 2024 yueyuankun - 1:2.12-21 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:Export all variables from the initial context when creating a submenu + * Tue Jun 25 2024 peng.zou - 1:2.12-20 - Type:bugfix - CVE:NA -- Gitee