summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-05-22 03:30:46 +0200
committerLennart Poettering <lennart@poettering.net>2010-05-22 03:30:46 +0200
commitc3f6d6757a0923428a82ff617c10635d4ff4b184 (patch)
tree0e34d596e9b2c8c9bd2a608cceee0984e854ff65 /src/util.c
parent9a34ec5fbb4b55413dc9d610b636fe760d34ecd7 (diff)
manager: canonicalize search paths and filter out non-existing paths and those pointing to the same fs directory
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 47b1b443f..85a8e37d4 100644
--- a/src/util.c
+++ b/src/util.c
@@ -652,6 +652,51 @@ char **strv_path_make_absolute_cwd(char **l) {
return l;
}
+char **strv_path_canonicalize(char **l) {
+ char **s;
+ unsigned k = 0;
+ bool enomem = false;
+
+ if (strv_isempty(l))
+ return l;
+
+ /* Goes through every item in the string list and canonicalize
+ * the path. This works in place and won't rollback any
+ * changes on failure. */
+
+ STRV_FOREACH(s, l) {
+ char *t, *u;
+
+ t = path_make_absolute_cwd(*s);
+ free(*s);
+
+ if (!t) {
+ enomem = true;
+ continue;
+ }
+
+ errno = 0;
+ u = canonicalize_file_name(t);
+ free(t);
+
+ if (!u) {
+ if (errno == ENOMEM || !errno)
+ enomem = true;
+
+ continue;
+ }
+
+ l[k++] = u;
+ }
+
+ l[k] = NULL;
+
+ if (enomem)
+ return NULL;
+
+ return l;
+}
+
int reset_all_signal_handlers(void) {
int sig;