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