[Dovecot] rewriting mail_location

Burckhard Schmidt bschmidt at cms.hu-berlin.de
Tue Jan 10 16:16:14 EET 2012


Hello,
I have LDAP as userdb. Entries containing attributes 
mail=alias.user1 at some.domain.de and
uid=user1

Mail to alias.user1 at some.domain.de gets delivered into
/datatest/user/alias.user1 instead of /datatest/user/user1 by lda.

I have
userdb {
   args = /usr/dovecot/etc/ldapuser.conf
   driver = ldap
}
with a ldapuser.conf:
hosts ...
base ...
user_filter = (&(|(mail=%u)(mail=%n at some.domain)
(uid=%u))(objectClass=posixAccount))

user_attrs = uid=mail_location=maildir:/datatest/user/%$,
uidNumber=29,gidNumber=133

I hoped local part of attribute mail could be replaced by uid for local 
delivery with dovecots lda?

Any hints how to do that?
(With postfix I could rewrite the address to uid at host and use 
local_transport = dovecot.)


postfix has virtual_transport = dovecot.

LDAP entry:
mail: alias.user1 at some.domain.de
uid: user1
homeDirectory: /dev/null
uidNumber: 464
gidNumber: 100

mail to alias.user1 at some.domain.de

Jan 10 14:03:24 ubu1004 postfix/qmgr[25221]: C434D1EE: 
from=<user at domain>, size=239, nrcpt=1 (queue active)
Jan 10 14:03:24 ubu1004 dovecot: lda: Debug: Loading modules from 
directory: /usr/dovecot/lib/dovecot
Jan 10 14:03:24 ubu1004 dovecot: lda: Debug: Module loaded: 
/usr/dovecot/lib/dovecot/lib20_autocreate_plugin.so
Jan 10 14:03:24 ubu1004 dovecot: auth: Debug: master in: 
USER#0111#011alias.user1#011service=lda
Jan 10 14:03:24 ubu1004 dovecot: auth: Debug: ldap(alias.user1): user 
search: base=ou=users,ou=...,c=de scope=subtree 
filter=(&(|(mail=alias.user1)(mail=alias.user1 at some.domain.de)(uid=alias.user1))(objectClass=posixAccount)) 
fields=uid,uidNumber,gidNumber

some substitutions are visibly:

Jan 10 14:03:24 ubu1004 dovecot: auth: Debug: ldap(alias.user1): result: 
uid(location=maildir:/datatest/user/%$/maildir)=user1 gidNumber(133)=100 
uidNumber(29)=464
Jan 10 14:03:24 ubu1004 dovecot: auth: Debug: master out: 
USER#0111#011alias.user1#011location=maildir:/datatest/user/user1/maildir#011133=100#01129=464
Jan 10 14:03:24 ubu1004 dovecot: lda: Debug: auth input: alias.user1 
location=maildir:/datatest/user/user1/maildir 133=100 29=464
Jan 10 14:03:24 ubu1004 dovecot: lda: Debug: Added userdb setting: 
plugin/location=maildir:/datatest/user/user1/maildir

but alias "alias.user1" still used for delivery:

Jan 10 14:03:24 ubu1004 dovecot: lda: Debug: Added userdb setting: 
plugin/133=100
Jan 10 14:03:24 ubu1004 dovecot: lda: Debug: Added userdb setting: 
plugin/29=464
Jan 10 14:03:24 ubu1004 dovecot: lda(alias.user1): Debug: Effective 
uid=29, gid=133, home=
Jan 10 14:03:24 ubu1004 dovecot: lda(alias.user1): Debug: Namespace : 
type=private, prefix=, sep=/, inbox=yes, hidden=no, list=yes, 
subscriptions=yes 
location=maildir:/datatest/user/alias.user1/maildir:INDEX=/datatest/addons/index/alias.user1:CONTROL=/datatest/user/alias.user1/control:LAYOUT=fs
Jan 10 14:03:24 ubu1004 dovecot: lda(alias.user1): Debug: fs: 
root=/datatest/user/alias.user1/maildir, 
index=/datatest/addons/index/alias.user1, 
control=/datatest/user/alias.user1/control, 
inbox=/datatest/user/alias.user1/maildir, alt=
Jan 10 14:03:24 ubu1004 dovecot: lda(alias.user1): Debug: Namespace : 
Using permissions from /datatest/user/alias.user1/maildir: mode=0700 gid=-1
Jan 10 14:03:24 ubu1004 dovecot: lda(alias.user1): Debug: none: root=, 
index=, control=, inbox=, alt=
Jan 10 14:03:24 ubu1004 dovecot: lda(alias.user1): Debug: Destination 
address: alias.user1 at ubu1004 (source: user at hostname)
Jan 10 14:03:24 ubu1004 dovecot: lda(alias.user1): msgid=unspecified: 
saved mail to INBOX
Jan 10 14:03:24 ubu1004 postfix/pipe[25226]: C434D1EE: 
to=<alias.user1 at some.domain.de>, relay=dovecot, delay=14, 
delays=14/0.01/0/0.02, dsn=2.0.0, status=sent (delivered via dovecot 
service)
Jan 10 14:03:24 ubu1004 postfix/qmgr[25221]: C434D1EE: removed

dovecot -n
# 2.0.17 (684381041dc4+): /usr/dovecot/etc/dovecot/dovecot.conf
# OS: Linux 2.6.32-34-generic-pae i686 Ubuntu 10.04.3 LTS ext4
mail_gid = sysdov
mail_location = 
maildir:/datatest/user/%n/maildir:INDEX=/datatest/addons/index/%n:CONTROL=/datatest/user/%n/control:LAYOUT=fs
mail_plugins = autocreate
mail_uid = sysdov

passdb {
   args = failure_show_msg=yes imap
   driver = pam
}
service auth {
   client_limit = 30000
   unix_listener auth-userdb {
     group = sysdov  #effective 133
     mode = 01204
     user = sysdov   #effective 29
   }
}
userdb {
   args = /usr/dovecot/etc/ldapuser.conf
   driver = ldap
}
protocol lda {
   mail_plugins = autocreate
}

and ldapuser.conf:
hosts ...
base ...

user_filter = (&(|(mail=%u)(mail=%n at some.domain)
(uid=%u))(objectClass=posixAccount))

user_attrs = uid=mail_location=maildir:/datatest/user/%$,
uidNumber=29,gidNumber=133
local part of mail should be replaced by uid for local delivery

-- 
Regards --- Burckhard Schmidt



More information about the dovecot mailing list