summaryrefslogtreecommitdiff
path: root/src/sysv-generator
diff options
context:
space:
mode:
authorLukas Nykryn <lnykryn@redhat.com>2016-01-20 15:16:32 +0100
committerLukas Nykryn <lnykryn@redhat.com>2016-01-21 12:53:14 +0100
commitc584ffc0b75d4b9e9229bf1d8edb7d89562be3c1 (patch)
tree8371dcfe3dccac9941ebbafb99c686b63e44db85 /src/sysv-generator
parent91c4b6db7840e68e4d7a019c3cb4d5d60d2a65c7 (diff)
sysv-generator: do not join dependencies on one line, split them
If there is a lot of initscripts and dependencies between them we might end generating After= (and similar) lines which are longer then LINE_MAX and thus rejected by parser in systemd. Fixes #2099
Diffstat (limited to 'src/sysv-generator')
-rw-r--r--src/sysv-generator/sysv-generator.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 5075548507..d48d5abbe3 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -161,7 +161,6 @@ static int add_alias(const char *service, const char *alias) {
}
static int generate_unit_file(SysvStub *s) {
- _cleanup_free_ char *before = NULL, *after = NULL, *wants = NULL, *conflicts = NULL;
_cleanup_fclose_ FILE *f = NULL;
const char *unit;
char **p;
@@ -174,14 +173,6 @@ static int generate_unit_file(SysvStub *s) {
unit = strjoina(arg_dest, "/", s->name);
- before = strv_join(s->before, " ");
- after = strv_join(s->after, " ");
- wants = strv_join(s->wants, " ");
- conflicts = strv_join(s->conflicts, " ");
-
- if (!before || !after || !wants || !conflicts)
- return log_oom();
-
/* We might already have a symlink with the same name from a Provides:,
* or from backup files like /etc/init.d/foo.bak. Real scripts always win,
* so remove an existing link */
@@ -204,14 +195,14 @@ static int generate_unit_file(SysvStub *s) {
if (s->description)
fprintf(f, "Description=%s\n", s->description);
- if (!isempty(before))
- fprintf(f, "Before=%s\n", before);
- if (!isempty(after))
- fprintf(f, "After=%s\n", after);
- if (!isempty(wants))
- fprintf(f, "Wants=%s\n", wants);
- if (!isempty(conflicts))
- fprintf(f, "Conflicts=%s\n", conflicts);
+ STRV_FOREACH(p, s->before)
+ fprintf(f, "Before=%s\n", *p);
+ STRV_FOREACH(p, s->after)
+ fprintf(f, "After=%s\n", *p);
+ STRV_FOREACH(p, s->wants)
+ fprintf(f, "Wants=%s\n", *p);
+ STRV_FOREACH(p, s->conflicts)
+ fprintf(f, "Conflicts=%s\n", *p);
fprintf(f,
"\n[Service]\n"