下面的日志文件出现在我目前的maillog:
Apr 24 17:44:48 h2290750 dovecot: auth: Error: pgsql: Connect failed to mail: could not connect to server: Permission denied Apr 24 17:44:48 h2290750 dovecot: auth: Error: #011Is the server running on host "localhost" (::1) and accepting Apr 24 17:44:48 h2290750 dovecot: auth: Error: #011TCP/IP connections on port 5432? Apr 24 17:44:48 h2290750 dovecot: auth: Error: could not connect to server: Permission denied Apr 24 17:44:48 h2290750 dovecot: auth: Error: #011Is the server running on host "localhost" (127.0.0.1) and accepting Apr 24 17:44:48 h2290750 dovecot: auth: Error: #011TCP/IP connections on port 5432?
我检查了postgresql服务器正在侦听端口5432.而我的pg_hba.conf看起来像这样。
# TYPE DATABASE USER ADDRESS METHOD # Mail stuff host mail mailreader 127.0.0.1/32 md5 host mail mailreader ::1/128 md5 # "local" is for Unix domain socket connections only local all all md5 # IPv4 local connections: host all all 127.0.0.1/32 ident # IPv6 local connections: host all all ::1/128 ident # Allow replication connections from localhost, by a user with the # replication privilege. #local replication postgres peer #host replication postgres 127.0.0.1/32 ident #host replication postgres ::1/128 ident
我的dovecot-sql.conf的连接configuration:
driver = pgsql connect = host=localhost dbname=mail user=mailreader password=secret default_pass_scheme = SHA512 password_query = SELECT email as user, password, 'maildir:/home/mail'||maildir as userdb_mail FROM users WHERE email = '%u'
有什么build议么? 也许我需要哈希密码,以便dovecot推送一个md5哈希密码到pgsql?
编辑: psql -U mailreader -d mail留给我在数据库mail的SQL提示
连接失败邮件:无法连接到服务器:权限被拒绝服务器运行在主机“本地主机”(:: 1)和接受
实际上是在暗示一个SELinux问题。 审查audit.log后,我发现下面一行,反复出现。
AVC msg = audit(1398759363.514:635):avc:denied {open} for pid = 12779 comm =“auth”name =“auth-token-secret.dat.tmp”dev = md1 ino = 11927980 scontext = unconfined_u: system_r:dovecot_auth_t:s0 tcontext = unconfined_u:object_r:dovecot_var_run_t:s0 tclass = file
havning使用以下命令安装策略内核使用情况后:
yum install policycoreutils-python
我可以用audit2allow命令为SELinux创build一个注意事项:
grep auth_t /var/log/audit/audit.log | audit2allow -M postgreylocal
之后,可以使用以下方式将exception加载到SELinux中:
semodule -i postgreylocal.pp
这就是它。 像魅力一样奔跑。
从它的外观来看,您的postgres,mailreader用户无权访问postgres数据库邮件。
一旦你解决了,它会开始为你工作。
这部分消息:
连接失败邮件:无法连接到服务器: 权限被拒绝
服务器是否在主机“localhost”(:: 1)上运行并接受
提示SELinux权限问题。 那是SELinux禁止从你的鸽舍进程发起TCP连接的时候。
请参阅SELinux不会让dovecot连接到 fedora-selinux-list上的postgresql ,以获取报告的示例策略。
它的主旨似乎是:
module dovecotauthfixes 1.0; require { type dovecot_auth_t; type postgresql_port_t; type postgresql_tmp_t; type postgresql_t; class sock_file write; class tcp_socket name_connect; class unix_stream_socket connectto; } #============= dovecot_auth_t ============== allow dovecot_auth_t postgresql_port_t:tcp_socket name_connect; allow dovecot_auth_t postgresql_t:unix_stream_socket connectto; allow dovecot_auth_t postgresql_tmp_t:sock_file write;