SELinux的应用
2013-10-12 00:00
127 查看
安装组件:
安装日志文件记录所需要的服务
现在我们在浏览器上访问,httpd服务器,如果不能访问查看iptables的给ACCEPT下
Aug 7 21:59:18 test auditd[1638]: Init complete, auditd 2.2 listening for events (startup state enable)
Aug 7 22:01:47 test setroubleshoot: SELinux is preventing /usr/sbin/httpd from getattr access on the file /var/www/html/index.html. For complete SELinux messages. run sealert -l 91a19ae3-b982-41d1-bbf2-302cf2032064
Aug 7 22:01:47 test setroubleshoot: SELinux is preventing /usr/sbin/httpd from getattr access on the file /var/www/html/index.html. For complete SELinux messages. run sealert -l 91a19ae3-b982-41d1-bbf2-302cf2032064
这样就看到了好多的错误的信息
SELinux is preventing /usr/sbin/httpd from open access on the file index.html.
***** Plugin catchall (100. confidence) suggests ***************************
If you believe that httpd should be allowed open access on the index.html file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep httpd /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp
******************** IMPORTANT ***********************
To make this policy package active, execute:
semodule -i mypol.pp
执行这两个就可以访问了
让setroubleshoot主动发送产生的信息到E-mail:
大约81行左右,这行要有才行
大约81行左右,这行要有才行
recipients_filepath = /var/lib/setroubleshoot/email_alert_recipients
大约在147行
# console: True|False, also log to the console
console = True
root
@localhost
f91jty@163.com
如果无法确定SELinux的问题出在哪里,建议这样处理:
一).在服务与RWX权限都没有问题,却无法成功的使用网络服务时,先使用setenforce 0设置为宽容模式。
二).再次使用该网络服务,如果这样就能用,表示SELinux出现问题,请往下继续处理;如果这样还不能使用,那问题就不是在SELinux上面,请再找其他解决方法,下面操作不适合你。
三).分析/var/log/messages内的信息,找到sealert -l 相关的信息并且执行。
四).找到Allow Access的关键词,按照里面的动作来进行SELinux的错误克服。
五).处理完重新setenforce 1,再次测试网络服务。
这样就能够很轻松的管理你的SELinux了。
yum -y install policycoreutils-python
yum -y install setools-console
安装日志文件记录所需要的服务
yum -y install setroubleshoot setroubleshoot-server
echo "My first selinux check" > index.html
mv index.html /var/www/html/
现在我们在浏览器上访问,httpd服务器,如果不能访问查看iptables的给ACCEPT下
tail /var/log/messages
Aug 7 21:59:18 test auditd[1638]: Init complete, auditd 2.2 listening for events (startup state enable)
Aug 7 22:01:47 test setroubleshoot: SELinux is preventing /usr/sbin/httpd from getattr access on the file /var/www/html/index.html. For complete SELinux messages. run sealert -l 91a19ae3-b982-41d1-bbf2-302cf2032064
Aug 7 22:01:47 test setroubleshoot: SELinux is preventing /usr/sbin/httpd from getattr access on the file /var/www/html/index.html. For complete SELinux messages. run sealert -l 91a19ae3-b982-41d1-bbf2-302cf2032064
这样就看到了好多的错误的信息
sealert -l b0332490-2505-4e1a-8a1a-b35f5041390a
SELinux is preventing /usr/sbin/httpd from open access on the file index.html.
***** Plugin catchall (100. confidence) suggests ***************************
If you believe that httpd should be allowed open access on the index.html file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
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
******************** IMPORTANT ***********************
To make this policy package active, execute:
semodule -i mypol.pp
semodule -i mypol.pp
执行这两个就可以访问了
让setroubleshoot主动发送产生的信息到E-mail:
vim /etc/setroubleshoot/setroubleshoot.conf
大约81行左右,这行要有才行
大约81行左右,这行要有才行
recipients_filepath = /var/lib/setroubleshoot/email_alert_recipients
大约在147行
# console: True|False, also log to the console
console = True
vim /var/lib/setroubleshoot/email_alert_recipients
root
@localhost
f91jty@163.com
service auditd restart
如果无法确定SELinux的问题出在哪里,建议这样处理:
一).在服务与RWX权限都没有问题,却无法成功的使用网络服务时,先使用setenforce 0设置为宽容模式。
二).再次使用该网络服务,如果这样就能用,表示SELinux出现问题,请往下继续处理;如果这样还不能使用,那问题就不是在SELinux上面,请再找其他解决方法,下面操作不适合你。
三).分析/var/log/messages内的信息,找到sealert -l 相关的信息并且执行。
四).找到Allow Access的关键词,按照里面的动作来进行SELinux的错误克服。
五).处理完重新setenforce 1,再次测试网络服务。
这样就能够很轻松的管理你的SELinux了。
相关文章推荐
- Linux中的SELinux原理与应用
- SELinux应用--移动App到sdcard
- selinux下添加android:sharedUserId="android.uid.phone"的应用开放访问"/mnt/asec/"
- selinux与NIS的应用
- Android给新增的二进制应用添加selinux权限
- Selinux的应用示例
- Linux中的SELinux原理与应用
- 监控及selinux的简单应用
- SELINUX在系统环境中的应用
- SELinux 相关应用
- Android的LocalSocket实现及SELinux权限设置.编译(应用层和native通信)
- SElinux 应用实例
- Linux中的SELinux原理与应用
- SpringCloud的应用发布(四)vmvare+linux,防火墙和selinux
- 谢烟客---------Linux之SELinux的基本应用
- Linux -- SELinux配置及应用(1)
- 树形控件(MS TreeView 6.0 ActiveX Control)在网页中的应用
- IIS 配置数据库中DirBrowseFlags属性的处理与应用
- OllyDbg应用方法大全
- Berkeley DB Windows应用