Red Hat Training
A Red Hat training course is available for RHEL 8
7.2. 为数据机密配置多类别安全性
默认情况下,Multi-Category Security (MCS)在 targeted
和 mls
SELinux 策略中处于活跃状态,但不会为用户配置。在 targeted
策略中,仅针对以下内容配置 MCS:
- OpenShift
- virt
- sandbox
- 网络标记
-
containers (
container-selinux
)
您可以通过创建本地 SELinux 模块并将 user_t
SELinux 类型限制在类型强制的情况下,将 MCS 规则配置为分类用户的 MCS 规则。
警告
更改某些文件的类别可能会导致某些服务无法正常运行。如果您并不是相关系统的专家,请联系红帽销售代表并请求咨询服务。
先决条件
-
SELinux 模式设置为
enforcing
。 -
SELinux 策略被设置为
targeted
或mls
。 -
已安装
policycoreutils-python-utils
和setools-console
软件包。
步骤
创建一个新文件,例如名为
local_mcs_user.cil
:# vim local_mcs_user.cil
插入以下规则:
(typeattributeset mcs_constrained_type (user_t))
安装策略模块:
# semodule -i local_mcs_user.cil
验证
对于每个用户域,显示所有组件的更多详情:
# seinfo -xt user_t Types: 1 type user_t, application_domain_type, nsswitch_domain, corenet_unlabeled_type, domain, kernel_system_state_reader, mcs_constrained_type, netlabel_peer_type, privfd, process_user_target, scsi_generic_read, scsi_generic_write, syslog_client_type, pcmcia_typeattr_1, user_usertype, login_userdomain, userdomain, unpriv_userdomain, userdom_home_reader_type, userdom_filetrans_type, xdmhomewriter, x_userdomain, x_domain, dridomain, xdrawable_type, xcolormap_type;
其他资源
- 创建本地 SELinux 策略模块
- 有关容器上下文中的 MCS 的更多信息,请参阅博客文章 如何使用多级安全性实现 SELinux 独立的容器,并 为什么您应该为您的 Linux 容器使用多类别安全性。