Blame SOURCES/0132-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch

28f7f8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
39700a
From: Peter Jones <pjones@redhat.com>
39700a
Date: Thu, 6 Mar 2014 11:51:33 -0500
28f7f8
Subject: [PATCH] Try mac/guid/etc before grub.cfg on tftp config files.
39700a
39700a
Signed-off-by: Peter Jones <pjones@redhat.com>
39700a
---
39700a
 grub-core/normal/main.c | 80 ++++++++++++++++++++++++++-----------------------
39700a
 1 file changed, 43 insertions(+), 37 deletions(-)
39700a
39700a
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
28f7f8
index 5e2ac150e12..4190985ad37 100644
39700a
--- a/grub-core/normal/main.c
39700a
+++ b/grub-core/normal/main.c
39700a
@@ -341,53 +341,59 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
39700a
       /* Guess the config filename. It is necessary to make CONFIG static,
39700a
 	 so that it won't get broken by longjmp.  */
39700a
       char *config;
39700a
-      const char *prefix, *fw_path;
39700a
-
39700a
-      prefix = fw_path = grub_env_get ("fw_path");
39700a
-      if (fw_path)
39700a
-	{
39700a
-	  config = grub_xasprintf ("%s/grub.cfg", fw_path);
39700a
-	  if (config)
39700a
-	    {
39700a
-	      grub_file_t file;
39700a
-
39700a
-	      file = grub_file_open (config);
39700a
-	      if (file)
39700a
-		{
39700a
-		  grub_file_close (file);
39700a
-		  grub_enter_normal_mode (config);
39700a
-		}
39700a
-              else
39700a
-                {
39700a
-                  /*  Ignore all errors.  */
39700a
-                  grub_errno = 0;
39700a
-                }
39700a
-	      grub_free (config);
39700a
-	    }
39700a
-	}
39700a
+      const char *prefix;
39700a
 
39700a
+      prefix = grub_env_get ("fw_path");
39700a
       if (! prefix)
39700a
 	      prefix = grub_env_get ("prefix");
39700a
+
39700a
       if (prefix)
39700a
-        {
39700a
-          grub_size_t config_len;
39700a
-          config_len = grub_strlen (prefix) +
39700a
-                      sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
39700a
-          config = grub_malloc (config_len);
39700a
+	{
39700a
+	  if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0)
39700a
+	    {
39700a
+	      grub_size_t config_len;
39700a
+	      config_len = grub_strlen (prefix) +
39700a
+		sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
39700a
+	      config = grub_malloc (config_len);
39700a
 
39700a
-          if (! config)
39700a
-            goto quit;
28f7f8
+	      if (! config)
28f7f8
+		goto quit;
39700a
 
39700a
-          grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
28f7f8
+	      grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
39700a
 
39700a
-          if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0)
39700a
-            grub_net_search_configfile (config);
28f7f8
+	      grub_net_search_configfile (config);
28f7f8
 
28f7f8
-	  grub_enter_normal_mode (config);
28f7f8
-	  grub_free (config);
39700a
+	      grub_enter_normal_mode (config);
39700a
+	      grub_free (config);
39700a
+	      config = NULL;
39700a
+	    }
28f7f8
+
39700a
+	  if (!config)
39700a
+	    {
39700a
+	      config = grub_xasprintf ("%s/grub.cfg", prefix);
39700a
+	      if (config)
39700a
+		{
39700a
+		  grub_file_t file;
39700a
+
39700a
+		  file = grub_file_open (config);
39700a
+		  if (file)
39700a
+		    {
39700a
+		      grub_file_close (file);
39700a
+		      grub_enter_normal_mode (config);
39700a
+		    }
39700a
+		  else
39700a
+		    {
39700a
+		      /*  Ignore all errors.  */
39700a
+		      grub_errno = 0;
39700a
+		    }
39700a
+		  grub_free (config);
39700a
+		}
39700a
+	    }
39700a
 	}
39700a
       else
39700a
-	grub_enter_normal_mode (0);
39700a
+	{
39700a
+	  grub_enter_normal_mode (0);
39700a
+	}
39700a
     }
39700a
   else
39700a
     grub_enter_normal_mode (argv[0]);