Blame SOURCES/0023-libmultipath-add-section-name-to-invalid-keyword-out.patch

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