From: Zbigniew Jędrzejewski-Szmek Date: Wed, 16 Sep 2020 07:42:47 +0000 (+0200) Subject: core/load-fragment: don't treat "; ;" as "/usr/bin/;" X-Git-Tag: v247-rc1~176^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=598c47c86e248c1e5905d35a3f907a9da38086b6;p=thirdparty%2Fsystemd.git core/load-fragment: don't treat "; ;" as "/usr/bin/;" We had a special test case that the second semicolon would be interpreted as an executable name. We would then try to find the executable and rely on ";" not being found to cause ENOEXEC to be returned. I think that's just crazy. Let's treat the second semicolon as a separator and ignore the whole thing as we would whitespace. --- diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 8630ef0d4da..701ed7487d5 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -721,6 +721,12 @@ int config_parse_exec( if (r <= 0) return 0; + /* A lone ";" is a separator. Let's make sure we don't treat it as an executable name. */ + if (streq(firstword, ";")) { + semicolon = true; + continue; + } + f = firstword; for (;;) { /* We accept an absolute path as first argument. If it's prefixed with - and the path doesn't diff --git a/src/test/test-load-fragment.c b/src/test/test-load-fragment.c index 66925c2b6da..799ac6a51a2 100644 --- a/src/test/test-load-fragment.c +++ b/src/test/test-load-fragment.c @@ -202,12 +202,11 @@ static void test_config_parse_exec(void) { "-@/RValue argv0 r1 ; ; " "/goo/goo boo", &c, u); - assert_se(r == -ENOEXEC); + assert_se(r >= 0); c1 = c1->command_next; check_execcommand(c1, "/RValue", "argv0", "r1", NULL, true); - - /* second command fails because the executable name is ";" */ - assert_se(c1->command_next == NULL); + c1 = c1->command_next; + check_execcommand(c1, "/goo/goo", "/goo/goo", "boo", NULL, false); log_info("/* trailing semicolon */"); r = config_parse_exec(NULL, "fake", 5, "section", 1,