chiark / gitweb /
shared: fix search_and_fopen with alternate roots
[elogind.git] / src / shared / util.c
index c1e1f9f020f6eb9287c6c46ee4c2f72e4aa1f785..aaf109ea63e6f89d7c7edc8bfd7aea5f88d9034b 100644 (file)
@@ -5686,7 +5686,10 @@ static int search_and_fopen_internal(const char *path, const char *mode, const c
                 _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;