有没有办法查看应用于 SELinux 的所有自定义策略,最好将它们全部汇总到一个策略“包”中?
当某个进程(来自 logrotate 脚本的 awstats 更新,FWIW)试图运行时,我刚刚花了上周左右的时间解决了一系列 SELinux 错误。在 SELinux 处于许可模式时,我会等待 logrotate 运行,查看审计日志中的 SELinux 块,运行 audit2allow 以创建允许策略,然后在第二天重复该过程,并提供一个全新的相关错误列表。最后,今天早上审计日志变得干净了,所以我认为我已经制定了所有必需的规则来允许脚本正常运行。
当然,当我彻底完成这个过程时,我并没有想到,所以我没有在此过程中创建所有 .pp/.te 文件。所以我想做的是将所有当前活动的自定义策略从 SELinux 中拉回来,这样我就可以有一个备份副本用于其他机器或恢复。这可能吗?
编辑:这是在运行 CentOS 6.7 的机器上,如果这有区别的话
这个答案是借用这个问题的。虽然它并没有完全回答查看应用于计算机的所有自定义 SELinux 策略的问题,但它确实提供了您想要用来查看任何自定义策略或稍微缩小范围的工具集。
获取此信息的一些命令是(示例使用httpd_log_t
):
seinfo
# seinfo -x --type=httpd_log_t /etc/selinux/default/policy/policy.26
httpd_log_t
file_type
non_security_file_type
logfile
Run Code Online (Sandbox Code Playgroud)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 ;
Run Code Online (Sandbox Code Playgroud)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
Run Code Online (Sandbox Code Playgroud)参考资料:RHEL6 SELinux手册
归档时间: |
|
查看次数: |
5770 次 |
最近记录: |