mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-11-24 14:32:58 +00:00
Fix menu entries having an unneeded initrd command and other BLS fixes
Resolves: rhbz#1806022 Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
parent
c9aee967d6
commit
749be472a6
6 changed files with 229 additions and 1 deletions
|
@ -0,0 +1,76 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 26 Nov 2019 09:51:41 +0100
|
||||
Subject: [PATCH] blscfg: add a space char when appending fields for variable
|
||||
expansion
|
||||
|
||||
The GRUB variables are expanded and replaced by their values before adding
|
||||
menu entries, but they didn't include space characters after the values so
|
||||
the result was not correct.
|
||||
|
||||
For the common case this wasn't a problem but it is if there are variables
|
||||
that are part of the values of other variables.
|
||||
|
||||
Resolves: rhbz#1669252
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
grub-core/commands/blscfg.c | 31 ++++++++++++++++++-------------
|
||||
1 file changed, 18 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
|
||||
index f2c1fd0733d..1504be30e8e 100644
|
||||
--- a/grub-core/commands/blscfg.c
|
||||
+++ b/grub-core/commands/blscfg.c
|
||||
@@ -593,26 +593,29 @@ static char **bls_make_list (struct bls_entry *entry, const char *key, int *num)
|
||||
|
||||
static char *field_append(bool is_var, char *buffer, char *start, char *end)
|
||||
{
|
||||
- char *temp = grub_strndup(start, end - start + 1);
|
||||
- const char *field = temp;
|
||||
+ char *tmp = grub_strndup(start, end - start + 1);
|
||||
+ const char *field = tmp;
|
||||
+ int term = is_var ? 2 : 1;
|
||||
|
||||
if (is_var) {
|
||||
- field = grub_env_get (temp);
|
||||
+ field = grub_env_get (tmp);
|
||||
if (!field)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
- if (!buffer) {
|
||||
- buffer = grub_strdup(field);
|
||||
- if (!buffer)
|
||||
- return NULL;
|
||||
- } else {
|
||||
- buffer = grub_realloc (buffer, grub_strlen(buffer) + grub_strlen(field));
|
||||
- if (!buffer)
|
||||
- return NULL;
|
||||
+ if (!buffer)
|
||||
+ buffer = grub_zalloc (grub_strlen(field) + term);
|
||||
+ else
|
||||
+ buffer = grub_realloc (buffer, grub_strlen(buffer) + grub_strlen(field) + term);
|
||||
|
||||
- grub_stpcpy (buffer + grub_strlen(buffer), field);
|
||||
- }
|
||||
+ if (!buffer)
|
||||
+ return NULL;
|
||||
+
|
||||
+ tmp = buffer + grub_strlen(buffer);
|
||||
+ tmp = grub_stpcpy (tmp, field);
|
||||
+
|
||||
+ if (is_var)
|
||||
+ tmp = grub_stpcpy (tmp, " ");
|
||||
|
||||
return buffer;
|
||||
}
|
||||
@@ -642,6 +645,8 @@ static char *expand_val(char *value)
|
||||
buffer = field_append(is_var, buffer, start, end);
|
||||
is_var = false;
|
||||
start = value;
|
||||
+ if (*start == ' ')
|
||||
+ start++;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Mon, 4 Nov 2019 17:33:30 +0100
|
||||
Subject: [PATCH] blscfg: Add support for sorting the plus ('+') higher than
|
||||
base version
|
||||
|
||||
Handle plus separator. Concept is the same as tilde, except that if one of
|
||||
the strings ends (base version), the other is considered as higher version.
|
||||
|
||||
A plus character is used for example by the Linux kernel build system to
|
||||
denote that is the base version plus some changes on top of it.
|
||||
|
||||
Currently for example rpmvercmp("5.3.0", "5.3.0+") will return 0 even when
|
||||
the two versions are not the same.
|
||||
|
||||
Resolves: rhbz#1767395
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
grub-core/commands/blscfg.c | 19 +++++++++++++++++--
|
||||
1 file changed, 17 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
|
||||
index 1504be30e8e..286a5b88d12 100644
|
||||
--- a/grub-core/commands/blscfg.c
|
||||
+++ b/grub-core/commands/blscfg.c
|
||||
@@ -163,8 +163,8 @@ static int vercmp(const char * a, const char * b)
|
||||
|
||||
/* loop through each version segment of str1 and str2 and compare them */
|
||||
while (*one || *two) {
|
||||
- while (*one && !grub_isalnum(*one) && *one != '~') one++;
|
||||
- while (*two && !grub_isalnum(*two) && *two != '~') two++;
|
||||
+ while (*one && !grub_isalnum(*one) && *one != '~' && *one != '+') one++;
|
||||
+ while (*two && !grub_isalnum(*two) && *two != '~' && *two != '+') two++;
|
||||
|
||||
/* handle the tilde separator, it sorts before everything else */
|
||||
if (*one == '~' || *two == '~') {
|
||||
@@ -175,6 +175,21 @@ static int vercmp(const char * a, const char * b)
|
||||
continue;
|
||||
}
|
||||
|
||||
+ /*
|
||||
+ * Handle plus separator. Concept is the same as tilde,
|
||||
+ * except that if one of the strings ends (base version),
|
||||
+ * the other is considered as higher version.
|
||||
+ */
|
||||
+ if (*one == '+' || *two == '+') {
|
||||
+ if (!*one) return -1;
|
||||
+ if (!*two) return 1;
|
||||
+ if (*one != '+') goto_return (1);
|
||||
+ if (*two != '+') goto_return (-1);
|
||||
+ one++;
|
||||
+ two++;
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
/* If we ran to the end of either, we are finished with the loop */
|
||||
if (!(*one && *two)) break;
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 14 Jan 2020 17:41:29 +0100
|
||||
Subject: [PATCH] blscfg: Always use the root variable to search for BLS
|
||||
snippets
|
||||
|
||||
The boot and root variables are set by grub2-mkconfig to tell GRUB what
|
||||
are the devices and partitions used as the EFI System Partition (ESP)
|
||||
and to store the /boot directory (or used as the /boot mount point).
|
||||
|
||||
But the boot variable is not needed anymore, this was added because the
|
||||
blscfg module used to search for the BLS snippets in the ESP, but was
|
||||
later changed to always search for the BLS files in /boot even for EFI.
|
||||
|
||||
When doing that change, the logic was made backwards and so the boot
|
||||
variable is wrongly used for legacy BIOS. This only works because this
|
||||
is set to the same value as the root variable.
|
||||
|
||||
So the correct thing to do is to always use the root variable to search
|
||||
the BLS snippets, since that is set to the partition that stores them.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
grub-core/commands/blscfg.c | 6 ++----
|
||||
1 file changed, 2 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
|
||||
index 286a5b88d12..aa4e624905e 100644
|
||||
--- a/grub-core/commands/blscfg.c
|
||||
+++ b/grub-core/commands/blscfg.c
|
||||
@@ -968,14 +968,12 @@ bls_load_entries (const char *path)
|
||||
if (!devid) {
|
||||
#ifdef GRUB_MACHINE_EMU
|
||||
devid = "host";
|
||||
-#elif defined(GRUB_MACHINE_EFI)
|
||||
+#else
|
||||
devid = grub_env_get ("root");
|
||||
-#else
|
||||
- devid = grub_env_get ("boot");
|
||||
#endif
|
||||
if (!devid)
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND,
|
||||
- N_("variable `%s' isn't set"), "boot");
|
||||
+ N_("variable `%s' isn't set"), "root");
|
||||
}
|
||||
|
||||
grub_dprintf ("blscfg", "opening %s\n", devid);
|
|
@ -0,0 +1,38 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Mon, 16 Mar 2020 13:51:45 +0100
|
||||
Subject: [PATCH] blscfg: return NULL instead of a zero-length array in
|
||||
bls_make_list()
|
||||
|
||||
The bls_make_list() function returns a list of all the values for a given
|
||||
key and if there is none a NULL pointer should be returned. But currently
|
||||
is returnin a zero-length array instead.
|
||||
|
||||
This makes the callers to wrongly assume that there are values for a key
|
||||
and populate wrong menu entries. For example menu entries are populated
|
||||
with an initrd command even if there is no initrd fiel in the BLS file.
|
||||
|
||||
Resolves: rhbz#1806022
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
grub-core/commands/blscfg.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
|
||||
index aa4e624905e..df6947f58cd 100644
|
||||
--- a/grub-core/commands/blscfg.c
|
||||
+++ b/grub-core/commands/blscfg.c
|
||||
@@ -600,6 +600,12 @@ static char **bls_make_list (struct bls_entry *entry, const char *key, int *num)
|
||||
list[nlist] = NULL;
|
||||
}
|
||||
|
||||
+ if (!nlist)
|
||||
+ {
|
||||
+ grub_free (list);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
if (num)
|
||||
*num = nlist;
|
||||
|
|
@ -192,3 +192,7 @@ Patch0191: 0191-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch
|
|||
Patch0192: 0192-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch
|
||||
Patch0193: 0193-10_linux.in-Also-use-GRUB_CMDLINE_LINUX_DEFAULT-to-s.patch
|
||||
Patch0194: 0194-Fix-savedefault-with-blscfg.patch
|
||||
Patch0195: 0195-blscfg-add-a-space-char-when-appending-fields-for-va.patch
|
||||
Patch0196: 0196-blscfg-Add-support-for-sorting-the-plus-higher-than-.patch
|
||||
Patch0197: 0197-blscfg-Always-use-the-root-variable-to-search-for-BL.patch
|
||||
Patch0198: 0198-blscfg-return-NULL-instead-of-a-zero-length-array-in.patch
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
Name: grub2
|
||||
Epoch: 1
|
||||
Version: 2.02
|
||||
Release: 105%{?dist}
|
||||
Release: 106%{?dist}
|
||||
Summary: Bootloader with support for Linux, Multiboot and more
|
||||
License: GPLv3+
|
||||
URL: http://www.gnu.org/software/grub/
|
||||
|
@ -518,6 +518,10 @@ rm -r /boot/grub2.tmp/ || :
|
|||
%endif
|
||||
|
||||
%changelog
|
||||
* Tue Mar 17 2020 Javier Martinez Canillas <javierm@redhat.com> - 2.02-106
|
||||
- Fix menu entries having an unneeded initrd command and other BLS fixes
|
||||
Resolves: rhbz#1806022
|
||||
|
||||
* Mon Jan 13 2020 Javier Martinez Canillas <javierm@redhat.com> - 2.02-105
|
||||
- 10_linux.in: Also use GRUB_CMDLINE_LINUX_DEFAULT to set kernelopts
|
||||
- Make the blscfg module honour the GRUB_SAVEDEFAULT option
|
||||
|
|
Loading…
Reference in a new issue