systemd-run: properly escape arguments

Spaces, quotes, and such, were not properly escaped. We should
write them like we read them.

https://bugs.freedesktop.org/show_bug.cgi?id=67971
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2013-09-09 13:49:29 -04:00
parent a012ab5293
commit a6fde35332
4 changed files with 125 additions and 48 deletions
+8 -13
View File
@@ -273,21 +273,16 @@ static int bus_service_set_transient_property(
fputs("ExecStart=\n", f);
LIST_FOREACH(command, c, s->exec_command[SERVICE_EXEC_START]) {
char **a;
fputs("ExecStart=", f);
_cleanup_free_ char *a;
if (c->ignore)
fputc('-', f);
a = strv_join_quoted(c->argv);
if (!a)
return -ENOMEM;
fputc('@', f);
fputs(c->path, f);
STRV_FOREACH(a, c->argv) {
fputc(' ', f);
fputs(*a, f);
}
fputc('\n', f);
fprintf(f, "ExecStart=%s@%s %s\n",
c->ignore ? "-" : "",
c->path,
a);
}
fflush(f);