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

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