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