Bug 722536 - selinux policy does not permit rsyslog(-mysql) to access the mysql database
selinux policy does not permit rsyslog(-mysql) to access the mysql database
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: selinux-policy (Show other bugs)
5.6
All Linux
medium Severity medium
: rc
: ---
Assigned To: Miroslav Grepl
Karel Srot
:
: 727550 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-07-15 11:31 EDT by Erik M Jacobs
Modified: 2012-10-11 04:06 EDT (History)
4 users (show)

See Also:
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 00:47:40 EST
Type: ---
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 Erik M Jacobs 2011-07-15 11:31:23 EDT
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 11:35:01 EDT
We have also this in RHEL6

optional_policy(`
    mysql_stream_connect(syslogd_t)
')
Comment 2 Daniel Walsh 2011-07-15 13:43:11 EDT
Looks good to me.
Comment 3 Erik M Jacobs 2011-07-22 14:17:13 EDT
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 08:16:47 EDT
Yes it will covered by 

optional_policy(`
    mysql_stream_connect(syslogd_t)
')
Comment 5 Erik M Jacobs 2011-07-25 08:47:07 EDT
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 08:11:31 EDT
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 09:21:45 EDT
*** Bug 727550 has been marked as a duplicate of this bug. ***
Comment 9 Miroslav Grepl 2011-09-29 07:29:44 EDT
Fixed in selinux-policy-2.4.6-317.el5
Comment 13 errata-xmlrpc 2012-02-21 00:47:40 EST
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

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