summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Marineau <michael.marineau@coreos.com>2014-05-16 16:58:31 -0700
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-05-17 00:29:07 -0400
commit342aea195051633c69ba7b8c02c82a0e5f8cbde4 (patch)
treec73239f4ea8c1512694676dc6e298699b1815196
parent24fe021ba517ab25081557837e618d8a65f0da2a (diff)
conf-parser: silently ignore sections starting with "X-"
This allows external tools to keep additional unit information in a separate section without scaring users with a big warning.
-rw-r--r--src/shared/conf-parser.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index d27b1b7eea..062b15b86a 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -204,6 +204,7 @@ static int parse_line(const char* unit,
bool allow_include,
char **section,
unsigned *section_line,
+ bool *section_ignored,
char *l,
void *userdata) {
@@ -266,7 +267,7 @@ static int parse_line(const char* unit,
if (sections && !nulstr_contains(sections, n)) {
- if (!relaxed)
+ if (!relaxed && !startswith(n, "X-"))
log_syntax(unit, LOG_WARNING, filename, line, EINVAL,
"Unknown section '%s'. Ignoring.", n);
@@ -274,10 +275,12 @@ static int parse_line(const char* unit,
free(*section);
*section = NULL;
*section_line = 0;
+ *section_ignored = true;
} else {
free(*section);
*section = n;
*section_line = line;
+ *section_ignored = false;
}
return 0;
@@ -285,7 +288,7 @@ static int parse_line(const char* unit,
if (sections && !*section) {
- if (!relaxed)
+ if (!relaxed && !*section_ignored)
log_syntax(unit, LOG_WARNING, filename, line, EINVAL,
"Assignment outside of section. Ignoring.");
@@ -328,6 +331,7 @@ int config_parse(const char *unit,
_cleanup_free_ char *section = NULL, *continuation = NULL;
_cleanup_fclose_ FILE *ours = NULL;
unsigned line = 0, section_line = 0;
+ bool section_ignored = false;
int r;
assert(filename);
@@ -399,6 +403,7 @@ int config_parse(const char *unit,
allow_include,
&section,
&section_line,
+ &section_ignored,
p,
userdata);
free(c);