diff options
author | Felipe Sateler <fsateler@debian.org> | 2015-06-27 21:02:53 -0300 |
---|---|---|
committer | Felipe Sateler <fsateler@debian.org> | 2015-06-29 16:07:49 -0300 |
commit | 2c09a745eba5f463e12b498a2f62a5036253c55c (patch) | |
tree | 6cbecb152a63e83785d4c02d819cb87b8bf48357 /src/sysv-generator | |
parent | 2ab4c7c9f3fd127f13fd4b91924d5432693fadc6 (diff) |
sysv-generator: detect invalid provided unit names
Do not assume that a non-service unit type is a target.
Diffstat (limited to 'src/sysv-generator')
-rw-r--r-- | src/sysv-generator/sysv-generator.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index 9ae518ac4a..c9dd3b6302 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -340,6 +340,7 @@ static int handle_provides(SysvStub *s, unsigned line, const char *full_text, co FOREACH_WORD_QUOTED(word, z, text, state_) { _cleanup_free_ char *n = NULL, *m = NULL; + UnitType t; n = strndup(word, z); if (!n) @@ -351,12 +352,13 @@ static int handle_provides(SysvStub *s, unsigned line, const char *full_text, co if (r == 0) continue; - if (unit_name_to_type(m) == UNIT_SERVICE) { + t = unit_name_to_type(m); + if (t == UNIT_SERVICE) { log_debug("Adding Provides: alias '%s' for '%s'", m, s->name); r = add_alias(s->name, m); if (r < 0) log_warning_errno(r, "[%s:%u] Failed to add LSB Provides name %s, ignoring: %m", s->path, line, m); - } else { + } else if (t == UNIT_TARGET) { /* NB: SysV targets which are provided by a * service are pulled in by the services, as * an indication that the generic service is @@ -374,6 +376,10 @@ static int handle_provides(SysvStub *s, unsigned line, const char *full_text, co return log_oom(); } } + else if (t == _UNIT_TYPE_INVALID) + log_warning("Unit name '%s' is invalid", m); + else + log_warning("Unknown unit type for unit '%s'", m); } if (!isempty(state_)) log_error("[%s:%u] Trailing garbage in Provides, ignoring.", s->path, line); |