]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Add quota_<backend> named filters
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 22 Aug 2024 08:22:53 +0000 (11:22 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:14 +0000 (12:34 +0200)
src/plugins/quota/quota-settings.c
src/plugins/quota/quota.c

index 1f6990a292c5d3cd126e98bd5bc5338710a2638b..59f9328b85bfae4674ab3630353cd99c408c1ead 100644 (file)
@@ -11,6 +11,11 @@ static bool quota_settings_check(void *_set, pool_t pool, const char **error_r);
 #define DEF(type, name) \
        SETTING_DEFINE_STRUCT_##type(#name, name, struct quota_settings)
 static const struct setting_define quota_setting_defines[] = {
+       { .type = SET_FILTER_NAME, .key = "quota_count" },
+       { .type = SET_FILTER_NAME, .key = "quota_fs" },
+       { .type = SET_FILTER_NAME, .key = "quota_imapc" },
+       { .type = SET_FILTER_NAME, .key = "quota_maildir" },
+
        { .type = SET_FILTER_ARRAY, .key = "quota",
          .offset = offsetof(struct quota_settings, quota_roots),
          .filter_array_field_name = "quota_name", },
index 4a7129d055808f8d272b7cf3f4af5efcb3edd478..90423441e728cc1b5c5dbe4cb8d9406077fb17fa 100644 (file)
@@ -229,18 +229,34 @@ quota_root_init(struct quota *quota, struct event *set_event, const char *root_n
 
        root = root_set->backend->v.alloc();
        root->pool = pool_alloconly_create("quota root", 512);
-       root->set = root_set;
        root->quota = quota;
        root->backend = *root_set->backend;
        p_array_init(&root->namespaces, root->pool, 4);
+       settings_free(root_set);
 
        array_create(&root->quota_module_contexts, root->pool,
                     sizeof(void *), 10);
 
+       const char *backend_filter =
+               t_strdup_printf("quota_%s", root->backend.name);
        root->backend.event = event_create(quota->event);
        event_add_str(root->backend.event, "quota", root_name);
+       event_set_ptr(root->backend.event, SETTINGS_EVENT_FILTER_NAME,
+                     p_strdup(event_get_pool(root->backend.event), backend_filter));
        event_drop_parent_log_prefixes(root->backend.event, 1);
 
+       /* Lookup settings again with quota_backend filter name */
+       set_event = event_create(set_event);
+       event_set_ptr(set_event, SETTINGS_EVENT_FILTER_NAME,
+                     p_strdup(event_get_pool(set_event), backend_filter));
+       if (settings_get_filter(set_event, "quota", root_name,
+                               &quota_setting_parser_info, 0,
+                               &root->set, error_r) < 0) {
+               event_unref(&set_event);
+               return -1;
+       }
+       event_unref(&set_event);
+
        root->bytes_limit = root->set->quota_storage_size > INT64_MAX ? 0 :
                root->set->quota_storage_size;
        root->count_limit = root->set->quota_message_count;