diff options
author | Michal Sekletar <msekleta@redhat.com> | 2022-09-07 17:37:34 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-11-24 01:28:22 +0100 |
commit | 88e4bfa62bd2561e04a90dc009e7a3865e0878fb (patch) | |
tree | 956166fb2a432e4fb5fa17804e76fe8e7c752781 /src | |
parent | portable: add a few more useful debug log messages (diff) | |
download | systemd-88e4bfa62bd2561e04a90dc009e7a3865e0878fb.tar.xz systemd-88e4bfa62bd2561e04a90dc009e7a3865e0878fb.zip |
core: add possibility to not track certain unit types
Diffstat (limited to 'src')
-rw-r--r-- | src/core/unit.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/unit.c b/src/core/unit.c index c8dc97b99d..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" @@ -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; |