[Dovecot] Custom quota setup
(Dovecot 2.2-ee)
We have a weird quota requirement, we have file storage that we manage through our own APIs but want that usage to come out of the user's mail quota.
The usage is in a maildirsize like file uncreatively called filestoresize in the user's maildir.
In the past we've been doing this by modifying the quota plugin and re-compiling, but it seems like it should be possible to do this via configuration.
Is there a way to add a quota setting pointing at this file for additional usage (not limits)?
The feature is used infrequently so it would probably be acceptable use the dirsize backend, but I can't figure out how to configure that to point at a certain directory.
We pass custom quota rules for each user in our userdb, and use a custom dict proxy program, so that program could read the file and pass a setting at log in time too (if, for example, there was a setting that said "offset the user's quota usage by X amount")
Thanks.
On 2.8.2013, at 18.15, Richard Platel <rplatel@tucows.com> wrote:
We have a weird quota requirement, we have file storage that we manage through our own APIs but want that usage to come out of the user's mail quota.
I've been thinking something like that as well for various other things: IMAP METADATA/ANNOTATE extension data, Sieve scripts, and also the actual file storage once Dovecot implements WebDAV. The quota plugin probably needs to be made extensible in some way to allow calculation of quota from multiple data sources. Or maybe lib-storage API needs to be made more aware of quota. I'm not entirely sure yet.
The usage is in a maildirsize like file uncreatively called filestoresize in the user's maildir.
In the past we've been doing this by modifying the quota plugin and re-compiling, but it seems like it should be possible to do this via configuration.
Is there a way to add a quota setting pointing at this file for additional usage (not limits)?
I can't think of any good way to do that.
The feature is used infrequently so it would probably be acceptable use the dirsize backend, but I can't figure out how to configure that to point at a certain directory.
I guess if you had a hidden non-listable namespace pointing to your file storage, the dirsize would find it and count them. The problem is, you would have to use dirsize backend for the Maildir as well, which is too slow. (Using a separate dirsize quota for files wouldn't then share the mail quota.) And the Maildir++ backend reads only new/ and cur/ directories.
We pass custom quota rules for each user in our userdb, and use a custom dict proxy program, so that program could read the file and pass a setting at log in time too (if, for example, there was a setting that said "offset the user's quota usage by X amount")
That I think would work.
On 2013-08-02, at 11:34 AM, Timo Sirainen <tss@iki.fi> wrote:
On 2.8.2013, at 18.15, Richard Platel <rplatel@tucows.com> wrote:
We pass custom quota rules for each user in our userdb, and use a custom dict proxy program, so that program could read the file and pass a setting at log in time too (if, for example, there was a setting that said "offset the user's quota usage by X amount")
That I think would work.
That's future development though? No such setting exists now?
On 2.8.2013, at 18.56, Richard Platel <rplatel@tucows.com> wrote:
On 2013-08-02, at 11:34 AM, Timo Sirainen <tss@iki.fi> wrote:
On 2.8.2013, at 18.15, Richard Platel <rplatel@tucows.com> wrote:
We pass custom quota rules for each user in our userdb, and use a custom dict proxy program, so that program could read the file and pass a setting at log in time too (if, for example, there was a setting that said "offset the user's quota usage by X amount")
That I think would work.
That's future development though? No such setting exists now?
I'm not exactly sure what you thought of, but my idea was simply that you'd add your own dict proxy in the middle which hooks into the GET command, and increases its value by reading the filestoresize. You can already do that by pointing to a UNIX socket different from the normal dict server socket, similar as in http://wiki2.dovecot.org/AuthDatabase/Dict
On 2013-08-02, at 12:05 PM, Timo Sirainen <tss@iki.fi> wrote:
On 2.8.2013, at 18.56, Richard Platel <rplatel@tucows.com> wrote:
On 2013-08-02, at 11:34 AM, Timo Sirainen <tss@iki.fi> wrote:
On 2.8.2013, at 18.15, Richard Platel <rplatel@tucows.com> wrote:
We pass custom quota rules for each user in our userdb, and use a custom dict proxy program, so that program could read the file and pass a setting at log in time too (if, for example, there was a setting that said "offset the user's quota usage by X amount")
That I think would work.
That's future development though? No such setting exists now?
I'm not exactly sure what you thought of, but my idea was simply that you'd add your own dict proxy in the middle which hooks into the GET command, and increases its value by reading the filestoresize. You can already do that by pointing to a UNIX socket different from the normal dict server socket, similar as in http://wiki2.dovecot.org/AuthDatabase/Dict
If, for example, the user has 2GB quota, and 750MB of mail, and 500MB of files, we'd like the mail client to show that the user has 2GB quota, and 1.25GB used, .75GB free.
I see how via the dict userdb proxy I could reduce the user's quota allowance by the filestorage amount: quota_rule=*:storage=<user allowed storage - filestore size>, and the client would show the correct free amount, but not the correct total or used amount.
Is this what you mean, or is there some other setting or some other dict proxy entirely that I'm missing?
On 2.8.2013, at 19.18, Richard Platel <rplatel@tucows.com> wrote:
I'm not exactly sure what you thought of, but my idea was simply that you'd add your own dict proxy in the middle which hooks into the GET command, and increases its value by reading the filestoresize. You can already do that by pointing to a UNIX socket different from the normal dict server socket, similar as in http://wiki2.dovecot.org/AuthDatabase/Dict
If, for example, the user has 2GB quota, and 750MB of mail, and 500MB of files, we'd like the mail client to show that the user has 2GB quota, and 1.25GB used, .75GB free.
I see how via the dict userdb proxy I could reduce the user's quota allowance by the filestorage amount: quota_rule=*:storage=<user allowed storage - filestore size>, and the client would show the correct free amount, but not the correct total or used amount.
Is this what you mean, or is there some other setting or some other dict proxy entirely that I'm missing?
I didn't mean userdb dict proxy. I meant you'd use dict backend for calculating quota instead of Maildir++. http://wiki2.dovecot.org/Quota/Dict
So for example you could still keep using the file based quota and first step would be to configure:
plugin { quota = dict:User quota::file:%h/Maildir/dovecot-quota }
Next I thought you could have configured dict proxy to access the file, but %h or ~/ don't actually work there.. So you'd probably have to implement the whole file access via your dict server:
plugin { quota = dict:User quota::proxy:/var/run/dovecot/tucows-quota:quota }
Then you'd have a process listening on tucows-quota UNIX socket that handles the get/set/unset/atomic-inc dict commands. Or alternatively implement a new dict backend as a Dovecot plugin that does the same thing:
plugin { quota = dict:User quota::proxy::quota } dict { quota = tucowsquota: }
participants (2)
-
Richard Platel
-
Timo Sirainen