Re: Peer authentication problem in CGI-Perl

From: Mo Holkar <pgsql(at)digitalmindgames(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Peer authentication problem in CGI-Perl
Date: 2002-02-13 18:09:53
Message-ID: 5.1.0.14.2.20020213180151.04bd2250@pop.ntlworld.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi there,

Are you running the Postgres postmaster with -i, to allow remote
connections? -- and is your pg_hba.conf
file edited so as to allow connections from the IP address you're using?
Even if it's your local machine you're testing on, you have to have
Postgres set up to allow TCP/IP connections if you want to test CGI
scripts. (At least, I think that's right: please do correct me, anyone who
knows different.)

best,

Mo

At 17:28 13/02/02, Arifin wrote:
>I am writing a CGI-Perl script that connects to
>PostgreSQL. For this I use the module Pg. I connect to
>PostgreSQL using the command
>
>Pg::connectdb("dbname=test user=johndoe
>password=pass");
>
>but everytime my connection is refused with the
>message:
>
>"Peer authentication failed for user 'johndoe'"
>
>The same thing does NOT happen whenever I login from
>shell-prompt with psql:
>
>psql -U johndoe -W test /* no problem here */
>
>Neither is it a problem to connect with Pg module in
>non-CGI script ("normal" Perl script that runs on
>shell).
>
>Back to the CGI Script, if I try to connect without
>user ID & password (only giving database name) the
>error message is,
>
>Peer authentication failed for user www-data.
>
>Does this mean I have to create user www-data? Would
>the same problem not happen again with user www-data?
>
>Here's my Perl script, please help me:
>
>#!/usr/bin/perl -w
>
>use strict;
>use Pg;
>use CGI qw(:standard);
>
>my $conn = Pg::connectdb("dbname=test user=johndoe
>password=johndoe");
>
>die $conn->errorMessage unless PGRES_CONNECTION_OK eq
> $conn->status;
>
>print header, start_html;
>
>my $result = $conn->exec("SELECT surname FROM people
>WHERE id=10001");
>
>die $conn->errorMessage unless PGRES_TUPLES_OK eq
> $result->resultStatus;
>
>while(my @row = $result->fetchrow) {
> print @row, "\n";
>}
>
>print end_html;
>
>
>Thanks beforehand
>Arifin

Mo Holkar
Undying King Games
mo(at)ukg(dot)co(dot)uk
Free games! at http://www.ukg.co.uk

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Brian Johnson 2002-02-13 19:16:10
Previous Message Patrick Hatcher 2002-02-13 18:07:52 Re: Function Hangs