-----SELinux相关指令工具-----
#reference from: http://www.cnblogs.com/zgx/archive/2011/08/31/2160330.html
#--restorecon
说明:恢复档案目录的预设的security Context
规格来源:/etc/selinux//contexts/files/目录内的file_contexts与file_contexts.local
常用参数如下:
-r | -R:包含子目录与其下档案目录
-F:恢復使用预设的項目(就算是檔案符合存取规范)
-v:显示执行过程
使用方式:restorecon [FRrv] [-e excludedir ] pathname... ]
使用范例如下:
restorecon /etc/ntp.conf
restorecon -v /etc/ntp.conf
restorecon -v -F /etc/ntp.conf
手动配置新增恢复规则
1)档案名称
/etc/selinux//contexts/files/file_contexts.local
2)新增配置范例
/var/ftp(/.*)? system_u:object_r:public_content_t
3)注意
可以使用semanage程式来维护会比较方便
#--fixfiles
说明:修正档案目录的预设的security Context,依据/etc/selinux//contexts/files/内相关档案修正
使用方式:
fixfiles { check | restore|[-F] relabel } [[dir] ... ]
fixfiles -R rpmpackage[,rpmpackage...] { check | restore }
参数:
-R:使用指定的rpm 套件所提供的檔案清單
使用范例:
fixfiles check /etc
fixfiles restore /etc
fixfiles -F relabel /
fixfiles -R setup check
#--audit2why
说明:检视SELinux audit讯息内容,提供检视/var/log/audit/audit.log内的记录资讯说明
使用范例:audit2why < /var/log/audit/audit.log
注意:需要搭配启动auditd服务程式一起使用