From 1d1c226f6c30f5fdbb34b0708621ee58e528d207 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 22 Aug 2022 14:07:27 +0200 Subject: [PATCH] conf-files: port conf_files_list() over to chase_symlinks() from prefix_roota() --- src/basic/conf-files.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c index 82c6dc5677b..532c9d19b83 100644 --- a/src/basic/conf-files.c +++ b/src/basic/conf-files.c @@ -5,6 +5,7 @@ #include #include +#include "chase-symlinks.h" #include "conf-files.h" #include "def.h" #include "dirent-util.h" @@ -28,23 +29,19 @@ static int files_add( unsigned flags, const char *path) { + _cleanup_free_ char *dirpath = NULL; _cleanup_closedir_ DIR *dir = NULL; - const char *dirpath; int r; assert(h); assert((flags & CONF_FILES_FILTER_MASKED) == 0 || masked); assert(path); - dirpath = prefix_roota(root, path); - - dir = opendir(dirpath); - if (!dir) { - if (errno == ENOENT) - return 0; - - return log_debug_errno(errno, "Failed to open directory '%s': %m", dirpath); - } + r = chase_symlinks_and_opendir(path, root, CHASE_PREFIX_ROOT, &dirpath, &dir); + if (r == -ENOENT) + return 0; + if (r < 0) + return log_debug_errno(r, "Failed to open directory '%s/%s': %m", empty_or_root(root) ? "" : root, dirpath); FOREACH_DIRENT(de, dir, return -errno) { struct stat st; -- 2.47.3