SELinux Impede Arquivos de Gravação httpd

1

Recentemente, configurei um site no RHEL7. O SELinux está no modo Imposição. No entanto, seja qual for a forma como eu ajustar o contexto, sempre impede httpd de escrever. Aqui está o audit.log:

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

type=SYSCALL msg=audit(1488922911.038:6188): arch=c000003e syscall=21 success=no exit=-13 a0=7f76f76142c0 a1=2 a2=0 a3=7f76e89b0ec0 items=0 ppid=740 pid=11773 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)

Parece que os contextos de origem e destino são incompatíveis. Mas, ainda assim, não funcionará depois que eu for unificado.

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

type=SYSCALL msg=audit(1488923356.905:6384): arch=c000003e syscall=21 success=no exit=-13 a0=7f76f76122b0 a1=2 a2=0 a3=7f76e89b0ec0 items=0 ppid=740 pid=11709 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)

Atualizar

Eu fiz uma restauração de permissão usando o comando restorecon. Mas não funcionou. Estou usando o host virtual, deixo tudo padrão:

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

Aqui estão as permissões do SeLinux dos meus arquivos.

# 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

Alguma sugestão?

    
por NeilWang 07.03.2017 / 22:53

1 resposta

1

Acho que você precisa aplicar httpd_sys_rw_content_t aos arquivos que são gravados em (o diretório de cache).

link

Tente

# semanage fcontext -a httpd_sys_rw_content_t "/var/www/web1/system/cache(/.*)?"
# restorecon -Rv /var/www/web1/system/cache
    
por 07.03.2017 / 23:51