SELinux对网站目录权限控制的不当的问题

来源:互联网 发布:金税盘怎么恢复数据 编辑:程序博客网 时间:2024/06/05 22:52
apache 报错

[Fri Jul 01 06:11:00 2016] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
[Fri Jul 01 06:11:00 2016] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Fri Jul 01 06:11:01 2016] [notice] Digest: generating secret for digest authentication ...
[Fri Jul 01 06:11:01 2016] [notice] Digest: done


所以使用chcon更改SELinux权限以及显示结果如下:

<span style="color:#FF0000;">setenforce 0 #必须暂时停止SELinux,否则可能导致操作失败。 chcon -t httpd_sys_content_t -R /var/www/html/home_start/ #R参数是递归操作的意思</span>



经过修改就会发现SELinux的对应权限已经和其他目录相同了!都是
httpd_sys_content_t。

  1. [root@localhost html]# setenforce --help 
  2. usage:  setenforce [ Enforcing | Permissive | 1 | 0 ] 
  3. [root@localhost html]# setenforce 0 
  4. [root@localhost html]# cd 
  5. [root@localhost ~]# ls /var/www/html/trunk/gz -Z 
  6. ……
  7. drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 gz
  8. ……
  9. [root@localhost ~]# chcon -t httpd_sys_content_t -R /var/www/html/gz
  10. [root@localhost ~]# ls /var/www/html/trunk/gz/ -Z 
  11. ……
  12. -rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 authorize.php
0 0
原创粉丝点击