Skip site navigation (1) Skip section navigation (2)

ident auth postgres 7.4 fedora core 3

From: Todd Gee <toddgee(at)yahoo(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: ident auth postgres 7.4 fedora core 3
Date: 2005-03-07 06:28:38
Message-ID: 20050307062838.11055.qmail@web30307.mail.mud.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
Hey Folks ->

So I just upgraded my RH 9 box to Fedora Core 3 and ident auth
stopped working.  I've been thru the ident authorization process
before and have become pretty conversant w/ it, but this issue is
really strange.  It seems that ident auth is only failing w/ JDBC
connections.

postgres version: postgresql-7.4.7-3.FC3.1
(includes JDBC driver jar pg74.215.jdbc3.jar)

I have the relevant line in my pg_hba.conf file:
host   all   all    127.0.0.1  0.0.0.0     ident sameuser

I have a user 'tod' created in postgres and I can connect using the
following command issued as (unix) user tod:
[tod(at)pedro ~]$ psql -h localhost -U tod cbfsrtsDev
which connects using tcp sockets and should thus exercise the above
line in the pg_hba.conf file.  (I have verified this by changing host
auth to 'password' and verifying that psql asks me for a password
before letting me in.)  Yes, I realize the "-U tod" is redundant. 
The command works the same with or without it.

Anyway, I am using this java program for a test (which I found in a
previous thread on this list):
----------- Begin include
import java.sql.*;
import java.io.*;

public class JdbcTest {
    public static void main(String[] args) throws Exception {
        System.out.println(System.getProperty("user.name"));

        Class.forName("org.postgresql.Driver");
        String url = "jdbc:postgresql:cbfsrtsDev";
        Connection db = DriverManager.getConnection(url, args[0],
                                                    args[0]);
        db.close();
    }
}
----------- End include

As you can see, I'm trying to connect to the same table 'cbfsrtsDev'
with the username and password set to the same thing.  When I run
this, I receive:
[tod(at)pedro ~]$ java JdbcTest tod
----------- Begin include
tod
Exception in thread "main" org.postgresql.util.PSQLException: A
connection error has occurred: org.postgresql.util.PSQLE
xception: FATAL: IDENT authentication failed for user "tod"

        at
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnectionV3(AbstractJdbc1Connection.java:337)
        at
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:214)
        at org.postgresql.Driver.connect(Driver.java:139)
        at
java.sql.DriverManager.getConnection(DriverManager.java:512)
        at
java.sql.DriverManager.getConnection(DriverManager.java:171)
        at JdbcTest.main(JdbcTest.java:12)
----------- End include

So, my question is this: how can I use ident auth to authenticate for
the psql terminal session but have my java program fail?  I even
checked to ensure that the java process wasn't set-UIDed (it's not). 
I tried the other JDBC drivers, but the results are all the same.

If anyone has any suggestions, I'd love to hear 'em.
thanks,
tod


Responses

pgsql-jdbc by date

Next:From: Tom LaneDate: 2005-03-07 07:16:02
Subject: Re: ident auth postgres 7.4 fedora core 3
Previous:From: Oliver JowettDate: 2005-03-06 22:42:26
Subject: Re: [BUGS] BUG #1523: precision column value returned from getTypeInfo()

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group