anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0448-core-if-the-start-command-vanishes-during-runtime-do.patch

803fb7
From a66f97acac8b99a49aac58adf6d652cad7e4be38 Mon Sep 17 00:00:00 2001
803fb7
From: Lennart Poettering <lennart@poettering.net>
803fb7
Date: Fri, 21 Oct 2016 12:27:46 +0200
803fb7
Subject: [PATCH] core: if the start command vanishes during runtime don't hit
803fb7
 an assert
803fb7
803fb7
This can happen when the configuration is changed and reloaded while we are
803fb7
executing a service. Let's not hit an assert in this case.
803fb7
803fb7
Fixes: #4444
803fb7
803fb7
Cherry-picked from: 47fffb3530af3e3ad4048570611685635fde062e
803fb7
Resolves: #1421658
803fb7
---
803fb7
 src/core/service.c | 10 +++++++++-
803fb7
 1 file changed, 9 insertions(+), 1 deletion(-)
803fb7
803fb7
diff --git a/src/core/service.c b/src/core/service.c
803fb7
index 6e7baa76c..84e00573f 100644
803fb7
--- a/src/core/service.c
803fb7
+++ b/src/core/service.c
803fb7
@@ -1563,7 +1563,15 @@ static void service_enter_start(Service *s) {
803fb7
         }
803fb7
 
803fb7
         if (!c) {
803fb7
-                assert(s->type == SERVICE_ONESHOT);
803fb7
+                if (s->type != SERVICE_ONESHOT) {
803fb7
+                        /* There's no command line configured for the main command? Hmm, that is strange. This can only
803fb7
+                         * happen if the configuration changes at runtime. In this case, let's enter a failure
803fb7
+                         * state. */
803fb7
+                        log_unit_error(UNIT(s), "There's no 'start' task anymore we could start: %m");
803fb7
+                        r = -ENXIO;
803fb7
+                        goto fail;
803fb7
+                }
803fb7
+
803fb7
                 service_enter_start_post(s);
803fb7
                 return;
803fb7
         }