conf-parser: accept trailing backslash at the end of the file (#8941)

This makes it behave the same whether there is a blank line or not at
the end of the file.  This is also consistent with the behavior of the
shell on a shell script that ends on a trailing backslash at the last
line.

Added tests to test_config_parse(), which only pass if the corresponding
change to config_parse() is included.
This commit is contained in:
Filipe Brandenburger
2018-05-09 18:10:07 -07:00
committed by Lennart Poettering
parent 3eff246a17
commit 4f29e0db12
2 changed files with 36 additions and 5 deletions
+21
View File
@@ -401,6 +401,27 @@ int config_parse(const char *unit,
continuation = mfree(continuation);
}
if (continuation) {
r = parse_line(unit,
filename,
++line,
sections,
lookup,
table,
flags,
&section,
&section_line,
&section_ignored,
continuation,
userdata);
if (r < 0) {
if (flags & CONFIG_PARSE_WARN)
log_warning_errno(r, "%s:%u: Failed to parse file: %m", filename, line);
return r;
}
}
return 0;
}