我已经成功编译,configuration并运行了具有虚拟用户function的Dovecot。
这是我的/etc/dovecot.conf
configuration文件的一部分:
mail_location = maildir:/home/%d/%n/Maildir auth default { mechanisms = plain login userdb passwd-file { args = /home/%d/etc/passwd } passdb passwd-file { args = /home/%d/etc/shadow } socket listen { master { path = /var/run/dovecot/auth-worker mode = 0600 } } }
我遇到了一个我无法解决的问题。 是否有创build用户的域名映射,并在mail_location
提供用户名?
例如:1.目前我有/home/domain.com/user/Maildir 2.我想有/home/USER/domain.com/user/Maildir
我可以做到这一点吗?
问候,斯托伊科
考虑一下你在问什么。 您想要将用户的主目录包含在mail_location
。 从表面上看,这似乎是一个合理的要求 – 但是你必须问 – Dovecot如何知道用户的主目录?
系统用户存储在/ etc / passwd文件中
username:password:uid:gid:comment:home:shell
(注意:密码不是密码,你可以用密码保存在/ etc / shadow中;或者*
去激活帐户;注释实际上是一个“ gecos”字段 )
如果Dovecot读取这个文件 – 它被提供给用户的主目录 – 一旦它有了这些信息,它就可以在别处使用它(也就是说它可以使用〜/ to signify the home directory, and will set
%h to signify the home directory, and will set
为一样)。
但是,如果您使用的是虚拟用户而不是系统用户,则其中一个基本思想是不是每个虚拟用户都必须是系统用户。 在这种情况下,Dovecot无法知道与系统用户共享同一名称的虚拟用户是否真的是同一个用户(它也不能使用UID,因为可能有多个虚拟用户映射到相同的UID)。 它不会假设你的userdb提供的东西以外的任何东西。
Userdb可以向Dovecot提供以下信息:
在你的configuration中,你正在使用一个passwd文件 – 也就是与系统passwd文件格式相同的文件,但是你为此设置了这个文件(即它不是系统passwd文件)。 Dovecot接受以下passwd文件格式 (并忽略gecos和shell字段):
user:password:uid:gid:(gecos):home:(shell):extra_fields
您可以通过指定(空格分隔) key=value
额外字段(大多数情况下带有以userdb_
为前缀的键)来覆盖某些默认值,基于每个用户。 例如, userdb_mail=Maildir:~/mail
将覆盖mail_location
。
只是为了重申,通过使用虚拟用户(而不是使用系统passwd文件),您已经告诉Dovecot这些用户可能与系统用户没有任何关系,因此只会使用您提供的信息,而不会假设还要别的吗。
最后,试着回答你的问题:
mail_location
使用多个variables – 这些variables是在Dovecot的“variables”页面上定义的 。 %h
或者最好~/
可以用来返回Dovecot从其UserDB查询中检索到的主目录(并设置mail_home
) mail_location
。 所以,基本上,如果你想在Dovecot中使用主目录,那么你的userdb就设置好了,因为它不知道你不告诉它什么。
根据这个链接你可以使用“在mail_location设置中的几个variables”
%u: Full username. %n: User part in user@domain, same as %u if there's no domain. %d: Domain part in user@domain, empty if there's no domain.
例如。
mail_location = maildir:/home/%n/%d/%n/Maildir
应该指向/ home / user / domain / user / Maildir