新安装的 Dovecot 不允许登录,尽管显示权限“显示正常”,但仍出现权限错误

新安装的 Dovecot 不允许登录,尽管显示权限“显示正常”,但仍出现权限错误

我正在将 dovecot 安装到运行 Ubuntu Server 64 位 14.04 客户机的 Virtualbox VM 上。Dovecot 本身正在安装到 Docker 容器中(我不确定这是否与此相关,但为了以防万一还是记下来了)。我无法让 dovecot 允许我通过 telnet 登录以使用 passwd 文件测试用户身份验证。

Dovecot 本身似乎安装得很好。我已经用 启动了它sudo dovecot,现在正尝试按照 wiki 指南进行测试http://wiki2.dovecot.org/TestInstallation

在容器内,我输入telnet localhost 143。Dovecot 可以很好地与 连接* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN] Dovecot (Ubuntu) ready.。然后我输入a login "test" "test",但得到以下输出:a NO [AUTHENTICATIONFAILED] Authentication failed.

我已经确认该命令可以在现有(正在运行)的 Ubuntu 12.04 dovecot 服务器上运行,并且在 /etc/dovecot/users 处有一个类似的密码文件。

/etc/dovecot/users文件包含以下行:

test:{SHA512-CRYPT}$6$PHmKiepXqf1vbk7u$.ruON3KVGW7LfuqxAFKG3kG5O0s3tocK5jpbaMH2Qh9scnjj.RENQ230ulYXgp9SEaZbJjFlD9HJdA6o4wVIJ1::::/home/dovecot-user/Maildir/test

这里的用户名为“test”,密码为“test”。

dovecot 日志文件包含以下内容:

Aug 04 08:49:18 imap-login: Debug: SSL: elliptic curve secp384r1 will be used for ECDH and ECDHE key exchanges
Aug 04 08:49:18 imap-login: Debug: SSL: elliptic curve secp384r1 will be used for ECDH and ECDHE key exchanges
Aug 04 08:49:18 auth: Error: passwd-file: open(/etc/dovecot/users) failed: Permission denied (euid=102(dovecot) egid=106(dovecot) missing +x perm: /etc/dovecot, UNIX perms appear ok (ACL/MAC wrong?))
Aug 04 08:49:18 auth: Error: passwd-file: open(/etc/dovecot/users) failed: Permission denied (euid=102(dovecot) egid=106(dovecot) missing +x perm: /etc/dovecot, UNIX perms appear ok (ACL/MAC wrong?))
Aug 04 08:49:23 auth: Error: passwd-file(test,::1,<4V3V0Mn/5QAAAAAAAAAAAAAAAAAAAAAB>): stat(/etc/dovecot/users) failed: Permission denied (euid=102(dovecot) egid=106(dovecot) missing +x perm: /etc/dovecot, UNIX perms appear ok (ACL/MAC wrong?))
Aug 04 08:49:26 imap-login: Info: Disconnected: Too many invalid commands (auth failed, 1 attempts in 3 secs): user=<test>, method=PLAIN, rip=::1, lip=::1, secured, session=<4V3V0Mn/5QAAAAAAAAAAAAAAAAAAAAAB>

/etc/dovecot/我没有找到任何解决此问题的方法,包括将和中的文件权限更改/home/dovecot-user/Maildir/为尽可能宽松,并将chown文件设置为 dovecot:dovecot、root:root 和 dovecot-user:dovecot-user。当前文件权限如下:

ls -lR /etc/dovecot

