Hi Dave,
David Mehler wrote:
I've got quotas set up on an all-user basis on my system, it's a Postfix, Dovecot, Mysql virtual users setup. Currently I have each user getting a 1GB quota with these settings in 90-quota.conf:
plugin { quota_rule = *:storage=1G quota_rule2 = Trash:storage=+100M } plugin { quota = maildir:User quota }
While this works it's not what I want for all users. Say I add a virtual user called user1 to the mysql database but he's a test user and I only want that user to have 25 megabytes of storage, reading the wiki on quotas per-user items such as for example in a database overrides the global items above, is this right?
If so, I'm hoping I'm not going to have to redo my entire user database, some users will have per-user quotas while I'll let others have the global quota.
You can just make your SQL query a bit more sophisticated in order to fit your needs.
MySQL supports SQL CASE statement and default value with ELSE: http://dev.mysql.com/doc/refman/5.1/en/case.html
This example sets quota to unlimited if mail comes in via port 20025, otherwise is uses the quota_bytes and quota_message columns:
user_query = SELECT username AS user,
home as home,
uid as uid,
gid as gid,
CASE '%a'
WHEN '20025' THEN '*:bytes=0:messages=0'
ELSE
CONCAT('*:bytes=', CAST(quota_bytes AS CHAR), ':messages=', CAST(quota_message AS CHAR))
END AS quota_rule
FROM dovecot_users
WHERE username='%u'