mirror of
https://github.com/clearlinux/systemd-stable.git
synced 2026-09-07 06:03:51 +00:00
conf-files: include root in returned file paths
This restores the original root handling logic that was present prior to112cfb18when path expansion moved to path_strv_canonicalize_absolute. That behavior partially went away in12ed81d9. Alternatively all users of conf_files_list* could be updated to concatenate the paths themselves as unit_file_query_preset did but since no user needs the un-concatenated form that is pointless duplication. (cherry picked from commitcba2ef0272) Conflicts: src/shared/install.c
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
98023e0968
commit
084c41bc14
+6
-10
@@ -37,20 +37,16 @@
|
||||
#include "hashmap.h"
|
||||
#include "conf-files.h"
|
||||
|
||||
static int files_add(Hashmap *h, const char *dirpath, const char *suffix, const char *root) {
|
||||
static int files_add(Hashmap *h, const char *root, const char *path, const char *suffix) {
|
||||
_cleanup_closedir_ DIR *dir = NULL;
|
||||
char *dirpath;
|
||||
|
||||
assert(dirpath);
|
||||
assert(path);
|
||||
assert(suffix);
|
||||
|
||||
if (isempty(root))
|
||||
dir = opendir(dirpath);
|
||||
else {
|
||||
const char *p;
|
||||
dirpath = strappenda(root ? root : "", path);
|
||||
|
||||
p = strappenda3(root, "/", dirpath);
|
||||
dir = opendir(p);
|
||||
}
|
||||
dir = opendir(dirpath);
|
||||
if (!dir) {
|
||||
if (errno == ENOENT)
|
||||
return 0;
|
||||
@@ -118,7 +114,7 @@ static int conf_files_list_strv_internal(char ***strv, const char *suffix, const
|
||||
return -ENOMEM;
|
||||
|
||||
STRV_FOREACH(p, dirs) {
|
||||
r = files_add(fh, *p, suffix, root);
|
||||
r = files_add(fh, root, *p, suffix);
|
||||
if (r == -ENOMEM) {
|
||||
hashmap_free_free(fh);
|
||||
return r;
|
||||
|
||||
@@ -1772,7 +1772,7 @@ UnitFileState unit_file_get_state(
|
||||
|
||||
int unit_file_query_preset(UnitFileScope scope, const char *name) {
|
||||
_cleanup_strv_free_ char **files = NULL;
|
||||
char **i;
|
||||
char **p;
|
||||
int r;
|
||||
|
||||
assert(scope >= 0);
|
||||
@@ -1800,10 +1800,10 @@ int unit_file_query_preset(UnitFileScope scope, const char *name) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
STRV_FOREACH(i, files) {
|
||||
STRV_FOREACH(p, files) {
|
||||
_cleanup_fclose_ FILE *f;
|
||||
|
||||
f = fopen(*i, "re");
|
||||
f = fopen(*p, "re");
|
||||
if (!f) {
|
||||
if (errno == ENOENT)
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user