SELinux阻止Apache写入pgbouncer的Unix域套接字

我正在使用新安装的CentOS 5.7 Linux 64位与PGDG软件包:

# rpm -qa|grep -i PG postgresql-libs-8.4.8-2PGDG.rhel5 pgdg-centos-8.4-2 postgresql-8.4.8-2PGDG.rhel5 pgbouncer-1.3.4-1.rhel5 postgresql-server-8.4.8-2PGDG.rhel5 

并在/var/log/audit/audit.log中获取以下Apache错误

 type=AVC msg=audit(1316700316.235:41): avc: denied { write } for pid=2748 comm="httpd" name=".s.PGSQL.6432" dev=sda1 ino=754350 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:tmp_t:s0 tclass=sock_file type=SYSCALL msg=audit(1316700316.235:41): arch=c000003e syscall=42 success=no exit=-13 a0=c a1=2b712748bee0 a2=6e a3=0 items=0 ppid=2721 pid=2748 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null) 

这里是有问题的文件(PostgreSQL在“端口”5432和pgbouncer在“端口”6432):

 # ls -aZ /tmp/ srwxrwxrwx postgres postgres system_u:object_r:postgresql_tmp_t .s.PGSQL.5432 -rw------- postgres postgres system_u:object_r:postgresql_tmp_t .s.PGSQL.5432.lock srwxrwxrwx postgres postgres system_u:object_r:tmp_t .s.PGSQL.6432 

有没有人请知道,如何永久使文件.s.PGSQL.6432以上的相同的postgresql_tmp_t “types”为s.PGSQL.5432(这可能会解决这个问题)?

通过查看我认为的过程,我必须将pgbouncer进程从initrc_t移到postgresql_t

 # ps uawxZ system_u:system_r:initrc_t postgres 2610 0.0 0.0 17020 780 ? S 15:47 0:00 pgbouncer -d /etc/pgbouncer.ini system_u:system_r:postgresql_t postgres 2666 0.1 2.4 1192464 25216 ? S 15:48 0:02 /usr/bin/postmaster -p 5432 -D /var/lib/pgsql/data system_u:system_r:httpd_t root 2721 0.0 1.0 260608 10564 ? Ss 15:48 0:00 /usr/sbin/httpd system_u:system_r:httpd_t apache 2747 0.0 0.9 261632 9728 ? S 15:48 0:00 /usr/sbin/httpd system_u:system_r:httpd_t apache 2748 0.0 0.9 261632 9728 ? S 15:48 0:00 /usr/sbin/httpd 

从量子偷一点,但它可能更多的沿线..

 # chcon -t postgresql_exec_t /path/to/pgbouncer 

然后重启。

尝试这个:

 # chcon -t postgresql_t /path/to/pgbouncer 

并重新启动pgbouncer