From 2d4fffb00bbf528683946ee04e04980549124b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 18 Jul 2019 11:28:55 +0200 Subject: [PATCH 1/3] shared/conf-parser: be nice and ignore lines without "=" We generally don't treat syntax error as fatal, but in this case we would completely refuse to load the file. I think we should treat the the same as assignment outside of a section, or an unknown key name. --- src/shared/conf-parser.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 62fc1c97b7..c3af230870 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -239,7 +239,6 @@ static int parse_line( } if (sections && !*section) { - if (!(flags & CONFIG_PARSE_RELAXED) && !*section_ignored) log_syntax(unit, LOG_WARNING, filename, line, 0, "Assignment outside of section. Ignoring."); @@ -247,10 +246,9 @@ static int parse_line( } e = strchr(l, '='); - if (!e) { - log_syntax(unit, LOG_WARNING, filename, line, 0, "Missing '='."); - return -EINVAL; - } + if (!e) + return log_syntax(unit, LOG_WARNING, filename, line, 0, + "Missing '=', ignoring line."); *e = 0; e++; From 8be8ed8ce1ed30450b6caf6e7dcf6dd28080e1f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 18 Jul 2019 11:30:43 +0200 Subject: [PATCH 2/3] shared/conf-parser: emit a nicer warning for something like "======" Urlich Windl wrote on the mailing list: > I noticed that a line of "=======" in "[Service]" cases the message " Unknown lvalue '' in section 'Service'". This now becomes: /etc/systemd/system/eqeqeqeq.service:3: Missing key name before '=', ignoring line. --- src/shared/conf-parser.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index c3af230870..b4ebc0f44b 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -249,6 +249,9 @@ static int parse_line( if (!e) return log_syntax(unit, LOG_WARNING, filename, line, 0, "Missing '=', ignoring line."); + if (e == l) + return log_syntax(unit, LOG_WARNING, filename, line, 0, + "Missing key name before '=', ignoring line."); *e = 0; e++; From 28f30f4051c3424b5f0757c76856a1102763e04f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 18 Jul 2019 11:33:48 +0200 Subject: [PATCH 3/3] shared/conf-parser: say "key name" not "lvalue", add dot "lvalue" is our internal jargon. Let's try not to confuse non-programmers. --- src/shared/conf-parser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index b4ebc0f44b..a495c2538b 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -138,7 +138,8 @@ static int next_assignment( /* Warn about unknown non-extension fields. */ if (!(flags & CONFIG_PARSE_RELAXED) && !startswith(lvalue, "X-")) - log_syntax(unit, LOG_WARNING, filename, line, 0, "Unknown lvalue '%s' in section '%s', ignoring", lvalue, section); + log_syntax(unit, LOG_WARNING, filename, line, 0, + "Unknown key name '%s' in section '%s', ignoring.", lvalue, section); return 0; }