0

On my server I am trying to peer authenticate some users using usermap on the postgresql 9.5 installation. What I am trying to do is to map user mailreader as you can see:

postgres=# \du
                              List of roles
 Role name  |                   Attributes                   | Member of 
------------+------------------------------------------------+-----------
 mailreader |                                                | {}
 postgres   | Superuser, Create role, Create DB, Replication | {}

Into system's user root,dovecot,postfix. Therefore I edited my pg_ident.cong and put the following content:

mailmap         dovecot                 mailreader
mailmap         postfix                 mailreader
mailmap         root                    mailreader

Also I edited the pg_hba.conf and appended with the following content:

local    mail        all                     peer map=mailmap

When I try to connect via sudo psql -U mailreader -d mail command I get:

psql: FATAL: Peer authentication failed for user "mailreader"

error.

I also tried the following configuration:

local    mail            all                                     ident map=mailmap

Without any progress.

May I have some help?

Edit 1

The generated logs regarding the error are:

2017-06-27 19:10:10 UTC [1188-1] mailreader@mail LOG:  provided user name (mailreader) and authenticated user name (root) do not match
2017-06-27 19:10:10 UTC [1188-2] mailreader@mail FATAL:  Peer authentication failed for user "mailreader"
2017-06-27 19:10:10 UTC [1188-3] mailreader@mail DETAIL:  Connection matched pg_hba.conf line 90: "local   all             all  
Dimitrios Desyllas
  • 563
  • 2
  • 11
  • 30

2 Answers2

0

local mail app peer map=mailmap looks wrong, you want either all or mailreader instead off app. Otherwise, your configuration looks correct. You might also need to reload postgres after changing pg_hba.conf.

Tollef Fog Heen
  • 712
  • 3
  • 10
0

In the end I had to comment the line:

local   all             all                                     peer

Or to put it below the following line:

local    mail            all                             ident map=mailmap

On /etc/postgresql/9.4/main/pg_hba.conf file

Dimitrios Desyllas
  • 563
  • 2
  • 11
  • 30