Allow restart for oneshot units

Picked up from https://github.com/systemd/systemd/pull/7474 , so
coauthored by @robermorales.
This commit is contained in:
Claudio Zumbo
2019-10-16 09:44:20 -07:00
parent 7891aa0040
commit 10e72727ee
5 changed files with 81 additions and 5 deletions
+3 -2
View File
@@ -577,8 +577,9 @@ static int service_verify(Service *s) {
return -ENOEXEC;
}
if (s->type == SERVICE_ONESHOT && s->restart != SERVICE_RESTART_NO) {
log_unit_error(UNIT(s), "Service has Restart= setting other than no, which isn't allowed for Type=oneshot services. Refusing.");
if (s->type == SERVICE_ONESHOT
&& !IN_SET(s->restart, SERVICE_RESTART_NO, SERVICE_RESTART_ON_FAILURE, SERVICE_RESTART_ON_ABNORMAL, SERVICE_RESTART_ON_WATCHDOG, SERVICE_RESTART_ON_ABORT)) {
log_unit_error(UNIT(s), "Service has Restart= set to either always or on-success, which isn't allowed for Type=oneshot services. Refusing.");
return -ENOEXEC;
}