nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0260-set-rootpath.patch

4fe85b
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4fe85b
From: Peter Jones <pjones@redhat.com>
4fe85b
Date: Wed, 24 May 2017 15:02:40 -0400
4fe85b
Subject: [PATCH] set rootpath
4fe85b
4fe85b
Signed-off-by: Peter Jones <pjones@redhat.com>
4fe85b
---
4fe85b
 grub-core/net/bootp.c | 20 ++++++++++++++++++++
4fe85b
 1 file changed, 20 insertions(+)
4fe85b
4fe85b
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
4fe85b
index d47ad80a2ad..249ca0c2dc6 100644
4fe85b
--- a/grub-core/net/bootp.c
4fe85b
+++ b/grub-core/net/bootp.c
4fe85b
@@ -398,11 +398,31 @@ grub_net_configure_by_dhcp_ack (const char *name,
4fe85b
 	      if (*path)
4fe85b
 		{
4fe85b
 		  char *slash;
4fe85b
+		  int root_path_len;
4fe85b
 		  slash = grub_strrchr (*path, '/');
4fe85b
 		  if (slash)
4fe85b
 		    *slash = 0;
4fe85b
 		  else
4fe85b
 		    **path = 0;
4fe85b
+		  root_path_len = grub_strlen (*path);
4fe85b
+		  if (root_path_len >= 9 &&
4fe85b
+		      !grub_strcasecmp (&(*path)[root_path_len - 9], "/efi/boot"))
4fe85b
+		    {
4fe85b
+		      char *root_path;
4fe85b
+		      grub_print_error ();
4fe85b
+		      if (root_path_len - 9 == 0)
4fe85b
+			{
4fe85b
+			  root_path_len = 1;
4fe85b
+			  root_path = grub_xasprintf ("/");
4fe85b
+			}
4fe85b
+		      else
4fe85b
+			{
4fe85b
+			  root_path_len -= 9;
4fe85b
+			  root_path = grub_strndup (*path, root_path_len);
4fe85b
+			}
4fe85b
+		      grub_env_set_net_property (name, "rootpath",
4fe85b
+						 root_path, root_path_len);
4fe85b
+		    }
4fe85b
 		}
4fe85b
 	    }
4fe85b
 	  grub_net_add_ipv4_local (inter, mask);