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