Fix build with rpm-4.16 and a HTTP boot issue with relative paths

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2020-06-08 10:14:57 +02:00
parent 0993459d92
commit 9f83bf2258
No known key found for this signature in database
GPG key ID: C751E590D63F3D69
4 changed files with 84 additions and 1 deletions

View file

@ -0,0 +1,47 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Tue, 2 Jun 2020 13:25:01 +0200
Subject: [PATCH] http: Prepend prefix when the HTTP path is relative as done
in efi/http
There are two different HTTP drivers that can be used when requesting an
HTTP resource: the efi/http that uses the EFI_HTTP_PROTOCOL and the http
that uses GRUB's HTTP and TCP/IP implementation.
The efi/http driver appends a prefix that is defined in the variable
http_path, but the http driver doesn't.
So using this driver and attempting to fetch a resource using a relative
path fails.
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
grub-core/net/http.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/grub-core/net/http.c b/grub-core/net/http.c
index b52b558d631..7f878b56157 100644
--- a/grub-core/net/http.c
+++ b/grub-core/net/http.c
@@ -501,13 +501,20 @@ http_open (struct grub_file *file, const char *filename)
{
grub_err_t err;
struct http_data *data;
+ const char *http_path;
data = grub_zalloc (sizeof (*data));
if (!data)
return grub_errno;
file->size = GRUB_FILE_SIZE_UNKNOWN;
- data->filename = grub_strdup (filename);
+ /* If path is relative, prepend http_path */
+ http_path = grub_env_get ("http_path");
+ if (http_path && filename[0] != '/')
+ data->filename = grub_xasprintf ("%s/%s", http_path, filename);
+ else
+ data->filename = grub_strdup (filename);
+
if (!data->filename)
{
grub_free (data);

View file

@ -0,0 +1,30 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Thierry Vignaud <thierry.vignaud@gmail.com>
Date: Mon, 8 Jun 2020 06:50:21 +0200
Subject: [PATCH] fix build with rpm-4.16
Signed-off-by: Thierry Vignaud <thierry.vignaud@gmail.com>
---
configure.ac | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/configure.ac b/configure.ac
index eff160b6931..5d3316185da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1887,6 +1887,15 @@ if test x"$rpm_sort_excuse" = x ; then
[Define to 1 if you have the rpm library.])
fi
+if test x"$LIBRPM" = x ; then
+ # Check for rpm library.
+ AC_CHECK_LIB([rpmio], [rpmvercmp], [],
+ [rpm_sort_excuse="rpmio missing rpmvercmp"])
+ LIBRPM="-lrpmio";
+ AC_DEFINE([HAVE_RPMIO], [1],
+ [Define to 1 if you have the rpm library.])
+fi
+
AC_SUBST([LIBRPM])
LIBGEOM=

View file

@ -217,3 +217,5 @@ Patch0216: 0216-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch
Patch0217: 0217-tpm-Enable-module-for-all-EFI-platforms.patch
Patch0218: 0218-10_linux.in-Don-t-update-BLS-files-that-aren-t-manag.patch
Patch0219: 0219-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch
Patch0220: 0220-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch
Patch0221: 0221-fix-build-with-rpm-4.16.patch

View file

@ -9,7 +9,7 @@
Name: grub2
Epoch: 1
Version: 2.04
Release: 23%{?dist}
Release: 24%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+
URL: http://www.gnu.org/software/grub/
@ -504,6 +504,10 @@ rm -r /boot/grub2.tmp/ || :
%endif
%changelog
* Mon Jun 08 2020 Javier Martinez Canillas <javierm@redhat.com> - 2.04-24
- http: Prepend prefix when the HTTP path is relative as done in efi/http
- Fix build with rpm-4.16 (thierry.vignaud)
* Fri Jun 05 2020 Javier Martinez Canillas <javierm@redhat.com> - 2.04-23
- Install GRUB as \EFI\BOOT\BOOTARM.EFI in armv7hl