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