Bug 743220

Summary: SELinux is preventing /usr/bin/python from 'name_connect' accesses on the tcp_socket port 3306.
Product: [Fedora] Fedora Reporter: reb <rbanks1959>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 15CC: dominick.grift, dwalsh, mgrepl
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard: setroubleshoot_trace_hash:e09d487305dc9d875083df47d06ce0948f000f7810938536437a21830ff8f987
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-10-04 10:05:45 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description reb 2011-10-04 09:46:12 UTC
SELinux is preventing /usr/bin/python from 'name_connect' accesses on the tcp_socket port 3306.

*****  Plugin catchall_boolean (47.5 confidence) suggests  *******************

If you want to allow HTTPD scripts and modules to connect to the network using any TCP port.
Then you must tell SELinux about this by enabling the 'httpd_can_network_connect' boolean.
Do
setsebool -P httpd_can_network_connect 1

*****  Plugin catchall_boolean (47.5 confidence) suggests  *******************

If you want to allow HTTPD scripts and modules to connect to databases over the network.
Then you must tell SELinux about this by enabling the 'httpd_can_network_connect_db' boolean.
Do
setsebool -P httpd_can_network_connect_db 1

*****  Plugin catchall (6.38 confidence) suggests  ***************************

If you believe that python should be allowed name_connect access on the port 3306 tcp_socket 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 python /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:mysqld_port_t:s0
Target Objects                port 3306 [ tcp_socket ]
Source                        python
Source Path                   /usr/bin/python
Port                          3306
Host                          (removed)
Source RPM Packages           python-2.7.1-7.fc15
Target RPM Packages           
Policy RPM                    selinux-policy-3.9.16-38.fc15
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 2.6.40.4-5.fc15.i686.PAE #1 SMP Tue Aug
                              30 14:43:52 UTC 2011 i686 i686
Alert Count                   9
First Seen                    Mon 03 Oct 2011 09:15:03 PM CDT
Last Seen                     Tue 04 Oct 2011 04:39:54 AM CDT
Local ID                      5e147ef3-0bcb-42fc-b24f-355de1b569ed

Raw Audit Messages
type=AVC msg=audit(1317721194.155:62): avc:  denied  { name_connect } for  pid=2431 comm="python" dest=3306 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:mysqld_port_t:s0 tclass=tcp_socket


type=SYSCALL msg=audit(1317721194.155:62): arch=i386 syscall=socketcall success=no exit=EACCES a0=3 a1=bfa2a0a0 a2=4c1f34dc a3=0 items=0 ppid=1224 pid=2431 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm=python exe=/usr/bin/python subj=system_u:system_r:httpd_t:s0 key=(null)

Hash: python,httpd_t,mysqld_port_t,tcp_socket,name_connect

audit2allow

#============= httpd_t ==============
#!!!! This avc is allowed in the current policy

allow httpd_t mysqld_port_t:tcp_socket name_connect;

audit2allow -R

#============= httpd_t ==============
#!!!! This avc is allowed in the current policy

allow httpd_t mysqld_port_t:tcp_socket name_connect;

Comment 1 Miroslav Grepl 2011-10-04 10:05:45 UTC
setsebool -P httpd_can_network_connect_db

will allow it which selaert tells you.


*****  Plugin catchall_boolean (47.5 confidence) suggests  *******************

If you want to allow HTTPD scripts and modules to connect to databases over the
network.
Then you must tell SELinux about this by enabling the
'httpd_can_network_connect_db' boolean.
Do
setsebool -P httpd_can_network_connect_db 1