SELinux 拒绝的定位与修复
服务启动或访问文件失败,ls -l 权限看起来正常,但 ausearch 里有 AVC denied。常见于自定义路径、非标准端口和容器挂载。
getenforce
ausearch -m avc -ts recent
sealert -a /var/log/audit/audit.log
ls -Z /path/to/file
semanage fcontext -l | grep /path
semanage port -l | grep <port>
getsebool -a | grep <service>
:z/:Z 选项不对。ls -Z。semanage fcontext -a -t <type> '/path(/.*)?',再 restorecon -Rv /path。semanage port -a -t <type> -p tcp <port>。setsebool -P <bool> on。audit2allow 生成策略,审查后再安装。setenforce 0 当长期方案;临时排障后要恢复 enforcing。getenforce — 当前模式ausearch — AVC 日志semanage — 上下文与端口restorecon — 恢复默认上下文setsebool — 布尔值