naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
be0c12
From 9dbb6564826a0def39a77ad292aecde75537d164 Mon Sep 17 00:00:00 2001
be0c12
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
be0c12
Date: Tue, 16 Oct 2018 14:49:36 +0200
be0c12
Subject: [PATCH] core: accept system mode emergency action specifiers with a
be0c12
 warning
be0c12
be0c12
Before we would only accept those "system" values, so there wasn't other
be0c12
chocie. Let's provide backwards compatiblity in case somebody made use of
be0c12
this functionality in user mode.
be0c12
be0c12
v2: use 'exit-force' not 'exit'
be0c12
v3: use error value in log_syntax
be0c12
(cherry picked from commit 469f76f170db39c72578e869ec7c087bb43f9350)
be0c12
be0c12
Related: #1860899
be0c12
---
be0c12
 src/core/load-fragment.c | 10 ++++++++++
be0c12
 1 file changed, 10 insertions(+)
be0c12
be0c12
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
be0c12
index c102ffb9f0..c0b1fd4f91 100644
be0c12
--- a/src/core/load-fragment.c
be0c12
+++ b/src/core/load-fragment.c
be0c12
@@ -4280,6 +4280,16 @@ int config_parse_emergency_action(
be0c12
 
be0c12
         r = parse_emergency_action(rvalue, MANAGER_IS_SYSTEM(m), x);
be0c12
         if (r < 0) {
be0c12
+                if (r == -EOPNOTSUPP && MANAGER_IS_USER(m)) {
be0c12
+                        /* Compat mode: remove for systemd 241. */
be0c12
+
be0c12
+                        log_syntax(unit, LOG_INFO, filename, line, r,
be0c12
+                                   "%s= in user mode specified as \"%s\", using \"exit-force\" instead.",
be0c12
+                                   lvalue, rvalue);
be0c12
+                        *x = EMERGENCY_ACTION_EXIT_FORCE;
be0c12
+                        return 0;
be0c12
+                }
be0c12
+
be0c12
                 if (r == -EOPNOTSUPP)
be0c12
                         log_syntax(unit, LOG_ERR, filename, line, r,
be0c12
                                    "%s= specified as %s mode action, ignoring: %s",