Bug 927020

Summary: SELinux is preventing /usr/sbin/php-fpm from 'read' accesses on the file index.php.
Product: [Fedora] Fedora Reporter: Mikhail <mikhail.v.gavrilov>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 18CC: dominick.grift, dwalsh, mgrepl
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Unspecified   
Whiteboard: abrt_hash:0e63baf96292a310cd489b4c00371a87be43d1bc80ea09b111494c2506a7f6ae
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-03-25 11:39:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mikhail 2013-03-24 21:36:32 UTC
Description of problem:
SELinux is preventing /usr/sbin/php-fpm from 'read' accesses on the file index.php.

*****  Plugin catchall_boolean (89.3 confidence) suggests  *******************

If you want to allow httpd to read user content
Then you must tell SELinux about this by enabling the 'httpd_read_user_content' boolean.
You can read 'user_selinux' man page for more details.
Do
setsebool -P httpd_read_user_content 1

*****  Plugin catchall (11.6 confidence) suggests  ***************************

If you believe that php-fpm should be allowed read access on the index.php file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep php-fpm /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                system_u:system_r:httpd_t:s0
Target Context                unconfined_u:object_r:user_home_t:s0
Target Objects                index.php [ file ]
Source                        php-fpm
Source Path                   /usr/sbin/php-fpm
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           php-fpm-5.4.13-1.fc18.i686
Target RPM Packages           
Policy RPM                    selinux-policy-3.11.1-87.fc18.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 3.8.4-202.fc18.i686.PAE #1 SMP Thu
                              Mar 21 17:14:12 UTC 2013 i686 i686
Alert Count                   2
First Seen                    2013-03-25 03:33:50 YEKT
Last Seen                     2013-03-25 03:33:51 YEKT
Local ID                      6f2bcc0b-b007-403d-8e86-61610765436c

Raw Audit Messages
type=AVC msg=audit(1364160831.850:436): avc:  denied  { read } for  pid=5411 comm="php-fpm" name="index.php" dev="sda3" ino=1184535 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file


type=SYSCALL msg=audit(1364160831.850:436): arch=i386 syscall=open success=no exit=EACCES a0=b6a94f0c a1=0 a2=1b6 a3=4080 items=0 ppid=5409 pid=5411 auid=4294967295 uid=991 gid=989 euid=991 suid=991 fsuid=991 egid=989 sgid=989 fsgid=989 ses=4294967295 tty=(none) comm=php-fpm exe=/usr/sbin/php-fpm subj=system_u:system_r:httpd_t:s0 key=(null)

Hash: php-fpm,httpd_t,user_home_t,file,read

audit2allow

#============= httpd_t ==============
#!!!! This avc can be allowed using the boolean 'httpd_read_user_content'

allow httpd_t user_home_t:file read;

audit2allow -R
require {
	type httpd_t;
}

#============= httpd_t ==============
userdom_mmap_user_home_content_files(httpd_t)


Additional info:
hashmarkername: setroubleshoot
kernel:         3.8.4-202.fc18.i686.PAE
type:           libreport

Comment 1 Mikhail 2013-03-24 21:44:01 UTC
I am do
setsebool -P httpd_enable_homedirs 1
setsebool -P httpd_can_network_connect_db 1
but it not helps

Comment 2 Miroslav Grepl 2013-03-25 11:39:15 UTC
Where is index.php localted?

Try to run

# restorecon -R -v /var/www

Comment 3 Mikhail 2013-03-25 15:39:55 UTC
index.php localted here ~/www/bes/index.php

restorecon -R -v / help to solve this problem

Comment 4 Daniel Walsh 2013-03-25 17:45:08 UTC
 matchpathcon  ~/www/bes/index.php
/home/dwalsh/www/bes/index.php	unconfined_u:object_r:httpd_user_content_t:s0

Meaning this file Was labeled incorrectly.

Comment 5 Mikhail 2013-03-25 19:19:59 UTC
$ matchpathcon  ~/www/bes/index.php
/home/mikhail/www/bes/index.php	unconfined_u:object_r:httpd_user_content_t:s0