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

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