Postgresql 无法使用 usermap 进行对等身份验证(提供的用户名 (^dbuser^) 和经过身份验证的用户名 (^sysuser^) 不匹配)

Dim*_*las 5 postgresql authentication postgresql-9.4

我正在尝试使用 usermap 对某些用户进行对等身份验证。我想要做的是映射用户邮件阅读器,如您所见:

postgres=# \du
                              List of roles
 Role name  |                   Attributes                   | Member of 
------------+------------------------------------------------+-----------
 mailreader |                                                | {}
 postgres   | Superuser, Create role, Create DB, Replication | {}
Run Code Online (Sandbox Code Playgroud)

进入系统的用户root,dovecot,postfix。因此,我编辑了我的pg_ident.conf并放置了以下内容:

mailmap         dovecot                 mailreader
mailmap         postfix                 mailreader
mailmap         root                    mailreader
Run Code Online (Sandbox Code Playgroud)

我还编辑pg_hba.conf并附加了以下内容:

local    mail        all                     peer map=mailmap
Run Code Online (Sandbox Code Playgroud)

当我尝试通过sudo psql -U mailreader -d mail命令连接时,我得到:

psql:致命:用户“mailreader”的对等身份验证失败

错误。

我还尝试了以下配置:

local    mail            all                                     ident map=mailmap
Run Code Online (Sandbox Code Playgroud)

没有任何进展。

我可以帮忙吗?

编辑 1

有关错误的日志是:

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                                     peer"
Run Code Online (Sandbox Code Playgroud)

Dim*_*las 5

In the end I had to comment the line:

local   all             all                                     peer
Run Code Online (Sandbox Code Playgroud)

Or to put it below the following line:

local    mail            all                             ident map=mailmap
Run Code Online (Sandbox Code Playgroud)