Blame SOURCES/0078-libmulitpath-add-section-name-to-invalid-keyword-out.patch

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