conf-files: introduce CONF_FILES_WARN flag and set it at various places
Closes #40285.
This commit is contained in:
@@ -78,7 +78,7 @@ int verb_nvpcrs(int argc, char *argv[], void *userdata) {
|
||||
&l,
|
||||
".nvpcr",
|
||||
/* root= */ NULL,
|
||||
CONF_FILES_REGULAR|CONF_FILES_BASENAME|CONF_FILES_FILTER_MASKED|CONF_FILES_TRUNCATE_SUFFIX,
|
||||
CONF_FILES_REGULAR|CONF_FILES_BASENAME|CONF_FILES_FILTER_MASKED|CONF_FILES_TRUNCATE_SUFFIX|CONF_FILES_WARN,
|
||||
CONF_PATHS_NULSTR("nvpcr"));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to find .nvpcr files: %m");
|
||||
|
||||
+88
-69
@@ -40,7 +40,11 @@ void conf_file_free_many(ConfFile **array, size_t n) {
|
||||
free(array);
|
||||
}
|
||||
|
||||
static int prepare_dirs(const char *root, char * const *dirs, int *ret_rfd, char **ret_root, char ***ret_dirs) {
|
||||
static int conf_files_log_level(ConfFilesFlags flags) {
|
||||
return FLAGS_SET(flags, CONF_FILES_WARN) ? LOG_WARNING : LOG_DEBUG;
|
||||
}
|
||||
|
||||
static int prepare_dirs(const char *root, ConfFilesFlags flags, char * const *dirs, int *ret_rfd, char **ret_root, char ***ret_dirs) {
|
||||
_cleanup_free_ char *root_abs = NULL;
|
||||
_cleanup_strv_free_ char **dirs_abs = NULL;
|
||||
int r;
|
||||
@@ -49,14 +53,16 @@ static int prepare_dirs(const char *root, char * const *dirs, int *ret_rfd, char
|
||||
assert(ret_root);
|
||||
assert(ret_dirs || strv_isempty(dirs));
|
||||
|
||||
int log_level = conf_files_log_level(flags);
|
||||
|
||||
r = empty_or_root_harder_to_null(&root);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to determine if '%s' points to the root directory: %m", strempty(root));
|
||||
return log_full_errno(log_level, r, "Failed to determine if '%s' points to the root directory: %m", strempty(root));
|
||||
|
||||
if (ret_dirs) {
|
||||
dirs_abs = strv_copy(dirs);
|
||||
if (!dirs_abs)
|
||||
return log_oom();
|
||||
return log_oom_full(log_level);
|
||||
}
|
||||
|
||||
if (root) {
|
||||
@@ -64,7 +70,7 @@ static int prepare_dirs(const char *root, char * const *dirs, int *ret_rfd, char
|
||||
* necessary to modify each config directories here. but needs to normalize the root directory. */
|
||||
r = path_make_absolute_cwd(root, &root_abs);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to make '%s' absolute: %m", root);
|
||||
return log_full_errno(log_level, r, "Failed to make '%s' absolute: %m", root);
|
||||
|
||||
path_simplify(root_abs);
|
||||
} else if (ret_dirs) {
|
||||
@@ -72,12 +78,12 @@ static int prepare_dirs(const char *root, char * const *dirs, int *ret_rfd, char
|
||||
* each config directory absolute if relative. */
|
||||
r = path_strv_make_absolute_cwd(dirs_abs);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to make directories absolute: %m");
|
||||
return log_full_errno(log_level, r, "Failed to make directories absolute: %m");
|
||||
}
|
||||
|
||||
_cleanup_close_ int rfd = open(empty_to_root(root_abs), O_CLOEXEC|O_DIRECTORY|O_PATH);
|
||||
if (rfd < 0)
|
||||
return log_debug_errno(errno, "Failed to open '%s': %m", empty_to_root(root_abs));
|
||||
return log_full_errno(log_level, errno, "Failed to open '%s': %m", empty_to_root(root_abs));
|
||||
|
||||
*ret_rfd = TAKE_FD(rfd);
|
||||
*ret_root = TAKE_PTR(root_abs);
|
||||
@@ -86,30 +92,31 @@ static int prepare_dirs(const char *root, char * const *dirs, int *ret_rfd, char
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int conf_file_prefix_root(ConfFile *c, const char *root) {
|
||||
static int conf_file_prefix_root(ConfFile *c, const char *root, ConfFilesFlags flags) {
|
||||
char *p;
|
||||
int r;
|
||||
|
||||
assert(c);
|
||||
|
||||
int log_level = conf_files_log_level(flags);
|
||||
|
||||
r = chaseat_prefix_root(c->result, root, &p);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to prefix '%s' with root '%s': %m", c->result, root);
|
||||
return log_full_errno(log_level, r, "Failed to prefix '%s' with root '%s': %m", c->result, root);
|
||||
free_and_replace(c->result, p);
|
||||
|
||||
r = chaseat_prefix_root(c->resolved_path, root, &p);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to prefix '%s' with root '%s': %m", c->resolved_path, root);
|
||||
return log_full_errno(log_level, r, "Failed to prefix '%s' with root '%s': %m", c->resolved_path, root);
|
||||
free_and_replace(c->resolved_path, p);
|
||||
|
||||
/* Do not use chaseat_prefix_root(), as it is for the result of chaseat(), but the path is not chased. */
|
||||
p = path_join(empty_to_root(root), skip_leading_slash(c->original_path));
|
||||
if (!p)
|
||||
return log_oom_debug();
|
||||
path_simplify(p);
|
||||
free_and_replace(c->original_path, p);
|
||||
return log_oom_full(log_level);
|
||||
|
||||
return 0;
|
||||
path_simplify(p);
|
||||
return free_and_replace(c->original_path, p);
|
||||
}
|
||||
|
||||
static bool conf_files_need_stat(ConfFilesFlags flags) {
|
||||
@@ -149,12 +156,14 @@ static int conf_file_chase_and_verify(
|
||||
assert(path);
|
||||
assert(name);
|
||||
|
||||
int log_level = conf_files_log_level(flags);
|
||||
|
||||
root = empty_to_root(root);
|
||||
|
||||
r = chaseat(rfd, path, conf_files_chase_flags(flags), &resolved_path, &fd);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to chase '%s%s': %m",
|
||||
root, skip_leading_slash(original_path));
|
||||
return log_full_errno(log_level, r, "Failed to chase '%s%s': %m",
|
||||
root, skip_leading_slash(original_path));
|
||||
if (r == 0) {
|
||||
if (FLAGS_SET(flags, CONF_FILES_FILTER_MASKED_BY_SYMLINK)) {
|
||||
/* If the path points to /dev/null in a image or so, then the device node may not exist. */
|
||||
@@ -163,7 +172,7 @@ static int conf_file_chase_and_verify(
|
||||
/* Mark this one as masked */
|
||||
r = set_put_strdup(masked, name);
|
||||
if (r < 0)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
}
|
||||
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(ERFKILL),
|
||||
@@ -174,14 +183,14 @@ static int conf_file_chase_and_verify(
|
||||
|
||||
if (conf_files_need_stat(flags))
|
||||
/* If we need to have stat, skip the entry. */
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(ENOENT), "Failed to chase '%s%s': %m",
|
||||
root, skip_leading_slash(original_path));
|
||||
return log_full_errno(log_level, SYNTHETIC_ERRNO(ENOENT), "Failed to chase '%s%s': %m",
|
||||
root, skip_leading_slash(original_path));
|
||||
}
|
||||
|
||||
/* Even if we do not need stat, let's take stat now. The caller may use the info later. */
|
||||
if (fd >= 0 && fstat(fd, &st) < 0)
|
||||
return log_debug_errno(errno, "Failed to stat '%s%s': %m",
|
||||
root, skip_leading_slash(original_path));
|
||||
return log_full_errno(log_level, errno, "Failed to stat '%s%s': %m",
|
||||
root, skip_leading_slash(original_path));
|
||||
|
||||
/* Is this a masking entry? */
|
||||
if (FLAGS_SET(flags, CONF_FILES_FILTER_MASKED_BY_SYMLINK) && stat_may_be_dev_null(&st)) {
|
||||
@@ -189,7 +198,7 @@ static int conf_file_chase_and_verify(
|
||||
/* Mark this one as masked */
|
||||
r = set_put_strdup(masked, name);
|
||||
if (r < 0)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
}
|
||||
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(ERFKILL),
|
||||
@@ -202,7 +211,7 @@ static int conf_file_chase_and_verify(
|
||||
/* Mark this one as masked */
|
||||
r = set_put_strdup(masked, name);
|
||||
if (r < 0)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
}
|
||||
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(ERFKILL),
|
||||
@@ -259,13 +268,15 @@ int conf_file_new_at(const char *path, int rfd, ConfFilesFlags flags, ConfFile *
|
||||
assert(rfd >= 0 || rfd == AT_FDCWD);
|
||||
assert(ret);
|
||||
|
||||
int log_level = conf_files_log_level(flags);
|
||||
|
||||
_cleanup_free_ char *root = NULL;
|
||||
if (rfd >= 0 && DEBUG_LOGGING)
|
||||
if (rfd >= 0)
|
||||
(void) fd_get_path(rfd, &root);
|
||||
|
||||
_cleanup_(conf_file_freep) ConfFile *c = new(ConfFile, 1);
|
||||
if (!c)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
|
||||
*c = (ConfFile) {
|
||||
.original_path = strdup(path),
|
||||
@@ -273,27 +284,27 @@ int conf_file_new_at(const char *path, int rfd, ConfFilesFlags flags, ConfFile *
|
||||
};
|
||||
|
||||
if (!c->original_path)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
|
||||
r = path_extract_filename(path, &c->name);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to extract filename from '%s': %m", path);
|
||||
return log_full_errno(log_level, r, "Failed to extract filename from '%s': %m", path);
|
||||
|
||||
_cleanup_free_ char *dirpath = NULL, *resolved_dirpath = NULL;
|
||||
r = path_extract_directory(path, &dirpath);
|
||||
if (r < 0 && r != -EDESTADDRREQ)
|
||||
return log_debug_errno(r, "Failed to extract directory from '%s': %m", path);
|
||||
return log_full_errno(log_level, r, "Failed to extract directory from '%s': %m", path);
|
||||
if (r >= 0) {
|
||||
r = chaseat(rfd, dirpath,
|
||||
CHASE_MUST_BE_DIRECTORY | conf_files_chase_flags(flags),
|
||||
&resolved_dirpath, /* ret_fd= */ NULL);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to chase '%s%s': %m", empty_to_root(root), skip_leading_slash(dirpath));
|
||||
return log_full_errno(log_level, r, "Failed to chase '%s%s': %m", empty_to_root(root), skip_leading_slash(dirpath));
|
||||
}
|
||||
|
||||
c->result = path_join(resolved_dirpath, c->name);
|
||||
if (!c->result)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
|
||||
r = conf_file_chase_and_verify(
|
||||
rfd,
|
||||
@@ -321,7 +332,7 @@ int conf_file_new(const char *path, const char *root, ConfFilesFlags flags, Conf
|
||||
|
||||
_cleanup_free_ char *root_abs = NULL;
|
||||
_cleanup_close_ int rfd = -EBADF;
|
||||
r = prepare_dirs(root, /* dirs= */ NULL, &rfd, &root_abs, /* ret_dirs= */ NULL);
|
||||
r = prepare_dirs(root, flags, /* dirs= */ NULL, &rfd, &root_abs, /* ret_dirs= */ NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -329,7 +340,7 @@ int conf_file_new(const char *path, const char *root, ConfFilesFlags flags, Conf
|
||||
if (!root_abs) {
|
||||
r = path_make_absolute_cwd(path, &path_abs);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to make '%s' absolute: %m", path);
|
||||
return log_full_errno(conf_files_log_level(flags), r, "Failed to make '%s' absolute: %m", path);
|
||||
|
||||
path = path_abs;
|
||||
}
|
||||
@@ -339,7 +350,7 @@ int conf_file_new(const char *path, const char *root, ConfFilesFlags flags, Conf
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = conf_file_prefix_root(c, root_abs);
|
||||
r = conf_file_prefix_root(c, root_abs, flags);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -372,14 +383,16 @@ static int files_add(
|
||||
assert(files);
|
||||
assert(masked);
|
||||
|
||||
int log_level = conf_files_log_level(flags);
|
||||
|
||||
root = empty_to_root(root);
|
||||
|
||||
FOREACH_DIRENT(de, dir, return log_debug_errno(errno, "Failed to read directory '%s%s': %m",
|
||||
root, skip_leading_slash(original_dirpath))) {
|
||||
FOREACH_DIRENT(de, dir, return log_full_errno(log_level, errno, "Failed to read directory '%s%s': %m",
|
||||
root, skip_leading_slash(original_dirpath))) {
|
||||
|
||||
_cleanup_free_ char *original_path = path_join(original_dirpath, de->d_name);
|
||||
if (!original_path)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
|
||||
/* Does this match the suffix? */
|
||||
if (suffix && !endswith(de->d_name, suffix)) {
|
||||
@@ -401,7 +414,7 @@ static int files_add(
|
||||
|
||||
_cleanup_free_ char *p = path_join(resolved_dirpath, de->d_name);
|
||||
if (!p)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
|
||||
_cleanup_free_ char *resolved_path = NULL;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
@@ -424,7 +437,7 @@ static int files_add(
|
||||
|
||||
_cleanup_(conf_file_freep) ConfFile *c = new(ConfFile, 1);
|
||||
if (!c)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
|
||||
*c = (ConfFile) {
|
||||
.name = strdup(de->d_name),
|
||||
@@ -436,12 +449,12 @@ static int files_add(
|
||||
};
|
||||
|
||||
if (!c->name)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
|
||||
r = hashmap_ensure_put(files, &conf_file_hash_ops, c->name, c);
|
||||
if (r < 0) {
|
||||
assert(r == -ENOMEM);
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
}
|
||||
assert(r > 0);
|
||||
|
||||
@@ -451,7 +464,7 @@ static int files_add(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dump_files(Hashmap *fh, const char *root, ConfFile ***ret_files, size_t *ret_n_files) {
|
||||
static int dump_files(Hashmap *fh, const char *root, ConfFilesFlags flags, ConfFile ***ret_files, size_t *ret_n_files) {
|
||||
ConfFile **files = NULL;
|
||||
size_t n_files = 0;
|
||||
int r;
|
||||
@@ -464,7 +477,7 @@ static int dump_files(Hashmap *fh, const char *root, ConfFile ***ret_files, size
|
||||
/* The entries in the array given by hashmap_dump_sorted() are still owned by the hashmap. */
|
||||
r = hashmap_dump_sorted(fh, (void***) &files, &n_files);
|
||||
if (r < 0)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(conf_files_log_level(flags));
|
||||
|
||||
/* Hence, we need to remove them from the hashmap. */
|
||||
FOREACH_ARRAY(i, files, n_files)
|
||||
@@ -472,7 +485,7 @@ static int dump_files(Hashmap *fh, const char *root, ConfFile ***ret_files, size
|
||||
|
||||
if (root)
|
||||
FOREACH_ARRAY(i, files, n_files) {
|
||||
r = conf_file_prefix_root(*i, root);
|
||||
r = conf_file_prefix_root(*i, root, flags);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -496,11 +509,13 @@ static int copy_and_sort_files_from_hashmap(
|
||||
|
||||
assert(ret);
|
||||
|
||||
int log_level = conf_files_log_level(flags);
|
||||
|
||||
/* The entries in the array given by hashmap_dump_sorted() are still owned by the hashmap.
|
||||
* Hence, do not use conf_file_free_many() for 'entries' */
|
||||
r = hashmap_dump_sorted(fh, (void***) &files, &n_files);
|
||||
if (r < 0)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
|
||||
FOREACH_ARRAY(i, files, n_files) {
|
||||
ConfFile *c = *i;
|
||||
@@ -513,7 +528,7 @@ static int copy_and_sort_files_from_hashmap(
|
||||
|
||||
r = chaseat_prefix_root(c->result, root, &p);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to prefix '%s' with root '%s': %m", c->result, root);
|
||||
return log_full_errno(log_level, r, "Failed to prefix '%s' with root '%s': %m", c->result, root);
|
||||
|
||||
if (FLAGS_SET(flags, CONF_FILES_TRUNCATE_SUFFIX) && suffix) {
|
||||
char *e = endswith(p, suffix);
|
||||
@@ -524,7 +539,7 @@ static int copy_and_sort_files_from_hashmap(
|
||||
}
|
||||
|
||||
if (strv_consume_with_size(&results, &n_results, TAKE_PTR(p)) < 0)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
|
||||
continue;
|
||||
} else
|
||||
@@ -537,20 +552,20 @@ static int copy_and_sort_files_from_hashmap(
|
||||
|
||||
_cleanup_free_ char *n = strndup(add, e - add);
|
||||
if (!n)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
|
||||
r = strv_consume_with_size(&results, &n_results, TAKE_PTR(n));
|
||||
} else
|
||||
r = strv_extend_with_size(&results, &n_results, add);
|
||||
if (r < 0)
|
||||
return log_oom_debug();
|
||||
return log_oom_full(log_level);
|
||||
}
|
||||
|
||||
*ret = TAKE_PTR(results);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int insert_replacement(Hashmap **fh, ConfFile *replacement, const ConfFile **ret) {
|
||||
static int insert_replacement(Hashmap **fh, ConfFile *replacement, ConfFilesFlags flags, const ConfFile **ret) {
|
||||
_cleanup_(conf_file_freep) ConfFile *c = ASSERT_PTR(replacement);
|
||||
int r;
|
||||
|
||||
@@ -570,7 +585,7 @@ static int insert_replacement(Hashmap **fh, ConfFile *replacement, const ConfFil
|
||||
r = hashmap_ensure_put(fh, &conf_file_hash_ops, c->name, c);
|
||||
if (r < 0) {
|
||||
assert(r == -ENOMEM);
|
||||
return log_oom_debug();
|
||||
return log_oom_full(conf_files_log_level(flags));
|
||||
}
|
||||
assert(r > 0);
|
||||
|
||||
@@ -602,7 +617,7 @@ static int conf_files_list_impl(
|
||||
root = empty_to_root(root);
|
||||
|
||||
if (replacement) {
|
||||
r = conf_file_new_at(replacement, rfd, /* flags= */ 0, &c);
|
||||
r = conf_file_new_at(replacement, rfd, flags & CONF_FILES_WARN, &c);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -614,13 +629,14 @@ static int conf_files_list_impl(
|
||||
r = chase_and_opendirat(rfd, *p, CHASE_AT_RESOLVE_IN_ROOT, &path, &dir);
|
||||
if (r < 0) {
|
||||
if (r != -ENOENT)
|
||||
log_debug_errno(r, "Failed to chase and open directory '%s%s', ignoring: %m",
|
||||
root, skip_leading_slash(*p));
|
||||
log_full_errno(conf_files_log_level(flags), r,
|
||||
"Failed to chase and open directory '%s%s', ignoring: %m",
|
||||
root, skip_leading_slash(*p));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c && streq_ptr(path_startswith(c->result, path), c->name)) {
|
||||
r = insert_replacement(&fh, TAKE_PTR(c), &inserted);
|
||||
r = insert_replacement(&fh, TAKE_PTR(c), flags, &inserted);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -631,7 +647,7 @@ static int conf_files_list_impl(
|
||||
}
|
||||
|
||||
if (c) {
|
||||
r = insert_replacement(&fh, TAKE_PTR(c), &inserted);
|
||||
r = insert_replacement(&fh, TAKE_PTR(c), flags, &inserted);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -657,7 +673,7 @@ int conf_files_list_strv(
|
||||
|
||||
assert(ret);
|
||||
|
||||
r = prepare_dirs(root, (char**) dirs, &rfd, &root_abs, &dirs_abs);
|
||||
r = prepare_dirs(root, flags, (char**) dirs, &rfd, &root_abs, &dirs_abs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -686,7 +702,7 @@ int conf_files_list_strv_full(
|
||||
assert(ret_files);
|
||||
assert(ret_n_files);
|
||||
|
||||
r = prepare_dirs(root, (char**) dirs, &rfd, &root_abs, &dirs_abs);
|
||||
r = prepare_dirs(root, flags, (char**) dirs, &rfd, &root_abs, &dirs_abs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -695,7 +711,7 @@ int conf_files_list_strv_full(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return dump_files(fh, empty_to_root(root_abs), ret_files, ret_n_files);
|
||||
return dump_files(fh, empty_to_root(root_abs), flags, ret_files, ret_n_files);
|
||||
}
|
||||
|
||||
int conf_files_list_strv_at(
|
||||
@@ -712,7 +728,7 @@ int conf_files_list_strv_at(
|
||||
assert(rfd >= 0 || rfd == AT_FDCWD);
|
||||
assert(ret);
|
||||
|
||||
if (rfd >= 0 && DEBUG_LOGGING)
|
||||
if (rfd >= 0)
|
||||
(void) fd_get_path(rfd, &root); /* for logging */
|
||||
|
||||
r = conf_files_list_impl(suffix, rfd, root, flags, dirs, /* replacement= */ NULL, &fh, /* ret_inserted= */ NULL);
|
||||
@@ -738,14 +754,14 @@ int conf_files_list_strv_at_full(
|
||||
assert(ret_files);
|
||||
assert(ret_n_files);
|
||||
|
||||
if (rfd >= 0 && DEBUG_LOGGING)
|
||||
if (rfd >= 0)
|
||||
(void) fd_get_path(rfd, &root); /* for logging */
|
||||
|
||||
r = conf_files_list_impl(suffix, rfd, root, flags, dirs, /* replacement= */ NULL, &fh, /* ret_inserted= */ NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return dump_files(fh, /* root= */ NULL, ret_files, ret_n_files);
|
||||
return dump_files(fh, /* root= */ NULL, flags, ret_files, ret_n_files);
|
||||
}
|
||||
|
||||
int conf_files_list(char ***ret, const char *suffix, const char *root, ConfFilesFlags flags, const char *dir) {
|
||||
@@ -771,7 +787,7 @@ int conf_files_list_nulstr(char ***ret, const char *suffix, const char *root, Co
|
||||
|
||||
d = strv_split_nulstr(dirs);
|
||||
if (!d)
|
||||
return -ENOMEM;
|
||||
return log_oom_full(conf_files_log_level(flags));
|
||||
|
||||
return conf_files_list_strv(ret, suffix, root, flags, (const char**) d);
|
||||
}
|
||||
@@ -784,7 +800,7 @@ int conf_files_list_nulstr_full(const char *suffix, const char *root, ConfFilesF
|
||||
|
||||
d = strv_split_nulstr(dirs);
|
||||
if (!d)
|
||||
return -ENOMEM;
|
||||
return log_oom_full(conf_files_log_level(flags));
|
||||
|
||||
return conf_files_list_strv_full(suffix, root, flags, (const char**) d, ret_files, ret_n_files);
|
||||
}
|
||||
@@ -796,7 +812,7 @@ int conf_files_list_nulstr_at(char ***ret, const char *suffix, int rfd, ConfFile
|
||||
|
||||
d = strv_split_nulstr(dirs);
|
||||
if (!d)
|
||||
return -ENOMEM;
|
||||
return log_oom_full(conf_files_log_level(flags));
|
||||
|
||||
return conf_files_list_strv_at(ret, suffix, rfd, flags, (const char**) d);
|
||||
}
|
||||
@@ -809,7 +825,7 @@ int conf_files_list_nulstr_at_full(const char *suffix, int rfd, ConfFilesFlags f
|
||||
|
||||
d = strv_split_nulstr(dirs);
|
||||
if (!d)
|
||||
return -ENOMEM;
|
||||
return log_oom_full(conf_files_log_level(flags));
|
||||
|
||||
return conf_files_list_strv_at_full(suffix, rfd, flags, (const char**) d, ret_files, ret_n_files);
|
||||
}
|
||||
@@ -823,7 +839,7 @@ int conf_files_list_with_replacement(
|
||||
|
||||
_cleanup_hashmap_free_ Hashmap *fh = NULL;
|
||||
_cleanup_free_ char *inserted = NULL;
|
||||
ConfFilesFlags flags = CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED_BY_SYMLINK;
|
||||
ConfFilesFlags flags = CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED_BY_SYMLINK | CONF_FILES_WARN;
|
||||
_cleanup_close_ int rfd = -EBADF;
|
||||
_cleanup_free_ char *root_abs = NULL;
|
||||
_cleanup_strv_free_ char **dirs_abs = NULL;
|
||||
@@ -832,7 +848,7 @@ int conf_files_list_with_replacement(
|
||||
|
||||
assert(ret_files);
|
||||
|
||||
r = prepare_dirs(root, config_dirs, &rfd, &root_abs, &dirs_abs);
|
||||
r = prepare_dirs(root, flags, config_dirs, &rfd, &root_abs, &dirs_abs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -844,7 +860,9 @@ int conf_files_list_with_replacement(
|
||||
if (c) {
|
||||
r = chaseat_prefix_root(c->result, root_abs, &inserted);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to prefix '%s' with root '%s': %m", c->result, empty_to_root(root_abs));
|
||||
return log_full_errno(conf_files_log_level(flags), r,
|
||||
"Failed to prefix '%s' with root '%s': %m",
|
||||
c->result, empty_to_root(root_abs));
|
||||
}
|
||||
|
||||
r = copy_and_sort_files_from_hashmap(fh, ".conf", empty_to_root(root_abs), flags, ret_files);
|
||||
@@ -860,6 +878,7 @@ int conf_files_list_dropins(
|
||||
char ***ret,
|
||||
const char *dropin_dirname,
|
||||
const char *root,
|
||||
ConfFilesFlags flags,
|
||||
const char * const *dirs) {
|
||||
|
||||
_cleanup_strv_free_ char **dropin_dirs = NULL;
|
||||
@@ -873,9 +892,9 @@ int conf_files_list_dropins(
|
||||
suffix = strjoina("/", dropin_dirname);
|
||||
r = strv_extend_strv_concat(&dropin_dirs, dirs, suffix);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return log_oom_full(conf_files_log_level(flags));
|
||||
|
||||
return conf_files_list_strv(ret, ".conf", root, 0, (const char* const*) dropin_dirs);
|
||||
return conf_files_list_strv(ret, ".conf", root, flags, (const char* const*) dropin_dirs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,6 +14,7 @@ typedef enum ConfFilesFlags {
|
||||
CONF_FILES_FILTER_MASKED_BY_EMPTY = 1 << 5, /* implement masking by empty file */
|
||||
CONF_FILES_FILTER_MASKED = CONF_FILES_FILTER_MASKED_BY_SYMLINK | CONF_FILES_FILTER_MASKED_BY_EMPTY,
|
||||
CONF_FILES_TRUNCATE_SUFFIX = 1 << 6, /* truncate specified suffix from return filename or path */
|
||||
CONF_FILES_WARN = 1 << 7, /* warn on some errors */
|
||||
} ConfFilesFlags;
|
||||
|
||||
typedef struct ConfFile {
|
||||
@@ -56,6 +57,7 @@ int conf_files_list_dropins(
|
||||
char ***ret,
|
||||
const char *dropin_dirname,
|
||||
const char *root,
|
||||
ConfFilesFlags flags,
|
||||
const char * const *dirs);
|
||||
|
||||
typedef int parse_line_t(
|
||||
|
||||
+1
-1
@@ -232,7 +232,7 @@ static int run(int argc, char *argv[]) {
|
||||
} else {
|
||||
_cleanup_strv_free_ char **files = NULL;
|
||||
|
||||
r = conf_files_list_strv(&files, ".conf", NULL, 0, (const char**) CONF_PATHS_STRV("binfmt.d"));
|
||||
r = conf_files_list_strv(&files, ".conf", /* root= */ NULL, CONF_FILES_WARN, (const char**) CONF_PATHS_STRV("binfmt.d"));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate binfmt.d files: %m");
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ int ipe_setup(void) {
|
||||
&policies,
|
||||
".p7b",
|
||||
/* root= */ NULL,
|
||||
CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED,
|
||||
CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED|CONF_FILES_WARN,
|
||||
CONF_PATHS_NULSTR("ipe"));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to assemble list of IPE policies: %m");
|
||||
|
||||
@@ -52,7 +52,7 @@ static int load_and_print(void) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = conf_files_list_strv(&files, ".conf", NULL, 0, (const char **) dirs);
|
||||
r = conf_files_list_strv(&files, ".conf", /* root= */ NULL, CONF_FILES_WARN, (const char **) dirs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -1521,7 +1521,7 @@ static int manager_load_public_keys(Manager *m) {
|
||||
&files,
|
||||
".public",
|
||||
NULL,
|
||||
CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED,
|
||||
CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED|CONF_FILES_WARN,
|
||||
KEY_PATHS_NULSTR);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to assemble list of public key directories: %m");
|
||||
|
||||
@@ -685,7 +685,7 @@ static int context_load_plugins(Context *c) {
|
||||
&c->plugins,
|
||||
".install",
|
||||
c->rfd,
|
||||
CONF_FILES_EXECUTABLE | CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED,
|
||||
CONF_FILES_EXECUTABLE | CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED | CONF_FILES_WARN,
|
||||
STRV_MAKE_CONST("/etc/kernel/install.d", "/usr/lib/kernel/install.d"));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to find plugins: %m");
|
||||
|
||||
@@ -453,7 +453,9 @@ int catalog_update(const char *database, const char *root, const char* const *di
|
||||
|
||||
CLEANUP_ARRAY(files, n_files, conf_file_free_many);
|
||||
|
||||
r = conf_files_list_strv_full(".catalog", root, CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED, dirs, &files, &n_files);
|
||||
r = conf_files_list_strv_full(".catalog", root,
|
||||
CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED | CONF_FILES_WARN,
|
||||
dirs, &files, &n_files);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get catalog files: %m");
|
||||
|
||||
|
||||
@@ -423,7 +423,7 @@ static int run(int argc, char *argv[]) {
|
||||
RET_GATHER(ret, modules_list_append_dup(&module_set, *i));
|
||||
|
||||
r = conf_files_list_nulstr_full(".conf", /* root= */ NULL,
|
||||
CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED,
|
||||
CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED | CONF_FILES_WARN,
|
||||
conf_file_dirs, &files, &n_files);
|
||||
if (r < 0)
|
||||
RET_GATHER(ret, log_error_errno(r, "Failed to enumerate modules-load.d files: %m"));
|
||||
|
||||
@@ -1098,7 +1098,7 @@ int netdev_load(Manager *manager) {
|
||||
|
||||
assert(manager);
|
||||
|
||||
r = conf_files_list_strv(&files, ".netdev", NULL, 0, NETWORK_DIRS);
|
||||
r = conf_files_list_strv(&files, ".netdev", /* root= */ NULL, CONF_FILES_WARN, NETWORK_DIRS);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate netdev files: %m");
|
||||
|
||||
@@ -1127,7 +1127,7 @@ int netdev_reload(Manager *manager) {
|
||||
|
||||
assert(manager);
|
||||
|
||||
r = conf_files_list_strv(&files, ".netdev", NULL, 0, NETWORK_DIRS);
|
||||
r = conf_files_list_strv(&files, ".netdev", /* root= */ NULL, CONF_FILES_WARN, NETWORK_DIRS);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate netdev files: %m");
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ static int get_config_files_by_name(
|
||||
if (!dropin_dirname)
|
||||
return -ENOMEM;
|
||||
|
||||
r = conf_files_list_dropins(ret_dropins, dropin_dirname, /* root= */ NULL, NETWORK_DIRS);
|
||||
r = conf_files_list_dropins(ret_dropins, dropin_dirname, /* root= */ NULL, CONF_FILES_WARN, NETWORK_DIRS);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -612,7 +612,7 @@ int network_load(Manager *manager, OrderedHashmap **ret) {
|
||||
assert(manager);
|
||||
assert(ret);
|
||||
|
||||
r = conf_files_list_strv(&files, ".network", NULL, 0, NETWORK_DIRS);
|
||||
r = conf_files_list_strv(&files, ".network", /* root= */ NULL, CONF_FILES_WARN, NETWORK_DIRS);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate network files: %m");
|
||||
|
||||
|
||||
@@ -1802,7 +1802,9 @@ static int event_log_add_component_dir(EventLog *el, const char *path, char **ba
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
r = conf_files_list_strv(&files, ".pcrlock", /* root= */ NULL, CONF_FILES_REGULAR, (const char*const*) search);
|
||||
r = conf_files_list_strv(&files, ".pcrlock", /* root= */ NULL,
|
||||
CONF_FILES_REGULAR|CONF_FILES_WARN,
|
||||
(const char*const*) search);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate .pcrlock files for component '%s': %m", id);
|
||||
|
||||
@@ -1829,7 +1831,9 @@ static int event_log_load_components(EventLog *el) {
|
||||
"/usr/local/lib/pcrlock.d",
|
||||
"/usr/lib/pcrlock.d");
|
||||
|
||||
r = conf_files_list_strv(&files, NULL, NULL, CONF_FILES_REGULAR|CONF_FILES_DIRECTORY|CONF_FILES_FILTER_MASKED, (const char*const*) dirs);
|
||||
r = conf_files_list_strv(&files, /* suffix= */ NULL, /* root= */ NULL,
|
||||
CONF_FILES_REGULAR|CONF_FILES_DIRECTORY|CONF_FILES_FILTER_MASKED|CONF_FILES_WARN,
|
||||
(const char*const*) dirs);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate .pcrlock files: %m");
|
||||
|
||||
|
||||
+1
-1
@@ -3375,7 +3375,7 @@ static int context_read_definitions(Context *context) {
|
||||
&files,
|
||||
".conf",
|
||||
context->definitions ? NULL : arg_root,
|
||||
CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED,
|
||||
CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED|CONF_FILES_WARN,
|
||||
dirs);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate *.conf files: %m");
|
||||
|
||||
@@ -211,7 +211,7 @@ int manager_load_delegates(Manager *m) {
|
||||
|
||||
assert(m);
|
||||
|
||||
r = conf_files_list_strv(&files, ".dns-delegate", /* root= */ NULL, /* flags= */ 0, DNS_DELEGATE_SEARCH_DIRS);
|
||||
r = conf_files_list_strv(&files, ".dns-delegate", /* root= */ NULL, CONF_FILES_WARN, DNS_DELEGATE_SEARCH_DIRS);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate .dns-delegate files: %m");
|
||||
|
||||
|
||||
@@ -437,7 +437,7 @@ static int dns_trust_anchor_load_files(
|
||||
assert(suffix);
|
||||
assert(loader);
|
||||
|
||||
r = conf_files_list_nulstr(&files, suffix, NULL, 0, trust_anchor_dirs);
|
||||
r = conf_files_list_nulstr(&files, suffix, /* root= */ NULL, CONF_FILES_WARN, trust_anchor_dirs);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate %s trust anchor files: %m", suffix);
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ int dnssd_load(Manager *manager) {
|
||||
if (manager->mdns_support != RESOLVE_SUPPORT_YES)
|
||||
return 0;
|
||||
|
||||
r = conf_files_list_strv(&files, ".dnssd", NULL, 0, DNSSD_SERVICE_DIRS);
|
||||
r = conf_files_list_strv(&files, ".dnssd", /* root= */ NULL, CONF_FILES_WARN, DNSSD_SERVICE_DIRS);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate .dnssd files: %m");
|
||||
|
||||
|
||||
@@ -615,7 +615,9 @@ int config_parse_many(
|
||||
assert(dropin_dirname);
|
||||
assert(table);
|
||||
|
||||
r = conf_files_list_dropins(&files, dropin_dirname, root, conf_file_dirs);
|
||||
r = conf_files_list_dropins(&files, dropin_dirname, root,
|
||||
FLAGS_SET(flags, CONFIG_PARSE_WARN) ? CONF_FILES_WARN : 0,
|
||||
conf_file_dirs);
|
||||
if (r < 0)
|
||||
return log_full_errno(FLAGS_SET(flags, CONFIG_PARSE_WARN) ? LOG_WARNING : LOG_DEBUG, r,
|
||||
"Failed to list drop-ins in %s: %m", dropin_dirname);
|
||||
@@ -690,7 +692,7 @@ static int dropins_get_stats_by_path(
|
||||
if (!strextend(&dropin_dirname, ".d"))
|
||||
return -ENOMEM;
|
||||
|
||||
r = conf_files_list_dropins(&files, dropin_dirname, /* root= */ NULL, conf_file_dirs);
|
||||
r = conf_files_list_dropins(&files, dropin_dirname, /* root= */ NULL, /* flags= */ 0, conf_file_dirs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -715,7 +717,7 @@ static int dropins_get_stats_by_path(
|
||||
int config_get_stats_by_path(
|
||||
const char *suffix,
|
||||
const char *root,
|
||||
unsigned flags,
|
||||
ConfFilesFlags flags,
|
||||
const char* const* dirs,
|
||||
bool check_dropins,
|
||||
Hashmap **ret) {
|
||||
|
||||
@@ -112,7 +112,7 @@ static inline int config_parse_standard_file_with_dropins(
|
||||
int config_get_stats_by_path(
|
||||
const char *suffix,
|
||||
const char *root,
|
||||
unsigned flags,
|
||||
ConfFilesFlags flags,
|
||||
const char* const* dirs,
|
||||
bool check_dropins,
|
||||
Hashmap **ret);
|
||||
|
||||
+1
-1
@@ -287,7 +287,7 @@ int unit_file_find_dropin_paths(
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = conf_files_list_strv(ret, file_suffix, NULL, 0, (const char**) dirs);
|
||||
r = conf_files_list_strv(ret, file_suffix, /* root= */ NULL, CONF_FILES_WARN, (const char**) dirs);
|
||||
if (r < 0)
|
||||
return log_warning_errno(r, "Failed to create the list of configuration files: %m");
|
||||
|
||||
|
||||
@@ -323,7 +323,7 @@ int execute_directories(
|
||||
&paths,
|
||||
/* suffix= */ NULL,
|
||||
/* root= */ NULL,
|
||||
CONF_FILES_EXECUTABLE|CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED,
|
||||
CONF_FILES_EXECUTABLE|CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED|CONF_FILES_WARN,
|
||||
directories);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "%s: failed to enumerate executables: %m", name);
|
||||
|
||||
@@ -610,7 +610,9 @@ int hwdb_update(const char *root, const char *hwdb_bin_dir, bool strict, bool co
|
||||
|
||||
CLEANUP_ARRAY(files, n_files, conf_file_free_many);
|
||||
|
||||
r = conf_files_list_strv_full(".hwdb", root, CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED, conf_file_dirs, &files, &n_files);
|
||||
r = conf_files_list_strv_full(".hwdb", root,
|
||||
CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED | CONF_FILES_WARN,
|
||||
conf_file_dirs, &files, &n_files);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate hwdb files: %m");
|
||||
|
||||
|
||||
@@ -418,7 +418,7 @@ static int relabel_extra(void) {
|
||||
*/
|
||||
|
||||
r = conf_files_list(&files, ".relabel", NULL,
|
||||
CONF_FILES_FILTER_MASKED | CONF_FILES_REGULAR,
|
||||
CONF_FILES_FILTER_MASKED | CONF_FILES_REGULAR | CONF_FILES_WARN,
|
||||
"/run/systemd/relabel-extra.d/");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate /run/systemd/relabel-extra.d/, ignoring: %m");
|
||||
|
||||
@@ -324,7 +324,7 @@ static int cat_file_by_path(const char *p, bool *newline, CatFlags flags) {
|
||||
|
||||
assert(p);
|
||||
|
||||
r = conf_file_new(p, /* root= */ NULL, CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED, &c);
|
||||
r = conf_file_new(p, /* root= */ NULL, CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED | CONF_FILES_WARN, &c);
|
||||
if (r == -ERFKILL) { /* masked */
|
||||
if (newline) {
|
||||
if (*newline)
|
||||
@@ -339,7 +339,7 @@ static int cat_file_by_path(const char *p, bool *newline, CatFlags flags) {
|
||||
return 0;
|
||||
}
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to chase '%s': %m", p);
|
||||
return r;
|
||||
|
||||
return cat_file(c, newline, flags);
|
||||
}
|
||||
@@ -486,7 +486,7 @@ int conf_files_cat(const char *root, const char *name, CatFlags flags) {
|
||||
ConfFile **dropins = NULL;
|
||||
size_t n_dropins = 0;
|
||||
CLEANUP_ARRAY(dropins, n_dropins, conf_file_free_many);
|
||||
r = conf_files_list_strv_full(extension, root, CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED, (const char* const*) dirs, &dropins, &n_dropins);
|
||||
r = conf_files_list_strv_full(extension, root, CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED | CONF_FILES_WARN, (const char* const*) dirs, &dropins, &n_dropins);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to query file list: %m");
|
||||
|
||||
|
||||
+2
-1
@@ -461,7 +461,8 @@ static int run(int argc, char *argv[]) {
|
||||
} else {
|
||||
_cleanup_strv_free_ char **files = NULL;
|
||||
|
||||
r = conf_files_list_strv(&files, ".conf", NULL, 0, (const char**) CONF_PATHS_STRV("sysctl.d"));
|
||||
r = conf_files_list_strv(&files, ".conf", /* root= */ NULL, CONF_FILES_WARN,
|
||||
(const char**) CONF_PATHS_STRV("sysctl.d"));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate sysctl.d files: %m");
|
||||
|
||||
|
||||
@@ -136,7 +136,9 @@ static int read_definitions(
|
||||
assert(dirs);
|
||||
assert(suffix);
|
||||
|
||||
r = conf_files_list_strv_full(suffix, arg_root, CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED, dirs, &files, &n_files);
|
||||
r = conf_files_list_strv_full(suffix, arg_root,
|
||||
CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED|CONF_FILES_WARN,
|
||||
dirs, &files, &n_files);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate sysupdate.d/*%s definitions: %m", suffix);
|
||||
|
||||
@@ -209,7 +211,7 @@ static int context_read_definitions(Context *c, const char* node, bool requires_
|
||||
CLEANUP_ARRAY(files, n_files, conf_file_free_many);
|
||||
|
||||
r = conf_files_list_strv_full(".feature", arg_root,
|
||||
CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED,
|
||||
CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED|CONF_FILES_WARN,
|
||||
(const char**) dirs, &files, &n_files);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate sysupdate.d/*.feature definitions: %m");
|
||||
@@ -1558,7 +1560,8 @@ static int verb_components(int argc, char **argv, void *userdata) {
|
||||
|
||||
CLEANUP_ARRAY(directories, n_directories, conf_file_free_many);
|
||||
|
||||
r = conf_files_list_strv_full(".d", arg_root, CONF_FILES_DIRECTORY, (const char * const *) CONF_PATHS_STRV(""), &directories, &n_directories);
|
||||
r = conf_files_list_strv_full(".d", arg_root, CONF_FILES_DIRECTORY|CONF_FILES_WARN,
|
||||
(const char * const *) CONF_PATHS_STRV(""), &directories, &n_directories);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate directories: %m");
|
||||
|
||||
|
||||
@@ -184,7 +184,9 @@ static int context_parse_ntp_services_from_disk(Context *c) {
|
||||
_cleanup_strv_free_ char **files = NULL;
|
||||
int r;
|
||||
|
||||
r = conf_files_list_strv(&files, ".list", NULL, CONF_FILES_FILTER_MASKED, UNIT_LIST_DIRS);
|
||||
r = conf_files_list_strv(&files, ".list", /* root= */ NULL,
|
||||
CONF_FILES_FILTER_MASKED | CONF_FILES_WARN,
|
||||
UNIT_LIST_DIRS);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate .list files: %m");
|
||||
|
||||
|
||||
@@ -450,7 +450,7 @@ static int setup_nvpcr(void) {
|
||||
&l,
|
||||
".nvpcr",
|
||||
/* root= */ NULL,
|
||||
CONF_FILES_REGULAR|CONF_FILES_BASENAME|CONF_FILES_FILTER_MASKED|CONF_FILES_TRUNCATE_SUFFIX,
|
||||
CONF_FILES_REGULAR|CONF_FILES_BASENAME|CONF_FILES_FILTER_MASKED|CONF_FILES_TRUNCATE_SUFFIX|CONF_FILES_WARN,
|
||||
CONF_PATHS_NULSTR("nvpcr"));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to find .nvpcr files: %m");
|
||||
|
||||
@@ -342,7 +342,7 @@ int link_config_load(LinkConfigContext *ctx) {
|
||||
|
||||
link_configs_free(ctx);
|
||||
|
||||
r = conf_files_list_strv(&files, ".link", NULL, 0, NETWORK_DIRS);
|
||||
r = conf_files_list_strv(&files, ".link", /* root= */ NULL, CONF_FILES_WARN, NETWORK_DIRS);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "failed to enumerate link files: %m");
|
||||
|
||||
|
||||
@@ -304,7 +304,7 @@ static int search_rules_file(const char *s, const char *root, ConfFile ***files,
|
||||
|
||||
CLEANUP_ARRAY(f, n, conf_file_free_many);
|
||||
|
||||
r = conf_files_list_strv_full(".rules", root, CONF_FILES_REGULAR, (const char* const*) STRV_MAKE_CONST(s), &f, &n);
|
||||
r = conf_files_list_strv_full(".rules", root, CONF_FILES_REGULAR | CONF_FILES_WARN, (const char* const*) STRV_MAKE_CONST(s), &f, &n);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate rules files in '%s%s': %m", empty_to_root(root), skip_leading_slash(s));
|
||||
|
||||
@@ -327,7 +327,7 @@ int search_rules_files(char * const *a, const char *root, ConfFile ***ret_files,
|
||||
assert(ret_n_files);
|
||||
|
||||
if (strv_isempty(a)) {
|
||||
r = conf_files_list_strv_full(".rules", root, CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED,
|
||||
r = conf_files_list_strv_full(".rules", root, CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED | CONF_FILES_WARN,
|
||||
(const char* const*) CONF_PATHS_STRV("udev/rules.d"), &files, &n_files);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate rules files: %m");
|
||||
|
||||
Reference in New Issue
Block a user