Bug 1018576 - Gallery2: SELinux is preventing httpd write access on /srv/gallery2/smarty/templates_c/%%626616196/matrix
Gallery2: SELinux is preventing httpd write access on /srv/gallery2/smarty/te...
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted (Show other bugs)
18
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Miroslav Grepl
Ben Levenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-13 10:18 EDT by Egon Kastelijn
Modified: 2014-02-05 18:14 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-02-05 18:14:51 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Egon Kastelijn 2013-10-13 10:18:43 EDT
Description of problem:
When SELinux is enforced on a system that runs Gallery2 under Apache httpd, an error is produced.
The error is produced by Gallery2 from this file /usr/share/gallery2/modules/core/classes/GalleryTemplate.class on line 288, because Gallery2 is unable to write its Smarty templates in the directory /srv/gallery2/smarty/templates_c/%%626616196/matrix


Version-Release number of selected component (if applicable):
gallery2: 2.3.2-7.fc18
httpd: 2.4.6-2.fc18
selinux-policy-targeted: 3.11.1-105.fc18

How reproducible:
Always

Steps to Reproduce:
1. setenforce 1
2. install gallery2 and start httpd 
3. 

Actual results:
Gallery2 produces an error because it is unable to write its Smarty templates.

Expected results:
A normal functioning Gallery2

Additional info:
type=AVC msg=audit(1381673149.787:4667): avc:  denied  { write } for  pid=17763 comm="/usr/sbin/httpd" name="matrix" dev="dm-1" ino=653319 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_sys_content_t:s0 tclass=dir
type=SYSCALL msg=audit(1381673149.787:4667): arch=c000003e syscall=21 success=no exit=-13 a0=7f6a34bc50e0 a1=2 a2=0 a3=7fffefdaa068 items=0 ppid=17756 pid=17763 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 ses=4294967295 tty=(none) comm="/usr/sbin/httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1381673149.791:4668): avc:  denied  { write } for  pid=17763 comm="/usr/sbin/httpd" name="matrix" dev="dm-1" ino=653319 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:httpd_sys_content_t:s0 tclass=dir
type=SYSCALL msg=audit(1381673149.791:4668): arch=c000003e syscall=21 success=no exit=-13 a0=7f6a34bfe180 a1=2 a2=0 a3=7fffefdaa068 items=0 ppid=17756 pid=17763 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 ses=4294967295 tty=(none) comm="/usr/sbin/httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)

A work-around is available.
Disable SELinux with this command:
setenforce 0
Comment 1 Miroslav Grepl 2013-10-14 08:39:47 EDT
Is /srv/gallery2/smarty/templates_c/%%626616196/matrix created on the fly?

# chcon -t httpd_sys_rw_content_t /srv/gallery2/smarty/templates_c/%%626616196/matrix

will fix it for now.
Comment 2 Egon Kastelijn 2013-10-14 13:00:16 EDT
Hi Miroslav,

The directory is not owner by an RPM package

# rpm -qf /srv
filesystem-3.1-2.fc18.x86_64
# rpm -qf /srv/gallery2
file /srv/gallery2 is not owned by any package
# rpm -qf /srv/gallery2/smarty
file /srv/gallery2/smarty is not owned by any package
# rpm -qf /srv/gallery2/smarty/templates_c
file /srv/gallery2/smarty/templates_c is not owned by any package
#

I think it is created by the gallery2 PHP code.
It uses Smarty templates which it compiles at runtime.
Therefor it needs write access to /srv/gallery2/smarty/templates_c

kind regards,

   Egon
Comment 3 Daniel Walsh 2013-10-16 15:05:56 EDT
# semanage fcontext -a -t httpd_sys_content_rw_t '/srv/gallery2/smarty(/.*)?'
# restorecon -R -v /srv/gallery2/

Should fix your problem.
Comment 4 Daniel Walsh 2013-10-16 15:10:14 EDT
# semanage fcontext -a -t httpd_sys_rw_content_t '/srv/gallery2/smarty(/.*)?'
# restorecon -R -v /srv/gallery2/

Lets add

+/srv/gallery2/smarty(/.*)?             gen_context(system_u:object_r:httpd_sys_rw_content_t,s0)
Comment 5 Fedora End Of Life 2013-12-21 10:37:42 EST
This message is a reminder that Fedora 18 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 18. 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 WONTFIX if it remains open with a Fedora 
'version' of '18'.

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 prior to Fedora 18's end of life.

Thank you for reporting this issue and we are sorry that we may not be 
able to fix it before Fedora 18 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 to Fedora 18's end of life.

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 2014-02-05 18:14:51 EST
Fedora 18 changed to end-of-life (EOL) status on 2014-01-14. Fedora 18 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.

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