summaryrefslogtreecommitdiff
path: root/src/shared/dropin.c
diff options
context:
space:
mode:
authorTopi Miettinen <toiwoton@gmail.com>2019-12-17 15:47:37 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-12-18 08:43:40 +0100
commit7a670b1dd981c645064f69faf85b04620aadbafb (patch)
tree1654f6597dcc2c0755121135a1f8f05748bb256b /src/shared/dropin.c
parent51692fab56efb0093bc74b02df7e30714f7d0fd7 (diff)
downloadsystemd-7a670b1dd981c645064f69faf85b04620aadbafb.tar.gz
shared/dropin: fix assert for invalid drop-in
Don't try to show top level drop-in for non-existent units or when trying to instantiate non-instantiated units: $ systemctl cat nonexistent@.service Assertion 'name' failed at src/shared/dropin.c:143, function unit_file_find_dirs(). Aborting. $ systemctl cat systemd-journald@.service Assertion 'name' failed at src/shared/dropin.c:143, function unit_file_find_dirs(). Aborting.
Diffstat (limited to 'src/shared/dropin.c')
-rw-r--r--src/shared/dropin.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/shared/dropin.c b/src/shared/dropin.c
index ca97285c97..96cd08aab2 100644
--- a/src/shared/dropin.c
+++ b/src/shared/dropin.c
@@ -230,7 +230,6 @@ int unit_file_find_dropin_paths(
char ***ret) {
_cleanup_strv_free_ char **dirs = NULL;
- UnitType type = _UNIT_TYPE_INVALID;
char *name, **p;
Iterator i;
int r;
@@ -240,22 +239,24 @@ int unit_file_find_dropin_paths(
/* All the names in the unit are of the same type so just grab one. */
name = (char*) set_first(names);
if (name) {
+ UnitType type = _UNIT_TYPE_INVALID;
+
type = unit_name_to_type(name);
if (type < 0)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Failed to to derive unit type from unit name: %s",
name);
- }
- /* Special top level drop in for "<unit type>.<suffix>". Add this first as it's the most generic
- * and should be able to be overridden by more specific drop-ins. */
- STRV_FOREACH(p, lookup_path)
- (void) unit_file_find_dirs(original_root,
- unit_path_cache,
- *p,
- unit_type_to_string(type),
- dir_suffix,
- &dirs);
+ /* Special top level drop in for "<unit type>.<suffix>". Add this first as it's the most generic
+ * and should be able to be overridden by more specific drop-ins. */
+ STRV_FOREACH(p, lookup_path)
+ (void) unit_file_find_dirs(original_root,
+ unit_path_cache,
+ *p,
+ unit_type_to_string(type),
+ dir_suffix,
+ &dirs);
+ }
SET_FOREACH(name, names, i)
STRV_FOREACH(p, lookup_path)