icinga-selinux的解决办法

如果在icinga服务器上启用了selinxu,那么icinga和icinga-web都可能无法访问,有四个解决办法。
1、逐条日志解决
more /var/log/messages|grep SELinux
查看日志会发现如下信息。
SELinux is preventing /usr/local/icinga/sbin/tac.cgi from read access on the file status.dat. For complete SELinux messages. run sealert -l b9675e88-c227-4fa6-af59-

7f93839cf833
按照提示运行如下命令:
sealert -l b9675e88-c227-4fa6-af59-7f93839cf833

在最后会告诉你如何解决,信息如下:
allow this access for now by executing:
# grep httpd /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

按照提示运行上面两条命令即可解决该问题。
grep httpd /var/log/audit/audit.log | audit2allow -M mypol
semodule -i mypol.pp
运行第一条命令会在当前目录产生mypol.pp和mypol.te的文件,其中mypol.te是源文件,可以查看。如果需要修改源文件可以用如下命令重新编译后安装
checkmodule -M -m -o icinga-cgi.mod icinga-cgi.te
semodule_package -o icinga-cgi.pp -m icinga-cgi.mod
semodule -i icinga-cgi.pp

注意:sealert命令需要安装setroubleshoot,audit2allow命令需要安装selinux-policy可以用yum进行安装
yum -y install selinux-policy* setroubleshoot

2、所有的selinux一起解决
audit2allow -M icinga -l -i /var/log/audit/audit.log
semodule -i icinga.pp
运行第一条命令会在当前目录产生icinga.pp和icinga.te的文件。第二个命令是安装

3、直接修改selinux的配置文件
vi /etc/selinux/targeted/contexts/files/file_contexts
添加如下内容
/usr/local/icinga-web/app(/.*)?  system_u:object_r:httpd_sys_content_t:s0
/usr/local/icinga-web/lib(/.*)?  system_u:object_r:httpd_sys_content_t:s0
/usr/local/icinga-web/pub(/.*)?  system_u:object_r:httpd_sys_content_t:s0
/var/cache/icinga-web(/.*)? system_u:object_r:httpd_sys_rw_content_t:s0
/var/log/icinga-web(/.*)? system_u:object_r:httpd_sys_rw_content_t:s0
/usr/local/icinga/sbin(/.*)?  system_u:object_r:httpd_sys_script_exec_t:s0
/usr/local/icinga/share(/.*)? system_u:object_r:httpd_sys_content_t:s0
/usr/local/icinga/var(/.*)? system_u:object_r:httpd_sys_rw_content_t:s0

最后再运行如下命令恢復档案目录的预设的security context
restorecon -R /usr/local/icinga-web

4、如果预先知道文件的security context类型可以运行chcon命令来改变

chcon -R -t httpd_nagios_script_exec_t /usr/local/icinga/sbin/
chcon -R -t httpd_sys_content_t /usr/local/icinga/share/
chcon -R -t httpd_sys_content_t /usr/share/icinga-web
chcon -R -t httpd_sys_rw_content_t /var/log/icinga-web/
chcon -R -t httpd_sys_rw_content_t /var/cache/icinga-web/

 以上方法也可以用于解决其他服务器的selinux问题

更多关于selinux的资料请参考如下网页

http://wiki.centos.org/zh/HowTos/SELinux

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值