pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mariusz Pękala <skoot@qi.pl>
To: pgsql-php@postgresql.org
Subject: Re: Unable to connect to PostgreSQL Server: Permission denied
Date: Mon, 3 Apr 2006 22:01:23 +0200
Message-ID: <20060403200123.GB9357@cthulhu.sdi.tpnet.pl> (raw)
In-Reply-To: <20060403170611.19617.qmail@webmail47.rediffmail.com>
References: <20060403170611.19617.qmail@webmail47.rediffmail.com>

On 2006-04-03 17:06:11 -0000 (Mon, Apr), muralidhar sortur wrote:
>   
> Hi ,
> Here is the complete description of the problem ...
> 
> I have newly installed fedora core 4 with option as everyting.
[...]
> -------------------------------------------------------------
> Error i get is
> [client 127.0.0.1] PHP Warning:  pg_connect(): Unable to connect to
> PostgreSQL server: could not connect to server: Permission
> denied\n\tIs the server running locally and accepting\n\tconnections
> on Unix domain socket &quot;/tmp/.s.PGSQL.5432&quot;? in
> /var/www/html/add-entry.php on line 5, referer:
> http://localhost/add.html

How does the file /tmp/.s.PGSQL.* look like? Does 'www' user have access
to it?
ls -l /tmp/.s.PGSQL.*

As you enabled network interface in postgresql, you may try to add
'host=127.0.0.1' to your pg_connect function. This should let 'www'
user to connect.

> [root@localhost html]# telnet localhost 5432
> Trying 127.0.0.1...
> Connected to localhost.localdomain (127.0.0.1).
> Escape character is '^]'.
> 
> 
> Connection closed by foreign host.
> 
> data/pg_log/postgresql-Mon.log contains
> 
> LOG:  invalid length of startup packet

Telnet is not the best tool for binary protocols.
You may try netcat (nc), but anyway - this test is not significant
here.

By the way, you used this construction:
> $Name=$_GET['Name'];
> $Email=$_GET['Email'];
> $Phone=$_GET['Phone'];
> 
> $query = "INSERT INTO Addresses VALUES( '$Name', '$Phone', '$Email' );";

Forgive me if that is only because this is test, and you know that, but
I just HAVE to say:
Don't let the untrusted parameters to go into query. Someone may call
your page like this:
http://example.com/add-entry.php?Email=a';); delete from Addresses; --

As *MINIMAL* precaution use:
  $Name = pg_escape_string( $_GET['Name');


-- 
No virus found in this outgoing message.
Checked by "grep -i virus $MESSAGE"
Trust me.

view thread (7+ messages)  latest in thread

Message-ID: <20060403200123.GB9357@cthulhu.sdi.tpnet.pl>
Permalink:  ../20060403200123.GB9357@cthulhu.sdi.tpnet.pl/
Also on:    postgresql.org/message-id/20060403200123.GB9357@cthulhu.sdi.tpnet.pl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: skoot@qi.pl
  Subject: Re: Unable to connect to PostgreSQL Server: Permission denied
  In-Reply-To: <20060403200123.GB9357@cthulhu.sdi.tpnet.pl>
  References: <20060403170611.19617.qmail@webmail47.rediffmail.com> <20060403200123.GB9357@cthulhu.sdi.tpnet.pl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox