anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone
Blob Blame History Raw
From 901779a7633bcb9831e14fd80eb6db0a22c39f22 Mon Sep 17 00:00:00 2001
From: Sylvia Else <sylviabz1@cryogenic.net>
Date: Sun, 6 Oct 2013 23:06:35 -0400
Subject: [PATCH] systemd: serialize/deserialize forbid_restart value

The Service type's forbid_restart field was not preserved by
serialization/deserialization, so the fact that the service should not
be restarted after stopping was lost.

If a systemctl stop foo command has been given, but the foo service
has not yet stopped, and then the systemctl --system daemon-reload was
given, then when the foo service eventually stopped, systemd would
restart it.

https://bugs.freedesktop.org/show_bug.cgi?id=69800
---
 src/core/service.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/core/service.c b/src/core/service.c
index fc04196..7a78060 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -2653,6 +2653,9 @@ static int service_serialize(Unit *u, FILE *f, FDSet *fds) {
         if (s->exec_context.var_tmp_dir)
                 unit_serialize_item(u, f, "var-tmp-dir", s->exec_context.var_tmp_dir);
 
+        if (s->forbid_restart)
+                unit_serialize_item(u, f, "forbid_restart", yes_no(s->forbid_restart));
+
         return 0;
 }
 
@@ -2789,6 +2792,14 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
                         return log_oom();
 
                 s->exec_context.var_tmp_dir = t;
+        } else if (streq(key, "forbid_restart")) {
+                int b;
+
+                b = parse_boolean(value);
+                if (b < 0)
+                        log_debug_unit(u->id, "Failed to parse forbid_restart value %s", value);
+                else
+                        s->forbid_restart = b;
         } else
                 log_debug_unit(u->id, "Unknown serialization key '%s'", key);