Bug 695698

Summary: Wordpress needs a bit of SELinux love to run in the Enforcing mode
Product: Red Hat Enterprise Linux 6 Reporter: Matěj Cepl <mcepl>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED ERRATA QA Contact: Michal Trunecka <mtruneck>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 6.3CC: dwalsh, ebenes, gwync, mgrepl, mmalik, mtruneck, nobody, wendellcraigbaker
Target Milestone: rcKeywords: Reopened, SELinux
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.7.19-156.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 08:34:25 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 Matěj Cepl 2011-04-12 13:10:48 UTC
Description of problem:
In order to make wordpress as packaged for RHEL 6 (in EPEL) I needed to do these little changes.

Special module mywordpress:
[root@luther selinux]# cat mywordpress.te

module mywordpress 1.0;

require {
	type httpd_t;
	type httpd_sys_script_exec_t;
	class lnk_file { read getattr };
}

#============= httpd_t ==============
allow httpd_t httpd_sys_script_exec_t:lnk_file { read getattr };

(/etc/wordpress/wp-config.php is a symlink to /usr/share/wordpress/wp-config.php).

Also I added these fcontext patterns:

[root@luther selinux]# semanage fcontext -l -C
SELinux fcontext                                   type               Context

/usr/share/wordpress/.*\.php$                      all files          system_u:object_r:httpd_sys_script_exec_t:s0 

SELinux fcontext Equivalence 

/usr/share/wordpress/wp-content/upgrade(/.*)? = /usr/share/wordpress/wp-content/uploads/
[root@luther selinux]# 



Version-Release number of selected component (if applicable):
wordpress-3.1-1.el6.noarch
selinux-policy-3.7.19-54.el6_0.5.noarch

Comment 1 Miroslav Grepl 2011-08-22 06:03:16 UTC
I added changes to the latest RHEL6.2 policy.

Comment 2 Matěj Cepl 2012-04-23 12:56:38 UTC
Not good. After removing all my local fixes, I still have

[root@luther ~]# restorecon -v -R /usr/share/wordpress/
restorecon reset /usr/share/wordpress/wp-config.php context system_u:object_r:httpd_sys_script_exec_t:s0->system_u:object_r:usr_t:s0
restorecon reset /usr/share/wordpress/wp-content/plugins/akismet/index.php context unconfined_u:object_r:usr_t:s0->unconfined_u:object_r:httpd_sys_script_exec_t:s0
restorecon reset /usr/share/wordpress/wp-content/plugins/browserid/browserid.php context system_u:object_r:usr_t:s0->system_u:object_r:httpd_sys_script_exec_t:s0
restorecon reset /usr/share/wordpress/wp-includes/class-simplepie.php context system_u:object_r:httpd_sys_script_exec_t:s0->system_u:object_r:usr_t:s0
[root@luther ~]#

Comment 3 Matěj Cepl 2012-04-23 13:04:26 UTC
Specifically I am missing

[root@luther ~]# semanage fcontext -a -t httpd_sys_script_exec_t '/usr/share/wordpress/.*\.php$'
[root@luther ~]# restorecon -v -R /usr/share/wordpress/restorecon reset /usr/share/wordpress/wp-config.php context system_u:object_r:usr_t:s0->system_u:object_r:httpd_sys_script_exec_t:s0
restorecon reset /usr/share/wordpress/wp-includes/class-simplepie.php context system_u:object_r:usr_t:s0->system_u:object_r:httpd_sys_script_exec_t:s0
[root@luther ~]#

Comment 4 Miroslav Grepl 2012-04-23 13:09:12 UTC
$ rpm -q selinux-policy

Comment 6 Matěj Cepl 2012-04-23 13:16:04 UTC
wycliff:~ $ ssh luther rpm -q selinux-policy
selinux-policy-3.7.19-145.el6.noarch
wycliff:~ $

Comment 7 Miroslav Grepl 2012-04-24 10:49:52 UTC
[root@localhost ~]# matchpathcon /usr/share/wordpress/wp-config.php
/usr/share/wordpress/wp-config.php	system_u:object_r:httpd_sys_script_exec_t:s0

[root@localhost ~]# matchpathcon /usr/share/wordpress/wp-ine.phes/class-simplepi 
/usr/share/wordpress/wp-includes/class-simplepie.ph	system_u:object_r:usr_t:s0


I am fixing the second path.

Comment 8 Matěj Cepl 2012-04-24 13:34:13 UTC
Thank you

Comment 15 errata-xmlrpc 2013-02-21 08:34:25 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-0314.html