Peer authentication problem in CGI-Perl

From: arifin purba <arifinpurbasigumonrong(at)yahoo(dot)gr>
To: pgsql-novice(at)postgresql(dot)org
Subject: Peer authentication problem in CGI-Perl
Date: 2002-02-13 17:28:35
Message-ID: 20020213172835.68566.qmail@web20308.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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

____________________________________________________________
Do You Yahoo!?
Αποκτήστε τη δωρεάν @yahoo.gr διεύθυνση σας στο http://www.otenet.gr

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message arifin purba 2002-02-13 17:28:45 Peer authentication problem in CGI-Perl
Previous Message Pam Wampler 2002-02-13 16:03:00 Cannot log in to DBI