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

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