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