conf-files: several cleanups and fixlets (#40290)
Fixes #40313. Closes #40285.
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "chase.h"
|
||||
#include "color-util.h"
|
||||
#include "conf-files.h"
|
||||
#include "constants.h"
|
||||
@@ -325,9 +324,22 @@ static int cat_file_by_path(const char *p, bool *newline, CatFlags flags) {
|
||||
|
||||
assert(p);
|
||||
|
||||
r = conf_file_new(p, /* root= */ NULL, CHASE_MUST_BE_REGULAR, &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)
|
||||
putc('\n', stdout);
|
||||
*newline = true;
|
||||
}
|
||||
|
||||
printf("%s# %s is a mask.%s\n",
|
||||
ansi_highlight_magenta(),
|
||||
p,
|
||||
ansi_normal());
|
||||
return 0;
|
||||
}
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to chase '%s': %m", p);
|
||||
return r;
|
||||
|
||||
return cat_file(c, newline, flags);
|
||||
}
|
||||
@@ -458,7 +470,8 @@ int conf_files_cat(const char *root, const char *name, CatFlags flags) {
|
||||
if (!p)
|
||||
return log_oom();
|
||||
|
||||
if (conf_file_new(p, root, CHASE_MUST_BE_REGULAR, &c) >= 0)
|
||||
r = conf_file_new(p, root, CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED, &c);
|
||||
if (r >= 0 || r == -ERFKILL) /* Found a regular file or masked file */
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -473,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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user