From: Mike Yuan Date: Wed, 31 Jan 2024 17:47:35 +0000 (+0800) Subject: core/service: make error msg match with conditions X-Git-Tag: v256-rc1~904^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d67c51e386bb9817b74b2968ff195fb06425aa8f;p=thirdparty%2Fsystemd.git core/service: make error msg match with conditions This was discussed in https://github.com/systemd/systemd/pull/13754#discussion_r333395362. I think we should actually list "success" Restart= settings instead. There are more error statuses than success ones after all, and this list hasn't really changed for quite some time. --- diff --git a/src/core/service.c b/src/core/service.c index 2b760eb7aa3..ae3f9ed266e 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -662,8 +662,7 @@ static int service_verify(Service *s) { if (s->type != SERVICE_ONESHOT && s->exec_command[SERVICE_EXEC_START]->command_next) return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Service has more than one ExecStart= setting, which is only 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)) + if (s->type == SERVICE_ONESHOT && IN_SET(s->restart, SERVICE_RESTART_ALWAYS, SERVICE_RESTART_ON_SUCCESS)) return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Service has Restart= set to either always or on-success, which isn't allowed for Type=oneshot services. Refusing."); if (s->type == SERVICE_ONESHOT && !exit_status_set_is_empty(&s->restart_force_status))