Skip to content

Commit

Permalink
core: lift restriction on order of - and @ in ExecStart
Browse files Browse the repository at this point in the history
  • Loading branch information
keszybz committed Nov 15, 2012
1 parent 7e1a84f commit 0f67f1e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
5 changes: 2 additions & 3 deletions man/systemd.service.xml
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,8 @@
abnormal exit due to signal) is ignored
and considered success. If both
<literal>-</literal> and
<literal>@</literal> are used for the
same command the former must precede
the latter. Unless
<literal>@</literal> are used they
can appear in either order. Unless
<varname>Type=forking</varname> is
set, the process started via this
command line will be considered the
Expand Down
20 changes: 12 additions & 8 deletions src/core/load-fragment.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ int config_parse_exec(
e += ltype;

for (;;) {
int i;
char *w;
size_t l;
char *state;
Expand All @@ -452,18 +453,21 @@ int config_parse_exec(
if (rvalue[0] == 0)
break;

if (rvalue[0] == '-') {
ignore = true;
rvalue ++;
}
for (i = 0; i < 2; i++) {
if (rvalue[0] == '-' && !ignore) {
ignore = true;
rvalue ++;
}

if (rvalue[0] == '@') {
honour_argv0 = true;
rvalue ++;
if (rvalue[0] == '@' && !honour_argv0) {
honour_argv0 = true;
rvalue ++;
}
}

if (*rvalue != '/') {
log_error("[%s:%u] Invalid executable path in command line, ignoring: %s", filename, line, rvalue);
log_error("[%s:%u] Executable path is not absolute, ignoring: %s",
filename, line, rvalue);
return 0;
}

Expand Down
23 changes: 23 additions & 0 deletions src/test/test-unit-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,29 @@ static void test_config_parse_exec(void) {
check_execcommand(c1,
"/RValue/slashes3", "argv0a", "r1", true);

/* ignore && honour_argv0 */
r = config_parse_exec("fake", 4, "section",
"LValue", 0, "@-/RValue///slashes4/// argv0b r1",
&c, NULL);
assert_se(r >= 0);
c1 = c1->command_next;
check_execcommand(c1,
"/RValue/slashes4", "argv0b", "r1", true);

/* ignore && ignore */
r = config_parse_exec("fake", 4, "section",
"LValue", 0, "--/RValue argv0 r1",
&c, NULL);
assert_se(r == 0);
assert_se(c1->command_next == NULL);

/* ignore && ignore */
r = config_parse_exec("fake", 4, "section",
"LValue", 0, "-@-/RValue argv0 r1",
&c, NULL);
assert_se(r == 0);
assert_se(c1->command_next == NULL);

/* semicolon */
r = config_parse_exec("fake", 5, "section",
"LValue", 0,
Expand Down

0 comments on commit 0f67f1e

Please sign in to comment.