aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/ldlinux
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-06-27 12:54:15 +0100
committerMatt Fleming <matt.fleming@intel.com>2013-06-27 13:03:30 +0100
commit00d0f3add99de6d9c83ff2492bac175a5e1b8a11 (patch)
tree147e50d4bded12ed4b1673907867002073af9ad5 /com32/elflink/ldlinux
parent398cee85e1835b77e1b83a01fc20587bee8cc578 (diff)
downloadsyslinux-00d0f3add99de6d9c83ff2492bac175a5e1b8a11.tar.gz
syslinux-00d0f3add99de6d9c83ff2492bac175a5e1b8a11.tar.xz
syslinux-00d0f3add99de6d9c83ff2492bac175a5e1b8a11.zip
ldlinux: fix INCLUDE regressionsyslinux-5.11-pre3
We don't want to overwrite 'ConfigName' when parsing a config file via the INCLUDE directive, which commit 5447ef821 ("ldlinux: Always update ConfigName when opening a config file") failed to take into account. In the INCLUDE case we're only parsing config fragments, and not a main config file. Rename parse_one_config() to parse_main_config() to more accurately reflect when it should be invoked (i.e. not for INCLUDE). Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'com32/elflink/ldlinux')
-rw-r--r--com32/elflink/ldlinux/readconfig.c92
1 files changed, 70 insertions, 22 deletions
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 3ee825d7..22efbe43 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -640,7 +640,7 @@ extern const char *append;
extern uint16_t PXERetry;
static struct labeldata ld;
-static int parse_one_config(const char *filename);
+static int parse_main_config(const char *filename);
static char *is_kernel_type(char *cmdstr, enum kernel_type *type)
{
@@ -810,6 +810,70 @@ bail:
return -1;
}
+static void parse_config_file(FILE * f);
+
+static void do_include_menu(char *str, struct menu *m)
+{
+ const char *file;
+ char *p;
+ FILE *f;
+ int fd;
+
+ p = skipspace(str);
+ file = refdup_word(&p);
+ p = skipspace(p);
+
+ fd = open(file, O_RDONLY);
+ if (fd < 0)
+ goto put;
+
+ f = fdopen(fd, "r");
+ if (!f)
+ goto bail;
+
+ if (*p) {
+ record(m, &ld, append);
+ m = current_menu = begin_submenu(p);
+ }
+
+ parse_config_file(f);
+
+ if (*p) {
+ record(m, &ld, append);
+ m = current_menu = end_submenu();
+ }
+
+bail:
+ close(fd);
+put:
+ refstr_put(file);
+
+}
+
+static void do_include(char *str)
+{
+ const char *file;
+ char *p;
+ FILE *f;
+ int fd;
+
+ p = skipspace(str);
+ file = refdup_word(&p);
+
+ fd = open(file, O_RDONLY);
+ if (fd < 0)
+ goto put;
+
+ f = fdopen(fd, "r");
+ if (f)
+ parse_config_file(f);
+
+bail:
+ close(fd);
+put:
+ refstr_put(file);
+}
+
static void parse_config_file(FILE * f)
{
char line[MAX_LINE], *p, *ep, ch;
@@ -898,7 +962,7 @@ static void parse_config_file(FILE * f)
m->menu_master_passwd = refstrdup(skipspace(p + 6));
}
} else if ((ep = looking_at(p, "include"))) {
- goto do_include;
+ do_include_menu(ep, m);
} else if ((ep = looking_at(p, "background"))) {
p = skipspace(ep);
refstr_put(m->menu_background);
@@ -1095,23 +1159,7 @@ static void parse_config_file(FILE * f)
m->fkeyhelp[fkeyno].background = refdup_word(&p);
}
} else if ((ep = looking_at(p, "include"))) {
-do_include:
- {
- const char *file;
- p = skipspace(ep);
- file = refdup_word(&p);
- p = skipspace(p);
- if (*p) {
- record(m, &ld, append);
- m = current_menu = begin_submenu(p);
- parse_one_config(file);
- record(m, &ld, append);
- m = current_menu = end_submenu();
- } else {
- parse_one_config(file);
- }
- refstr_put(file);
- }
+ do_include(ep);
} else if (looking_at(p, "append")) {
const char *a = refstrdup(skipspace(p + 6));
if (ld.label) {
@@ -1386,7 +1434,7 @@ do_include:
}
}
-static int parse_one_config(const char *filename)
+static int parse_main_config(const char *filename)
{
const char *mode = "r";
FILE *f;
@@ -1466,14 +1514,14 @@ void parse_configs(char **argv)
current_menu = root_menu;
if (!argv || !*argv) {
- if (parse_one_config(NULL) < 0) {
+ if (parse_main_config(NULL) < 0) {
printf("WARNING: No configuration file found\n");
return;
}
} else {
while ((filename = *argv++)) {
dprintf("Parsing config: %s", filename);
- parse_one_config(filename);
+ parse_main_config(filename);
}
}