From 470a5e6dcec4637439ae953002127af214d396ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 24 May 2019 08:59:23 +0200 Subject: [PATCH] pid1: don't reset setting from /proc/cmdline upon restart We have settings which may be set on the kernel command line, and also in /proc/cmdline (for pid1). The settings in /proc/cmdline have higher priority of course. When a reload was done, we'd reload just the configuration file, losing the overrides. So read /proc/cmdline again during reload. Also, when initially reading the configuration file when program starts, don't treat any errors as fatal. The configuration done in there doesn't seem important enough to refuse boot. --- src/core/main.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/core/main.c b/src/core/main.c index 1f83566757..44b0a65f22 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -141,6 +141,8 @@ static OOMPolicy arg_default_oom_policy = OOM_STOP; static CPUSet arg_cpu_affinity = {}; +static int parse_configuration(void); + _noreturn_ static void freeze_or_exit_or_reboot(void) { /* If we are running in a container, let's prefer exiting, after all we can propagate an exit code to @@ -1910,9 +1912,7 @@ static int invoke_main_loop( saved_log_level = m->log_level_overridden ? log_get_max_level() : -1; saved_log_target = m->log_target_overridden ? log_get_target() : _LOG_TARGET_INVALID; - r = parse_config_file(); - if (r < 0) - log_warning_errno(r, "Failed to parse config file, ignoring: %m"); + (void) parse_configuration(); set_manager_defaults(m); @@ -2214,18 +2214,14 @@ static void free_arguments(void) { cpu_set_reset(&arg_cpu_affinity); } -static int load_configuration(int argc, char **argv, const char **ret_error_message) { +static int parse_configuration(void) { int r; - assert(ret_error_message); - arg_default_tasks_max = system_tasks_max_scale(DEFAULT_TASKS_MAX_PERCENTAGE, 100U); r = parse_config_file(); - if (r < 0) { - *ret_error_message = "Failed to parse config file"; - return r; - } + if (r < 0) + log_warning_errno(r, "Failed to parse config file, ignoring: %m"); if (arg_system) { r = proc_cmdline_parse(parse_proc_cmdline_item, NULL, 0); @@ -2236,6 +2232,16 @@ static int load_configuration(int argc, char **argv, const char **ret_error_mess /* Note that this also parses bits from the kernel command line, including "debug". */ log_parse_environment(); + return 0; +} + +static int load_configuration(int argc, char **argv, const char **ret_error_message) { + int r; + + assert(ret_error_message); + + (void) parse_configuration(); + r = parse_argv(argc, argv); if (r < 0) { *ret_error_message = "Failed to parse commandline arguments";