]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Move quota_args=noenforcing to quota_enforce=no
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 22 Aug 2024 08:26:15 +0000 (11:26 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:40:00 +0000 (10:40 +0200)
src/plugins/quota/quota-imapc.c
src/plugins/quota/quota-private.h
src/plugins/quota/quota-settings.c
src/plugins/quota/quota-settings.h
src/plugins/quota/quota.c

index 3d9678d3ab7b751792298e442c5302621e388429..9d024e393dc602e5dc1bcea5c8913f6d8b7d86e1 100644 (file)
@@ -74,9 +74,6 @@ static int imapc_quota_init(struct quota_root *_root, const char *args,
 
        if (root->box_name == NULL && root->root_name == NULL)
                root->box_name = "INBOX";
-       /* we'll never try to enforce the quota - it's just a lot of
-          unnecessary remote GETQUOTA calls. */
-       _root->no_enforcing = TRUE;
        return 0;
 }
 
index 9887f10a6a2b9537653866fac694b826c41de61f..30f5bb242fa2e1be0cf6b3ced42a15fe191ba1b2 100644 (file)
@@ -82,8 +82,6 @@ struct quota_root {
        /* Module-specific contexts. See quota_module_id. */
        ARRAY(void) quota_module_contexts;
 
-       /* don't enforce quota when saving */
-       bool no_enforcing:1;
        /* quota is automatically updated. update() should be called but the
           bytes won't be changed. count is still changed, because it's cheap
           to do and it's internally used to figure out whether there have
index 59ffb00f306384e56f9673bf40793dd54bda0768..f76f713e9ca07103205518e1f2465e3a99dbb061 100644 (file)
@@ -29,6 +29,7 @@ static const struct setting_define quota_setting_defines[] = {
        DEF(STR, quota_args),
        DEF(BOOL, quota_ignore),
        DEF(BOOL, quota_ignore_unlimited),
+       DEF(BOOL, quota_enforce),
        DEF(BOOL, quota_hidden),
        DEF(SIZE, quota_storage_size),
        DEF(UINT, quota_storage_percentage),
@@ -64,6 +65,7 @@ static const struct quota_settings quota_default_settings = {
        .quota_args = "",
        .quota_ignore = FALSE,
        .quota_ignore_unlimited = FALSE,
+       .quota_enforce = TRUE,
        .quota_hidden = FALSE,
        .quota_storage_size = SET_SIZE_UNLIMITED,
        .quota_storage_percentage = 100,
@@ -88,10 +90,17 @@ static const struct quota_settings quota_default_settings = {
        .quota_exceeded_message = "Quota exceeded (mailbox for user is full)",
 };
 
+static const struct setting_keyvalue quota_default_settings_keyvalue[] = {
+       /* imapc should never try to enforce the quota - it's just a lot of
+          unnecessary remote GETQUOTA calls. */
+       { "quota_imapc/quota_enforce", "no" },
+       { NULL, NULL }
+};
 const struct setting_parser_info quota_setting_parser_info = {
        .name = "quota",
        .defines = quota_setting_defines,
        .defaults = &quota_default_settings,
+       .default_settings = quota_default_settings_keyvalue,
        .struct_size = sizeof(struct quota_settings),
 #ifndef CONFIG_BINARY
        .check_func = quota_settings_check,
index 0f13abba2540b3717d5ee7b5661e14940ec35e1b..a059237a1fb70975e580265e79632f5e49a38071 100644 (file)
@@ -28,6 +28,8 @@ struct quota_settings {
        bool quota_ignore;
        /* IF TRUE, quota is ignored only when quota is unlimited. */
        bool quota_ignore_unlimited;
+       /* Whether to actually enforce quota limits. */
+       bool quota_enforce;
        /* Quota root is hidden (to e.g. IMAP GETQUOTAROOT) */
        bool quota_hidden;
        /* Quota storage size is counted as:
index 737721a0498b4aa969ceb04243d4695231f4dec7..b1a4f206a399e56dec9435159211b7fe8c899436 100644 (file)
@@ -49,10 +49,6 @@ static const struct quota_backend *quota_internal_backends[] = {
 
 static ARRAY(const struct quota_backend*) quota_backends;
 
-static void noenforcing_param_handler(struct quota_root *_root, const char *param_value);
-
-struct quota_param_parser quota_param_noenforcing = {.param_name = "noenforcing", .param_handler = noenforcing_param_handler};
-
 static enum quota_alloc_result quota_default_test_alloc(
                struct quota_transaction_context *ctx, uoff_t size,
                const char **error_r);
@@ -149,7 +145,6 @@ int quota_root_default_init(struct quota_root *root, const char *args,
                            const char **error_r)
 {
        const struct quota_param_parser default_params[] = {
-               quota_param_noenforcing,
                {.param_name = NULL}
        };
        return quota_parse_parameters(root, &args, error_r, default_params, TRUE);
@@ -783,7 +778,7 @@ int quota_transaction_set_limits(struct quota_transaction_context *ctx,
                bytes_limit = count_limit = 0;
                if (!quota_root_is_visible(roots[i], ctx->box))
                        continue;
-               else if (roots[i]->no_enforcing) {
+               else if (!roots[i]->set->quota_enforce) {
                        ignored = FALSE;
                } else if (quota_root_get_rule_limits(roots[i], ctx->box->event,
                                                      &bytes_limit, &count_limit,
@@ -1236,7 +1231,7 @@ static enum quota_alloc_result quota_default_test_alloc(
                uint64_t bytes_limit, count_limit;
 
                if (!quota_root_is_visible(roots[i], ctx->box) ||
-                   roots[i]->no_enforcing)
+                   !roots[i]->set->quota_enforce)
                        continue;
 
                if (quota_root_get_rule_limits(roots[i], ctx->box->event,
@@ -1284,11 +1279,6 @@ void quota_recalculate(struct quota_transaction_context *ctx,
        ctx->recalculate = recalculate;
 }
 
-static void noenforcing_param_handler(struct quota_root *_root, const char *param_value ATTR_UNUSED)
-{
-       _root->no_enforcing = TRUE;
-}
-
 int quota_parse_parameters(struct quota_root *root, const char **args, const char **error_r,
                           const struct quota_param_parser *valid_params, bool fail_on_unknown)
 {