Bug 666103

Summary: SELinux is preventing /var/www/cgi-bin/cachemgr.cgi from 'getattr' accesses on the file /etc/squid/cachemgr.conf.
Product: [Fedora] Fedora Reporter: Nivag <gavinflower>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 14CC: dwalsh, gavinflower, mgrepl
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard: setroubleshoot_trace_hash:04be3ec727773b66ec642172df2359757273d5cea81ba1f7227b3ae1826a3ad3
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-12-30 14:00:49 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 Nivag 2010-12-29 01:51:03 UTC
Suggested fix generates errors.

SELinux is preventing /var/www/cgi-bin/cachemgr.cgi from 'getattr' accesses on the file /etc/squid/cachemgr.conf.

*****  Plugin catchall (100. confidence) suggests  ***************************

If you believe that cachemgr.cgi should be allowed getattr access on the cachemgr.conf file 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 /var/www/cgi-bin/cachemgr.cgi /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                system_u:system_r:httpd_sys_script_t:s0
Target Context                system_u:object_r:squid_conf_t:s0
Target Objects                /etc/squid/cachemgr.conf [ file ]
Source                        cachemgr.cgi
Source Path                   /var/www/cgi-bin/cachemgr.cgi
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           squid-3.1.9-3.fc14
Policy RPM                    selinux-policy-3.9.7-19.fc14
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Permissive
Host Name                     (removed)
Platform                      Linux (removed) 2.6.35.10-74.fc14.x86_64 #1 SMP Thu
                              Dec 23 16:04:50 UTC 2010 x86_64 x86_64
Alert Count                   1
First Seen                    Wed 29 Dec 2010 02:37:39 PM NZDT
Last Seen                     Wed 29 Dec 2010 02:37:39 PM NZDT
Local ID                      ed8723f4-a48c-4f5b-aeff-b7e2049d881c

Raw Audit Messages
type=AVC msg=audit(1293586659.244:48852): avc:  denied  { getattr } for  pid=7217 comm="cachemgr.cgi" path="/etc/squid/cachemgr.conf" dev=md2 ino=42731333 scontext=system_u:system_r:httpd_sys_script_t:s0 tcontext=system_u:object_r:squid_conf_t:s0 tclass=file

cachemgr.cgi,httpd_sys_script_t,squid_conf_t,file,getattr
type=SYSCALL msg=audit(1293586659.244:48852): arch=x86_64 syscall=fstat success=yes exit=0 a0=3 a1=7fff97c7bc10 a2=7fff97c7bc10 a3=7fff97c7baf0 items=0 ppid=2633 pid=7217 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm=cachemgr.cgi exe=/var/www/cgi-bin/cachemgr.cgi subj=system_u:system_r:httpd_sys_script_t:s0 key=(null)
cachemgr.cgi,httpd_sys_script_t,squid_conf_t,file,getattr

#============= httpd_sys_script_t ==============
allow httpd_sys_script_t squid_conf_t:file getattr;

Comment 1 Daniel Walsh 2010-12-30 13:57:49 UTC
*** Bug 666104 has been marked as a duplicate of this bug. ***

Comment 2 Daniel Walsh 2010-12-30 14:00:49 UTC
/usr/lib/squid/cachemgr\.cgi -- gen_context(system_u:object_r:httpd_squid_script_exec_t,s0)
/usr/lib64/squid/cachemgr\.cgi -- gen_context(system_u:object_r:httpd_squid_script_exec_t,s0)

In their usual location they are labeled httpd_squid_script_exec_t, why are these scripts located in a different directory.

You can fix the labeling with the following commands.

# semanage fcontext -a -t httpd_squid_script_exec_t /var/www/cgi-bin/cachemgr.cgi
# restorecon -v /var/www/cgi-bin/cachemgr.cgi

If you believe this should be the default or some package installs them there, please comment in this bug.

Comment 3 Daniel Walsh 2010-12-30 14:04:43 UTC
*** Bug 665681 has been marked as a duplicate of this bug. ***

Comment 4 Nivag 2010-12-30 15:30:59 UTC
(In reply to comment #2)
/usr/lib/squid/cachemgr\.cgi --
[...]

I have not changed the directory for these scripts, they are as the package manager placed them, so the SELinux stuff should have been set correctly by default.  So I think it is a valid bug.

# semanage fcontext -a -t httpd_squid_script_exec_t
/usr/sbin/semanage: bad option
# 

The suggested fix fails.

Comment 5 Miroslav Grepl 2011-01-03 13:58:46 UTC
You need to use whole suggested command

# semanage fcontext -a -t httpd_squid_script_exec_t /var/www/cgi-bin/cachemgr.cgi

Comment 6 Nivag 2011-01-03 20:34:54 UTC
Sorry, I had not picked up that the second line was actually a continuation of the first...

Obvious in hindsight!