Bug 799221 - Allow PostgreSQL to talk to self over dblink -- AVC denial
Allow PostgreSQL to talk to self over dblink -- AVC denial
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Miroslav Grepl
Ben Levenson
Depends On:
  Show dependency treegraph
Reported: 2012-03-02 02:22 EST by Jan Pazdziora
Modified: 2012-03-23 20:36 EDT (History)
1 user (show)

See Also:
Fixed In Version: selinux-policy-3.10.0-80.fc16
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-03-23 20:36:26 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jan Pazdziora 2012-03-02 02:22:16 EST
Description of problem:

When dblink is used with no host specified, PostgreSQL server tries to connect to itself over the socket in /tmp. It leads to AVC denial.

Version-Release number of selected component (if applicable):

# rpm -q selinux-policy postgresql-server postgresql-contrib

How reproducible:


Steps to Reproduce:
1. # yum install -y postgresql-server postgresql-contrib
2. # postgresql-setup initdb
3. # service postgresql start
4. # su - postgres
5. $ psql
6. postgres=# create extension dblink;
7. postgres=# select * from dblink('dbname=' || current_database(), 'select 1') as x(i numeric);
8. # grep AVC /var/log/audit/audit.log
Actual results:

postgres=# select * from dblink('dbname=' || current_database(), 'select 1') as x(i numeric);;
ERROR:  could not establish connection
DETAIL:  could not connect to server: Permission denied
	Is the server running locally and accepting
	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

type=AVC msg=audit(1330672651.814:210): avc:  denied  { connectto } for  pid=7075 comm="postgres" path="/tmp/.s.PGSQL.5432" scontext=system_u:system_r:postgresql_t:s0 tcontext=system_u:system_r:postgresql_t:s0 tclass=unix_stream_socket

Expected results:

postgres=# select * from dblink('dbname=' || current_database(), 'select 1') as x(i numeric);
(1 row)

which you get when you switch to permissive, and no AVC denial.

Additional info:

In Spacewalk SELinux policy, adding

                type postgresql_t;
        allow postgresql_t self:unix_stream_socket { connectto };

fixed the problem for us on RHEL 5, 6, Fedora 15, 16.
Comment 1 Miroslav Grepl 2012-03-02 03:40:13 EST
commit 659cb46cd208fa1750ea930847bf75dbb28355ec
Author: Miroslav Grepl <mgrepl@redhat.com>
Date:   Fri Mar 2 10:33:24 2012 +0000

    Make PostgreSQL working when dblink is used with no host specified

Also added to RHEL.
Comment 2 Fedora Update System 2012-03-13 08:25:13 EDT
selinux-policy-3.10.0-80.fc16 has been submitted as an update for Fedora 16.
Comment 3 Fedora Update System 2012-03-20 22:24:18 EDT
Package selinux-policy-3.10.0-80.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing selinux-policy-3.10.0-80.fc16'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).
Comment 4 Fedora Update System 2012-03-23 20:36:26 EDT
selinux-policy-3.10.0-80.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.

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