AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 461936
Accepted
nn4l
nn4l
Asked: 2013-01-01 04:22:53 +0800 CST2013-01-01 04:22:53 +0800 CST 2013-01-01 04:22:53 +0800 CST

SELinux:如何启用对 Joomla 缓存目录的写访问权限?

  • 772

我已经在运行 Joomla 网站的 Debian 压缩系统上设置了 SELinux。Joomla PHP 代码想要对某些缓存目录具有写入权限。

/var/log/messages 文件包含如下条目:

Dec 31 10:26:16 s0022 kernel: [ 2116.423199] type=1400 audit(1356945976.634:14831): 
  avc:  denied  { write } for  pid=1886 comm="apache2" name="_system" dev=xvda3 
  ino=790893 scontext=system_u:system_r:httpd_t:s0
  tcontext=unconfined_u:object_r:httpd_t:s0 tclass=dir
Dec 31 10:26:16 s0022 kernel: [ 2116.447613] type=1400 audit(1356945976.658:14837): 
  avc:  denied  { write } for  pid=1886 comm="apache2" name="mod_mainmenu" dev=xvda3
  ino=791346 scontext=system_u:system_r:httpd_t:s0
  tcontext=unconfined_u:object_r:httpd_t:s0 tclass=dir

与 inode 值对应的目录可由 apache2(以 wwwrun 运行)写入。缓存文件是在 SELinux 关闭时创建的,而不是在它被激活时创建的。然而,这些目录的路径与 Debian Squeeze 的默认 DocumentRoot 不同。

# ls -ldZ cache cache/_system cache/mod_mainmenu
drwxrwxr-x. 5 wwwrun www unconfined_u:object_r:httpd_t:s0 4096 Dec 29 23:13 cache
drwxrwxr-x. 2 wwwrun www unconfined_u:object_r:httpd_t:s0 4096 Dec 30 19:31 cache/mod_mainmenu
drwxrwxr-x. 2 wwwrun www unconfined_u:object_r:httpd_t:s0 4096 Dec 30 19:31 cache/_system

我还尝试启用写入相关的布尔标志,但这也无济于事:

# getsebool -a | grep httpd
allow_httpd_anon_write --> on
allow_httpd_mod_auth_pam --> off
allow_httpd_sys_script_anon_write --> on
allow_httpd_user_script_anon_write --> on
httpd_builtin_scripting --> off
httpd_can_network_connect --> off
httpd_can_network_connect_db --> on
httpd_can_network_relay --> off
httpd_can_sendmail --> off
httpd_dbus_avahi --> off
httpd_enable_cgi --> off
httpd_enable_ftp_server --> off
httpd_enable_homedirs --> on
httpd_ssi_exec --> off
httpd_tty_comm --> off
httpd_unified --> off
httpd_use_cifs --> off
httpd_use_gpg --> off
httpd_use_nfs --> off

我已经使用 audit2allow 创建可加载模块以启用对其他守护程序的写访问(例如 rotatelog),但我认为在这种情况下这不是可行的方法。httpd 的模块已经存在,如果可以避免,我不想以任何方式接触它。

我只是在寻找一种方法让 apache2 / php / Joomla 在我的特定 DocumentRoot 内的特定目录中写入,而不授予对其他任何内容的写入权限。请指教。

php
  • 2 2 个回答
  • 7315 Views

2 个回答

  • Voted
  1. mricon
    2013-01-01T10:26:27+08:002013-01-01T10:26:27+08:00

    您需要告诉 SELinux 缓存位置是 type httpd_cache_t:

    # semanage fcontext -a -t 'httpd_cache_t' '/path/to/wwwroot/cache(/.*)?'
    # restorecon -Rvvv /path/to/wwwroot/cache
    
    • 4
  2. Best Answer
    Oldskool
    2013-01-01T04:36:51+08:002013-01-01T04:36:51+08:00

    缓存目录由所有不同类型的用户使用,如您已经提到的,apache 用户、php 用户,如果您使用 mod_fcgid,甚至可能是单独的 Joomla 用户。对于这样的目录,有public_content_rw_t类型上下文。这使得它对所有涉及的服务都是可写的,并且(因为它“只是”一个带有临时文件的缓存目录)不应该带来太多的安全风险。所以我建议使用命令将类型更改为公共类型

    chcon -R -t public_content_rw_t /path/to/wwwroot/cache
    
    • 1

相关问题

  • 用户特定的 Php.ini 当 php 作为模块运行时?

  • 使 php mail() 函数在 ubuntu-server 上工作的步骤是什么?

  • Web 服务器和数据库服务器位于完全不同的位置

  • PHP 作为 CGI 还是 Apache 模块?

  • 通过 VPN 连接什么是远程服务器 IP?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve