]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/load-fragment: don't treat "; ;" as "/usr/bin/;"
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 16 Sep 2020 07:42:47 +0000 (09:42 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 18 Sep 2020 13:28:48 +0000 (15:28 +0200)
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.

src/core/load-fragment.c
src/test/test-load-fragment.c

index 8630ef0d4dac896254aeb0b4a1364aa894ec4bf2..701ed7487d52e437e67e6d56e94677d3bef24541 100644 (file)
@@ -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
index 66925c2b6daf26df5076622f1501c5fa9fb5aea7..799ac6a51a263f2fd8f2fdd135cc1f0a427e0e39 100644 (file)
@@ -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,