6.8. Separating system administration from security administration in MLS
By default, the sysadm_r role has the rights of the secadm_r role, which means a user with the sysadm_r role can manage the security policy. If you need more control over security authorizations, you can separate system administration from security administration by assigning a Linux user to the secadm_r role and disabling the sysadm_secadm module in the SELinux policy.
Prerequisites
-
The SELinux policy is set to
mls. -
The SELinux mode is set to
enforcing. -
The
policycoreutils-python-utilspackage is installed. A Linux user which will be assigned to the
secadm_rrole:-
The user is assigned to the
staff_uSELinux user - A password for this user has been defined.
주의Make sure you can log in as the user which will be assigned to the
secadmrole. If not, you can prevent any future modifications of the system’s SELinux policy.-
The user is assigned to the
Procedure
Create a new
sudoersfile in the/etc/sudoers.ddirectory for the user:# visudo -f /etc/sudoers.d/<sec_adm_user>To keep the
sudoersfiles organized, replace<sec_adm_user>with the Linux user which will be assigned to thesecadmrole.Add the following content into the
/etc/sudoers.d/<sec_adm_user>file:<sec_adm_user> ALL=(ALL) TYPE=secadm_t ROLE=secadm_r ALLThis line authorizes
<sec_adm_user>on all hosts to perform all commands, and maps the user to thesecadmSELinux type and role by default.Log in as the <sec_adm_user> user.
To make sure that the SELinux context (which consists of SELinux user, role, and type) is changed, log in using
ssh, the console, orxdm. Other ways, such assuandsudo, cannot change the entire SELinux context.Verify the user’s security context:
$ id uid=1000(<sec_adm_user>) gid=1000(<sec_adm_user>) groups=1000(<sec_adm_user>) context=staff_u:staff_r:staff_t:s0-s15:c0.c1023Run the interactive shell for the root user:
$ sudo -i [sudo] password for <sec_adm_user>:Verify the current user’s security context:
# id uid=0(root) gid=0(root) groups=0(root) context=staff_u:secadm_r:secadm_t:s0-s15:c0.c1023Disable the
sysadm_secadmmodule from the policy:# semodule -d sysadm_secadm중요Use the
semodule -dcommand instead of removing the system policy module by using thesemodule -rcommand. Thesemodule -rcommand deletes the module from your system’s storage, which means it cannot be loaded again without reinstalling theselinux-policy-mlspackage.
Verification
As the user assigned to the
secadmrole, and in the interactive shell for the root user, verify that you can access the security policy data:# seinfo -xt secadm_t Types: 1 type secadm_t, can_relabelto_shadow_passwords, (…) userdomain;Log out from the root shell:
# logoutLog out from the
<sec_adm_user>user:$ logout Connection to localhost closed.Display the current security context:
# id uid=0(root) gid=0(root) groups=0(root) context=root:sysadm_r:sysadm_t:s0-s15:c0.c1023Attempt to enable the
sysadm_secadmmodule. The command should fail:# semodule -e sysadm_secadm SELinux: Could not load policy file /etc/selinux/mls/policy/policy.31: Permission denied /sbin/load_policy: Can't load policy: Permission denied libsemanage.semanage_reload_policy: load_policy returned error code 2. (No such file or directory). SELinux: Could not load policy file /etc/selinux/mls/policy/policy.31: Permission denied /sbin/load_policy: Can't load policy: Permission denied libsemanage.semanage_reload_policy: load_policy returned error code 2. (No such file or directory). semodule: Failed!Attempt to display the details about the
sysadm_tSELinux type. The command should fail:# seinfo -xt sysadm_t [Errno 13] Permission denied: '/sys/fs/selinux/policy'