From 77bf8f8905c0c5c5a23f88146cfcf81e55541562 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 3 Jul 2025 12:10:55 +0200 Subject: [PATCH] conf-files: if CONF_FILES_REGULAR|CONF_FILES_DIRECTORY is used together allow either file or dir This fixes a a bug introduced by 50c81130b69d04288f50217bede709bac6ca2b1a. --- src/basic/conf-files.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c index cabdbd0f4d..8b4d3d7548 100644 --- a/src/basic/conf-files.c +++ b/src/basic/conf-files.c @@ -136,16 +136,23 @@ static int files_add( continue; } - /* Is this node a regular file? */ - if (FLAGS_SET(flags, CONF_FILES_REGULAR) && !S_ISREG(st.st_mode)) { - log_debug("Ignoring '%s/%s', as it is not a regular file.", root, skip_leading_slash(p)); - continue; - } + if (FLAGS_SET(flags, CONF_FILES_REGULAR|CONF_FILES_DIRECTORY)) { + if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode)) { + log_debug("Ignoring '%s/%s', as it is neither a regular file or directory.", root, skip_leading_slash(p)); + continue; + } + } else { + /* Is this node a regular file? */ + if (FLAGS_SET(flags, CONF_FILES_REGULAR) && !S_ISREG(st.st_mode)) { + log_debug("Ignoring '%s/%s', as it is not a regular file.", root, skip_leading_slash(p)); + continue; + } - /* Is this node a directory? */ - if (FLAGS_SET(flags, CONF_FILES_DIRECTORY) && !S_ISDIR(st.st_mode)) { - log_debug("Ignoring '%s/%s', as it is not a directory.", root, skip_leading_slash(p)); - continue; + /* Is this node a directory? */ + if (FLAGS_SET(flags, CONF_FILES_DIRECTORY) && !S_ISDIR(st.st_mode)) { + log_debug("Ignoring '%s/%s', as it is not a directory.", root, skip_leading_slash(p)); + continue; + } } /* Does this node have the executable bit set?