core: don't go to disk for masked unit state if we know it anyway
This should speed up our selinux checks a bit, since in most cases we already know if a unit is masked, so use that info.
This commit is contained in:
committed by
Luca Boccassi
parent
836fb00f21
commit
9cbf128202
@@ -5497,10 +5497,19 @@ const char *unit_label_path(const Unit *u) {
|
||||
/* Returns the file system path to use for MAC access decisions, i.e. the file to read the SELinux label off
|
||||
* when validating access checks. */
|
||||
|
||||
if (IN_SET(u->load_state, UNIT_MASKED, UNIT_NOT_FOUND, UNIT_MERGED))
|
||||
return NULL; /* Shortcut things if we know there is no real, relevant unit file around */
|
||||
|
||||
p = u->source_path ?: u->fragment_path;
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
if (IN_SET(u->load_state, UNIT_LOADED, UNIT_BAD_SETTING, UNIT_ERROR))
|
||||
return p; /* Shortcut things, if we successfully loaded at least some stuff from the unit file */
|
||||
|
||||
/* Not loaded yet, we need to go to disk */
|
||||
assert(u->load_state == UNIT_STUB);
|
||||
|
||||
/* If a unit is masked, then don't read the SELinux label of /dev/null, as that really makes no sense */
|
||||
if (null_or_empty_path(p) > 0)
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user