#include "nulstr-util.h"
#include "parse-util.h"
#include "path-util.h"
+#include "percent-util.h"
#include "process-util.h"
#include "rlimit-util.h"
#include "sd-id128.h"
if (ret_mtime)
*ret_mtime = mtime;
- return 0;
+ return 1;
}
static int config_parse_many_files(
- const char *conf_file,
+ const char* const* conf_files,
char **files,
const char *sections,
ConfigItemLookup lookup,
char **fn;
int r;
- if (conf_file) {
- r = config_parse(NULL, conf_file, NULL, sections, lookup, table, flags, userdata, &mtime);
+ /* First read the first found main config file. */
+ STRV_FOREACH(fn, (char**) conf_files) {
+ r = config_parse(NULL, *fn, NULL, sections, lookup, table, flags, userdata, &mtime);
if (r < 0)
return r;
+ if (r > 0)
+ break;
}
+ /* Then read all the drop-ins. */
STRV_FOREACH(fn, files) {
usec_t t;
r = config_parse(NULL, *fn, NULL, sections, lookup, table, flags, userdata, &t);
if (r < 0)
return r;
- if (t > mtime) /* Find the newest */
- mtime = t;
+ mtime = MAX(mtime, t); /* Find the newest */
}
if (ret_mtime)
if (r < 0)
return r;
- return config_parse_many_files(conf_file, files, sections, lookup, table, flags, userdata, ret_mtime);
+ return config_parse_many_files(STRV_MAKE_CONST(conf_file),
+ files, sections, lookup, table, flags, userdata,
+ ret_mtime);
}
/* Parse each config file in the directories specified as strv. */
int config_parse_many(
- const char *conf_file,
+ const char* const* conf_files,
const char* const* conf_file_dirs,
const char *dropin_dirname,
const char *sections,
if (r < 0)
return r;
- return config_parse_many_files(conf_file, files, sections, lookup, table, flags, userdata, ret_mtime);
+ return config_parse_many_files(conf_files, files, sections, lookup, table, flags, userdata, ret_mtime);
}
#define DEFINE_PARSER(type, vartype, conv_func) \
assert(rvalue);
assert(data);
- if (free_and_strdup(s, empty_to_null(rvalue)) < 0)
- return log_oom();
-
- return 0;
+ return free_and_strdup_warn(s, empty_to_null(rvalue));
}
int config_parse_path(
x = log_facility_unshifted_from_string(rvalue);
if (x < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse log facility, ignoring: %s", rvalue);
+ log_syntax(unit, LOG_WARNING, filename, line, x, "Failed to parse log facility, ignoring: %s", rvalue);
return 0;
}
x = log_level_from_string(rvalue);
if (x < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse log level, ignoring: %s", rvalue);
+ log_syntax(unit, LOG_WARNING, filename, line, x, "Failed to parse log level, ignoring: %s", rvalue);
return 0;
}
r = signal_from_string(rvalue);
if (r <= 0) {
- log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse signal name, ignoring: %s", rvalue);
+ log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse signal name, ignoring: %s", rvalue);
return 0;
}