5509c00
From 3db5dbae9f8315684f2e18b3eddcbf2004f3ad03 Mon Sep 17 00:00:00 2001
5509c00
From: Michael Marineau <michael.marineau@coreos.com>
5509c00
Date: Thu, 19 Jun 2014 19:07:04 -0700
5509c00
Subject: [PATCH] conf-files: include root in returned file paths
5509c00
5509c00
This restores the original root handling logic that was present prior to
5509c00
112cfb18 when path expansion moved to path_strv_canonicalize_absolute.
5509c00
That behavior partially went away in 12ed81d9.
5509c00
5509c00
Alternatively all users of conf_files_list* could be updated to
5509c00
concatenate the paths themselves as unit_file_query_preset did but since
5509c00
no user needs the un-concatenated form that is pointless duplication.
5509c00
5509c00
(cherry picked from commit cba2ef02722114da2b730d57f1e3bb43013d8921)
5509c00
5509c00
Conflicts:
5509c00
	src/shared/install.c
5509c00
---
5509c00
 src/shared/conf-files.c | 16 ++++++----------
5509c00
 src/shared/install.c    |  6 +++---
5509c00
 2 files changed, 9 insertions(+), 13 deletions(-)
5509c00
5509c00
diff --git a/src/shared/conf-files.c b/src/shared/conf-files.c
5509c00
index 44e137e8..64ce8a0e 100644
5509c00
--- a/src/shared/conf-files.c
5509c00
+++ b/src/shared/conf-files.c
5509c00
@@ -37,20 +37,16 @@
5509c00
 #include "hashmap.h"
5509c00
 #include "conf-files.h"
5509c00
 
5509c00
-static int files_add(Hashmap *h, const char *dirpath, const char *suffix, const char *root) {
5509c00
+static int files_add(Hashmap *h, const char *root, const char *path, const char *suffix) {
5509c00
         _cleanup_closedir_ DIR *dir = NULL;
5509c00
+        char *dirpath;
5509c00
 
5509c00
-        assert(dirpath);
5509c00
+        assert(path);
5509c00
         assert(suffix);
5509c00
 
5509c00
-        if (isempty(root))
5509c00
-                dir = opendir(dirpath);
5509c00
-        else {
5509c00
-                const char *p;
5509c00
+        dirpath = strappenda(root ? root : "", path);
5509c00
 
5509c00
-                p = strappenda3(root, "/", dirpath);
5509c00
-                dir = opendir(p);
5509c00
-        }
5509c00
+        dir = opendir(dirpath);
5509c00
         if (!dir) {
5509c00
                 if (errno == ENOENT)
5509c00
                         return 0;
5509c00
@@ -118,7 +114,7 @@ static int conf_files_list_strv_internal(char ***strv, const char *suffix, const
5509c00
                 return -ENOMEM;
5509c00
 
5509c00
         STRV_FOREACH(p, dirs) {
5509c00
-                r = files_add(fh, *p, suffix, root);
5509c00
+                r = files_add(fh, root, *p, suffix);
5509c00
                 if (r == -ENOMEM) {
5509c00
                         hashmap_free_free(fh);
5509c00
                         return r;
5509c00
diff --git a/src/shared/install.c b/src/shared/install.c
5509c00
index 8322970a..c6d13eca 100644
5509c00
--- a/src/shared/install.c
5509c00
+++ b/src/shared/install.c
5509c00
@@ -1753,7 +1753,7 @@ UnitFileState unit_file_get_state(
5509c00
 
5509c00
 int unit_file_query_preset(UnitFileScope scope, const char *name) {
5509c00
         _cleanup_strv_free_ char **files = NULL;
5509c00
-        char **i;
5509c00
+        char **p;
5509c00
         int r;
5509c00
 
5509c00
         assert(scope >= 0);
5509c00
@@ -1781,10 +1781,10 @@ int unit_file_query_preset(UnitFileScope scope, const char *name) {
5509c00
         if (r < 0)
5509c00
                 return r;
5509c00
 
5509c00
-        STRV_FOREACH(i, files) {
5509c00
+        STRV_FOREACH(p, files) {
5509c00
                 _cleanup_fclose_ FILE *f;
5509c00
 
5509c00
-                f = fopen(*i, "re");
5509c00
+                f = fopen(*p, "re");
5509c00
                 if (!f) {
5509c00
                         if (errno == ENOENT)
5509c00
                                 continue;