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

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