Bug 1136092 - SELinux is preventing php-fpm from 'create' accesses on the directory gavrilovmv.
Summary: SELinux is preventing php-fpm from 'create' accesses on the directory gavrilo...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 25
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Lukas Vrabec
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: abrt_hash:83bb3d006793f056e4afff66fe4...
: 1380937 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-09-01 16:41 UTC by Mikhail
Modified: 2016-10-03 10:57 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2015-12-02 03:40:24 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Mikhail 2014-09-01 16:41:41 UTC
Description of problem:
Very strange php can create and write files, but can't create directories.... Why?
SELinux is preventing php-fpm from 'create' accesses on the directory gavrilovmv.

*****  Plugin catchall_boolean (89.3 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 (11.6 confidence) suggests   **************************

If you believe that php-fpm should be allowed create access on the gavrilovmv 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                system_u:object_r:httpd_user_ra_content_t:s0
Target Objects                gavrilovmv [ dir ]
Source                        php-fpm
Source Path                   php-fpm
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-77.fc21.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 3.16.1-301.fc21.x86_64 #1 SMP Mon
                              Aug 25 13:06:39 UTC 2014 x86_64 x86_64
Alert Count                   8
First Seen                    2014-09-01 22:39:08 YEKT
Last Seen                     2014-09-01 22:39:08 YEKT
Local ID                      31b5708d-1463-42fe-a85e-35101245fde6

Raw Audit Messages
type=AVC msg=audit(1409589548.525:2303): avc:  denied  { create } for  pid=10238 comm="php-fpm" name="gavrilovmv" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_user_ra_content_t:s0 tclass=dir permissive=0


Hash: php-fpm,httpd_t,httpd_user_ra_content_t,dir,create

Version-Release number of selected component:
selinux-policy-3.13.1-77.fc21.noarch

Additional info:
reporter:       libreport-2.2.3
hashmarkername: setroubleshoot
kernel:         3.16.1-301.fc21.x86_64
type:           libreport

Potential duplicate: bug 927371

Comment 1 Daniel Walsh 2014-09-03 10:05:34 UTC
You want to allow apache to create directories in a label that it is only allowed to append to?

Comment 2 Mikhail 2014-09-03 14:30:34 UTC
(In reply to Daniel Walsh from comment #1)
> You want to allow apache to create directories in a label that it is only
> allowed to append to?

yes.

$ ls -Z ~/www/bpl-syrena/logs/
-rw-r--r--. mikhail mikhail system_u:object_r:httpd_user_ra_content_t:s0 boroda.log
-rw-r--r--. mikhail mikhail system_u:object_r:httpd_user_ra_content_t:s0 compositor.log
-rw-r--r--. mikhail mikhail system_u:object_r:httpd_user_ra_content_t:s0 error.log
-rw-r--r--. mikhail mikhail system_u:object_r:httpd_user_ra_content_t:s0 get_auth_source.log
-rw-r--r--. mikhail mikhail system_u:object_r:httpd_user_ra_content_t:s0 run.log
-rw-r--r--. mikhail mikhail system_u:object_r:httpd_user_ra_content_t:s0 sql.log

$ ls -Zd ~/www/bpl-syrena/logs
drwxr-xr-x. mikhail mikhail unconfined_u:object_r:httpd_user_ra_content_t:s0 /home/mikhail/www/bpl-syrena/logs


I think if directory have object_r:httpd_user_ra_content_t and allow write and append files, why do we restrict recursive directory creation in this directory?

Comment 3 Lukas Vrabec 2014-12-11 17:28:11 UTC
Why you need this?

Comment 4 Mikhail 2014-12-11 18:22:02 UTC
(In reply to Lukas Vrabec from comment #3)
> Why you need this?

Very convenient to store logs for each user in a separate folder.

And I think we can found find many cases when php application needed create folders.

For example optimization storing uploaded files.

Comment 5 Fedora End Of Life 2015-11-04 14:44:32 UTC
This message is a reminder that Fedora 21 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 21. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '21'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 21 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 6 Fedora End Of Life 2015-12-02 03:40:27 UTC
Fedora 21 changed to end-of-life (EOL) status on 2015-12-01. Fedora 21 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 7 Lukas Vrabec 2016-10-03 10:57:03 UTC
You reported this issue also on F25. Closing this issue as WONTFIX. You can create own module to fix this issue, more info: 
https://lvrabec-selinux.rhcloud.com/2016/09/19/creating-local-module-quickly-in-cil/

Comment 8 Lukas Vrabec 2016-10-03 10:57:11 UTC
*** Bug 1380937 has been marked as a duplicate of this bug. ***


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