SELinux策略定制步骤如下:
selinux-basics、selinux-policy-default等基础工具包。sestatus查看当前模式(Enforcing/Permissive/Disabled)。setenforce 0:设为Permissive(仅记录违规,不阻止)。setenforce 1:设为Enforcing(强制执行策略)。/etc/selinux/config,修改SELINUX=参数后重启生效。.te文件(如custom_policy.te),定义类型、规则(如allow user_t file_t:file { read write };)。make -f /usr/share/selinux/devel/Makefile编译生成.pp文件。semodule -i custom_policy.pp安装策略。ausearch或audit2why查看日志,确认策略生效。注意:修改策略需谨慎,建议先在测试环境验证,避免影响系统安全性。
不同发行版(如Ubuntu/CentOS)的策略路径和工具略有差异,可参考对应文档。