Dovecot migration from static to passwd-file userdb driver

Solution 1:

Just to complement your answer, you only need two colons after the password field for the default_values in userdb to be picked up.

/etc/dovecot/local.conf
-----------------------
passdb { 
  driver = passwd-file
  args = scheme=CRYPT username_format=%u /etc/dovecot/passwd
}

userdb {
    driver = passwd-file
    args = username_format=%u /etc/dovecot/passwd
    default_fields = uid=vmail gid=vmail home=/srv/vmail/%u
#    driver = static
#    args = uid=vmail gid=vmail home=/srv/vmail/%u
}
/etc/dovecot/passwd
-------------------
[email protected]:{SHA512}longPasswordHash::

Verification with doveadm gives also the home folder :

$ doveadm user [email protected]
field   value
uid     5000
gid     5000
home    /srv/vmail/[email protected]
mail    maildir:/srv/vmail/[email protected]/Maildir

Solution 2:

I wrongly assumed that fields other than user and password were optional since default_fields would take care of them.

Actually, the documentation states (emphasis mine)

[The password file is] in the following format:

user:password:uid:gid:(gecos):home:(shell):extra_fields

For a password database it's enough to have only the user and password fields. For a user database, you need to set also uid, gid and preferably also home (see VirtualUsers). (gecos) and (shell) fields are unused by Dovecot.

So those fields are actually mandatory. But since they are already set by default_fields, they can be empty :

user:{SHA512}pwd:::

I figured it by chance because the only working account was the one I was testing the quota on (using the per user userdb_quota_rule extra field)…

The doveadm user [email protected] was also very useful for debugging this issue.