Sql user and maildirs

@lbutlr kremels at kreme.com
Sun Jun 9 18:42:37 EEST 2019


For many years I had the following in my dovecot.conf:

userdb {
  args = /usr/local/etc/dovecot/dovecot-sql.conf.ext
  default_fields = uid=vpopmail gid=vchkpw mail_location=/usr/local/virtual/%u/Maildir mail=maildir:/usr/local/virtual/%u/Maildir
  driver = sql
}

Recently, I started having quite a lot of errors on one MySQL account (used as a bcc backup account) along the lines of 

Fatal: Namespace '': Ambiguous mail location setting, don't know what to do with it: /usr/local/virtual/backup at domain/Maildir (try prefixing it with mbox: or maildir:

Messages were sitting in the mail and were also getting dumped into /usr/local/virtual/backup at domain/new and I ended up running a fun little awk to move them into the right folders:

grep -r "<backup+" . |awk -F: '{t=tolower($2);
	f=tolower($1); 
	gsub(/@.*/, "/", t); 
	sub(/<backup\+/, "../Maildir/", t);
	sub(/\.\//, "",f);
	cmd="mv " f" “t;
	system(cmd);
}’

So I changed my doevecot.conf to:

userdb {
  args = /usr/local/etc/dovecot/dovecot-sql.conf.ext
  default_fields = uid=vpopmail gid=vchkpw mail_location=maildir:/usr/local/virtual/%u/Maildir mail=maildir:/usr/local/virtual/%u/Maildir
  driver = sql
}

And the errors went away.

So, no problem here to solve, but I am curious why I haven’t been having issues until quite recently? Was there a change or have I stumbled into something where it only looks like I’ve fixed the issue?

In case it matters?

# cat dovecot-sql.conf.ex                                                                                                                                                                                                                                     [7:57] [/etc/dovecot] 
driver =  mysql
connect = host=localhost dbname=postfixusers user=dovecot password=x
default_pass_scheme = SHA256-CRYPT
password_query = select password FROM mailbox where username ='%u'
user_query = select 89 as uid, 89 as gid, concat('/usr/local/virtual/', maildir, 'Maildir') as home FROM mailbox where username = '%u'

The only ‘recent’ change I’ve made to my configuration was creating the Maildir/ subfolder for all the virtual users instead of using the ‘mailder’ from the sql table (that is, I added  “, ‘Maildir’” to the concat, but that was quite awhile ago. I’m pretty sure I’d have noticed this before.

Is that user_query as it should be or should I set concat('/usr/local/virtual/', maildir) as home and also set concat(‘maildir:/usr/local/virtual/', maildir, 'Maildir') as mail here rather than in the userdb block?



-- 
K is for KATE who was struck by an axe
L is for Leo who swallowed some tacks




More information about the dovecot mailing list