diff --git a/src/core/service.c b/src/core/service.c index 278d93272a..141c85745a 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -672,25 +672,11 @@ static int service_verify(Service *s) { assert(s); assert(UNIT(s)->load_state == UNIT_LOADED); - for (ServiceExecCommand c = 0; c < _SERVICE_EXEC_COMMAND_MAX; c++) - LIST_FOREACH(command, command, s->exec_command[c]) { - if (!path_is_absolute(command->path) && !filename_is_valid(command->path)) - return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), - "Service %s= binary path \"%s\" is neither a valid executable name nor an absolute path. Refusing.", - command->path, - service_exec_command_to_string(c)); - if (strv_isempty(command->argv)) - return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), - "Service has an empty argv in %s=. Refusing.", - service_exec_command_to_string(c)); - } - if (!s->exec_command[SERVICE_EXEC_START] && !s->exec_command[SERVICE_EXEC_STOP] && UNIT(s)->success_action == EMERGENCY_ACTION_NONE) /* FailureAction= only makes sense if one of the start or stop commands is specified. * SuccessAction= will be executed unconditionally if no commands are specified. Hence, * either a command or SuccessAction= are required. */ - return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing."); if (s->type != SERVICE_ONESHOT && !s->exec_command[SERVICE_EXEC_START]) @@ -3204,7 +3190,7 @@ int service_deserialize_exec_command( bool control, found = false, last = false; int r; - enum ExecCommandState { + enum { STATE_EXEC_COMMAND_TYPE, STATE_EXEC_COMMAND_INDEX, STATE_EXEC_COMMAND_PATH, @@ -3230,6 +3216,7 @@ int service_deserialize_exec_command( break; switch (state) { + case STATE_EXEC_COMMAND_TYPE: id = service_exec_command_from_string(arg); if (id < 0) @@ -3237,11 +3224,12 @@ int service_deserialize_exec_command( state = STATE_EXEC_COMMAND_INDEX; break; + case STATE_EXEC_COMMAND_INDEX: - /* PID 1234 is serialized as either '1234' or '+1234'. The second form is used to - * mark the last command in a sequence. We warn if the deserialized command doesn't - * match what we have loaded from the unit, but we don't need to warn if that is the - * last command. */ + /* ExecCommand index 1234 is serialized as either '1234' or '+1234'. The second form + * is used to mark the last command in a sequence. We warn if the deserialized command + * doesn't match what we have loaded from the unit, but we don't need to warn if + * that is the last command. */ r = safe_atou(arg, &idx); if (r < 0) @@ -3250,15 +3238,18 @@ int service_deserialize_exec_command( state = STATE_EXEC_COMMAND_PATH; break; + case STATE_EXEC_COMMAND_PATH: path = TAKE_PTR(arg); state = STATE_EXEC_COMMAND_ARGS; break; + case STATE_EXEC_COMMAND_ARGS: r = strv_extend(&argv, arg); if (r < 0) return r; break; + default: assert_not_reached(); }