diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-11-24 00:44:57 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-12-14 00:54:13 +0100 |
commit | 4ea0d7f431ad036608020a78d8f8a00c414fe693 (patch) | |
tree | 23ee99aa61e342dc0d643e3fc3940b0aee225867 | |
parent | d2d6c096f6373a76f3b303a7a116e7cfe7139c4d (diff) |
core: make "Restart" service property accessible via the transient API
Fixes: #4402
-rw-r--r-- | src/core/dbus-service.c | 23 | ||||
-rw-r--r-- | src/shared/bus-unit-util.c | 2 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c index 61b83d2d62..85b67318ed 100644 --- a/src/core/dbus-service.c +++ b/src/core/dbus-service.c @@ -143,6 +143,29 @@ static int bus_service_set_transient_property( return 1; + } else if (streq(name, "Restart")) { + ServiceRestart sr; + const char *v; + + r = sd_bus_message_read(message, "s", &v); + if (r < 0) + return r; + + if (isempty(v)) + sr = SERVICE_RESTART_NO; + else { + sr = service_restart_from_string(v); + if (sr < 0) + return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid restart setting: %s", v); + } + + if (mode != UNIT_CHECK) { + s->restart = sr; + unit_write_drop_in_private_format(UNIT(s), mode, name, "Restart=%s", service_restart_to_string(sr)); + } + + return 1; + } else if (STR_IN_SET(name, "StandardInputFileDescriptor", "StandardOutputFileDescriptor", diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 735b8effc9..b030b3b9d1 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -266,7 +266,7 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen "StandardInput", "StandardOutput", "StandardError", "Description", "Slice", "Type", "WorkingDirectory", "RootDirectory", "SyslogIdentifier", "ProtectSystem", - "ProtectHome", "SELinuxContext")) + "ProtectHome", "SELinuxContext", "Restart")) r = sd_bus_message_append(m, "v", "s", eq); else if (streq(field, "SyslogLevel")) { |