SELinuxはhttpdがファイルを書き込むのを防ぎます。

SELinuxはhttpdがファイルを書き込むのを防ぎます。

私は最近RHEL7にウェブサイトを開設しました。 SELinuxが実行モードになっています。しかし、コンテキストをどのように調整しても、常にhttpdの書き込みはブロックされます。監査ログは次のとおりです。

type=AVC msg=audit(1488922911.038:6188): avc:deny{write} for pid=11773 comm="httpd" name="cache" dev="xvda2" ino=42006369 scontext=system_u:system_r =system_u:object_r:httpd_t:s0 tclass=dir

type=SYSCALL msg=audit(1488922911.038:6188):arch=c000003e syscall=21 成功=いいえ終了=-13 a0=7f76f76142c0 a1=2 a2=0 a3=7f76e87 294967 295 uid = 48 gid = 48 euid = 48 suid = 48 fsuid = 48 egid = 48 sgid = 48 fsgid = 48 tty = (なし) ses = 4294967295 comm = "httpd" exe = "/usr/sbin system_u:system_r:httpd_t:s0キー=(null)

ソースとターゲットのコンテキストが一致しないようです。ところが、統一した後もまだ動作しませんでした。

type=AVC msg=audit(1488923356.905:6384): avc:deny{write} for pid=11709 comm="httpd" name="cache" dev="xvda2" ino=42006369 scontext=system_u:system_r =system_u:system_r:httpd_t:s0 tclass=dir

type=SYSCALL msg=audit(1488923356.905:6384): arch=c000003e syscall=21 成功=no 終了=-13 a0=7f76f76122b0 a1=2 a2=0 a3=7f76e89d0 949 672 9 5 番号=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(なし) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj = system_u:system_r:httpd_t:s0キー=(空)

修正する

Restoreconコマンドを使用して権限を復元しました。しかし、それはうまくいきませんでした。私は仮想ホストを使用しており、すべてをデフォルト値のままにしました。

<VirtualHost *:80>
ServerName www.hometest.com
DocumentRoot /var/www/web1
</VirtualHost>

私のファイルに対するSeLinux権限は次のとおりです。

# ls -Z /var/www/web1
drwxr-x---. apache apache system_u:object_r:httpd_sys_content_t:s0 admin
drwxr-x---. apache apache system_u:object_r:httpd_sys_content_t:s0 core
drwxr-x---. apache apache system_u:object_r:httpd_sys_content_t:s0 download
drwxr-x---. apache apache system_u:object_r:httpd_sys_content_t:s0 extensions
drwxr-x---. apache apache system_u:object_r:httpd_sys_content_t:s0 image
-rwxr-x---. apache apache system_u:object_r:httpd_sys_content_t:s0 index.php
-rwxr-x---. apache apache system_u:object_r:httpd_sys_content_t:s0 license.txt
-rwxr-x---. apache root   system_u:object_r:httpd_sys_content_t:s0 list.bak
-rwxr-x---. apache apache system_u:object_r:httpd_sys_content_t:s0 php.ini
drwxr-x---. apache apache system_u:object_r:httpd_sys_content_t:s0 resources
-rwxr-x---. apache apache system_u:object_r:httpd_sys_content_t:s0 robots.txt
drwxr-x---. apache apache system_u:object_r:httpd_sys_content_t:s0 static_pages
drwxr-x---. apache apache system_u:object_r:httpd_sys_content_t:s0 storefront
drwxr-x---. apache apache system_u:object_r:httpd_sys_content_t:s0 system
-rwxr-x---. apache apache system_u:object_r:httpd_sys_content_t:s0 task.php
# ls -dZ web1/system/cache/
drwxr-x---. apache apache system_u:system_r:httpd_t:s0     web1/system/cache

どんな提案がありますか?

ベストアンサー1

httpd_sys_rw_content_t私の考えでは、あなたが書くファイル(キャッシュディレクトリ)に適用する必要があると思います。

http://www.serverlab.ca/tutorials/linux/web-servers-linux/configuring-selinux-policies-for-apache-web-servers/

努力する

# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/web1/system/cache(/.*)?"
# restorecon -Rv /var/www/web1/system/cache

おすすめ記事