From 8249bb728db6c2abaf12575d661b52571bdc1ab1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 14 Sep 2017 16:53:34 +0200 Subject: [PATCH 1/2] core: don't synthesize empty list when empty string is read in config_parse_strv() This was added to make https://bugs.freedesktop.org/show_bug.cgi?id=62558 work, which has long been removed, hence let's revert to the original behaviour and fully flush out the list when an empty string is assigned. --- src/shared/conf-parser.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 96618fbb92..c0afe45577 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -755,16 +755,17 @@ finalize: return 0; } -int config_parse_strv(const char *unit, - const char *filename, - unsigned line, - const char *section, - unsigned section_line, - const char *lvalue, - int ltype, - const char *rvalue, - void *data, - void *userdata) { +int config_parse_strv( + const char *unit, + const char *filename, + unsigned line, + const char *section, + unsigned section_line, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { char ***sv = data; int r; @@ -775,19 +776,7 @@ int config_parse_strv(const char *unit, assert(data); if (isempty(rvalue)) { - char **empty; - - /* Empty assignment resets the list. As a special rule - * we actually fill in a real empty array here rather - * than NULL, since some code wants to know if - * something was set at all... */ - empty = new0(char*, 1); - if (!empty) - return log_oom(); - - strv_free(*sv); - *sv = empty; - + *sv = strv_free(*sv); return 0; } @@ -809,6 +798,7 @@ int config_parse_strv(const char *unit, free(word); continue; } + r = strv_consume(sv, word); if (r < 0) return log_oom(); From 40fdd636ad8eb7cd8dbf18db8ad724ff4ac2ba33 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 14 Sep 2017 16:54:32 +0200 Subject: [PATCH 2/2] conf-parser: when the empty string assigned to Personality= reset it Let's support assigning the empty string to reset things in one more place. --- src/shared/conf-parser.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index c0afe45577..a84b61243e 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -916,10 +916,14 @@ int config_parse_personality( assert(rvalue); assert(personality); - p = personality_from_string(rvalue); - if (p == PERSONALITY_INVALID) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse personality, ignoring: %s", rvalue); - return 0; + if (isempty(rvalue)) + p = PERSONALITY_INVALID; + else { + p = personality_from_string(rvalue); + if (p == PERSONALITY_INVALID) { + log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse personality, ignoring: %s", rvalue); + return 0; + } } *personality = p;