2018-07-12 14:56:34 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2014-07-02 15:49:28 +00:00
|
|
|
From: Peter Jones <pjones@redhat.com>
|
2019-08-15 06:01:31 +00:00
|
|
|
Date: Mon, 8 Jul 2019 17:33:22 +0200
|
2018-07-10 19:08:14 +00:00
|
|
|
Subject: [PATCH] Try mac/guid/etc before grub.cfg on tftp config files.
|
2014-07-02 15:49:28 +00:00
|
|
|
|
|
|
|
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
|
---
|
2021-03-12 21:54:28 +00:00
|
|
|
grub-core/normal/main.c | 97 ++++++++++++++++++++++++++-----------------------
|
|
|
|
1 file changed, 51 insertions(+), 46 deletions(-)
|
2014-07-02 15:49:28 +00:00
|
|
|
|
|
|
|
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
|
2021-11-04 16:29:49 +00:00
|
|
|
index 02577502116..880d0ebd454 100644
|
2014-07-02 15:49:28 +00:00
|
|
|
--- a/grub-core/normal/main.c
|
|
|
|
+++ b/grub-core/normal/main.c
|
2021-11-04 16:29:49 +00:00
|
|
|
@@ -345,61 +345,66 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
|
2014-07-02 15:49:28 +00:00
|
|
|
/* Guess the config filename. It is necessary to make CONFIG static,
|
|
|
|
so that it won't get broken by longjmp. */
|
|
|
|
char *config;
|
|
|
|
- const char *prefix, *fw_path;
|
|
|
|
-
|
|
|
|
- prefix = fw_path = grub_env_get ("fw_path");
|
|
|
|
- if (fw_path)
|
|
|
|
- {
|
|
|
|
- config = grub_xasprintf ("%s/grub.cfg", fw_path);
|
|
|
|
- if (config)
|
|
|
|
- {
|
|
|
|
- grub_file_t file;
|
|
|
|
-
|
2019-08-15 06:01:31 +00:00
|
|
|
- file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
|
2014-07-02 15:49:28 +00:00
|
|
|
- if (file)
|
|
|
|
- {
|
|
|
|
- grub_file_close (file);
|
|
|
|
- grub_enter_normal_mode (config);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- /* Ignore all errors. */
|
|
|
|
- grub_errno = 0;
|
|
|
|
- }
|
|
|
|
- grub_free (config);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
+ const char *prefix;
|
2021-03-12 21:54:28 +00:00
|
|
|
+ const char *net_search_cfg;
|
|
|
|
+ int disable_net_search = 0;
|
2014-07-02 15:49:28 +00:00
|
|
|
|
|
|
|
+ prefix = grub_env_get ("fw_path");
|
|
|
|
if (! prefix)
|
|
|
|
prefix = grub_env_get ("prefix");
|
2021-03-12 21:54:28 +00:00
|
|
|
+
|
|
|
|
+ net_search_cfg = grub_env_get ("feature_net_search_cfg");
|
|
|
|
+ if (net_search_cfg && net_search_cfg[0] == 'n')
|
|
|
|
+ disable_net_search = 1;
|
2014-07-02 15:49:28 +00:00
|
|
|
+
|
|
|
|
if (prefix)
|
2019-08-15 06:01:31 +00:00
|
|
|
{
|
2014-07-02 15:49:28 +00:00
|
|
|
- grub_size_t config_len;
|
2021-03-12 21:54:28 +00:00
|
|
|
- int disable_net_search = 0;
|
|
|
|
- const char *net_search_cfg;
|
|
|
|
-
|
2014-07-02 15:49:28 +00:00
|
|
|
- config_len = grub_strlen (prefix) +
|
2021-03-12 21:54:28 +00:00
|
|
|
- sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
|
2014-07-02 15:49:28 +00:00
|
|
|
- config = grub_malloc (config_len);
|
2019-08-15 06:01:31 +00:00
|
|
|
-
|
2021-03-12 21:54:28 +00:00
|
|
|
- if (!config)
|
2014-07-02 15:49:28 +00:00
|
|
|
- goto quit;
|
2019-08-15 06:01:31 +00:00
|
|
|
-
|
2014-07-02 15:49:28 +00:00
|
|
|
- grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
|
2019-08-15 06:01:31 +00:00
|
|
|
-
|
2021-03-12 21:54:28 +00:00
|
|
|
- net_search_cfg = grub_env_get ("feature_net_search_cfg");
|
|
|
|
- if (net_search_cfg && net_search_cfg[0] == 'n')
|
|
|
|
- disable_net_search = 1;
|
|
|
|
-
|
|
|
|
if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0 &&
|
|
|
|
!disable_net_search)
|
|
|
|
- grub_net_search_config_file (config);
|
2019-08-15 06:01:31 +00:00
|
|
|
+ {
|
|
|
|
+ grub_size_t config_len;
|
|
|
|
+ config_len = grub_strlen (prefix) +
|
|
|
|
+ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
|
|
|
|
+ config = grub_malloc (config_len);
|
2018-02-27 18:56:41 +00:00
|
|
|
|
|
|
|
- grub_enter_normal_mode (config);
|
|
|
|
- grub_free (config);
|
2019-08-15 06:01:31 +00:00
|
|
|
- }
|
|
|
|
+ if (! config)
|
|
|
|
+ goto quit;
|
|
|
|
+
|
|
|
|
+ grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
|
|
|
|
+
|
|
|
|
+ grub_net_search_configfile (config);
|
|
|
|
+
|
|
|
|
+ grub_enter_normal_mode (config);
|
|
|
|
+ grub_free (config);
|
|
|
|
+ config = NULL;
|
|
|
|
+ }
|
2018-02-27 18:56:41 +00:00
|
|
|
+
|
2019-08-15 06:01:31 +00:00
|
|
|
+ if (!config)
|
|
|
|
+ {
|
|
|
|
+ config = grub_xasprintf ("%s/grub.cfg", prefix);
|
|
|
|
+ if (config)
|
|
|
|
+ {
|
|
|
|
+ grub_file_t file;
|
2014-07-02 15:49:28 +00:00
|
|
|
+
|
2019-08-15 06:01:31 +00:00
|
|
|
+ file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
|
|
|
|
+ if (file)
|
|
|
|
+ {
|
|
|
|
+ grub_file_close (file);
|
|
|
|
+ grub_enter_normal_mode (config);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ /* Ignore all errors. */
|
|
|
|
+ grub_errno = 0;
|
|
|
|
+ }
|
|
|
|
+ grub_free (config);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2014-07-02 15:49:28 +00:00
|
|
|
else
|
|
|
|
- grub_enter_normal_mode (0);
|
2019-08-15 06:01:31 +00:00
|
|
|
+ {
|
|
|
|
+ grub_enter_normal_mode (0);
|
|
|
|
+ }
|
2014-07-02 15:49:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
grub_enter_normal_mode (argv[0]);
|