我有一个 courier-imap IMAP 系统,由 LDAP 支持,保存用户数据。我想将 IMAP 转换为 dovecot,并且能够成功配置基本登录;它工作正常。
但是我在启用 QUOTA 命令时遇到了麻烦。dovecot 中的配额后端无法初始化,因为存储在 LDAP 中的配额值附加了 S。当 dovecot 解析此值时,它认为这是一个单位规范,发出抱怨并中止:
Feb 6 09:12:15 site02 dovecot: auth: Debug: ldap([email protected],10.1.1.238,
<JzSd+b/xswAKAQHu>): result: gidNumber=1000 uidNumber=1101
homeDirectory=/netapp1/mail/maildirs/t/o/d/todd.todd.com
quota=943718400S
Feb 6 09:12:15 site02 dovecot: imap([email protected]): Error: user [email protected]:
Initialization failed: Failed to initialize quota: Invalid quota root quota:
Invalid rule *:bytes=943718400S: Invalid rule limit value 'bytes=943718400S':
Unknown unit: S
以上内容来自开发机器。调试输出显示 LDAP 查找返回的值是943718400S,而鸽舍无法识别年代为有效单位。
我希望它能正常工作,因为根据http://wiki2.dovecot.org/Quota/Configuration,它指出后端特定配置目前仅用于 Maildir++ 配额后端。这意味着您可以拥有 Maildir++ 格式的配额(例如“10000000S”)。 本文档有误,或者我对文档的理解有误
LDAP 中的数据无法更改,因此在我看来,有四种方法可以解决此问题:
- dovecot 可以在配置文件中设置变量并进行字符串操作吗?如果可以,这是首选方法。
- 从 LDAP 搜索中的配额值中删除 S。(这是否可行,就像使用 SQL 查询一样?)
- 从 plugins/quota.c 中的配额值中去掉 S。
- 通过在 plugins/quota.c 中添加“S”作为单位并将乘数设置为 1 来伪造它。
如果您有任何建议,认为其中哪一种是最佳的前进方式,我们将不胜感激。以下是原始数据和配置。
dovecot -n 的输出:
auth_debug = yes
disable_plaintext_auth = no
listen = *
mail_fsync = always
mail_nfs_index = yes
mail_nfs_storage = yes
mail_plugins = " quota"
mbox_write_locks = fcntl
mmap_disable = yes
namespace inbox {
inbox = yes
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 = /etc/dovecot/dovecot-ldap.conf.ext
driver = ldap
}
plugin {
quota = maildir:User quota
}
protocols = imap
ssl_cert = </etc/pki/dovecot/certs/dovecot.pem
ssl_key = </etc/pki/dovecot/private/dovecot.pem
userdb {
args = /etc/dovecot/dovecot-ldap.conf.ext
driver = ldap
}
protocol imap {
mail_plugins = " quota imap_quota"
}
上面引用的 dovecot ldap 特定文件:
hosts = localhost
dn = cn=ldap_user,dc=dev,dc=ivenue,dc=net
dnpass = ldap_pass
auth_bind = no
ldap_version = 3
base = ou=users,dc=dev,dc=ivenue,dc=net
deref = never
scope = subtree
user_attrs = homeDirectory=home,uidNumber=uid,gidNumber=gid,=quota_rule=*:bytes=%{ldap:quota}
user_filter = (&(objectClass=posixAccount)(objectClass=CourierMailAccount)(uid=%u))
pass_attrs = mail=user,userPassword=password
pass_filter = (&(objectClass=posixAccount)(objectClass=CourierMailAccount)(uid=%u))
iterate_attrs = mail=user
iterate_filter = (&(objectClass=posixAccount)(objectClass=CourierMailAccount))
default_pass_scheme = PLAIN
该测试用户的 LDIF:
# todd.todd.com, users, dev.ivenue.net
dn: uid=todd.todd.com,ou=users,dc=dev,dc=ivenue,dc=net
gidNumber: 1000
uidNumber: 1101
shadowMax: 99999
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
objectClass: account
objectClass: CourierMailAccount
uid: [email protected]
uid: todd.todd.com
mail: [email protected]
gecos:: IA==
shadowLastChange: 11740
cn:: IA==
homeDirectory: /netapp1/mail/maildirs/t/o/d/todd.todd.com
description: customerNumber->46791
shadowWarning: 7
quota: 943718400S
loginShell: /bin/sh
2月7日添加:显示 maildir 的配额配置:
# doveconf -a | egrep "mail_loca|quota"
lmtp_rcpt_check_quota = no
mail_location =
mail_plugins = " quota"
quota = maildir:User quota
quota_full_tempfail = no
mail_plugins = " quota imap_quota"