Viewing Standard Permissions
The basic Linux commandls -l can be used to display the standard file and directory permissions:
Understanding SELinux Context Labels
SELinux introduces an additional security layer by assigning each file and process a security context label. This label comprises four components in the following order: user, role, type, and level. Consider the example label below:-
User:
unconfined_u
Represents the SELinux user defined within the SELinux policy, which may differ from the Linux login username. -
Role:
object_r
Specifies the role that helps determine permitted operations. -
Type:
user_home_t
Defines the allowed operations for the file or process and effectively serves as a security “jail.” -
Level:
s0
Often used for multi-level security in organizations, indicating the sensitivity level of the object.
Remember: In SELinux, only files with the correct type (e.g.,
sshd_exec_t for SSH daemon) can initiate a process that transitions into the corresponding security domain.Exploring Process Contexts
Processes also carry SELinux security contexts. You can check the SELinux labels for running processes using theps command with the -Z option:
sshd) runs within the sshd_t domain. Strict policies enforce that only files labeled with the correct type (in this case, often sshd_exec_t) can start a process that enters this domain. Conversely, processes running with the unconfined_t label operate with minimal restrictions.
Viewing the Current User’s SELinux Context
To determine your current SELinux security context, use theid command with the -Z option:
The default mapping assigns non-root users to the
unconfined_u SELinux user, ensuring that even root processes are subject to the same security policies.Checking SELinux Enforcement Status
To check if SELinux is actively enforcing its security policies, use thegetenforce command:
- Enforcing: SELinux policies are enforced, and unauthorized actions are blocked.
- Permissive: SELinux is not actively enforcing policies but logs actions that would have been denied.
- Disabled: SELinux is turned off, and no access control is performed.