我如何查询所有影响types的selinux规则/默认文件上下文/ etc

我需要知道与正在运行的系统当前规则selinuxtypes相关的所有内容:

  • allowaudit,dontaudit规则。
  • 使用types标记上下文的文件。
  • 过渡。

…和其他任何信息。

有没有我可以用来查询这些信息的命令,或者我应该下载所有与selinux相关的“src”软件包,过滤掉那些没有使用的模块,并且grep每个文件的信息? 必须有一个更简单的方法来做到这一点。

一些获取这些信息的命令是(例子使用httpd_log_t ):

  1. seinfo

     # seinfo -x --type=httpd_log_t /etc/selinux/default/policy/policy.26 httpd_log_t file_type non_security_file_type logfile 
  2. sesearch

     # sesearch --dontaudit -t httpd_log_t /etc/selinux/default/policy/policy.26 | head Found 35 semantic av rules: dontaudit run_init_t file_type : dir { getattr search open } ; dontaudit staff_t non_security_file_type : file getattr ; dontaudit staff_t non_security_file_type : dir { ioctl read getattr lock search open } ; dontaudit staff_t non_security_file_type : lnk_file getattr ; dontaudit staff_t non_security_file_type : sock_file getattr ; dontaudit staff_t non_security_file_type : fifo_file getattr ; dontaudit unconfined_t non_security_file_type : file getattr ; dontaudit unconfined_t non_security_file_type : dir { ioctl read getattr lock search open } ; dontaudit unconfined_t non_security_file_type : lnk_file getattr ; 
  3. semanage

     # semanage fcontext -l | grep httpd_log_t /etc/httpd/logs all files system_u:object_r:httpd_log_t:s0 /var/log/apache(2)?(/.*)? all files system_u:object_r:httpd_log_t:s0 /var/log/apache-ssl(2)?(/.*)? all files system_u:object_r:httpd_log_t:s0 /var/log/cacti(/.*)? all files system_u:object_r:httpd_log_t:s0 /var/log/cgiwrap\.log.* regular file system_u:object_r:httpd_log_t:s0 /var/log/horde2(/.*)? all files system_u:object_r:httpd_log_t:s0 /var/log/httpd(/.*)? all files system_u:object_r:httpd_log_t:s0 /var/log/lighttpd(/.*)? all files system_u:object_r:httpd_log_t:s0 /var/log/piranha(/.*)? all files system_u:object_r:httpd_log_t:s0 /var/www(/.*)?/logs(/.*)? all files system_u:object_r:httpd_log_t:s0 

参考文献: RHEL6 SELinux手册