Linux SELinux 更新注意事项

一 升级前准备
二 升级中操作
getenforce 返回 Enforcing。三 升级后验证与回滚
ausearch -m AVC,USER_AVC -ts boot 或 ausearch -m avc -ts recent 检索升级后的拒绝日志,优先判断是否为合理访问,再决定是调整文件上下文、布尔值,还是编写最小化的自定义策略模块。sestatus、getenforce 确认处于 enabled/enforcing;必要时用 sealert 辅助分析复杂拒绝。四 常见坑与规避
chcon 做持久化修改,优先用 semanage fcontext + restorecon;变更后用 ls -lZ/ps -Z 复核。五 关键命令清单
sestatus、getenforce、setenforce 0|1(临时切换)ausearch -m AVC,USER_AVC -ts boot、ausearch -m avc -ts recent、sealert -a /var/log/audit/audit.logsemanage fcontext -a -t <type> <path>、restorecon -R <path>、ls -lZ、ps -Zsemodule -l、semodule -i <module.pp>、audit2allow -M <name>getsebool -a > sebools.txt、semanage fcontext -l > fcontext.txt、find / -type f -exec ls -Z {} ; > file_contexts.txt