chiark / gitweb /
shared: fix search_and_fopen with alternate roots
[elogind.git] / src / shared / util.c
index 34e91762bc01d123499c09def03c78597020644b..aaf109ea63e6f89d7c7edc8bfd7aea5f88d9034b 100644 (file)
@@ -5679,14 +5679,17 @@ static int search_and_fopen_internal(const char *path, const char *mode, const c
         assert(mode);
         assert(_f);
 
-        if (!path_strv_canonicalize_absolute_uniq(search, root))
+        if (!path_strv_resolve_uniq(search, root))
                 return -ENOMEM;
 
         STRV_FOREACH(i, search) {
                 _cleanup_free_ char *p = NULL;
                 FILE *f;
 
-                p = strjoin(*i, "/", path, NULL);
+                if (root)
+                        p = strjoin(root, *i, "/", path, NULL);
+                else
+                        p = strjoin(*i, "/", path, NULL);
                 if (!p)
                         return -ENOMEM;