richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
4fbe94
From f71f3271fa149d2b5f022830d43071d97b022b38 Mon Sep 17 00:00:00 2001
4fbe94
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
4fbe94
Date: Fri, 24 May 2019 08:59:23 +0200
4fbe94
Subject: [PATCH] pid1: don't reset setting from /proc/cmdline upon restart
4fbe94
4fbe94
We have settings which may be set on the kernel command line, and also
4fbe94
in /proc/cmdline (for pid1). The settings in /proc/cmdline have higher priority
4fbe94
of course. When a reload was done, we'd reload just the configuration file,
4fbe94
losing the overrides.
4fbe94
4fbe94
So read /proc/cmdline again during reload.
4fbe94
4fbe94
Also, when initially reading the configuration file when program starts,
4fbe94
don't treat any errors as fatal. The configuration done in there doesn't
4fbe94
seem important enough to refuse boot.
4fbe94
4fbe94
(cherry picked from commit 470a5e6dcec4637439ae953002127af214d396ac)
4fbe94
4fbe94
Related: #1734787
4fbe94
---
4fbe94
 src/core/main.c | 26 ++++++++++++++++----------
4fbe94
 1 file changed, 16 insertions(+), 10 deletions(-)
4fbe94
4fbe94
diff --git a/src/core/main.c b/src/core/main.c
4fbe94
index bc1db2af7b..9a9f145080 100644
4fbe94
--- a/src/core/main.c
4fbe94
+++ b/src/core/main.c
4fbe94
@@ -129,6 +129,8 @@ static sd_id128_t arg_machine_id = {};
4fbe94
 static EmergencyAction arg_cad_burst_action = EMERGENCY_ACTION_REBOOT_FORCE;
4fbe94
 static CPUSet arg_cpu_affinity = {};
4fbe94
 
4fbe94
+static int parse_configuration(void);
4fbe94
+
4fbe94
 _noreturn_ static void freeze_or_reboot(void) {
4fbe94
 
4fbe94
         if (arg_crash_reboot) {
4fbe94
@@ -1659,9 +1661,7 @@ static int invoke_main_loop(
4fbe94
                         saved_log_level = m->log_level_overridden ? log_get_max_level() : -1;
4fbe94
                         saved_log_target = m->log_target_overridden ? log_get_target() : _LOG_TARGET_INVALID;
4fbe94
 
4fbe94
-                        r = parse_config_file();
4fbe94
-                        if (r < 0)
4fbe94
-                                log_warning_errno(r, "Failed to parse config file, ignoring: %m");
4fbe94
+                        (void) parse_configuration();
4fbe94
 
4fbe94
                         set_manager_defaults(m);
4fbe94
 
4fbe94
@@ -1965,18 +1965,14 @@ static void free_arguments(void) {
4fbe94
         cpu_set_reset(&arg_cpu_affinity);
4fbe94
 }
4fbe94
 
4fbe94
-static int load_configuration(int argc, char **argv, const char **ret_error_message) {
4fbe94
+static int parse_configuration(void) {
4fbe94
         int r;
4fbe94
 
4fbe94
-        assert(ret_error_message);
4fbe94
-
4fbe94
         arg_default_tasks_max = system_tasks_max_scale(DEFAULT_TASKS_MAX_PERCENTAGE, 100U);
4fbe94
 
4fbe94
         r = parse_config_file();
4fbe94
-        if (r < 0) {
4fbe94
-                *ret_error_message = "Failed to parse config file";
4fbe94
-                return r;
4fbe94
-        }
4fbe94
+        if (r < 0)
4fbe94
+                log_warning_errno(r, "Failed to parse config file, ignoring: %m");
4fbe94
 
4fbe94
         if (arg_system) {
4fbe94
                 r = proc_cmdline_parse(parse_proc_cmdline_item, NULL, 0);
4fbe94
@@ -1987,6 +1983,16 @@ static int load_configuration(int argc, char **argv, const char **ret_error_mess
4fbe94
         /* Note that this also parses bits from the kernel command line, including "debug". */
4fbe94
         log_parse_environment();
4fbe94
 
4fbe94
+        return 0;
4fbe94
+}
4fbe94
+
4fbe94
+static int load_configuration(int argc, char **argv, const char **ret_error_message) {
4fbe94
+        int r;
4fbe94
+
4fbe94
+        assert(ret_error_message);
4fbe94
+
4fbe94
+        (void) parse_configuration();
4fbe94
+
4fbe94
         r = parse_argv(argc, argv);
4fbe94
         if (r < 0) {
4fbe94
                 *ret_error_message = "Failed to parse commandline arguments";