ryantimwilson / rpms / systemd

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