Re: Peer authentication problem in CGI-Perl - Mailing list pgsql-novice

From Mo Holkar
Subject Re: Peer authentication problem in CGI-Perl
Date
Msg-id 5.1.0.14.2.20020213180151.04bd2250@pop.ntlworld.com
Whole thread Raw
In response to Peer authentication problem in CGI-Perl  (arifin purba <arifinpurbasigumonrong@yahoo.gr>)
Responses Re: Peer authentication problem in CGI-Perl  (Oliver Elphick <olly@lfix.co.uk>)
List 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@ukg.co.uk
Free games! at http://www.ukg.co.uk


pgsql-novice by date:

Previous
From: Pam Wampler
Date:
Subject: Re: Cannot log in to DBI
Next
From: "Brian Johnson"
Date:
Subject: