Aki Tuomi wrote on Thu, 16 Aug 2018 21:03:44 +0300 (EEST):
> Can you provide doveconf -n please?
Thanks for the quick reply. I think I already provided the most relevant
portions of config. I ran a doveconf -n and it doesn't reveal important
information like sql setup. I'll do my best to sum up the relevant parts
below, anyway.
But first I would like to know how the dictionary-based domain quota is
intended to work as that is mentioned nowhere. Is it like in the either/or
example where they say that dovecot can only act on one of the quotas at a
given time or is it intended to be used like the filesystem aquota works?
So, there are two things:
First: I do not quite understand how it is supposed to work. Once I knew I
could test my setup whether it acts on the limits correctly.
The second is the apparent bug with recalc. I omitted to say that the
updating of both quotas by dovecot when mail comes in *does* seem to work
correctly. But if I run a recalc it all gets messed up. This has been
reported a few times over time, so I guess it's not specific to my setup.
So, here's the relevant bits again (and a bit more):
dict {
quota = mysql:/etc/dovecot/dovecot-dict-sql-user.conf
quota_domain = mysql:/etc/dovecot/dovecot-dict-sql-domain.conf
}
mail_home = /var/vmail/%d/%n
mail_location = maildir:/var/vmail/%d/%n/mail/
mail_plugins = " quota"
plugin {
quota = dict:user::proxy::quota
quota2 = dict:domain:%d:proxy::quota_domain
quota_rule = *:storage=100M
quota_rule2 = Trash:storage=+10%%
quota_rule3 = Spam:ignore
quota2_rule = *:storage=1000M
quota2_rule2 = Trash:storage=+10%%
quota2_rule3 = Spam:ignore
quota_vsizes = yes
(+ quota_status, _warning etc. not relevant ...)
}
service dict {
unix_listener dict {
group = vmail
mode = 0600
user = vmail
}
}
service quota-status {
client_limit = 1
executable = quota-status -p postfix
inet_listener {
port = 10024
}
}
userdb {
args = /etc/dovecot/dovecot-sql.conf
driver = sql
}
/etc/dovecot/dovecot-dict-sql-user.conf
connect = ...
map {
pattern = priv/quota/storage
table = quota
username_field = username
value_field = bytes
}
map {
pattern = priv/quota/messages
table = quota
username_field = username
value_field = messages
}
/etc/dovecot/dovecot-dict-sql-domain.conf
connect =
map {
pattern = priv/quota/storage
table = quota_domain
username_field = domain
value_field = bytes
}
map {
pattern = priv/quota/messages
table = quota_domain
username_field = domain
value_field = messages
}
/etc/dovecot/dovecot-sql.conf
user_query = SELECT CONCAT('/var/vmail/',m.maildir) AS home, CONCAT
('maildir:/var/vmail/',m.maildir,'mail/') AS mail, 200 AS uid,
200 AS gid,
concat('*:bytes=', m.quota) AS quota_rule, concat('*:bytes=',
(s.ServerPopQuota*1024*1024)) AS quota2_rule FROM mailbox AS m LEFT JOIN
server AS s ON (m.ServerID = s.ServerID) WHERE (m.username = '%u' OR
m.local_part = "%n") AND m.active = '1'
doveadm quota get of a test domain:
Username Quota name Type Value Limit %
example_01 at example.com user STORAGE 5567 100000 5
example_01 at example.com user MESSAGE 70 - 0
example_01 at example.com domain STORAGE 33426 1024000 3
example_01 at example.com domain MESSAGE 1292 - 0
example_spam at example.com user STORAGE 33403 100000 33
example_spam at example.com user MESSAGE 1280 - 0
example_spam at example.com domain STORAGE 33426 1024000 3
example_spam at example.com domain MESSAGE 1292 - 0
Note: these are values after a recalc and after the users (both) received
some more test mails. So, the figures in general are not correct (if I sum
them up), but you see that user quota is getting updated separate for each
user and that domain quota is equal for both but not equal with any of the
users. Now, if I would do a recalc -A it would look like this:
example_01 at example.com user STORAGE 5567 100000 5
example_01 at example.com user MESSAGE 70 - 0
example_01 at example.com domain STORAGE 33403 1024000 3
example_01 at example.com domain MESSAGE 1280 - 0
example_spam at example.com user STORAGE 33403 100000 33
example_spam at example.com user MESSAGE 1280 - 0
example_spam at example.com domain STORAGE 33403 1024000 3
example_spam at example.com domain MESSAGE 1280 - 0
So, the last user processed determiens the domain values.
Actually, the user values would be recalculated correctly after the recalc
and might be different from above and the domain quota then follows that
by using the last processed user as the single source for it.
Thanks!
Kai