httpd, vsftpd e o irritante selinux

3

Eu tenho um CentOS 6.3 instalado com httpd em execução e vsftpd , mas não consigo equilibrar a permissão entre o usuário capaz de fazer o upload pelo ftp e o funcionamento de seu website.

O que eu faço:

I create a user with their home directory as '/home/username' 
I create a sub folder called 'html' for their website
I chown their directory 'chown -R username:apache /home/username'
I chmod their directory 'chmod -R 750 /home/username'
I chcon their directory 'chcon -R -t httpd_sys_rw_content_t /home/username' 

e seu site carrega muito bem, mas eles não conseguem fazer o ftp, mas se eu fizer o seguinte, eles poderão fazer o ftp, mas o site deles não carrega:

chcon -R -t user_home_dir_t /home/username

Se eu desabilitar o selinux, o usuário poderá fazer o ftp e o site ser carregado. então qual é a resposta para manter o selinux?

EDITAR

Curiosamente, segui os comentários de Michael abaixo e apenas corri restorecon e funcionou. Mas então eu reiniciei e agora vsftp está bem e httpd pode ler bem, mas o httpd não pode escrever.

Esta é minha ls -Z response

drwxr-x---. itmanx apache unconfined_u:object_r:user_home_dir_t:s0 itmanx

Estes são os conjuntos booleanos

allow_console_login                         on
allow_daemons_dump_core                     on
allow_daemons_use_tty                       on
allow_domain_fd_use                         on
allow_execmem                               on
allow_execmod                               on
allow_execstack                             on
allow_gssd_read_tmp                         on
allow_kerberos                              on
allow_mount_anyfile                         on
allow_nsplugin_execmem                      on
allow_postfix_local_write_mail_spool        on
allow_staff_exec_content                    on
allow_sysadm_exec_content                   on
allow_user_exec_content                     on
allow_zebra_write_config                    on
ftp_home_dir                                on
httpd_builtin_scripting                     on
httpd_can_network_connect_db                on
httpd_can_sendmail                          on
httpd_dbus_avahi                            on
httpd_enable_cgi                            on
httpd_enable_homedirs                       on
httpd_tty_comm                              on
httpd_unified                               on
init_upstart                                on
nscd_use_shm                                on
nsplugin_can_network                        on
openvpn_enable_homedirs                     on
privoxy_connect_any                         on
qemu_full_network                           on
qemu_use_cifs                               on
qemu_use_nfs                                on
qemu_use_usb                                on
sepgsql_enable_users_ddl                    on
sepgsql_unconfined_dbadm                    on
spamd_enable_home_dirs                      on
squid_connect_any                           on
unconfined_login                            on
use_nfs_home_dirs                           on
user_direct_dri                             on
user_ping                                   on
user_rw_noexattrfile                        on
user_setrlimit                              on
virt_use_sysfs                              on
virt_use_usb                                on
xguest_connect_network                      on
xguest_mount_media                          on
xguest_use_bluetooth                        on

AUDIT LOG