/etc/dovecot/dovecot:
-rwxrwx--- 1 dovecot dovecot  116 Aug  3 20:07 README
drwxrwx--- 2 dovecot dovecot 4096 Aug  4 08:45 conf.d
-rwxrwx--- 1 dovecot dovecot  410 Aug  3 20:07 dovecot-db.conf.ext
-rwxrwx--- 1 dovecot dovecot  782 Aug  3 20:07 dovecot-dict-sql.conf.ext
-rwxrwx--- 1 dovecot dovecot 5348 Aug  3 20:07 dovecot-sql.conf.ext
-rwxrwx--- 1 dovecot dovecot 3794 Aug  3 20:07 dovecot.conf
-rwxrwx--- 1 dovecot dovecot 3795 Aug  3 20:07 dovecot.conf.factory_settings
-rw-r--r-- 1 dovecot dovecot 1314 Aug  3 22:02 dovecot.pem
drwx------ 2 dovecot dovecot 4096 Aug  4 03:53 private
-rwxr-xr-x 1 dovecot dovecot  357 Aug  4 08:23 users


/etc/dovecot/conf.d:
total 108
-rwxrwx--- 1 dovecot dovecot  5258 Aug  3 20:07 10-auth.conf
-rwxrwx--- 1 dovecot dovecot  1691 Aug  3 20:07 10-director.conf
-rwxrwx--- 1 dovecot dovecot  2650 Aug  4 03:50 10-logging.conf
-rwxrwx--- 1 dovecot dovecot 14476 Aug  3 20:07 10-mail.conf
-rwxrwx--- 1 dovecot dovecot  2920 Aug  3 20:07 10-master.conf
-rwxrwx--- 1 dovecot dovecot  1654 Aug  3 20:07 10-ssl.conf
-rwxrwx--- 1 dovecot dovecot  1654 Aug  3 20:07 10-ssl.conf.save
-rw-r--r-- 1 dovecot dovecot   291 May 14 18:11 10-tcpwrapper.conf
-rwxrwx--- 1 dovecot dovecot  1607 Aug  3 20:07 15-lda.conf
-rw-r--r-- 1 dovecot dovecot  1137 May 14 18:11 15-mailboxes.conf
-rwxrwx--- 1 dovecot dovecot  2402 Aug  3 20:07 20-imap.conf
-rw-r--r-- 1 dovecot dovecot  4007 May 14 18:11 20-pop3.conf
-rwxrwx--- 1 dovecot dovecot   676 Aug  3 20:07 90-acl.conf
-rwxrwx--- 1 dovecot dovecot   292 Aug  3 20:07 90-plugin.conf
-rwxrwx--- 1 dovecot dovecot  2251 Aug  3 20:07 90-quota.conf
-rw-r--r-- 1 dovecot dovecot   499 May 14 18:11 auth-checkpassword.conf.ext
-rwxrwx--- 1 dovecot dovecot   486 Aug  3 20:07 auth-deny.conf.ext
-rwxrwx--- 1 dovecot dovecot   558 Aug  3 20:07 auth-master.conf.ext
-rwxrwx--- 1 dovecot dovecot   329 Aug  4 03:45 auth-passwdfile.conf.ext
-rw-r--r-- 1 dovecot dovecot   788 May 14 18:11 auth-sql.conf.ext
-rwxrwx--- 1 dovecot dovecot   608 Aug  3 20:07 auth-static.conf.ext
-rwxrwx--- 1 dovecot dovecot  2106 Aug  3 20:07 auth-system.conf.ext
-rwxrwx--- 1 dovecot dovecot   327 Aug  3 20:07 auth-vpopmail.conf.ext

ls -lR /home/dovecot-user/Maildir/

/home/dovecot-user/Maildir/:
total 4
drwx------ 10 dovecot-user dovecot-user 4096 Aug  4 03:45 test

/主页/ dovecot-用户/ Maildir /测试:

total 12
drwx------ 2 dovecot-user dovecot-user 4096 Aug  4 03:45 cur
drwx------ 2 dovecot-user dovecot-user 4096 Aug  4 03:45 new
drwx------ 2 dovecot-user dovecot-user 4096 Aug  4 03:45 tmp

输出自dovecot -n

