SELinux 以強制存取控制(MAC)保護系統,警告通常源自四大類原因。本文逐一拆解並給出標準排查流程。
type=AVC msg=audit(...): avc: denied { read } for pid=... comm="httpd" name="index.html" scontext=system_u:system_r:httpd_t:s0 tcontext=user_home_t:s0ls -Z /path/to/file 檢查標籤,正確應為 httpd_sys_content_t。semanage fcontext -a -t httpd_sys_content_t "/var/www(/.*)?"
restorecon -Rv /var/www
/srv/web。semanage boolean -l | grep httpdsetsebool -P httpd_enable_cgi on 或 setsebool -P httpd_use_nfs on。semanage port -a -t http_port_t -p tcp 8080。sealert -a /var/log/audit/audit.log 分析,依建議建立本地策略模組:ausearch -c 'appname' --raw | audit2allow -M myapp
semodule -i myapp.pp
setenforce 0(全域寬容)或 semanage permissive -a httpd_t(單一域寬容)。/tmp/.../malware)、非預期網路連線、嘗試修改關鍵檔案(/etc/passwd、/etc/shadow)、產生大量 AVC denied 但操作合理。rkhunter, chkrootkit)、重建受損系統。sealert 分析restorecon 修正setsebool/semanage portaudit2allow