]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Allow negative percentage rules up to -99%
authorTimo Sirainen <tss@iki.fi>
Tue, 18 Sep 2012 16:16:04 +0000 (19:16 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 18 Sep 2012 16:16:04 +0000 (19:16 +0300)
src/plugins/quota/quota-private.h
src/plugins/quota/quota.c

index 573c70d744b6df0ad522ac3c7b79e1abaaee4ad5..fa408f5e63b19379f19bc09634e390d07112b14e 100644 (file)
@@ -34,7 +34,7 @@ struct quota_rule {
 
        int64_t bytes_limit, count_limit;
        /* relative to default_rule */
-       unsigned int bytes_percent, count_percent;
+       int bytes_percent, count_percent;
 
        /* Don't include this mailbox in quota */
        unsigned int ignore:1;
index f42038aae21060b8adff1081be9e1c4f36890325..9387dd38bdf2f90452adc3575b62800855b1babe 100644 (file)
@@ -361,7 +361,7 @@ quota_rule_parse_percentage(struct quota_root_settings *root_set,
 {
        int64_t percentage = *limit;
 
-       if (percentage <= 0 || percentage >= -1U) {
+       if (percentage <= -100 || percentage >= -1U) {
                *error_r = p_strdup_printf(root_set->set->pool,
                        "Invalid rule percentage: %lld", (long long)percentage);
                return -1;
@@ -385,9 +385,9 @@ static void
 quota_rule_recalculate_relative_rules(struct quota_rule *rule,
                                      int64_t bytes_limit, int64_t count_limit)
 {
-       if (rule->bytes_percent > 0)
+       if (rule->bytes_percent != 0)
                rule->bytes_limit = bytes_limit * rule->bytes_percent / 100;
-       if (rule->count_percent > 0)
+       if (rule->count_percent != 0)
                rule->count_limit = count_limit * rule->count_percent / 100;
 }