Blob Blame History Raw
From ff96d0f2ca97d7e94cb6252714e3b4c46136a462 Mon Sep 17 00:00:00 2001
From: Michael Marineau <michael.marineau@coreos.com>
Date: Thu, 19 Jun 2014 19:07:06 -0700
Subject: [PATCH] shared: fix search_and_fopen with alternate roots

Update for the current behavior of path_strv_resolve which now returns
paths relative to the given root, not the full absolute paths.

(cherry picked from commit 375eadd911a9f83f89f1e7de5e05f44cc81e3642)
(cherry picked from commit 686e842aecfc9f89547f9d9021afb9e1a21067ec)
---
 src/shared/util.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/shared/util.c b/src/shared/util.c
index 65a09d90da..7aa3d0271c 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5701,7 +5701,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;