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