Bug 1034298 - SELinux is preventing /usr/sbin/php-fpm from 'write' accesses on the directory tmp.
Summary: SELinux is preventing /usr/sbin/php-fpm from 'write' accesses on the director...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 20
Hardware: i686
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: abrt_hash:7f44e3a73d3922bdac3e4cd2fee...
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-25 14:48 UTC by Mikhail
Modified: 2013-11-25 15:39 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-11-25 15:39:59 UTC
Type: ---


Attachments (Terms of Use)

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


Note You need to log in before you can comment on or make changes to this bug.