|
|
ebef98 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
ebef98 |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
ebef98 |
Date: Thu, 23 Sep 2021 14:16:51 -0500
|
|
|
ebef98 |
Subject: [PATCH] libmultipath: add section name to invalid keyword output
|
|
|
ebef98 |
|
|
|
ebef98 |
If users forget the closing brace for a section in multipath.conf,
|
|
|
ebef98 |
multipath has no way to detect that. When it sees the keyword at the
|
|
|
ebef98 |
start of the next section, it will complain that there is an invalid
|
|
|
ebef98 |
keyword, because that keyword doesn't belong in previous section (which
|
|
|
ebef98 |
was never ended with a closing brace). This can confuse users. To make
|
|
|
ebef98 |
this easier to understand, when multipath prints an invalid keyword
|
|
|
ebef98 |
message, it now also prints the current section name, which can give
|
|
|
ebef98 |
users a hint that they didn't end the previous section.
|
|
|
ebef98 |
|
|
|
ebef98 |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
ebef98 |
---
|
|
|
ebef98 |
libmultipath/parser.c | 20 +++++++++++++-------
|
|
|
ebef98 |
1 file changed, 13 insertions(+), 7 deletions(-)
|
|
|
ebef98 |
|
|
|
ebef98 |
diff --git a/libmultipath/parser.c b/libmultipath/parser.c
|
|
|
ebef98 |
index 8ca91bf2..611054f7 100644
|
|
|
ebef98 |
--- a/libmultipath/parser.c
|
|
|
ebef98 |
+++ b/libmultipath/parser.c
|
|
|
ebef98 |
@@ -504,7 +504,7 @@ validate_config_strvec(vector strvec, const char *file)
|
|
|
ebef98 |
|
|
|
ebef98 |
static int
|
|
|
ebef98 |
process_stream(struct config *conf, FILE *stream, vector keywords,
|
|
|
ebef98 |
- const char *file)
|
|
|
ebef98 |
+ const char *section, const char *file)
|
|
|
ebef98 |
{
|
|
|
ebef98 |
int i;
|
|
|
ebef98 |
int r = 0, t;
|
|
|
ebef98 |
@@ -568,16 +568,22 @@ process_stream(struct config *conf, FILE *stream, vector keywords,
|
|
|
ebef98 |
if (keyword->sub) {
|
|
|
ebef98 |
kw_level++;
|
|
|
ebef98 |
r += process_stream(conf, stream,
|
|
|
ebef98 |
- keyword->sub, file);
|
|
|
ebef98 |
+ keyword->sub,
|
|
|
ebef98 |
+ keyword->string,
|
|
|
ebef98 |
+ file);
|
|
|
ebef98 |
kw_level--;
|
|
|
ebef98 |
}
|
|
|
ebef98 |
break;
|
|
|
ebef98 |
}
|
|
|
ebef98 |
}
|
|
|
ebef98 |
- if (i >= VECTOR_SIZE(keywords))
|
|
|
ebef98 |
- condlog(1, "%s line %d, invalid keyword: %s",
|
|
|
ebef98 |
- file, line_nr, str);
|
|
|
ebef98 |
-
|
|
|
ebef98 |
+ if (i >= VECTOR_SIZE(keywords)) {
|
|
|
ebef98 |
+ if (section)
|
|
|
ebef98 |
+ condlog(1, "%s line %d, invalid keyword in the %s section: %s",
|
|
|
ebef98 |
+ file, line_nr, section, str);
|
|
|
ebef98 |
+ else
|
|
|
ebef98 |
+ condlog(1, "%s line %d, invalid keyword: %s",
|
|
|
ebef98 |
+ file, line_nr, str);
|
|
|
ebef98 |
+ }
|
|
|
ebef98 |
free_strvec(strvec);
|
|
|
ebef98 |
}
|
|
|
ebef98 |
if (kw_level == 1)
|
|
|
ebef98 |
@@ -608,7 +614,7 @@ process_file(struct config *conf, const char *file)
|
|
|
ebef98 |
|
|
|
ebef98 |
/* Stream handling */
|
|
|
ebef98 |
line_nr = 0;
|
|
|
ebef98 |
- r = process_stream(conf, stream, conf->keywords, file);
|
|
|
ebef98 |
+ r = process_stream(conf, stream, conf->keywords, NULL, file);
|
|
|
ebef98 |
fclose(stream);
|
|
|
ebef98 |
//free_keywords(keywords);
|
|
|
ebef98 |
|