[Dovecot] Problem with configuring dovecot to take namespaces from database
Hello! I'd like to set up dovecot to keep namespaces in database, keep more than one namespace per user.
I try to create the simplest rule (even without tuple in db table) to get new namespace, unfortunately it doesn't work.
My user_query is: SELECT '/dane/domeny/%d/mail/%n/' as home, dovecot_typ_skrzynki ||':'|| '/dane/domeny/%d/mail/%n/' ||'.'|| dovecot_typ_skrzynki as mail_location, '*:bytes='||quota_mb||'M' as quota_rule , 'test33/location=mdbox:~/.mdbox/test33/' as "namespace/test3/prefix"
In debug log i'm getting: Debug: master out: USER#0111#011user@examle.com#011home=/dane/domeny/mejor.pl/mail/marcin/#011mail_location=maildir:/dane/domeny/mejor.pl/mail/marcin/.maildir#011quota_rule=*:bytes=0M#011namespace/test3/prefix=test33/location=mdbox:~/.mdbox/test33/
If i knew how it should look like the line in auth debug log for working configuration it could be easier for me to write correct sql query. May i please for advice?
dovecot -n output (with version number)?
On 7.9.2011, at 17.42, Marcin Mirosław wrote:
Hello! I'd like to set up dovecot to keep namespaces in database, keep more than one namespace per user.
I try to create the simplest rule (even without tuple in db table) to get new namespace, unfortunately it doesn't work.
My user_query is: SELECT '/dane/domeny/%d/mail/%n/' as home, dovecot_typ_skrzynki ||':'|| '/dane/domeny/%d/mail/%n/' ||'.'|| dovecot_typ_skrzynki as mail_location, '*:bytes='||quota_mb||'M' as quota_rule , 'test33/location=mdbox:~/.mdbox/test33/' as "namespace/test3/prefix"
In debug log i'm getting: Debug: master out: USER#0111#011user@examle.com#011home=/dane/domeny/mejor.pl/mail/marcin/#011mail_location=maildir:/dane/domeny/mejor.pl/mail/marcin/.maildir#011quota_rule=*:bytes=0M#011namespace/test3/prefix=test33/location=mdbox:~/.mdbox/test33/
If i knew how it should look like the line in auth debug log for working configuration it could be easier for me to write correct sql query. May i please for advice?
W dniu 07.09.2011 16:50, Timo Sirainen pisze:
dovecot -n output (with version number)?
Argh, i've forgot about it:( Dovecot-2.0.14
# 2.0.14: /etc/dovecot/dovecot.conf # OS: Linux 3.1.0-rc4-git2 x86_64 Gentoo Base System release 2.0.3 auth_cache_size = 1 k auth_debug = yes auth_mechanisms = login digest-md5 cram-md5 plain default_vsz_limit = 32 M deliver_log_format = msgid=%m: from=%f: phys=%p: virt=%w %$ dict { quota = pgsql:/etc/dovecot/dovecot-dict-sql.conf.ext } first_valid_uid = 8 last_valid_uid = 8 lda_mailbox_autocreate = yes lda_mailbox_autosubscribe = yes mail_attachment_dir = /dane/domeny/zalaczniki mail_attachment_min_size = 64000 k mail_cache_min_mail_count = 20 mail_gid = mail mail_plugins = autocreate quota fts fts_squat notify mail_log zlib mail_privileged_group = mail mail_uid = mail maildir_stat_dirs = yes managesieve_notify_capability = mailto managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include var iables body enotify environment mailbox date mdbox_rotate_interval = 60 days mdbox_rotate_size = 50 M namespace { inbox = yes list = yes location = prefix = separator = . subscriptions = yes type = private } passdb { args = /etc/dovecot/dovecot-sql.conf.ext driver = sql } plugin { autocreate = Trash autocreate2 = Spam autocreate3 = Sent autocreate4 = Drafts autosubscribe = Trash autosubscribe2 = Spam autosubscribe3 = Sent autosubscribe4 = Drafts fts = squat fts_squat = partial=4 full=10 quota = dict:User quota::proxy::quota quota_exceeded_message = Quota exceeded / Skrzynka odbiorcy jest przepelniona, wiadomosc nie zostala dostarczona sieve = /dane/domeny/%d/mail/%n/.maildir/.dovecot.sieve sieve_dir = /dane/domeny/%d/mail/%n/.maildir/sieve zlib_save = bz2 } postmaster_address = forspam@kolekcja.mejor.pl protocols = imap pop3 sieve service auth { unix_listener auth-userdb { group = mail mode = 0660 user = root } } service dict { unix_listener dict { user = mail } } service managesieve-login { inet_listener sieve_deprecated { port = 2000 } vsz_limit = 4 M } ssl_cert = </etc/ssl/gwiazdka.mejor.pl.pem ssl_key = </etc/ssl/gwiazdka.mejor.pl.pem userdb { driver = prefetch } userdb { args = /etc/dovecot/dovecot-sql.conf.ext driver = sql } verbose_proctitle = yes protocol lda { mail_plugins = autocreate quota fts fts_squat notify mail_log zlib sieve } protocol imap { imap_client_workarounds = tb-extra-mailbox-sep mail_max_userip_connections = 25 mail_plugins = autocreate quota fts fts_squat notify mail_log zlib imap_quota imap_zlib }
On 7.9.2011, at 17.59, Marcin Mirosław wrote:
namespace { inbox = yes list = yes location = prefix = separator = . subscriptions = yes type = private }
You want to modify this namespace, or add a completely new namespace? I don't think you can add new ones via userdb lookup.. You'll basically have to have a template in the config file first, like:
namespace newspace { }
Then you can add settings to it via e.g. 'namespace/newspace/location'.
If all users don't have a namespace, you can set the defaults so it's invisible:
namespace newspace { list = no hidden = yes }
W dniu 07.09.2011 17:09, Timo Sirainen pisze:
On 7.9.2011, at 17.59, Marcin Mirosław wrote:
namespace { inbox = yes list = yes location = prefix = separator = . subscriptions = yes type = private }
You want to modify this namespace, or add a completely new namespace?
I want to add completely new.
I don't think you can add new ones via userdb lookup.. You'll basically have to have a template in the config file first, like:
namespace newspace { }
Hmm, it doesn't looks flexible ;) But probably should be enough for my purposes. Is feature "namespace from db" in your plans or it's too rarely needed to spend time on it?
On 7.9.2011, at 18.19, Marcin Mirosław wrote:
I don't think you can add new ones via userdb lookup.. You'll basically have to have a template in the config file first, like:
namespace newspace { }
Hmm, it doesn't looks flexible ;) But probably should be enough for my purposes. Is feature "namespace from db" in your plans or it's too rarely needed to spend time on it?
Actually I'm not completely sure if this is needed. Get it working first with this template, and then see if it continues working after removing the template.
'test33/location=mdbox:~/.mdbox/test33/' as "namespace/test3/prefix"
This is wrong in any case. It should be something like:
'mdbox:~/.mdbox/test33' as 'namespace/test33/location', 'test33.' as 'namespace/test33/prefix'
W dniu 07.09.2011 17:24, Timo Sirainen pisze:
On 7.9.2011, at 18.19, Marcin Mirosław wrote: Actually I'm not completely sure if this is needed. Get it working first with this template, and then see if it continues working after removing the template.
I did namespace template: namespace test33 { separator = . # without this i got error: Initialization #failed: namespace configuration error: list=yes requires #prefix=test33. to end with separator }
I've change sql query to get data from table. For other user which doesn't have configured namespace in db i've got error: Initialization failed: namespace configuration error: Duplicate namespace prefix: ""
So there is something which i should fix. Thanks
On Thu, 2011-09-08 at 11:26 +0200, Marcin Mirosław wrote:
W dniu 07.09.2011 17:24, Timo Sirainen pisze:
On 7.9.2011, at 18.19, Marcin Mirosław wrote: Actually I'm not completely sure if this is needed. Get it working first with this template, and then see if it continues working after removing the template.
I did namespace template: namespace test33 { separator = . # without this i got error: Initialization #failed: namespace configuration error: list=yes requires #prefix=test33. to end with separator }
I've change sql query to get data from table. For other user which doesn't have configured namespace in db i've got error: Initialization failed: namespace configuration error: Duplicate namespace prefix: ""
You can't have two namespaces with prefix="". So for example add:
namespace test33 { prefix = test33. }
W dniu 08.09.2011 11:40, Timo Sirainen pisze:
You can't have two namespaces with prefix="". So for example add:
namespace test33 { prefix = test33. }
I admit that I slightly lost me. Let me try to summarize: than Z. I can get from db "location" for such namespace used by user Z.
- i can't use db to keep completely definition of namespace(s) -- e.g. user X has no additional namespace, user Y has 3 additonal namespaces with location Y1, Y2, Y3
- if user Z wants new namespace i have to define it in config and user_db query should return list=no and hidden=yes for users diffrent
This is how i understood all our talk. I hope i didn't missed too much :) Thank you.
On Thu, 2011-09-08 at 13:00 +0200, Marcin Mirosław wrote:
W dniu 08.09.2011 11:40, Timo Sirainen pisze:
You can't have two namespaces with prefix="". So for example add:
namespace test33 { prefix = test33. }
I admit that I slightly lost me. Let me try to summarize: than Z. I can get from db "location" for such namespace used by user Z.
- i can't use db to keep completely definition of namespace(s) -- e.g. user X has no additional namespace, user Y has 3 additonal namespaces with location Y1, Y2, Y3
- if user Z wants new namespace i have to define it in config and user_db query should return list=no and hidden=yes for users diffrent
Forget all of that. I just tried a few ways and looks like you can add more namespaces by returning e.g. these fields (from SQL):
namespace=nsname namespace/nsname/prefix=prefix/ namespace/nsname/location=maildir:/elsewhere namespace/nsname/separator=/
Where nsname is some unique name for the namespace. If you want more than one namespace, I think you can do it by adding another name to "namespace" field, e.g.:
namespace=nsname nsname2 nsname3
W dniu 08.09.2011 15:18, Timo Sirainen pisze:
Forget all of that. I just tried a few ways and looks like you can add more namespaces by returning e.g. these fields (from SQL):
namespace=nsname namespace/nsname/prefix=prefix/ namespace/nsname/location=maildir:/elsewhere namespace/nsname/separator=/
Where nsname is some unique name for the namespace. If you want more than one namespace, I think you can do it by adding another name to "namespace" field, e.g.:
namespace=nsname nsname2 nsname3
select .... "test1 test2" AS namespace works, it gives me two namespaces. It's nice. Now i've another problem, how to configure them usinq sql. I can't do "recursive sql query" , sql can't create variable number of output columns depended on values in table. E.g: I imagine such table:
|user_id | namespace | prefix | location |
| 648 | test1 | test1. | mdbox:~/test1/.mdbox |
| 648 | test2 | test2. | maildir:~/test2/.maildir |
etc...
In query i have to know all namespaces names to mention them in query: select ... as "namespace/test1/prefix" but i don't know if there is "test1" namespace untill i fetch record from table.
Ok, maybe could it be possible to do it in other way:
|user_id | namespace_full_definition |
| 7684 | /name=test1/prefix=test1./location=mdbox:~/test1/.mdbox/ name=test2/prefix=test2/location=... |
but this isn't supported by dovecot as i know. Maybe something like "user_namespace" query could be usefull? Query could be very easy: select ... namespace_name, namespace_prefix, namespace_location where user='somuser' (and table schema like in first example). Maybe there i other, way to do it by i can't see it now.
Btw, i can see dovecot 2.1 can proxy imap connections. It's a great idea!
Thanks.
On Fri, 2011-09-09 at 13:24 +0200, Marcin Mirosław wrote:
Ok, maybe could it be possible to do it in other way:
|user_id | namespace_full_definition |
| 7684 | /name=test1/prefix=test1./location=mdbox:~/test1/.mdbox/ name=test2/prefix=test2/location=... |
but this isn't supported by dovecot as i know.
Not exactly like that, but you should be able to have a field called "userdb_import" that contains data like:
namespace=n1 n2<TAB>namespace/n1/prefix=blah.<TAB>etc. other fields
The <TAB>s would of course have to be actual tab characters.
W dniu 12.09.2011 12:21, Timo Sirainen pisze:
Not exactly like that, but you should be able to have a field called "userdb_import" that contains data like:
namespace=n1 n2<TAB>namespace/n1/prefix=blah.<TAB>etc. other fields
The<TAB>s would of course have to be actual tab characters.
Cool. I've changed field separator in db to more visible for human eyes, next i do replace in sql to tab and works good. Thank you for help! Regards, Marcin
participants (2)
-
Marcin Mirosław
-
Timo Sirainen