Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 722536

Summary: selinux policy does not permit rsyslog(-mysql) to access the mysql database
Product: Red Hat Enterprise Linux 5 Reporter: Erik M Jacobs <ejacobs>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED ERRATA QA Contact: Karel Srot <ksrot>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.6CC: dwalsh, ejacobs, ksrot, mmalik
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-2.4.6-317.el5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-21 05:47:40 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 Erik M Jacobs 2011-07-15 15:31:23 UTC
Description of problem:
rsyslog-mysql provides for the ability for rsyslog to put log information into a mysql database.  The current selinux-policy (2.4.6-300.el5_6.1) does not appear to provide the correct access

Version-Release number of selected component (if applicable):
2.4.6-300.el5_6.1

How reproducible:
100%

Steps to Reproduce:
1. install rsyslog/rsyslog-mysql/mysql
2. set everything up
3. run rsyslog/mysql
  
Actual results:
When rsyslog attempts to connect to the database, you get an AVC denial.

Expected results:
rsyslog should be able to read the database

Additional info:
type=AVC msg=audit(1310742955.892:196139): avc:  denied  { search } for  pid=32754 comm="rsyslogd" name="mysql" dev=md1 ino=331710489 scontext=user_u:system_r:syslogd_t:s0 tcontext=system_u:object_r:mysqld_db_t:s0 tclass=dir

#============= syslogd_t ==============
allow syslogd_t mysqld_db_t:dir search;

Comment 1 Miroslav Grepl 2011-07-15 15:35:01 UTC
We have also this in RHEL6

optional_policy(`
    mysql_stream_connect(syslogd_t)
')

Comment 2 Daniel Walsh 2011-07-15 17:43:11 UTC
Looks good to me.

Comment 3 Erik M Jacobs 2011-07-22 18:17:13 UTC
Here's what I ended up with:

require {
	type syslogd_t;
	type mysqld_t;
	type mysqld_var_run_t;
	type mysqld_db_t;
	class sock_file write;
	class unix_stream_socket connectto;
	class dir search;
}

#============= syslogd_t ==============
allow syslogd_t mysqld_db_t:dir search;
allow syslogd_t mysqld_t:unix_stream_socket connectto;
allow syslogd_t mysqld_var_run_t:sock_file write;

This appears to grant sufficient access for rsyslog to write into the database.

Comment 4 Miroslav Grepl 2011-07-25 12:16:47 UTC
Yes it will covered by 

optional_policy(`
    mysql_stream_connect(syslogd_t)
')

Comment 5 Erik M Jacobs 2011-07-25 12:47:07 UTC
OK -- guess I don't understand enough about how SELinux works.  Suppose that's all good, then! Any ETA?

Comment 6 Miroslav Grepl 2011-07-28 12:11:31 UTC
Well, this is for RHEL5.8 which I guess is in planning. If I get all acks I will do a build.

Comment 7 Karel Srot 2011-08-23 13:21:45 UTC
*** Bug 727550 has been marked as a duplicate of this bug. ***

Comment 9 Miroslav Grepl 2011-09-29 11:29:44 UTC
Fixed in selinux-policy-2.4.6-317.el5

Comment 13 errata-xmlrpc 2012-02-21 05:47:40 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-2012-0158.html