[Dovecot] Shared mailboxes not working with . dot namespace separator - values truncated in SQL

Frantisek Kucera konference at frantovo.cz
Tue Apr 22 21:08:04 UTC 2014


Hello,

I have Dovecot configured for multiple domains (usernames are user at domain.tld) and I wanted to enable shared mailboxes. 

But there is some problem - if I share a folder, other user can't see it.

In the log I foud:

>  Apr 22 19:21:02 veverka dovecot: imap(user at veverka.tld): Error: Couldn't create namespace 'shared.' for user petr: userdb didn't return a home directory, but location used it (%h): maildir:%h/Maildir:INDEX=~/Maildir/shared/%%u
>  Apr 22 19:21:02 veverka dovecot: imap(user at veverka.tld): Error: Couldn't create namespace 'shared.' for user emclient at veverka: userdb didn't return a home directory, but location used it (%h): maildir:%h/Maildir:INDEX=~/Maildir/shared/%%u

Which is weird because the user name is "petr.surname" not only "petr" and the domain is "veverka.tld" not only "veverka".

So I turned on SQL logging on my PostgreSQL and saw that Dovecot executes these queries:

>  2014-04-22 19:21:02 CEST LOG:  statement: SELECT * FROM dovecot_uzivatel WHERE login = 'petr' AND domena = ''
>  2014-04-22 19:21:02 CEST LOG:  statement: SELECT * FROM dovecot_uzivatel WHERE login = 'emclient' AND domena = 'veverka'

The first username was "petr.surname at veverka.tld" and the second one was "emclient at veverka.tld" so it seems that it was truncated right after first "." dot and I afraid that this is a bug.
Then it is obvious that Dovecot can't find the home directory and complains in log (as mentioned above).

I found workaround – I had "." configured as namespace separator so I reconfigured it to "/" slash and now mailbox sharing works!
But I think that it should work also with "." dot separator and the values should not be truncated in SQL queries.
I tried also using '%u' in my SQL and its value was also truncated.

Values in "dovecot-acl" a "shared-mailboxes" files seem to be ok.

BTW: I have also another server with only one domain and simple user names (no dots) and there the mailbox sharing works –  but now it seems that it works only accidentally. This might lead to hardly debuggable problems if someone has usernames with and without dots – mailbox sharing will work for some users but for some not.

My old configuration:

> password_query = SELECT * FROM dovecot_heslo WHERE login = '%n' AND domena = '%d'
> user_query = SELECT * FROM dovecot_uzivatel WHERE login = '%n' AND domena = '%d'
> iterate_query = SELECT login AS username, domena AS domain FROM dovecot_uzivatel

>  namespace {
>    type = shared
>    separator = .
>    prefix = shared.%%u.
>    location = maildir:%h/Maildir:INDEX=~/Maildir/shared/%%u
>    subscriptions = yes
>    list = children
>  }

Had to be reconfigured to:

>    separator = /
>    prefix = shared/%%u/

Used version:

> # dovecot --version
> 2.1.7
> # uname -a
> Linux veverka 3.11.0-19-generic #33-Ubuntu SMP Tue Mar 11 18:48:34 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Regards,
Franta

P.S. If you have similar problem and have to switch from "." to "/" separators, don't forget to update your Sieve scripts (with fileinto). And sometimes also reconfiguration of the client is needed (e.g. NGImap4ConnectionStringSeparator in SOGo; and Kontact/KMail stopped working and I had to recreate the account in this client).


More information about the dovecot mailing list