]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Add mail_storage_service_get_set_roots()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sun, 13 Nov 2022 14:50:00 +0000 (16:50 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 30 Nov 2022 12:46:43 +0000 (14:46 +0200)
src/lib-storage/mail-storage-service.c
src/lib-storage/mail-storage-service.h

index a67dcd97f75765084cc96f9d60a8f997858df77a..e3691188cf0d2678047bff9b29eb3c5003a6c434 100644 (file)
@@ -55,7 +55,7 @@ struct mail_storage_service_ctx {
 
        struct auth_master_connection *conn, *iter_conn;
        struct auth_master_user_list_ctx *auth_list;
-       const struct setting_parser_info **set_roots;
+       ARRAY(const struct setting_parser_info *) set_roots;
        enum mail_storage_service_flags flags;
 
        const char *set_cache_module, *set_cache_service;
@@ -977,13 +977,10 @@ mail_storage_service_init(struct master_service *service,
                count = 0;
        else
                for (count = 0; set_roots[count] != NULL; count++) ;
-       ctx->set_roots =
-               p_new(pool, const struct setting_parser_info *, count + 2);
-       ctx->set_roots[0] = &mail_user_setting_parser_info;
-       if (set_roots != NULL) {
-               memcpy(ctx->set_roots + 1, set_roots,
-                      sizeof(*ctx->set_roots) * count);
-       }
+       p_array_init(&ctx->set_roots, pool, count + 1);
+       const struct setting_parser_info *info = &mail_user_setting_parser_info;
+       array_push_back(&ctx->set_roots, &info);
+       array_append(&ctx->set_roots, set_roots, count);
 
        /* note: we may not have read any settings yet, so this logging
           may still be going to wrong location */
@@ -1024,6 +1021,15 @@ mail_storage_service_input_get_flags(struct mail_storage_service_ctx *ctx,
        return flags;
 }
 
+const struct setting_parser_info *const *
+mail_storage_service_get_set_roots(struct mail_storage_service_ctx *ctx)
+{
+       /* Make sure the array is NULL-terminated */
+       array_append_zero(&ctx->set_roots);
+       array_pop_back(&ctx->set_roots);
+       return array_front(&ctx->set_roots);
+}
+
 int mail_storage_service_read_settings(struct mail_storage_service_ctx *ctx,
                                       const struct mail_storage_service_input *input,
                                       pool_t pool,
@@ -1044,7 +1050,7 @@ int mail_storage_service_read_settings(struct mail_storage_service_ctx *ctx,
                mail_storage_service_input_get_flags(ctx, input);
 
        i_zero(&set_input);
-       set_input.roots = ctx->set_roots;
+       set_input.roots = mail_storage_service_get_set_roots(ctx);
        set_input.preserve_user = TRUE;
        /* settings reader may exec doveconf, which is going to clear
           environment, and if we're not doing a userdb lookup we want to
index 95e5b44be14f6fcbd9f36e46837332da5c1d8ca5..80c57aca95d1cef8618bd788ab1ce208456334bc 100644 (file)
@@ -169,6 +169,8 @@ pool_t mail_storage_service_user_get_pool(struct mail_storage_service_user *user
 const char *
 mail_storage_service_user_get_log_prefix(struct mail_storage_service_user *user);
 
+const struct setting_parser_info *const *
+mail_storage_service_get_set_roots(struct mail_storage_service_ctx *ctx);
 const char *
 mail_storage_service_get_log_prefix(struct mail_storage_service_ctx *ctx);
 const struct var_expand_table *