<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>HTTP (php) can't connect to local postgresql</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>First at all: I'm using targeted policy and</FONT>
<BR><FONT SIZE=2>When my web application (using php) try to connect to postgresql </FONT>
<BR><FONT SIZE=2>database I get:</FONT>
</P>

<P><FONT SIZE=2>*Warning*: pg_connect(): Unable to connect to PostgreSQL server: could </FONT>
<BR><FONT SIZE=2>not connect to server: 8���|</FONT>
<BR><FONT SIZE=2>Is the server running locally and accepting</FONT>
<BR><FONT SIZE=2>connections on Unix domain socket "/tmp/.s.PGSQL.5432"? in </FONT>
<BR><FONT SIZE=2>*/var/www/html/encuesta/index.php* on line *7</FONT>
</P>

<P><FONT SIZE=2>*In dmesg I see:</FONT>
</P>

<P><FONT SIZE=2>audit(1100638278.903:0): avc: denied { connectto } for pid=2481 </FONT>
<BR><FONT SIZE=2>exe=/usr/sbin/httpd path=/tmp/.s.PGSQL.5432 </FONT>
<BR><FONT SIZE=2>scontext=user_u:system_r:httpd_t tcontext=user_u:system_r:unconfined_t </FONT>
<BR><FONT SIZE=2>tclass=unix_stream_socke</FONT>
</P>

<P><FONT SIZE=2>and ls -laZ /tmp/s.PGSQL.5432 show:</FONT>
</P>

<P><FONT SIZE=2>srwxrwxrwx postgres postgres user_u:object_r:tmp_t /tmp/.s.PGSQL.5432</FONT>
</P>

<P><FONT SIZE=2>What can I do?</FONT>
<BR><FONT SIZE=2>What if I append line "can_unix_connect(httpd_php_t, unconfined_t)" in </FONT>
<BR><FONT SIZE=2>/etc/selinux/targeted/src/policy/domains/program/apache.te ? (What if I </FONT>
<BR><FONT SIZE=2>don't want that 'httpd' can connect to other socks?).</FONT>
</P>

<P><FONT SIZE=2>Thanks in advance and excuse my english.</FONT>
</P>

<P><FONT SIZE=2>Ricardo.-</FONT>
</P>

</BODY>
</HTML>