Skip to content

Commit

Permalink
core: add possibility to not track certain unit types
Browse files Browse the repository at this point in the history
(cherry picked from commit 88e4bfa62bd2561e04a90dc009e7a3865e0878fb)

Related: RHEL-5877
  • Loading branch information
msekletar authored and jamacku committed Nov 6, 2024
1 parent a4e0b7a commit dd79448
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/core/unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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"
Expand Down Expand Up @@ -4786,11 +4787,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;

Expand Down

0 comments on commit dd79448

Please sign in to comment.