# 2.2.9: /etc/dovecot/dovecot.conf  
doveconf: Error: setmntent(/etc/mtab) failed: No such file or directory  
 # OS: Linux 3.13.0-32-generic x86_64 Ubuntu 14.04.1 LTS  
first_valid_uid = 8
last_valid_uid = 1001
log_path = /testout
mail_gid = 1000
mail_location = maildir:/home/dovecot-user/Maildir/%u
mail_privileged_group = mail
mail_uid = 1000
namespace {
  inbox = yes
  location = 
  prefix = 
  separator = /
  type = private
}
namespace inbox {
  location = 
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    special_use = \Trash
  }
  prefix = 
}
passdb {
  args = scheme=CRYPT username_format=%u /etc/dovecot/users
  driver = passwd-file
}
protocols = " imap pop3"
ssl = required
ssl_cert = </etc/ssl/certs/dovecot.pem
ssl_key = </etc/ssl/private/dovecot.pem
userdb {
  args = username_format=%u /etc/dovecot/users
  driver = passwd-file
}
verbose_ssl = yes

我不确定这是文件权限问题还是apparmor问题selinux,以及如何进行调试和修复。过去几年,我已经看到了十几篇关于这个问题的论坛帖子,但没有记录完备的修复方法。因此,我认为这个问题并不是我独有的,我希望在这里得到一些帮助,将来会有详尽的记录。

答案1

我不确定这是否确实是 AppArmor 问题(遵循上述 @André-Daniel 的评论),因为关闭/卸载 AppArmor 对错误消息没有帮助。不过,据记录,我找到了一种解决问题的方法。修复涉及几个组件:

  1. 确保在 /etc/dovecot/conf.d/10-mail.conf 中设置了有效的 uid 和 gid(例如,存储 Maildir 目录的主目录中的用户的 uid 和 gid)
  2. 确保 Maildir 目录中的所有文件都归该 uid 和 gid 所有(chown --recursive $(id -u):$(id -g) /home/username/Maildir
  3. 将用户/密码文件存储在 /etc/dovecot 之外,上面 (1) 中的用户可以访问它。完成此操作后,并chown按照上面 (2) 中的操作进行编辑,我开始在 dovecot 日志中收到一条单独的错误消息,关于重复的命名空间。
  4. 我解决了上面(3)中的错误https://workaround.org/comment/3326#comment-3326,建议在 /etc/dovecot/conf.d/15-mailboxes.conf 部分inbox = yes中添加namespace inbox {...,并注释掉namespace/etc/dovecot/conf.d/10-mail.conf 中的整个部分

答案2

就我而言,我解决了以下错误:

Mar  7 22:55:01 servername dovecot: pop3-login: Error: auth: connect(login) in directory / failed: Permission denied (euid=996(<unknown>) egid=995(<unknown>) missing +w perm: //login, dir owned by 0:995 mode=0750)
Mar  7 22:55:03 servername dovecot: pop3-login: Error: auth: connect(login) in directory / failed: Permission denied (euid=996(<unknown>) egid=995(<unknown>) missing +w perm: //login, dir owned by 0:995 mode=0750)
Mar  7 22:55:06 servername dovecot: imap-login: Warning: Auth process not responding, delayed sending initial response (greeting): user=<>, rip=12.12.123.123, lip=12.12.123.124, session=<vzAfW30twwDVf4d6>
Mar  7 22:55:11 servername dovecot: pop3-login: Warning: Auth process not responding, delayed sending initial response (greeting): user=<>, rip=127.0.0.1, lip=127.0.0.1, secured, session=<8Z5uW30tLgB/AAAB>
Mar  7 22:55:13 servername dovecot: pop3-login: Warning: Auth process not responding, delayed sending initial response (greeting): user=<>, rip=12.12.123.123, lip=12.12.123.124, session=<B9+JW30tAgBRBHv8>

通过运行:

setfacl -k /var/run/dovecot/login

相关内容