Blame SOURCES/0087-efi-http-Make-root_url-reflect-the-protocol-hostname.patch

5593c8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
5593c8
From: Peter Jones <pjones@redhat.com>
5593c8
Date: Mon, 30 Jul 2018 16:39:57 -0400
5593c8
Subject: [PATCH] efi/http: Make root_url reflect the protocol+hostname of our
5593c8
 boot url.
5593c8
5593c8
This lets you write config files that don't know urls.
5593c8
5593c8
Signed-off-by: Peter Jones <pjones@redhat.com>
5593c8
---
5593c8
 grub-core/net/efi/http.c | 19 +++++++++++++++++++
5593c8
 1 file changed, 19 insertions(+)
5593c8
5593c8
diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c
fd0330
index 3f61fd2fa5..243acbaa35 100644
5593c8
--- a/grub-core/net/efi/http.c
5593c8
+++ b/grub-core/net/efi/http.c
5593c8
@@ -4,6 +4,7 @@
5593c8
 #include <grub/misc.h>
5593c8
 #include <grub/net/efi.h>
5593c8
 #include <grub/charset.h>
5593c8
+#include <grub/env.h>
5593c8
 
5593c8
 static void
5593c8
 http_configure (struct grub_efi_net_device *dev, int prefer_ip6)
5593c8
@@ -351,6 +352,24 @@ grub_efihttp_open (struct grub_efi_net_device *dev,
5593c8
   grub_err_t err;
5593c8
   grub_off_t size;
5593c8
   char *buf;
5593c8
+  char *root_url;
5593c8
+  grub_efi_ipv6_address_t address;
5593c8
+  const char *rest;
5593c8
+
5593c8
+  if (grub_efi_string_to_ip6_address (file->device->net->server, &address, &rest) && *rest == 0)
5593c8
+    root_url = grub_xasprintf ("%s://[%s]", type ? "https" : "http", file->device->net->server);
5593c8
+  else
5593c8
+    root_url = grub_xasprintf ("%s://%s", type ? "https" : "http", file->device->net->server);
5593c8
+  if (root_url)
5593c8
+    {
5593c8
+      grub_env_unset ("root_url");
5593c8
+      grub_env_set ("root_url", root_url);
5593c8
+      grub_free (root_url);
5593c8
+    }
5593c8
+  else
5593c8
+    {
5593c8
+      return grub_errno;
5593c8
+    }
5593c8
 
5593c8
   err = efihttp_request (dev->http, file->device->net->server, file->device->net->name, type, 1, 0);
5593c8
   if (err != GRUB_ERR_NONE)