blob: 82543602a357403f8c420b27e96df69322da9511 [file] [log] [blame]
Zbigniew Jędrzejewski-Szmek5d6eedd2017-01-31 12:11:17 -05001From 59ebe5b42ccd7cacbf5975f8ddc1aa42c78e45db Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek03e93e22017-01-29 17:22:41 -05002From: Lennart Poettering <lennart@poettering.net>
3Date: Tue, 6 Dec 2016 19:36:30 +0100
4Subject: [PATCH] sysv-generator: properly translate sysv facilities
5
6We used the wrong return value in one case, so that our translations were
7thrown away.
8
9While we are at it, make sure to always initialize *ret on successful function
10exits.
11
12Fixes: #4762
13(cherry picked from commit e932f5407ef5ad05d25d7dfefa4cda0fe81cc346)
14---
15 src/sysv-generator/sysv-generator.c | 10 +++++++---
16 1 file changed, 7 insertions(+), 3 deletions(-)
17
18diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
19index c2c80175a2..212cf7a988 100644
20--- a/src/sysv-generator/sysv-generator.c
21+++ b/src/sysv-generator/sysv-generator.c
22@@ -292,8 +292,10 @@ static int sysv_translate_facility(SysvStub *s, unsigned line, const char *name,
23 if (!streq(table[i], n))
24 continue;
25
26- if (!table[i+1])
27+ if (!table[i+1]) {
28+ *ret = NULL;
29 return 0;
30+ }
31
32 m = strdup(table[i+1]);
33 if (!m)
34@@ -312,7 +314,7 @@ static int sysv_translate_facility(SysvStub *s, unsigned line, const char *name,
35 if (r < 0)
36 return log_error_errno(r, "[%s:%u] Could not build name for facility %s: %m", s->path, line, name);
37
38- return r;
39+ return 1;
40 }
41
42 /* Strip ".sh" suffix from file name for comparison */
43@@ -324,8 +326,10 @@ static int sysv_translate_facility(SysvStub *s, unsigned line, const char *name,
44 }
45
46 /* Names equaling the file name of the services are redundant */
47- if (streq_ptr(n, filename))
48+ if (streq_ptr(n, filename)) {
49+ *ret = NULL;
50 return 0;
51+ }
52
53 /* Everything else we assume to be normal service names */
54 m = sysv_translate_name(n);