diff options
Diffstat (limited to 'src/core/unit.c')
-rw-r--r-- | src/core/unit.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/core/unit.c b/src/core/unit.c index d08c73613b..29b07a6e7a 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -22,6 +22,7 @@ #include "dbus-unit.h" #include "dbus.h" #include "dropin.h" +#include "env-util.h" #include "escape.h" #include "execute.h" #include "fd-util.h" @@ -127,7 +128,7 @@ Unit* unit_new(Manager *m, size_t size) { u->last_section_private = -1; u->start_ratelimit = (RateLimit) { m->default_start_limit_interval, m->default_start_limit_burst }; - u->auto_start_stop_ratelimit = (RateLimit) { 10 * USEC_PER_SEC, 16 }; + u->auto_start_stop_ratelimit = (const RateLimit) { 10 * USEC_PER_SEC, 16 }; return u; } @@ -4781,11 +4782,28 @@ int unit_setup_dynamic_creds(Unit *u) { } bool unit_type_supported(UnitType t) { + static int8_t cache[_UNIT_TYPE_MAX] = {}; /* -1: disabled, 1: enabled: 0: don't know */ + int r; + if (_unlikely_(t < 0)) return false; if (_unlikely_(t >= _UNIT_TYPE_MAX)) return false; + if (cache[t] == 0) { + char *e; + + e = strjoina("SYSTEMD_SUPPORT_", unit_type_to_string(t)); + + r = getenv_bool(ascii_strupper(e)); + if (r < 0 && r != -ENXIO) + log_debug_errno(r, "Failed to parse $%s, ignoring: %m", e); + + cache[t] = r == 0 ? -1 : 1; + } + if (cache[t] < 0) + return false; + if (!unit_vtable[t]->supported) return true; |