![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I created a database in debian using psql (as database user russell). My php4 script can't access it. It reports: Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user "russell" . in /home/russell/public_html/hello.php on line 2 |
|
I have apache-1.3 running ok. In /etc/postgresql/pg_hba.conf, i have "ident sameuser". I can access the database ok from my user account using psql. What can i check now? |
#3
| |||
| |||
|
|
I don't know php, but is it (or Apache) running as user russell? If not, then you can't authorize by IDENT. |
#4
| |||
| |||
|
|
?php $conn=pg_connect("dbname=parts_list user=russell"); if(!$conn) exit(pg_result_error($conn)); ? I have apache-1.3 running ok. In /etc/postgresql/pg_hba.conf, i have "ident sameuser". I can access the database ok from my user |
#5
| |||
| |||
|
|
-----Original Message----- From: pgsql-novice-owner (AT) postgresql (DOT) org [mailto gsql-novice-owner (AT) postgresql (DOT) org]On Behalf Of Russell ShawSent: Monday, January 12, 2004 10:33 AM To: pgsql-novice (AT) postgresql (DOT) org Subject: [NOVICE] Connect error Hi, I created a database in debian using psql (as database user russell). My php4 script can't access it. It reports: Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT authentication failed for user "russell" . in /home/russell/public_html/hello.php on line 2 The script is: ?php $conn=pg_connect("dbname=parts_list user=russell"); if(!$conn) exit(pg_result_error($conn)); ? I have apache-1.3 running ok. In /etc/postgresql/pg_hba.conf, i have "ident sameuser". I can access the database ok from my user account using psql. What can i check now? ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster |
#6
| |||
| |||
|
|
On Mon, Jan 12, 2004 at 07:42:41 -0800, Bill Moseley <moseley (AT) hank (DOT) org> wrote: I don't know php, but is it (or Apache) running as user russell? If not, then you can't authorize by IDENT. It is possible to authenticate using ident using a map that says the webserver account is allowed to use the db account "russell". The web server must either be on the same machine uisng domain sockets for connecting (which looks to be the case here) or be running an ident server. |
#7
| ||||
| ||||
|
|
I was not able to get this configuration working, so I think I'm not understanding the documentation correctly. Or maybe I was expecting that "sameuser" would work: |
|
moseley@bumby:~$ createdb newdb CREATE DATABASE moseley@bumby:~$ psql newdb Welcome to psql 7.4.1, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit newdb=> \q moseley@bumby:~$ su Password: bumby:/home/moseley# fgrep moseley /etc/postgresql/pg_ident.conf sameuser www-data moseley |
|
bumby:/home/moseley# /etc/init.d/postgresql restart Stopping PostgreSQL database server: postmaster. Starting PostgreSQL database server: postmaster. bumby:/home/moseley# su www-data bumby:/home/moseley$ psql newdb psql: FATAL: user "www-data" does not exist bumby:/home/moseley$ psql -Umoseley newdb psql: FATAL: IDENT authentication failed for user "moseley" I even tried using my own map name instead of "sameuser". bumby:/etc/postgresql# fgrep testmap pg_hba.conf pg_ident.conf pg_hba.conf:host all all 127.0.0.1 255.255.255.255 ident testmap pg_ident.conf:testmap moseley www-data So I think I'm missing an important concept. |
| -- Bill Moseley moseley (AT) hank (DOT) org ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings |
#8
| |||
| |||
|
|
Since sameuser is a special ident map you can't use it as a named map in the pg_ident.conf map. |
|
bumby:/etc/postgresql# fgrep testmap pg_hba.conf pg_ident.conf pg_hba.conf:host all all 127.0.0.1 255.255.255.255 ident testmap pg_ident.conf:testmap moseley www-data So I think I'm missing an important concept. I think you are pretty close. In the last case you enabled ident authentication using testmap for internet connections, but unless you did this for local connections (domain sockets) as well, it wouldn't apply since the way you are using psql will use a domain socket to connect (unless you have set the PGHOST environment variable). |
#9
| |||||||
| |||||||
|
|
On Mon, Jan 12, 2004 at 11:57:42AM -0600, Bruno Wolff III wrote: Since sameuser is a special ident map you can't use it as a named map in the pg_ident.conf map. I thought maybe the pg_ident.conf file was enough to simply say "connections from www-data should be considered as coming from user moseley" and then sameuser would work (i.e. www-data would be able to connect to moseley's databases). |
|
BTW -- when using a map like this that uses the ident service, what dsn string is used when connecting? (I'm using Perl, BTW.) |
|
bumby:/etc/postgresql# fgrep testmap pg_hba.conf pg_ident.conf pg_hba.conf:host all all 127.0.0.1 255.255.255.255 ident testmap pg_ident.conf:testmap moseley www-data So I think I'm missing an important concept. I think you are pretty close. In the last case you enabled ident authentication using testmap for internet connections, but unless you did this for local connections (domain sockets) as well, it wouldn't apply since the way you are using psql will use a domain socket to connect (unless you have set the PGHOST environment variable). You mean adding a "local" entry too? host all all 127.0.0.1 255.255.255.255 ident testmap local all all ident testmap |
|
bumby:/etc/postgresql$ psql newdb psql: FATAL: user "www-data" does not exist |
|
bumby:/etc/postgresql$ psql -Umoseley newdb psql: FATAL: IDENT authentication failed for user "moseley" |
|
pg_ident.conf:testmap moseley www-data According to the documentation the ident name should be the first name |
|
bumby:/etc/postgresql$ psql -Uwww-data newdb psql: FATAL: user "www-data" does not exist This is why I ended up creating a new database user with a password and then granting access to ALL of my objects to the new database user. And then using that username/password in the connect string in the web application. Can I turn on debugging in Postgresql to see why it's failing? That would likely help resolve the problem. |
#10
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |