diff options
Diffstat (limited to 'load-dropin.c')
-rw-r--r-- | load-dropin.c | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/load-dropin.c b/load-dropin.c index 13d7bc8fe4..af95d37a03 100644 --- a/load-dropin.c +++ b/load-dropin.c @@ -25,6 +25,7 @@ #include "unit.h" #include "load-dropin.h" #include "log.h" +#include "strv.h" int unit_load_dropin(Unit *u) { Iterator i; @@ -39,52 +40,56 @@ int unit_load_dropin(Unit *u) { char *path; DIR *d; struct dirent *de; + char **p; - if (asprintf(&path, "%s/%s.wants", unit_path(), t) < 0) - return -ENOMEM; + STRV_FOREACH(p, u->meta.manager->unit_path) { - if (!(d = opendir(path))) { - r = -errno; - free(path); + if (asprintf(&path, "%s/%s.wants", *p, t) < 0) + return -ENOMEM; - if (r == -ENOENT) - continue; + if (!(d = opendir(path))) { + r = -errno; + free(path); - return r; - } + if (r == -ENOENT) + continue; - free(path); + return r; + } - while ((de = readdir(d))) { - if (de->d_name[0] == '.') - continue; + free(path); - assert(de->d_name[0]); + while ((de = readdir(d))) { + if (de->d_name[0] == '.') + continue; - if (de->d_name[strlen(de->d_name)-1] == '~') - continue; + assert(de->d_name[0]); - if (asprintf(&path, "%s/%s.wants/%s", unit_path(), t, de->d_name) < 0) { - closedir(d); - return -ENOMEM; - } + if (de->d_name[strlen(de->d_name)-1] == '~') + continue; - if (!unit_name_is_valid(de->d_name)) { - log_info("Name of %s is not a valid unit name. Ignoring.", path); - free(path); - continue; - } + if (asprintf(&path, "%s/%s.wants/%s", *p, t, de->d_name) < 0) { + closedir(d); + return -ENOMEM; + } - r = unit_add_dependency_by_name(u, UNIT_WANTS, path); - free(path); + if (!unit_name_is_valid(de->d_name)) { + log_info("Name of %s is not a valid unit name. Ignoring.", path); + free(path); + continue; + } - if (r < 0) { - closedir(d); - return r; + r = unit_add_dependency_by_name(u, UNIT_WANTS, path); + free(path); + + if (r < 0) { + closedir(d); + return r; + } } - } - closedir(d); + closedir(d); + } } return 0; |