Tim Jones
2015-Feb-27 18:20 UTC
userdb passwd-file default_fields uid not expanding %variable
Hi all, I'm trying to set up a very simple shared mail server, where each 'domain' is a system user, i.e. 'example.com' is a real user with /home/example.com/, a uid of 5001 (and gid 'example.com' of 5001). Each domain\user has their own maildir inside their home, and a plain passwd-file with the virtual mail users associated with that domain. Version & config info: # dovecot -n # 2.2.13: /etc/dovecot/dovecot.conf # OS: Linux 3.2.0-4-amd64 x86_64 Debian 7.8 auth_mechanisms = plain login auth_verbose = yes disable_plaintext_auth = no mail_location = mbox:~/mail:INBOX=/var/mail/%u 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 = username_format=%n /home/%d/mail_users driver = passwd-file } protocols = " imap lmtp pop3" ssl = no userdb { args = username_format=%n /home/%d/mail_users default_fields = uid=%d gid=%d home=/home/%d/mail/%n mail=maildir:/home/%d/mail/%n driver = passwd-file } Every time I try to authenticate via imap, I get the error> <timestamp> <host> dovecot: auth: Fatal: passwd-file userdb: Invalid uid: %dIf I put fixed a uid and gid in the userdb default_fields line:> default_fields = uid=example.com gid=example.com home=/home/%d/mail/%n mail=maildir:/home/%d/mail/%nauthentication passes without a problem, but of course, only for users of example.com. Checking the wiki (http://wiki2.dovecot.org/UserDatabase#Userdb_settings) clearly states that the default_fields values support %variables, so I'm not sure if I'm missing some other config required for this to work. Many thanks in advance, Tim Jones Software Development +34 612345678 C/ Quintanavides 15, Edificio 2, Planta 1? Parque Empresarial V?a Norte de Metrovacesa Las Tablas 28050 Madrid Skype: tim.jones.fon All information in this email is confidential
Tim Jones
2015-Feb-27 21:24 UTC
userdb passwd-file default_fields uid not expanding %variable
First, sorry for the double post, not sure how that happened. Secondly, I should add the userdb error happens as soon as any connection attempt is map to the pop3\imap port, before a login command can be sent. Obviously, since no login is started, there will be no username from which to extract the %d domain name variable. So the error makes sense. My problem is that the userdb is being checked upon connection rather than login, is there a way to bypass or disable that. Or maybe a 'failover' userdb to try if the correct one fails. Many thanks, Tim Jones Software Development +34 612345678 C/ Quintanavides 15, Edificio 2, Planta 1? Parque Empresarial V?a Norte de Metrovacesa Las Tablas 28050 Madrid Skype: tim.jones.fon All information in this email is confidential On 27 February 2015 at 19:20, Tim Jones <tim.jones at fon.com> wrote:> Hi all, > > I'm trying to set up a very simple shared mail server, where each > 'domain' is a system user, i.e. 'example.com' is a real user with > /home/example.com/, a uid of 5001 (and gid 'example.com' of 5001). > Each domain\user has their own maildir inside their home, and a plain > passwd-file with the virtual mail users associated with that domain. > > Version & config info: > > # dovecot -n > # 2.2.13: /etc/dovecot/dovecot.conf > # OS: Linux 3.2.0-4-amd64 x86_64 Debian 7.8 > auth_mechanisms = plain login > auth_verbose = yes > disable_plaintext_auth = no > mail_location = mbox:~/mail:INBOX=/var/mail/%u > 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 = username_format=%n /home/%d/mail_users > driver = passwd-file > } > protocols = " imap lmtp pop3" > ssl = no > userdb { > args = username_format=%n /home/%d/mail_users > default_fields = uid=%d gid=%d home=/home/%d/mail/%n > mail=maildir:/home/%d/mail/%n > driver = passwd-file > } > > Every time I try to authenticate via imap, I get the error > >> <timestamp> <host> dovecot: auth: Fatal: passwd-file userdb: Invalid uid: %d > > > If I put fixed a uid and gid in the userdb default_fields line: > >> default_fields = uid=example.com gid=example.com home=/home/%d/mail/%n mail=maildir:/home/%d/mail/%n > > authentication passes without a problem, but of course, only for users > of example.com. > > Checking the wiki > (http://wiki2.dovecot.org/UserDatabase#Userdb_settings) clearly states > that the default_fields values support %variables, so I'm not sure if > I'm missing some other config required for this to work. > > Many thanks in advance, > > Tim Jones > Software Development > +34 612345678 > C/ Quintanavides 15, Edificio 2, Planta 1? > Parque Empresarial V?a Norte de Metrovacesa > Las Tablas > 28050 Madrid > Skype: tim.jones.fon > All information in this email is confidential
Steffen Kaiser
2015-Mar-02 07:37 UTC
userdb passwd-file default_fields uid not expanding %variable
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Fri, 27 Feb 2015, Tim Jones wrote:> userdb { > args = username_format=%n /home/%d/mail_users > default_fields = uid=%d gid=%d home=/home/%d/mail/%n > mail=maildir:/home/%d/mail/%n > driver = passwd-file > } > > Every time I try to authenticate via imap, I get the error > >> <timestamp> <host> dovecot: auth: Fatal: passwd-file userdb: Invalid uid: %dPutting aside the question, whether or not %d is/should be expanded in default_fields = uid=%d gid=%d couldn't or shouldn't you place the correct numerical ids in the file anyway?> If I put fixed a uid and gid in the userdb default_fields line: > >> default_fields = uid=example.com gid=example.com home=/home/%d/mail/%n mail=maildir:/home/%d/mail/%n > > authentication passes without a problem, but of course, only for users > of example.com.- -- Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEVAwUBVPQTPXz1H7kL/d9rAQIXQAgAx2u5pds6c3YygbHwCj4lkK1DR3FVKx4+ u24cLNacU/AiqNYC4AN6gQ180EaqK3M3bPnfV0rsuyy6fOcHwXm6HpbYIUNkUbBV WZYZPu0K+FoLWLL0JnjoXAe2QWK0whb9h4BLeG9xIA6FpRKwwnJYv0MuEqk78rZv HHrwbZra1XEbqKJsMHxYyhZ+ZOA9cC/mz25iZhBdygPPuxVgr7RtFfppI2DwdU+n XeDsr7OExgMgetBFImEYnA9YzZ5P7kxpNguaNoMtB5MFKsfhtaeCkATOoBW8Mpcw KTfVQriL3TiyVfYFU4eruJBcz6XOOvkEcrWiZytJV5WDl8GDYfYRqA==X8eE -----END PGP SIGNATURE-----
Tim Jones
2015-Mar-02 08:12 UTC
userdb passwd-file default_fields uid not expanding %variable
> Putting aside the question, whether or not %d is/should be expanded in > default_fields = uid=%d gid=%d > couldn't or shouldn't you place the correct numerical ids in the file > anyway?The issue is, and maybe this was a bad requirement on my part, that each domains' mailbox is owned by the user associated with that domain. I don't have a global 'virtualmail' user that handles the mailboxes. Each 'domain' hosted on the server is a system user, with their own PHP instance, Python virtualenv etc, and maildir inside $HOME. So until the client issues a log in, I don't know which uid\gid to assign to them. Many thanks, Tim Jones Software Development +34 612345678 C/ Quintanavides 15, Edificio 2, Planta 1? Parque Empresarial V?a Norte de Metrovacesa Las Tablas 28050 Madrid Skype: tim.jones.fon All information in this email is confidential