免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1926 | 回复: 3
打印 上一主题 下一主题

[系统安全] linux nginx selinux 的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-09-17 16:14 |只看该作者 |倒序浏览
问题1:/usr/local/nginx/logs/nginx.pid
/dev/shm/php.socket 这两个文件在机器重启后,selinux type都自动变掉,需要restorecon还原后可以正常,为什么type在重启后会变掉
问题2:selinux 在enforcing 下,将网页根目录改到/home/www下某个文件,文件type为user_home_t,但是在浏览器页能正常访问
不是应该为httpd_sys_content_t才能正常访问吗
  1. [root@localhost ~]# semanage fcontext -l|grep nginx
  2. /dev/shm/php.socket                                all files          system_u:object_r:nginx_var_lib_t:s0
  3. /usr/local/nginx/client_body_temp(/.*)?            all files          system_u:object_r:nginx_var_lib_t:s0
  4. /usr/local/nginx/conf(/.*)?                        all files          system_u:object_r:etc_t:s0
  5. /usr/local/nginx/fastcgi_temp(/.*)?                all files          system_u:object_r:nginx_var_lib_t:s0
  6. /usr/local/nginx/html(/.*)?                        all files          user_u:object_r:httpd_sys_content_t:s0
  7. /usr/local/nginx/htmlbak(/.*)?                     all files          system_u:object_r:httpd_sys_content_t:s0
  8. /usr/local/nginx/htmlbak/                          all files          system_u:object_r:httpd_sys_content_t:s0
  9. /usr/local/nginx/logs(/.*)?                        all files          system_u:object_r:nginx_var_log_t:s0
  10. /usr/local/nginx/logs/nginx.pid                    all files          system_u:object_r:nginx_var_run_t:s0
  11. /usr/local/nginx/proxy_temp(/.*)?                  all files          system_u:object_r:nginx_var_lib_t:s0
  12. /usr/local/nginx/sbin/nginx                        regular file       system_u:object_r:nginx_exec_t:s0
  13. /var/log/nginx(/.*)?                               all files          system_u:object_r:nginx_var_log_t:s0
  14. dso_tool                                           all files          system_u:object_r:nginx_exec_t:s0
  15. sbin                                               all files          system_u:object_r:nginx_exec_t:s0
复制代码

论坛徽章:
0
2 [报告]
发表于 2013-09-18 10:46 |只看该作者
本帖最后由 helloiac 于 2013-09-18 10:47 编辑

  1. [root@test-206 ~]# sealert -l 9c2e19aa-04e8-4828-b537-afd8c33ff94c
  2. SELinux is preventing /usr/local/nginx/sbin/nginx from search access on the directory /dev/shm.

  3. *****  Plugin catchall (100. confidence) suggests  ***************************

  4. If you believe that nginx should be allowed search access on the shm directory by default.
  5. Then you should report this as a bug.
  6. You can generate a local policy module to allow this access.
  7. Do
  8. allow this access for now by executing:
  9. # grep nginx /var/log/audit/audit.log | audit2allow -M mypol
  10. # semodule -i mypol.pp


  11. [root@test-206 ~]# ls -Z /usr/local/nginx/sbin/nginx
  12. -rwxr-xr-x. www www system_u:object_r:nginx_exec_t:s0 /usr/local/nginx/sbin/nginx
  13. [root@test-206 ~]# ls -Z /dev/shm/php-fpm.sock
  14. srw-rw-rw-. root root unconfined_u:object_r:nginx_var_lib_t:s0 /dev/shm/php-fpm.sock
  15. [root@test-206 ~]# semanage fcontext -l|grep nginx
  16. /dev/shm                                           all files          system_u:object_r:nginx_var_lib_t:s0
  17. /dev/shm/php-fpm.sock                              all files          system_u:object_r:nginx_var_lib_t:s0
  18. /usr/loca/nginx/sbin/nginx                         all files          system_u:object_r:nginx_exec_t:s0
  19. /usr/local/nginx/client_body_temp(/.*)?            all files          system_u:object_r:nginx_var_lib_t:s0
  20. /usr/local/nginx/conf(/.*)?                        all files          system_u:object_r:etc_t:s0
  21. /usr/local/nginx/fastcgi_temp(/.*)?                all files          system_u:object_r:nginx_var_lib_t:s0
  22. /usr/local/nginx/html(/.*)?                        all files          user_u:object_r:httpd_sys_content_t:s0
  23. /usr/local/nginx/logs(/.*)?                        all files          system_u:object_r:nginx_var_log_t:s0
  24. /usr/local/nginx/logs/nginx.pid                    all files          system_u:object_r:nginx_var_run_t:s0
  25. /usr/local/nginx/proxy_temp(/.*)?                  all files          system_u:object_r:nginx_var_lib_t:s0
  26. /usr/local/nginx/sbin/nginx                        all files          system_u:object_r:nginx_exec_t:s0
  27. /usr/local/nginx/sbin/nginx                        regular file       system_u:object_r:nginx_exec_t:s0
  28. /var/log/nginx(/.*)?                               all files          system_u:object_r:nginx_var_log_t:s0
  29. [root@test-206 ~]#
复制代码
SELinux is preventing /usr/local/nginx/sbin/nginx from search access on the directory /dev/shm.

求解,哪里配置错误了

论坛徽章:
0
3 [报告]
发表于 2013-09-18 20:37 |只看该作者
1) 你把文件的type写道selinux的配置文件里试试呢。
2)Selinux好像是可以根据MLS做访问控制而不是type。

论坛徽章:
0
4 [报告]
发表于 2013-09-22 15:36 |只看该作者
回复 3# Iinvincible
我想说是不是我的selinux bool值设置有问题
  1. [root@localhost policy]# getsebool -a|grep httpd
  2. allow_httpd_anon_write --> off
  3. allow_httpd_mod_auth_ntlm_winbind --> off
  4. allow_httpd_mod_auth_pam --> off
  5. allow_httpd_sys_script_anon_write --> off
  6. httpd_builtin_scripting --> on
  7. httpd_can_check_spam --> off
  8. httpd_can_network_connect --> off
  9. httpd_can_network_connect_cobbler --> off
  10. httpd_can_network_connect_db --> off
  11. httpd_can_network_memcache --> off
  12. httpd_can_network_relay --> off
  13. httpd_can_sendmail --> off
  14. httpd_dbus_avahi --> on
  15. httpd_enable_cgi --> on
  16. httpd_enable_ftp_server --> off
  17. httpd_enable_homedirs --> on
  18. httpd_execmem --> off
  19. httpd_manage_ipa --> off
  20. httpd_read_user_content --> on
  21. httpd_run_stickshift --> off
  22. httpd_setrlimit --> off
  23. httpd_ssi_exec --> off
  24. httpd_tmp_exec --> off
  25. httpd_tty_comm --> on
  26. httpd_unified --> off
  27. httpd_use_cifs --> off
  28. httpd_use_fusefs --> off
  29. httpd_use_gpg --> off
  30. httpd_use_nfs --> off
  31. httpd_use_openstack --> off
  32. httpd_verify_dns --> off
复制代码
里面没有看到 httpd_sys_content_rw_t 的设置,但是又不知道从哪里添加
我发现网上selinux的材料一般都比较浅显,是用selinux的不多吗
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP