]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/core/unit-serialize.c
core: cache unit file selinux label, and make decisions based on that
authorLennart Poettering <lennart@poettering.net>
Tue, 12 Jul 2022 14:13:40 +0000 (16:13 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 20 Jul 2022 17:08:28 +0000 (19:08 +0200)
commit23e9a7dde519694120a493c8600c2168456e8a4f
tree0cb66ef7b3d064d2e7350d8cf671438f2ad07c59
parent74c1cf626730a34fbd2d39ed016db21c9748d944
core: cache unit file selinux label, and make decisions based on that

Do not go back to disk on each selinux access, but instead cache the
label off the inode we are actually reading. That way unit file contents
and unit file label we use for access checks are always in sync.

Based on discussions here:

https://github.com/systemd/systemd/pull/10023#issuecomment-1179835586

Replaces:

https://github.com/systemd/systemd/pull/23910

This changes behaviour a bit, because we'll reach and cache the label at
the moment of loading the unit (i.e. usually on boot and reload), but
not after relabelling. Thus, users must refresh the cache explicitly via
a "systemctl daemon-reload" if they relabelled things.

This makes the SELinux story a bit more debuggable, as it adds an
AccessSELinuxContext bus property to units that will report the label we are
using for a unit (or the empty string if not known).

This also drops using the "source" path of a unit as label source. if
there's value in it, then generators should manually copy the selinux
label from the source files onto the generated unit files, so that the
rule that "access labels are read when we read the definition files" is
upheld. But I am not convinced this is really a necessary, good idea.
man/org.freedesktop.systemd1.xml
src/core/dbus-unit.c
src/core/load-fragment.c
src/core/selinux-access.c
src/core/selinux-access.h
src/core/unit-serialize.c
src/core/unit.c
src/core/unit.h