SELinux调试与审计全解析
一、SELinux约束查询与分析
SELinux约束是SELinux策略中额外的限制条件,它不仅基于SELinux类型,还考虑了SELinux角色和用户。一些访问拒绝可能是由这些约束导致的,但从拒绝信息中往往难以明确。
1. 借助audit2why初步判断
使用ausearch和audit2why可以帮助开发者判断拒绝是否由约束违规引起:
~# ausearch -m avc -ts recent | grep type=AVC | audit2why示例输出:
type=AVC msg=audit(1401134596.932:62843): avc: denied { search } for pid=19384 comm="mount.nfs4" scontext=system_u:system_r:mount_t:s0 tcontext=system_u:object_r:nfs_t:s0 tclass=dir Was caused by: Policy constraint violation. May require adding a type attribute to the domain or type to satisfy the constraint. Constra