If anyone's interested about implementing quota code for Dovecot (there were a few of you before! :), now it's finally your chance to do it quite easily. With the API changes committed today to CVS, it's now much easier to write plugins that modify mail-storage behavior. So, I finally fixed my half-working quota plugin that had been lying there for a while. It implements the RFC2087 quota commands for IMAP, a generic quota API that should allow pretty much any kind of quota implementation, and the actual quota limit checking for saving and copying mails. As an example there's an implementation which just scans through all files in a directory and sums their sizes. Currently it can be made to work only when starting from command line, eg.: export QUOTA=~/mail:storage=1024 export MODULE_DIR=/usr/local/lib/dovecot/imap ./imap The QUOTA variable is passed to the quota implementation. In this case quota-dirsize reads it, figures out that ~/mail is the directory where to count the files, and 1024kB is the maximum for quota. I think I'll change the master process code so that any unrecognized varibles that come from userdb are fed to imap/pop3 processes. That way you could simply make the userdb return the quota value (and set other user-specific settings as well). Available from: http://dovecot.org/patches/1.0/quota.tar.gz Unpack under dovecot/src, compile command is at the beginning of quota-plugin.c I'm still wondering where this code should be placed. Maybe the core implementation should be built into Dovecot, while the different quota implementations would be plugins? ..And even better would be if Dovecot's build process was modified so that it's possible to specify with configure script what to compile in and what to compile as plugins.. Anyway, comments welcome, Maildir++ implementation welcome, other implementations welcome as well :) -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://dovecot.org/pipermail/dovecot/attachments/20050316/62d72e2d/attachment-0001.bin>
On Wed, Mar 16, 2005 at 12:15:43AM +0200, Timo Sirainen wrote:> If anyone's interested about implementing quota code for Dovecot (there > were a few of you before! :), now it's finally your chance to do it > quite easily.Hah, excellent. I suspect my colleague Cor was one of the people interested in quota support, and I know I am. So I took the example and turned it into an rquotad (quota-over-nfs) implementation. It's fairly FreeBSD specific at the moment, as rquotad is an RPC mess and I had to be inspired by the source of the 'quota' command, but I suspect it's probably possible to port it to other operating systems. When it's done, that is. The plugin seems a bit out-of-date, by the way; it passes the wrong number of arguments to 'mailbox_open', and uses a nonexistant function 'i_stream_get_size'. I had to fudge around that creatively to get the plugin to compile. The rquotad plugin is done, more or less, except for figuring out how to properly get at a mailbox's physical location, if it has one. I really don't want to maintain a static list in an environment variable; we currently use 10 different filesystems (all NFS) for mail storage, and they all have different quotas and usage. I don't particularly care about checking quotas before an attempted write, but I implemented that as best I could; I still need to figure out how to decode the mail_transaction_context to see where a mail is moved from/to in order to finish it. The quota-plugin thing obviously isn't quite done yet (at least, not the tarball version from the patches/1.0 directory) -- it lacks some error checking, I think, and a capability hook from what I can tell. (There *is* a capability for quotas, I hope, in IMAP ?) If you lack time but have an idea as to what needs to be done, I can work on it and submit patches. Once I get the rquotad plugin *somewhat* working I'll put it up somewhere, too. -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!