chiark / gitweb /
lookup: drop empty directories from search paths
authorLennart Poettering <lennart@poettering.net>
Thu, 28 Apr 2011 02:55:05 +0000 (04:55 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 28 Apr 2011 02:55:05 +0000 (04:55 +0200)
TODO
src/path-lookup.c
src/util.c
src/util.h

diff --git a/TODO b/TODO
index 106ee974d3f8df45b9a5bbfc74dd27162d7189df..d5479b501fb97d8d4d92eb3f6270ad88c3566810 100644 (file)
--- a/TODO
+++ b/TODO
@@ -34,8 +34,6 @@ Features:
 
 * Maybe merge nss-myhostname into systemd?
 
-* ensure we strip empty directories from search path
-
 * GC unreferenced jobs (such as .device jobs)
 
 * support wildcard expansion in ListenStream= and friends
index b39ce8b699784284a9f0189b2ea1a2e2369d8d79..b1c69814cade62115d1335087a0822dd970011dd 100644 (file)
@@ -205,6 +205,7 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) {
                         return -ENOMEM;
 
         strv_uniq(p->unit_path);
+        strv_path_remove_empty(p->unit_path);
 
         if (!strv_isempty(p->unit_path)) {
 
@@ -259,6 +260,9 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) {
                 strv_uniq(p->sysvinit_path);
                 strv_uniq(p->sysvrcnd_path);
 
+                strv_path_remove_empty(p->sysvinit_path);
+                strv_path_remove_empty(p->sysvrcnd_path);
+
                 if (!strv_isempty(p->sysvinit_path)) {
 
                         if (!(t = strv_join(p->sysvinit_path, "\n\t")))
index 5029896ef0635d507fcb9bc8e6e10dab537c81d3..6037455f705fd3e6f0dd40eb8f9091dc7fb8bf55 100644 (file)
@@ -1209,6 +1209,26 @@ char **strv_path_canonicalize(char **l) {
         return l;
 }
 
+char **strv_path_remove_empty(char **l) {
+        char **f, **t;
+
+        if (!l)
+                return NULL;
+
+        for (f = t = l; *f; f++) {
+
+                if (dir_is_empty(*f) > 0) {
+                        free(*f);
+                        continue;
+                }
+
+                *(t++) = *f;
+        }
+
+        *t = NULL;
+        return l;
+}
+
 int reset_all_signal_handlers(void) {
         int sig;
 
index 7fa488b0f57c0edb3e764e5a24eea8b9fe348a50..ff294745028534e9a8ab69fc0a2a5b80216fe679 100644 (file)
@@ -224,6 +224,7 @@ char *path_make_absolute_cwd(const char *p);
 
 char **strv_path_make_absolute_cwd(char **l);
 char **strv_path_canonicalize(char **l);
+char **strv_path_remove_empty(char **l);
 
 int reset_all_signal_handlers(void);