dovecot-2.2: quota: Allow mailbox names in quota_rules to contai...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Dec 8 23:04:29 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/78b34eb7c6c5
changeset: 17050:78b34eb7c6c5
user: Timo Sirainen <tss at iki.fi>
date: Sun Dec 08 23:04:18 2013 +0200
description:
quota: Allow mailbox names in quota_rules to contain "*" and "?" wildcards.
diffstat:
src/plugins/quota/quota-private.h | 2 +-
src/plugins/quota/quota-storage.c | 2 +-
src/plugins/quota/quota.c | 36 +++++++++++++++++++++++++-----------
3 files changed, 27 insertions(+), 13 deletions(-)
diffs (112 lines):
diff -r d837bd49ddee -r 78b34eb7c6c5 src/plugins/quota/quota-private.h
--- a/src/plugins/quota/quota-private.h Sun Dec 08 22:30:10 2013 +0200
+++ b/src/plugins/quota/quota-private.h Sun Dec 08 23:04:18 2013 +0200
@@ -30,7 +30,7 @@
};
struct quota_rule {
- const char *mailbox_name;
+ const char *mailbox_mask;
int64_t bytes_limit, count_limit;
/* relative to default_rule */
diff -r d837bd49ddee -r 78b34eb7c6c5 src/plugins/quota/quota-storage.c
--- a/src/plugins/quota/quota-storage.c Sun Dec 08 22:30:10 2013 +0200
+++ b/src/plugins/quota/quota-storage.c Sun Dec 08 23:04:18 2013 +0200
@@ -610,7 +610,7 @@
}
array_foreach(&root->set->rules, rule) {
- name = rule->mailbox_name;
+ name = rule->mailbox_mask;
ns = mail_namespace_find(namespaces, name);
if ((ns->flags & NAMESPACE_FLAG_UNUSABLE) != 0 &&
!silent_errors)
diff -r d837bd49ddee -r 78b34eb7c6c5 src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c Sun Dec 08 22:30:10 2013 +0200
+++ b/src/plugins/quota/quota.c Sun Dec 08 23:04:18 2013 +0200
@@ -7,6 +7,7 @@
#include "net.h"
#include "write-full.h"
#include "eacces-error.h"
+#include "wildcard-match.h"
#include "dict.h"
#include "mailbox-list-private.h"
#include "quota-private.h"
@@ -384,7 +385,20 @@
struct quota_rule *rule;
array_foreach_modifiable(&root_set->rules, rule) {
- if (strcmp(rule->mailbox_name, name) == 0)
+ if (wildcard_match(name, rule->mailbox_mask) == 0)
+ return rule;
+ }
+ return NULL;
+}
+
+static struct quota_rule *
+quota_root_rule_find_exact(struct quota_root_settings *root_set,
+ const char *name)
+{
+ struct quota_rule *rule;
+
+ array_foreach_modifiable(&root_set->rules, rule) {
+ if (strcmp(rule->mailbox_mask, name) == 0)
return rule;
}
return NULL;
@@ -570,7 +584,7 @@
const char *rule_def, const char **error_r)
{
struct quota_rule *rule;
- const char *p, *mailbox_name;
+ const char *p, *mailbox_mask;
int ret = 0;
p = strchr(rule_def, ':');
@@ -579,20 +593,20 @@
return -1;
}
- /* <mailbox name>:<quota limits> */
- mailbox_name = t_strdup_until(rule_def, p++);
+ /* <mailbox mask>:<quota limits> */
+ mailbox_mask = t_strdup_until(rule_def, p++);
- rule = quota_root_rule_find(root_set, mailbox_name);
+ rule = quota_root_rule_find_exact(root_set, mailbox_mask);
if (rule == NULL) {
- if (strcmp(mailbox_name, RULE_NAME_DEFAULT_NONFORCE) == 0)
+ if (strcmp(mailbox_mask, RULE_NAME_DEFAULT_NONFORCE) == 0)
rule = &root_set->default_rule;
- else if (strcmp(mailbox_name, RULE_NAME_DEFAULT_FORCE) == 0) {
+ else if (strcmp(mailbox_mask, RULE_NAME_DEFAULT_FORCE) == 0) {
rule = &root_set->default_rule;
root_set->force_default_rule = TRUE;
} else {
rule = array_append_space(&root_set->rules);
- rule->mailbox_name = strcasecmp(mailbox_name, "INBOX") == 0 ? "INBOX" :
- p_strdup(root_set->set->pool, mailbox_name);
+ rule->mailbox_mask = strcasecmp(mailbox_mask, "INBOX") == 0 ? "INBOX" :
+ p_strdup(root_set->set->pool, mailbox_mask);
}
}
@@ -600,7 +614,7 @@
rule->ignore = TRUE;
if (root_set->set->debug) {
i_debug("Quota rule: root=%s mailbox=%s ignored",
- root_set->name, mailbox_name);
+ root_set->name, mailbox_mask);
}
return 0;
}
@@ -629,7 +643,7 @@
i_debug("Quota rule: root=%s mailbox=%s "
"bytes=%s%lld%s messages=%s%lld%s",
- root_set->name, mailbox_name,
+ root_set->name, mailbox_mask,
rule->bytes_limit > 0 ? rule_plus : "",
(long long)rule->bytes_limit,
rule->bytes_percent == 0 ? "" :
More information about the dovecot-cvs
mailing list