[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 18/20] http: Prepend prefix when the HTTP path is relative
From: |
Robbie Harwood |
Subject: |
[PATCH v5 18/20] http: Prepend prefix when the HTTP path is relative |
Date: |
Tue, 25 Apr 2023 11:05:29 -0400 |
From: Javier Martinez Canillas <javierm@redhat.com>
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. Match the
behavior of efi/http.
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Co-authored-by: Robbie Harwood <rharwood@redhat.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/net/http.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/grub-core/net/http.c b/grub-core/net/http.c
index a96659963e..796b5bd381 100644
--- a/grub-core/net/http.c
+++ b/grub-core/net/http.c
@@ -16,6 +16,7 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <grub/env.h>
#include <grub/misc.h>
#include <grub/net/tcp.h>
#include <grub/net/ip.h>
@@ -505,13 +506,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);
--
2.40.0
- [PATCH v5 19/20] normal/main: Discover the device to read the config from as a fallback, (continued)
- [PATCH v5 19/20] normal/main: Discover the device to read the config from as a fallback, Robbie Harwood, 2023/04/25
- [PATCH v5 10/20] Support UEFI networking protocols, Robbie Harwood, 2023/04/25
- [PATCH v5 03/20] net/http: check result of grub_netbuff_put() in http_receive(), Robbie Harwood, 2023/04/25
- [PATCH v5 16/20] Prepend prefix when HTTP path is relative, Robbie Harwood, 2023/04/25
- [PATCH v5 11/20] efinet: also use the firmware acceleration for http, Robbie Harwood, 2023/04/25
- [PATCH v5 08/20] efinet Configure network from UEFI device path, Robbie Harwood, 2023/04/25
- [PATCH v5 06/20] grub.texi: Add net_bootp6 doumentation, Robbie Harwood, 2023/04/25
- [PATCH v5 15/20] Try mac/guid/etc before grub.cfg on tftp config files, Robbie Harwood, 2023/04/25
- [PATCH v5 20/20] efinet: Add DHCP proxy support, Robbie Harwood, 2023/04/25
- [PATCH v5 05/20] efinet: add structures for PXE messages, Robbie Harwood, 2023/04/25
- [PATCH v5 18/20] http: Prepend prefix when the HTTP path is relative,
Robbie Harwood <=
- [PATCH v5 07/20] bootp: Process DHCPACK packet during HTTP Boot, Robbie Harwood, 2023/04/25
- [PATCH v5 09/20] efinet: set DNS server from UEFI protocol, Robbie Harwood, 2023/04/25
- [PATCH v5 02/20] net: read bracketed ipv6 addrs and port numbers, Robbie Harwood, 2023/04/25
- [PATCH v5 17/20] efi/http: Enclose literal IPv6 addresses in square brackets, Robbie Harwood, 2023/04/25
- [PATCH v5 12/20] efi/http: match protocol+hostname of boot url in root_url, Robbie Harwood, 2023/04/25
- [PATCH v5 14/20] use fw_path prefix when fallback searching for grub config, Robbie Harwood, 2023/04/25