Zbigniew Jędrzejewski-Szmek | 5d6eedd | 2017-01-31 12:11:17 -0500 | [diff] [blame] | 1 | From 59ebe5b42ccd7cacbf5975f8ddc1aa42c78e45db Mon Sep 17 00:00:00 2001 |
Zbigniew Jędrzejewski-Szmek | 03e93e2 | 2017-01-29 17:22:41 -0500 | [diff] [blame] | 2 | From: Lennart Poettering <lennart@poettering.net> |
| 3 | Date: Tue, 6 Dec 2016 19:36:30 +0100 |
| 4 | Subject: [PATCH] sysv-generator: properly translate sysv facilities |
| 5 | |
| 6 | We used the wrong return value in one case, so that our translations were |
| 7 | thrown away. |
| 8 | |
| 9 | While we are at it, make sure to always initialize *ret on successful function |
| 10 | exits. |
| 11 | |
| 12 | Fixes: #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 | |
| 18 | diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c |
| 19 | index 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); |