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

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