teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0667-core-allow-services-with-no-commands-but-SuccessActi.patch

be0c12
From f97c6d921fb6b3d7ba88e064b03d3dd767df9ba1 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 15:07:42 +0200
be0c12
Subject: [PATCH] core: allow services with no commands but SuccessAction set
be0c12
be0c12
(cherry picked from commit 3f00d379fa6221a4570c8cd955afd9b661787db9)
be0c12
be0c12
Related: #1860899
be0c12
---
be0c12
 src/core/service.c | 13 +++++++++----
be0c12
 1 file changed, 9 insertions(+), 4 deletions(-)
be0c12
be0c12
diff --git a/src/core/service.c b/src/core/service.c
be0c12
index 4da1c5accb..7969bbf071 100644
be0c12
--- a/src/core/service.c
be0c12
+++ b/src/core/service.c
be0c12
@@ -556,8 +556,13 @@ static int service_verify(Service *s) {
be0c12
                 }
be0c12
         }
be0c12
 
be0c12
-        if (!s->exec_command[SERVICE_EXEC_START] && !s->exec_command[SERVICE_EXEC_STOP]) {
be0c12
-                log_unit_error(UNIT(s), "Service lacks both ExecStart= and ExecStop= setting. Refusing.");
be0c12
+        if (!s->exec_command[SERVICE_EXEC_START] && !s->exec_command[SERVICE_EXEC_STOP]
be0c12
+            && UNIT(s)->success_action == EMERGENCY_ACTION_NONE) {
be0c12
+                /* FailureAction= only makes sense if one of the start or stop commands is specified.
be0c12
+                 * SuccessAction= will be executed unconditionally if no commands are specified. Hence,
be0c12
+                 * either a command or SuccessAction= are required. */
be0c12
+
be0c12
+                log_unit_error(UNIT(s), "Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing.");
be0c12
                 return -ENOEXEC;
be0c12
         }
be0c12
 
be0c12
@@ -566,8 +571,8 @@ static int service_verify(Service *s) {
be0c12
                 return -ENOEXEC;
be0c12
         }
be0c12
 
be0c12
-        if (!s->remain_after_exit && !s->exec_command[SERVICE_EXEC_START]) {
be0c12
-                log_unit_error(UNIT(s), "Service has no ExecStart= setting, which is only allowed for RemainAfterExit=yes services. Refusing.");
be0c12
+        if (!s->remain_after_exit && !s->exec_command[SERVICE_EXEC_START] && UNIT(s)->success_action == EMERGENCY_ACTION_NONE) {
be0c12
+                log_unit_error(UNIT(s), "Service has no ExecStart= and no SuccessAction= settings and does not have RemainAfterExit=yes set. Refusing.");
be0c12
                 return -ENOEXEC;
be0c12
         }
be0c12