Using substitution definitions
Sometimes, applications and their resources get installed at different locations than expected by the SELinux policy. Trying to accommodate this by defining additional context definitions for each and every subdirectory can easily become unmanageable.
To help administrators, the SELinux utilities support substitution entries, which tell SELinux "if a path starts with this, then label it as if it starts with that". Administrators can set such a substitution (which is called an equivalence class) using semanage
, as follows:
~# semanage fcontext –a –e / /mnt/chroots/bind
In this example, any location under /mnt/chroots/bind/
will be labeled as if it started from the main /
directory (so /mnt/chroots/bind/etc/
becomes etc_t
as /etc/
is etc_t
).
Target locations for chroots
are a good use case for this. A chroot
is an alternate location on the filesystem, which will act as the root filesystem for one or a set of applications.
For administrators...