Hello folks - I'm running dovecot on top of qmail/vpopmail/mysql, serving up about 2500 mailboxes. Everything is running very smooth and fast.... I recently upgraded dovecot to 1.1, so I'm trying to implement some extra features like IMAP quotas. I'm using the sql passdb, with the following config: driver = mysql connect = host=/var/lib/mysql/mysql.sock user=username password=password dbname=vpopmail default_pass_scheme = PLAIN password_query = SELECT CONCAT(pw_name, '@', pw_domain) AS user, pw_clear_passwd AS password FROM vpopmail WHERE pw_name = '%n' AND pw_domain = '%d' user_query = SELECT pw_dir as home, 508 AS uid, 503 AS gid FROM vpopmail WHERE pw_name = '%n' AND pw_domain = '%d' My vpopmail installation keeps the quota information in the mysql database (pw_shell field) instead of maildirsize. The quota is in maildir format, e.g. 400M or 50331648S. Unlimited quota is specified as NOQUOTA. The question is... Is it possible to make dovecot understand this format and get it directly from SQL (via user_query, for example) or would it be easier to reconfigure the vpopmail installation somehow to use maildirsize? Thanks! Vlad
On Fri, 2009-03-13 at 09:09 -0500, Vlad Sedov wrote:> My vpopmail installation keeps the quota information in the mysql > database (pw_shell field) instead of maildirsize. The quota is in > maildir format, e.g. 400M or 50331648S.The 400M means 400 messages, right? "backend" limit is supposed to work here, but I don't know if anyone's actually tried it yet. So try something like: select concat('*:backend=', pw_shell) as quota_rule, ..> Unlimited quota is specified as NOQUOTA.That probably gives an error. You should return 0 instead. For that you need to use MySQL's CASE or IF somehow. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part URL: <http://dovecot.org/pipermail/dovecot/attachments/20090313/e8e75784/attachment-0002.bin>
I think I figured it out... I reformatted all of the quotas from the old vpopmail style (e.g. 400M, which is 400 megabytes) to the Maildir++ format (e.g. 419430400S,2000C which is 400MB or 2000 messages quota). Here's my new user_query (we don't limit by message count, hence 0C... UID/GID is specific to the box): user_query = SELECT pw_dir as home, 508 AS uid, 503 AS gid, concat('*:backend=', if(pw_shell LIKE 'NOQUOTA', '0S', pw_shell), ',0C') as quota_rule FROM vpopmail WHERE pw_name = '%n' AND pw_domain = '$d' I'm still using vpopmail's delivery agent, but now the quotas are understood by both vpopmail and dovecot, so It's all good :-) Vlad Timo Sirainen wrote:> On Fri, 2009-03-13 at 09:09 -0500, Vlad Sedov wrote: > >> My vpopmail installation keeps the quota information in the mysql >> database (pw_shell field) instead of maildirsize. The quota is in >> maildir format, e.g. 400M or 50331648S. >> > > The 400M means 400 messages, right? "backend" limit is supposed to work > here, but I don't know if anyone's actually tried it yet. So try > something like: > > select concat('*:backend=', pw_shell) as quota_rule, .. > > >> Unlimited quota is specified as NOQUOTA. >> > > That probably gives an error. You should return 0 instead. For that you > need to use MySQL's CASE or IF somehow. > >