type=SYSCALL msg=audit(1350111166.254:3204): arch=40000003 syscall=4 success=yes exit=2 a0=1 a1=b778e000 a2=2 a3=2 items=0 ppid=4114 pid=4119 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=96 comm="bash" exe="/bin/bash" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)
type=AVC msg=audit(1350111180.584:3205): avc:  denied  { write } for  pid=2376 comm="httpd" name="cache" dev=dm-2 ino=11012856 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.584:3205): arch=40000003 syscall=10 success=no exit=-13 a0=b5ef0e64 a1=3234 a2=b776cad8 a3=b5ef0e64 items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1350111180.584:3206): avc:  denied  { write } for  pid=2376 comm="httpd" name="logs" dev=dm-2 ino=11012903 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.584:3206): arch=40000003 syscall=5 success=no exit=-13 a0=b5e6fcfc a1=442 a2=1b6 a3=b5e6fcfc items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1350111180.586:3207): avc:  denied  { write } for  pid=2376 comm="httpd" name="cache" dev=dm-2 ino=11012856 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.586:3207): arch=40000003 syscall=10 success=no exit=-13 a0=b5ef0e64 a1=3234 a2=b776cad8 a3=b5ef0e64 items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1350111180.586:3208): avc:  denied  { write } for  pid=2376 comm="httpd" name="logs" dev=dm-2 ino=11012903 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.586:3208): arch=40000003 syscall=5 success=no exit=-13 a0=b5e6b9a0 a1=442 a2=1b6 a3=b5e6b9a0 items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1350111180.586:3209): avc:  denied  { write } for  pid=2376 comm="httpd" name="cache" dev=dm-2 ino=11012856 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.586:3209): arch=40000003 syscall=5 success=no exit=-13 a0=b5f05f5c a1=241 a2=1b6 a3=b5f05f5c items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1350111180.587:3210): avc:  denied  { write } for  pid=2376 comm="httpd" name="logs" dev=dm-2 ino=11012903 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.587:3210): arch=40000003 syscall=5 success=no exit=-13 a0=b5e6d9d0 a1=442 a2=1b6 a3=b5e6d9d0 items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1350111180.587:3211): avc:  denied  { write } for  pid=2376 comm="httpd" name="logs" dev=dm-2 ino=11012903 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.587:3211): arch=40000003 syscall=5 success=no exit=-13 a0=b5e6d9d0 a1=442 a2=1b6 a3=b5e6d9d0 items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1350111180.587:3212): avc:  denied  { write } for  pid=2376 comm="httpd" name="logs" dev=dm-2 ino=11012903 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.587:3212): arch=40000003 syscall=5 success=no exit=-13 a0=b5e6d9d0 a1=442 a2=1b6 a3=b5e6d9d0 items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1350111180.588:3213): avc:  denied  { write } for  pid=2376 comm="httpd" name="cache" dev=dm-2 ino=11012856 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.588:3213): arch=40000003 syscall=10 success=no exit=-13 a0=b5ef0e64 a1=3430 a2=b776cad8 a3=b5ef0e64 items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1350111180.588:3214): avc:  denied  { write } for  pid=2376 comm="httpd" name="logs" dev=dm-2 ino=11012903 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.588:3214): arch=40000003 syscall=5 success=no exit=-13 a0=b5e6d9d0 a1=442 a2=1b6 a3=b5e6d9d0 items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1350111180.592:3215): avc:  denied  { write } for  pid=2376 comm="httpd" name="cache" dev=dm-2 ino=11012856 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.592:3215): arch=40000003 syscall=10 success=no exit=-13 a0=b5ef0e64 a1=3234 a2=b776cad8 a3=b5ef0e64 items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1350111180.592:3216): avc:  denied  { write } for  pid=2376 comm="httpd" name="logs" dev=dm-2 ino=11012903 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.592:3216): arch=40000003 syscall=5 success=no exit=-13 a0=b5e6af14 a1=442 a2=1b6 a3=b5e6af14 items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1350111180.593:3217): avc:  denied  { write } for  pid=2376 comm="httpd" name="cache" dev=dm-2 ino=11012856 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.593:3217): arch=40000003 syscall=10 success=no exit=-13 a0=b5ef0e64 a1=3234 a2=b776cad8 a3=b5ef0e64 items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1350111180.593:3218): avc:  denied  { write } for  pid=2376 comm="httpd" name="logs" dev=dm-2 ino=11012903 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.593:3218): arch=40000003 syscall=5 success=no exit=-13 a0=b5e6aaf0 a1=442 a2=1b6 a3=b5e6aaf0 items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1350111180.594:3219): avc:  denied  { write } for  pid=2376 comm="httpd" name="cache" dev=dm-2 ino=11012856 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1350111180.594:3219): arch=40000003 syscall=5 success=no exit=-13 a0=b5f05f5c a1=241 a2=1b6 a3=b5f05f5c items=0 ppid=2372 pid=2376 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=2 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
    
por Christian 12.10.2012 / 16:30

1 resposta

2

Nenhuma das opções acima.

Você defina os valores booleanos do SELinux que permitem que o httpd e o vsftpd acessem os diretórios home dos usuários.

setsebool -P httpd_enable_homedirs on
setsebool -P ftp_home_dir on

E depois de toda a sua brincadeira, você provavelmente deve corrigir os contextos de segurança confusos:

restorecon -r -v /home
    
por 12.10.2012 / 19:00