]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sysv-generator: properly translate sysv facilities
authorLennart Poettering <lennart@poettering.net>
Tue, 6 Dec 2016 18:36:30 +0000 (19:36 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 14 Dec 2016 17:29:30 +0000 (18:29 +0100)
We used the wrong return value in one case, so that our translations were
thrown away.

While we are at it, make sure to always initialize *ret on successful function
exits.

Fixes: #4762
src/sysv-generator/sysv-generator.c

index 921fd478d0a517db150fcf156e346ed9fc68fe02..9fde9b18842dc78a57191f16cb82a89d1e149314 100644 (file)
@@ -292,8 +292,10 @@ static int sysv_translate_facility(SysvStub *s, unsigned line, const char *name,
                 if (!streq(table[i], n))
                         continue;
 
-                if (!table[i+1])
+                if (!table[i+1]) {
+                        *ret = NULL;
                         return 0;
+                }
 
                 m = strdup(table[i+1]);
                 if (!m)
@@ -312,7 +314,7 @@ static int sysv_translate_facility(SysvStub *s, unsigned line, const char *name,
                 if (r < 0)
                         return log_error_errno(r, "[%s:%u] Could not build name for facility %s: %m", s->path, line, name);
 
-                return r;
+                return 1;
         }
 
         /* Strip ".sh" suffix from file name for comparison */
@@ -324,8 +326,10 @@ static int sysv_translate_facility(SysvStub *s, unsigned line, const char *name,
         }
 
         /* Names equaling the file name of the services are redundant */
-        if (streq_ptr(n, filename))
+        if (streq_ptr(n, filename)) {
+                *ret = NULL;
                 return 0;
+        }
 
         /* Everything else we assume to be normal service names */
         m = sysv_translate_name(n);