65878a
From d5a7089608ccde2302b185ec367165c8b5623a12 Mon Sep 17 00:00:00 2001
65878a
From: Sylvia Else <sylviabz1@cryogenic.net>
65878a
Date: Sun, 6 Oct 2013 23:06:35 -0400
65878a
Subject: [PATCH] systemd: serialize/deserialize forbid_restart value
65878a
65878a
The Service type's forbid_restart field was not preserved by
65878a
serialization/deserialization, so the fact that the service should not
65878a
be restarted after stopping was lost.
65878a
65878a
If a systemctl stop foo command has been given, but the foo service
65878a
has not yet stopped, and then the systemctl --system daemon-reload was
65878a
given, then when the foo service eventually stopped, systemd would
65878a
restart it.
65878a
65878a
https://bugs.freedesktop.org/show_bug.cgi?id=69800
65878a
---
65878a
 src/core/service.c | 11 +++++++++++
65878a
 1 file changed, 11 insertions(+)
65878a
65878a
diff --git a/src/core/service.c b/src/core/service.c
65878a
index 6792024..98b1599 100644
65878a
--- a/src/core/service.c
65878a
+++ b/src/core/service.c
65878a
@@ -2651,6 +2651,9 @@ static int service_serialize(Unit *u, FILE *f, FDSet *fds) {
65878a
         if (s->exec_context.var_tmp_dir)
65878a
                 unit_serialize_item(u, f, "var-tmp-dir", s->exec_context.var_tmp_dir);
65878a
 
65878a
+        if (s->forbid_restart)
65878a
+                unit_serialize_item(u, f, "forbid_restart", yes_no(s->forbid_restart));
65878a
+
65878a
         return 0;
65878a
 }
65878a
 
65878a
@@ -2787,6 +2790,14 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
65878a
                         return log_oom();
65878a
 
65878a
                 s->exec_context.var_tmp_dir = t;
65878a
+        } else if (streq(key, "forbid_restart")) {
65878a
+                int b;
65878a
+
65878a
+                b = parse_boolean(value);
65878a
+                if (b < 0)
65878a
+                        log_debug_unit(u->id, "Failed to parse forbid_restart value %s", value);
65878a
+                else
65878a
+                        s->forbid_restart = b;
65878a
         } else
65878a
                 log_debug_unit(u->id, "Unknown serialization key '%s'", key);
65878a