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 selinux-policy-3.10.0-75.fc16.noarch postgresql-server-9.1.2-2.fc16.i686 postgresql-contrib-9.1.2-2.fc16.i686 How reproducible: Deterministic. 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); i --- 1 (1 row) which you get when you switch to permissive, and no AVC denial. Additional info: In Spacewalk SELinux policy, adding optional_policy(` gen_require(` type postgresql_t; ') allow postgresql_t self:unix_stream_socket { connectto }; ') fixed the problem for us on RHEL 5, 6, Fedora 15, 16.
commit 659cb46cd208fa1750ea930847bf75dbb28355ec Author: Miroslav Grepl <mgrepl> Date: Fri Mar 2 10:33:24 2012 +0000 Make PostgreSQL working when dblink is used with no host specified Also added to RHEL.
selinux-policy-3.10.0-80.fc16 has been submitted as an update for Fedora 16. https://admin.fedoraproject.org/updates/FEDORA-2012-2733/selinux-policy-3.10.0-80.fc16
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: https://admin.fedoraproject.org/updates/FEDORA-2012-2733/selinux-policy-3.10.0-80.fc16 then log in and leave karma (feedback).
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.