if (!s)
return -ENOMEM;
- if (!unit_name_is_valid(s)) {
+ if (!unit_name_is_valid(s, false)) {
r = -EINVAL;
goto fail;
}
set_free_free(u->meta.names);
- free(u->meta.instance);
+ condition_free_list(u->meta.conditions);
+ free(u->meta.instance);
free(u);
}
if (u->meta.job_timeout > 0)
fprintf(f, "%s\tJob Timeout: %s\n", prefix, format_timespan(timespan, sizeof(timespan), u->meta.job_timeout));
+ condition_dump_list(u->meta.conditions, f, prefix);
+
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++) {
Unit *other;
if (!UNIT_VTABLE(u)->start)
return -EBADR;
+ /* If the conditions failed, don't do anything at all */
+ if (!condition_test_list(u->meta.conditions)) {
+ log_debug("Starting of %s requested but condition failed. Ignoring.", u->meta.id);
+ return -EALREADY;
+ }
+
/* We don't suppress calls to ->start() here when we are
* already starting, to allow this request to be used as a
* "hurry up" call, for example when the unit is in some "auto
if (u->meta.type == UNIT_SERVICE &&
!UNIT_IS_ACTIVE_OR_RELOADING(os)) {
/* Write audit record if we have just finished starting up */
- manager_send_unit_audit(u->meta.manager, u, AUDIT_SERVICE_START, 1);
+ manager_send_unit_audit(u->meta.manager, u, AUDIT_SERVICE_START, true);
u->meta.in_audit = true;
}
+ if (!UNIT_IS_ACTIVE_OR_RELOADING(os))
+ manager_send_unit_plymouth(u->meta.manager, u);
+
} else {
if (unit_has_name(u, SPECIAL_SYSLOG_SERVICE))
return false;
}
+UnitType unit_name_to_type(const char *n) {
+ UnitType t;
+
+ assert(n);
+
+ for (t = 0; t < _UNIT_TYPE_MAX; t++)
+ if (endswith(n, unit_vtable[t]->suffix))
+ return t;
+
+ return _UNIT_TYPE_INVALID;
+}
+
+bool unit_name_is_valid(const char *n, bool template_ok) {
+ UnitType t;
+
+ t = unit_name_to_type(n);
+ if (t < 0 || t >= _UNIT_TYPE_MAX)
+ return false;
+
+ return unit_name_is_valid_no_type(n, template_ok);
+}
+
static const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = {
[UNIT_STUB] = "stub",
[UNIT_LOADED] = "loaded",
[UNIT_ERROR] = "error",
- [UNIT_MERGED] = "merged"
+ [UNIT_MERGED] = "merged",
+ [UNIT_MASKED] = "masked"
};
DEFINE_STRING_TABLE_LOOKUP(unit_load_state, UnitLoadState);