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