pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Todd Gee <toddgee@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: ident auth postgres 7.4 fedora core 3
Date: Sun, 6 Mar 2005 22:28:38 -0800 (PST)
Message-ID: <20050307062838.11055.qmail@web30307.mail.mud.yahoo.com> (raw)


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@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@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




view thread (12+ messages)  latest in thread

Message-ID: <20050307062838.11055.qmail@web30307.mail.mud.yahoo.com>
Permalink:  ../20050307062838.11055.qmail@web30307.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/20050307062838.11055.qmail@web30307.mail.mud.yahoo.com

 · 

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-jdbc@postgresql.org
  Cc: toddgee@yahoo.com
  Subject: Re: ident auth postgres 7.4 fedora core 3
  In-Reply-To: <20050307062838.11055.qmail@web30307.mail.mud.yahoo.com>
  References: <20050307062838.11055.qmail@web30307.mail.mud.yahoo.com>

* 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