dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0316-blscfg-Don-t-hardcode-an-env-var-as-fallback-for-the.patch

2bd82f
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2bd82f
From: Javier Martinez Canillas <javierm@redhat.com>
2bd82f
Date: Tue, 11 Aug 2020 13:16:45 +0200
2bd82f
Subject: [PATCH] blscfg: Don't hardcode an env var as fallback for the BLS
2bd82f
 options field
2bd82f
2bd82f
If the BLS fragments don't have an options field or if this was set to an
2bd82f
environment variable that was not defined in the grubenv file, the blscfg
2bd82f
module searches for a default_kernelopts variable that is defined in the
2bd82f
grub.cfg file.
2bd82f
2bd82f
But the blscfg module shouldn't hardcode fallbacks variables and instead
2bd82f
this logic should be handled in the GRUB config file itself.
2bd82f
2bd82f
Also, add a comment explaining where the kernelopts variable is supposed
2bd82f
to be defined and what is the process for the user to change its value.
2bd82f
2bd82f
Resolves: rhbz#1850193
2bd82f
2bd82f
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2bd82f
---
2bd82f
 util/grub.d/10_linux.in | 12 +++++++++++-
2bd82f
 1 file changed, 11 insertions(+), 1 deletion(-)
2bd82f
2bd82f
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
2bd82f
index 58d18504790..48857bb81d3 100644
2bd82f
--- a/util/grub.d/10_linux.in
2bd82f
+++ b/util/grub.d/10_linux.in
2bd82f
@@ -158,7 +158,17 @@ linux_entry ()
2bd82f
     populate_header_warn
2bd82f
 
2bd82f
     cat << EOF
2bd82f
-set default_kernelopts="root=${linux_root_device_thisversion} ro ${args}"
2bd82f
+# The kernelopts variable should be defined in the grubenv file. But to ensure that menu
2bd82f
+# entries populated from BootLoaderSpec files that use this variable work correctly even
2bd82f
+# without a grubenv file, define a fallback kernelopts variable if this has not been set.
2bd82f
+#
2bd82f
+# The kernelopts variable in the grubenv file can be modified using the grubby tool or by
2bd82f
+# executing the grub2-mkconfig tool. For the latter, the values of the GRUB_CMDLINE_LINUX
2bd82f
+# and GRUB_CMDLINE_LINUX_DEFAULT options from /etc/default/grub file are used to set both
2bd82f
+# the kernelopts variable in the grubenv file and the fallback kernelopts variable.
2bd82f
+if [ -z "\${kernelopts}" ]; then
2bd82f
+  set kernelopts="root=${linux_root_device_thisversion} ro ${args}"
2bd82f
+fi
2bd82f
 
2bd82f
 insmod blscfg
2bd82f
 blscfg