1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
|
Quota Configuration
===================
Contents
1. Quota Configuration
1. Quota rules
1. Limit configuration
2. Per-user quota
1. LDAP
2. MySQL
3. PostgreSQL, SQLite
4. passwd-file
5. passwd
3. Quota for public namespaces
4. Quota for private namespaces
5. Custom Quota Exceeded Message
6. Quota warnings
The configuration is split into multiple settings:
First you have the quota root backend configuration. Quota root is a concept
from IMAP Quota specifications [http://www.rfc-editor.org/rfc/rfc2087.txt].
Normally you'll have only one quota root, but in theory there could be e.g.
"user quota" and "domain quota" roots. It's unspecified how the quota roots
interact with each others (if at all). In some systems for example INBOX could
have a completely different quota root from the rest of the mailboxes (e.g.
INBOX in '/var/mail/' partition and others in '/home/' partition).
Quota root configuration includes the backend name, quota root name and its
parameters, if there are any:
---%<-------------------------------------------------------------------------
quota = <backend>[:<quota root name>[:<backend args>]]
---%<-------------------------------------------------------------------------
The quota root name is just an arbitrary string that is sent to IMAP clients,
which in turn may show it to the user. The name has no meaning. By default an
empty string is used, but you may want to change that since some clients (Apple
Mail) break and don't show quota at all then.
You can define multiple quota roots by appending an increasing number, for
example:
---%<-------------------------------------------------------------------------
plugin {
quota = maildir:User quota
quota2 = fs:Disk quota
#quota3 = ...
}
---%<-------------------------------------------------------------------------
Quota rules
-----------
Quota rules configure the actual quota limits. The syntax is:
---%<-------------------------------------------------------------------------
quota_rule = <mailbox name>:<limit configuration>
#quota_rule2 = ...
#quota_rule3 = ..etc..
---%<-------------------------------------------------------------------------
"*" as the mailbox name configures the default limit, which is applied on top
of a mailbox-specific limit if found. So for example:
---%<-------------------------------------------------------------------------
quota_rule = *:storage=1G
quota_rule2 = Trash:storage=+100M
quota_rule3 = SPAM:ignore
---%<-------------------------------------------------------------------------
This means that the user has 1GB quota, but when saving messages to Trash
mailbox it's possible to use up to 1.1GB of quota. The quota isn't specifically
assigned to Trash, so if you had 1GB of mails in Trash you could still save
100MB of mails to Trash, but nothing to other mailboxes. The idea of this is
mostly to allow the clients' move-to-Trash feature work while user is deleting
messages to get under quota. Additionally, any messages in the SPAM folder are
ignored per the 'ignore' directive and would not count against the quota.
"?" as the mailbox name works almost like "*". The difference is that "?" is
used only if quota backend doesn't override the limit. For example with
Maildir++ [http://www.inter7.com/courierimap/README.maildirquota.html] quota if
'maildirsize' file exists the limits are taken from it, but if it doesn't exist
the "?" limits are used.
"*" can't be used as a generic wildcard in mailbox names, so for example "box*"
wouldn't match "boxes". As shown in the above example, the first quota rule is
named 'quota_rule' while the following rules have an increasing digit in them.
You can have as many quota rules as you want.
Limit configuration
-------------------
The following limit names are supported:
* *storage*: Quota limit in kilobytes, 0 means unlimited.
* *bytes*: Quota limit in bytes, 0 means unlimited.
* *messages*: Quota limit in number of messages, 0 means unlimited. This
probably isn't very useful.
* *backend*: Quota backend-specific limit configuration.
* *ignore*: Don't include the specified mailbox in quota at all.
All of these support also b/k/M/G/T/% suffixes. So storage=100M and bytes=100M
both mean the exact same thing. messages=1k also means 1024 messages (not
1000).
Percents are relative to the default rule. For example:
---%<-------------------------------------------------------------------------
plugin {
quota = maildir:User quota
quota_rule = *:storage=1GB
# 10% of 1GB = 100MB
quota_rule2 = Trash:storage=+10%%
# 20% of 1GB = 200MB
quota_rule3 = Spam:storage=+20%%
}
---%<-------------------------------------------------------------------------
Note that % is written twice to escape it, because <%variables> [Variables.txt]
are expanded in plugin section. <userdb> [UserDatabase.txt] configuration may
or may not require this escaping.
Backend-specific configuration currently is used only with Maildir++ quota
backend. It means you can have the quota in Maildir++ format (e.g.
"10000000S").
Per-user quota
--------------
You can override quota rules in your <userdb> [UserDatabase.txt]'s <extra
fields> [UserDatabase.ExtraFields.txt]. Keep all the global settings in plugin
section and override only those settings you need to in your userdb.
If you're wondering why per-user quota isn't working:
* Check that 'dovecot-lda' is called with *-d* parameter.
* Check that you're not using <userdb static> [UserDatabase.Static.txt].
* Check that 'quota_rule' setting is properly returned by userdb. Enable
'auth_debug=yes' and 'mail_debug=yes' to see this.
For example:
---%<-------------------------------------------------------------------------
plugin {
quota = maildir:User quota
quota_rule = *:storage=1G
quota_rule2 = Trash:storage=+100M
}
---%<-------------------------------------------------------------------------
Next override the default 1GB quota for users:
LDAP
----
Quota limit is in quotaBytes field:
---%<-------------------------------------------------------------------------
user_attrs = homeDirectory=home, quotaBytes=quota_rule=*:bytes=%$
---%<-------------------------------------------------------------------------
Remember that 'user_attrs' is used only if you use <userdb ldap>
[AuthDatabase.LDAP.txt].
MySQL
-----
---%<-------------------------------------------------------------------------
user_query = SELECT uid, gid, home, \
concat('*:bytes=', quota_limit_bytes) AS quota_rule \
FROM users WHERE userid = '%u'
# MySQL with userdb prefetch: Remember to prefix quota_rule with userdb_
# (just like all other userdb extra fields):
password_query = SELECT userid AS user, password, \
uid AS userdb_uid, gid AS userdb_gid, \
concat('*:bytes=', quota_limit_bytes) AS userdb_quota_rule \
FROM users WHERE userid = '%u'
---%<-------------------------------------------------------------------------
Remember that 'user_query' is used only if you use <userdb sql>
[AuthDatabase.SQL.txt].
PostgreSQL, SQLite
------------------
---%<-------------------------------------------------------------------------
user_query = SELECT uid, gid, home, \
'*:bytes=' || quota_limit_bytes AS quota_rule \
FROM users WHERE userid = '%u'
---%<-------------------------------------------------------------------------
Remember that 'user_query' is used only if you use <userdb sql>
[AuthDatabase.SQL.txt].
passwd-file
-----------
Example passwd-file entries:
---%<-------------------------------------------------------------------------
user:{plain}pass:1000:1000::/home/user::userdb_quota_rule=*:bytes=100M
user2:{plain}pass2:1001:1001::/home/user2::userdb_quota_rule=*:bytes=200M
user3:{plain}pass3:1002:1002::/home/user3::userdb_mail=maildir:~/Maildir
userdb_quota_rule=*:bytes=300M
---%<-------------------------------------------------------------------------
passwd
------
The <passwd> [AuthDatabase.Passwd.txt] userdb doesn't support extra fields.
That's why you can't directly set users' quota limits to passwd file. One
possibility would be to write a script that reads quota limits from another
file, merges them with passwd file and produces another passwd-file, which you
could then use with Dovecot's <userdb passwd-file>
[AuthDatabase.PasswdFile.txt].
Quota for public namespaces
---------------------------
You can create a separate namespace-specific quota that's shared between all
users. This is done simply by adding ':ns=<namespace prefix>' parameter to
quota setting. For example you could have something like:
---%<-------------------------------------------------------------------------
namespace {
type = public
prefix = Public/
#location = ..
}
plugin {
quota = maildir:User quota
quota2 = maildir:Shared quota:ns=Public/
#quota_rules and quota2_rules..
}
---%<-------------------------------------------------------------------------
Quota for private namespaces
----------------------------
You can create a separate namespace-specific quota for a folder hierarchie.
This is done by adding another namespace and the ':ns=<namespace prefix>'
parameter to quota setting. For example you could have something like:
---%<-------------------------------------------------------------------------
namespace {
type = private
prefix = Archive/
#location = ..
}
plugin {
# Maildir quota
quota = maildir:User quota:ns=
quota2 = maildir:Archive quota:ns=Archive/
# Dict quota
#quota = dict:User quota:%u.default:ns=:proxy::quota
#quota2 = dict:Archive quota:%u.archive:ns=Archive/:proxy::quota
#quota_rules and quota2_rules..
}
---%<-------------------------------------------------------------------------
Note: If you're using dict quota, you need to make sure that the quota of the
'Archive' namespace is calculated for another "user" than the default
namespace. Either track different namespaces in different backends or make sure
the users differs.'%u.archive' defines '<username>.archive' as key to track
quota for the 'Archive' namespace, the '%u.default' tracks the quota of other
folders. See <Variables.txt> for further help on variables.
Custom Quota Exceeded Message
-----------------------------
You can configure Dovecot to send a custom string instead of the default quota
exceeded message. You could have something like:
---%<-------------------------------------------------------------------------
plugin {
quota_exceeded_message = Quota exceeded, please go to
http://www.example.com/over_quota_help for instructions on how to fix this.
}
---%<-------------------------------------------------------------------------
Dovecot can also read the quota exceeded message from a file:
---%<-------------------------------------------------------------------------
plugin {
quota_exceeded_message = </path/to/quota_exceeded_message.txt
}
---%<-------------------------------------------------------------------------
Quota warnings
--------------
You can configure Dovecot to run an external command when user's quota exceeds
a specified limit. Note that the warning is ONLY executed at the exact time
when the limit is being crossed, so when you're testing it you have to do it by
crossing the limit by saving a new mail. If something else besides Dovecot
updates quota so that the limit is crossed, the warning is never executed. The
syntax is:
---%<-------------------------------------------------------------------------
quota_warning = <limit configuration> <quota-warning socket name> <parameters>
#quota_warning2 = ...
#quota_warning3 = ..etc..
---%<-------------------------------------------------------------------------
Limit configuration is almost exactly same as for rules, with the exception of
adding "-" before the value for "reverse" warnings where the script is called
when quota drops below the value. Usually you want to use percents instead of
absolute limits. Only the command for the first exceeded limit is executed, so
configure the highest limit first. The actual commands that are run need to be
created as services.
An example configuration:
---%<-------------------------------------------------------------------------
plugin {
quota_warning = storage=95%% quota-warning 95 %u
quota_warning2 = storage=80%% quota-warning 80 %u
quota_warning3 = -storage=100%% quota-warning below %u # user is no longer
over quota
}
service quota-warning {
executable = script /usr/local/bin/quota-warning.sh
# use some unprivileged user for executing the quota warnings
user = vmail
unix_listener quota-warning {
}
}
---%<-------------------------------------------------------------------------
With the above example when user's quota exceeds 80%, 'quota-warning.sh' is
executed with parameter 80. The same goes for when quota exceeds 95%. If user
suddenly receives a huge mail and the quota jumps from 70% to 99%, only the 95
script is executed.
You have to create the 'quota-warning.sh' script yourself. Here is an example
that sends a mail to the user:
---%<-------------------------------------------------------------------------
#!/bin/sh
PERCENT=$1
USER=$2
cat << EOF | /usr/local/libexec/dovecot/dovecot-lda -d $USER -o
"plugin/quota=maildir:User quota:noenforcing"
From: postmaster@domain.com
Subject: quota warning
Your mailbox is now $PERCENT% full.
EOF
---%<-------------------------------------------------------------------------
The quota enforcing is disabled to avoid looping. You'll of course need to
change the 'plugin/quota' value to match the quota backend and other
configuration you use. Basically preserve your original "quota" setting and
just insert ":noenforcing" to proper location in it. For example with dict
quota, you can use something like:'-o "plugin/quota=dict:User
quota::noenforcing:proxy::quota"'
(This file was created from the wiki on 2013-11-24 04:42)
|