SELinux users and roles
In SELinux-enabled environments, the login binary calls the libselinux
API to establish the initial mapping between SELinux users and local users. Then, after finding the right SELinux user, the system looks up the role and domain that the user should be in and sets that as the user's context.
Listing SELinux user mappings
When logged in to the system, we can use id -Z
to obtain the current SELinux context. For many users, this context will be defined by the unconfined user (unconfined_u
), regardless of their username. If not that, it will generally be a context based on one of sysadm_u
, staff_u
, or user_u
. This is because most Linux distributions will only provide a limited set of SELinux users by default, aligned with the SELinux roles that they support.
During login, the service process through which the login is handled will check a local definition file to find the appropriate mapping between the Linux account and the SELinux user. Let&apos...