From: Lennart Poettering Date: Thu, 3 Jul 2025 10:10:55 +0000 (+0200) Subject: conf-files: if CONF_FILES_REGULAR|CONF_FILES_DIRECTORY is used together allow either... X-Git-Tag: v258-rc1~192 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=77bf8f8905c0c5c5a23f88146cfcf81e55541562;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c index cabdbd0f4dd..8b4d3d75486 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?