Bug 1034298

Summary: SELinux is preventing /usr/sbin/php-fpm from 'write' accesses on the directory tmp.
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: 20CC: dominick.grift, dwalsh, lvrabec, mgrepl
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Unspecified   
Whiteboard: abrt_hash:7f44e3a73d3922bdac3e4cd2fee5930e0560f0917c615c8f9ee90a1abd2ba21e
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-11-25 15:39:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Mikhail 2013-11-25 14:48:00 UTC
Description of problem:
SELinux is preventing /usr/sbin/php-fpm from 'write' accesses on the directory tmp.

*****  Plugin httpd_write_content (92.2 confidence) suggests   ***************

If you want to allow php-fpm to have write access on the tmp directory
Then you need to change the label on 'tmp'
Do
# semanage fcontext -a -t httpd_sys_rw_content_t 'tmp'
# restorecon -v 'tmp'

*****  Plugin catchall_boolean (7.83 confidence) suggests   ******************

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

*****  Plugin catchall (1.41 confidence) suggests   **************************

If you believe that php-fpm should be allowed write access on the tmp directory 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:httpd_sys_content_t:s0
Target Objects                tmp [ dir ]
Source                        php-fpm
Source Path                   /usr/sbin/php-fpm
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           php-fpm-5.5.6-1.fc20.i686
Target RPM Packages           filesystem-3.2-19.fc20.i686
Policy RPM                    selinux-policy-3.12.1-90.fc20.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 3.12.0-2.fc21.i686+PAE #1 SMP Sat
                              Nov 9 21:31:51 UTC 2013 i686 i686
Alert Count                   12
First Seen                    2013-11-25 20:38:11 YEKT
Last Seen                     2013-11-25 20:40:00 YEKT
Local ID                      3f852780-e6b0-4b4e-aa35-9309bebfae87

Raw Audit Messages
type=AVC msg=audit(1385390400.635:790): avc:  denied  { write } for  pid=13522 comm="php-fpm" name="tmp" dev="sda1" ino=665683 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:httpd_sys_content_t:s0 tclass=dir


type=SYSCALL msg=audit(1385390400.635:790): arch=i386 syscall=open success=no exit=EACCES a0=bfced01c a1=42 a2=180 a3=b0e9b370 items=0 ppid=13505 pid=13522 auid=4294967295 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 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,httpd_sys_content_t,dir,write

Additional info:
reporter:       libreport-2.1.9
hashmarkername: setroubleshoot
kernel:         3.12.0-2.fc21.i686+PAE
type:           libreport

Comment 1 Daniel Walsh 2013-11-25 15:02:06 UTC
Did you change the label of /tmp or /var/tmp to httpd_sys_content_t?

Comment 2 Mikhail 2013-11-25 15:16:02 UTC
no, but I try to move php sessions to /var/www/mikhail/tmp

php_value[session.save_path]    = /var/www/mikhail/tmp
php_value[soap.wsdl_cache_dir]  = /var/www/mikhail/tmp

Comment 3 Daniel Walsh 2013-11-25 15:39:59 UTC
# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/mikhail/tmp(/.*)?'
# restorecon -R -v /var/www/mikhail