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

前端之家收集整理的这篇文章主要介绍了如何查询影响类型的所有selinux规则/默认文件上下文/ etc前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要知道运行系统当前规则中与se linux类型相关的所有内容

>允许,allowaudit,dontaudit规则.
>使用类型标记上下文的文件.
>过渡.

……以及任何其他信息.

是否有任何可用于查询该信息的命令,或者我是否应该下载所有与selinux相关的“src”软件包,过滤掉未使用的模块并为该信息grep每个文件?必须有一种更简单的方法来做到这一点.

解决方法

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

> seinfo

  1. # seinfo -x --type=httpd_log_t /etc/selinux/default/policy/policy.26
  2. httpd_log_t
  3. file_type
  4. non_security_file_type
  5. logfile

>搜索

  1. # sesearch --dontaudit -t httpd_log_t /etc/selinux/default/policy/policy.26 | head
  2. Found 35 semantic av rules:
  3. dontaudit run_init_t file_type : dir { getattr search open } ;
  4. dontaudit staff_t non_security_file_type : file getattr ;
  5. dontaudit staff_t non_security_file_type : dir { ioctl read getattr lock search open } ;
  6. dontaudit staff_t non_security_file_type : lnk_file getattr ;
  7. dontaudit staff_t non_security_file_type : sock_file getattr ;
  8. dontaudit staff_t non_security_file_type : fifo_file getattr ;
  9. dontaudit unconfined_t non_security_file_type : file getattr ;
  10. dontaudit unconfined_t non_security_file_type : dir { ioctl read getattr lock search open } ;
  11. dontaudit unconfined_t non_security_file_type : lnk_file getattr ;

> semanage

  1. # semanage fcontext -l | grep httpd_log_t
  2. /etc/httpd/logs all files system_u:object_r:httpd_log_t:s0
  3. /var/log/apache(2)?(/.*)? all files system_u:object_r:httpd_log_t:s0
  4. /var/log/apache-ssl(2)?(/.*)? all files system_u:object_r:httpd_log_t:s0
  5. /var/log/cacti(/.*)? all files system_u:object_r:httpd_log_t:s0
  6. /var/log/cgiwrap\.log.* regular file system_u:object_r:httpd_log_t:s0
  7. /var/log/horde2(/.*)? all files system_u:object_r:httpd_log_t:s0
  8. /var/log/httpd(/.*)? all files system_u:object_r:httpd_log_t:s0
  9. /var/log/lighttpd(/.*)? all files system_u:object_r:httpd_log_t:s0
  10. /var/log/piranha(/.*)? all files system_u:object_r:httpd_log_t:s0
  11. /var/www(/.*)?/logs(/.*)? all files system_u:object_r:httpd_log_t:s0

参考文献:RHEL6 SELinux manual

猜你在找的Linux相关文章