]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Replace settings_parser_get_root_set() with master_service_settings_pars...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 13 Jan 2023 00:13:05 +0000 (02:13 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 20 Nov 2023 12:20:53 +0000 (14:20 +0200)
18 files changed:
src/lib-storage/index/dbox-multi/mdbox-settings.c
src/lib-storage/index/dbox-multi/mdbox-settings.h
src/lib-storage/index/dbox-multi/mdbox-storage.c
src/lib-storage/index/imapc/Makefile.am
src/lib-storage/index/imapc/imapc-settings.c
src/lib-storage/index/imapc/imapc-settings.h
src/lib-storage/index/imapc/imapc-storage.c
src/lib-storage/index/maildir/Makefile.am
src/lib-storage/index/maildir/maildir-settings.c
src/lib-storage/index/maildir/maildir-settings.h
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/index/mbox/mbox-settings.c
src/lib-storage/index/mbox/mbox-settings.h
src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/index/pop3c/Makefile.am
src/lib-storage/index/pop3c/pop3c-settings.c
src/lib-storage/index/pop3c/pop3c-settings.h
src/lib-storage/index/pop3c/pop3c-storage.c

index 5948ce8201ec42cc650d3290540e4da7047bdfb6..094b163a9d220e3cc6e60a0f1aab961ceb712840 100644 (file)
@@ -31,6 +31,7 @@ static const struct setting_parser_info mdbox_setting_parser_info = {
        .defaults = &mdbox_default_settings,
 
        .struct_size = sizeof(struct mdbox_settings),
+       .pool_offset1 = 1 + offsetof(struct mdbox_settings, pool),
        .parent = &mail_user_setting_parser_info
 };
 
index 353da69618643c7f5200e1a3a88b8bd5e0f89bb5..ab3e67265c6383d754d8058a6a3fc8654b86f54e 100644 (file)
@@ -2,6 +2,7 @@
 #define MDBOX_SETTINGS_H
 
 struct mdbox_settings {
+       pool_t pool;
        bool mdbox_preallocate_space;
        uoff_t mdbox_rotate_size;
        unsigned int mdbox_rotate_interval;
index 1bbdd3b26654f4eb42b8cb0816326afc8a5448df..8bcdb00f4b79a51f0ea3b986dcb36b4468c35a81 100644 (file)
@@ -5,6 +5,7 @@
 #include "ioloop.h"
 #include "mkdir-parents.h"
 #include "master-service.h"
+#include "master-service-settings.h"
 #include "settings-parser.h"
 #include "mail-index-modseq.h"
 #include "mail-index-alloc-cache.h"
@@ -46,8 +47,13 @@ int mdbox_storage_create(struct mail_storage *_storage,
        struct mdbox_storage *storage = MDBOX_STORAGE(_storage);
        const char *dir;
 
-       storage->set = settings_parser_get_root_set(_storage->user->set_parser,
-               mdbox_get_setting_parser_info());
+       if (master_service_settings_parser_get(_storage->event,
+                       _storage->user->set_parser,
+                       mdbox_get_setting_parser_info(),
+                       MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND,
+                       &storage->set, error_r) < 0)
+               return -1;
+
        storage->preallocate_space = storage->set->mdbox_preallocate_space;
 
        if (*ns->list->set.mailbox_dir_name == '\0') {
@@ -90,6 +96,7 @@ void mdbox_storage_destroy(struct mail_storage *_storage)
                array_free(&storage->move_to_alt_map_uids);
        array_free(&storage->open_files);
        i_free(storage->corrupted_reason);
+       master_service_settings_free(storage->set);
        dbox_storage_destroy(_storage);
 }
 
index 72ee102ff3e5d017bbbca7d9567ffeed10a120f3..07c2da585fe5209021b48877f2dfba05dd7ebe3a 100644 (file)
@@ -4,6 +4,7 @@ AM_CPPFLAGS = \
        -I$(top_srcdir)/src/lib \
        -I$(top_srcdir)/src/lib-test \
        -I$(top_srcdir)/src/lib-settings \
+       -I$(top_srcdir)/src/lib-master \
        -I$(top_srcdir)/src/lib-mail \
        -I$(top_srcdir)/src/lib-imap \
        -I$(top_srcdir)/src/lib-imap-client \
index cd3542e6a5e64aec8c2b7f61f61fd698287cb7f8..9a99020ae96917be0bf0138932ec805efa8aa549 100644 (file)
@@ -69,6 +69,7 @@ static const struct setting_parser_info imapc_setting_parser_info = {
        .defaults = &imapc_default_settings,
 
        .struct_size = sizeof(struct imapc_settings),
+       .pool_offset1 = 1 + offsetof(struct imapc_settings, pool),
        .parent = &mail_user_setting_parser_info,
 
        .check_func = imapc_settings_check
index c9aa811d270dac805be8d545fa0e79e913ba2c50..504c6205ca4e69a46017c6b9c172cc4c3ab7c8ff 100644 (file)
@@ -30,6 +30,7 @@ enum imapc_features {
  * serialization of settings.
  */
 struct imapc_settings {
+       pool_t pool;
        const char *imapc_host;
        in_port_t imapc_port;
 
index c5573ccf3204a32169600b0828af9e3bd26b4f64..489b921745480356f4c588a48ede72149275f603 100644 (file)
@@ -4,6 +4,7 @@
 #include "ioloop.h"
 #include "str.h"
 #include "settings-parser.h"
+#include "master-service-settings.h"
 #include "imap-arg.h"
 #include "imap-resp-code.h"
 #include "mailbox-tree.h"
@@ -315,13 +316,17 @@ int imapc_storage_client_create(struct mail_namespace *ns,
        struct imapc_client_settings set;
        string_t *str;
 
-       imapc_set = settings_parser_get_root_set(ns->user->set_parser,
-               imapc_get_setting_parser_info());
+       if (master_service_settings_parser_get(ns->user->event,
+                       ns->user->set_parser, imapc_get_setting_parser_info(),
+                       MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND,
+                       &imapc_set, error_r) < 0)
+               return -1;
 
        i_zero(&set);
        set.host = imapc_set->imapc_host;
        if (*set.host == '\0') {
                *error_r = "missing imapc_host";
+               master_service_settings_free(imapc_set);
                return -1;
        }
        set.port = imapc_set->imapc_port;
@@ -335,6 +340,7 @@ int imapc_storage_client_create(struct mail_namespace *ns,
        set.password = imapc_set->imapc_password;
        if (*set.password == '\0') {
                *error_r = "missing imapc_password";
+               master_service_settings_free(imapc_set);
                return -1;
        }
        set.sasl_mechanisms = imapc_set->imapc_sasl_mechanisms;
@@ -405,6 +411,7 @@ void imapc_storage_client_unref(struct imapc_storage_client **_client)
        if (--client->refcount > 0)
                return;
        imapc_client_deinit(&client->client);
+       master_service_settings_free(client->set);
        array_foreach_modifiable(&client->untagged_callbacks, cb)
                i_free(cb->name);
        array_free(&client->untagged_callbacks);
index 7acf2496d17f4c8feadeb10f921ab1f0596e8622..962cb1de28d3186a266dc24dbe3b0ff10eb9e469 100644 (file)
@@ -3,6 +3,7 @@ noinst_LTLIBRARIES = libstorage_maildir.la
 AM_CPPFLAGS = \
        -I$(top_srcdir)/src/lib \
        -I$(top_srcdir)/src/lib-settings \
+       -I$(top_srcdir)/src/lib-master \
        -I$(top_srcdir)/src/lib-mail \
        -I$(top_srcdir)/src/lib-imap \
        -I$(top_srcdir)/src/lib-index \
index ac4bdcde5db479425db5e00bd85e5864a33d6bb9..e203cd0e966ea9aa8ae1fb28e27f06ce80d107e4 100644 (file)
@@ -33,6 +33,7 @@ static const struct setting_parser_info maildir_setting_parser_info = {
        .defaults = &maildir_default_settings,
 
        .struct_size = sizeof(struct maildir_settings),
+       .pool_offset1 = 1 + offsetof(struct maildir_settings, pool),
        .parent = &mail_user_setting_parser_info
 };
 
index cfcb732e3d470ea597988e59de7072c9213671ec..055bcac6ef976a04fd18cc046bd7284703ce342d 100644 (file)
@@ -2,6 +2,7 @@
 #define MAILDIR_SETTINGS_H
 
 struct maildir_settings {
+       pool_t pool;
        bool maildir_copy_with_hardlinks;
        bool maildir_very_dirty_syncs;
        bool maildir_broken_filename_sizes;
index 35698b098263f9701bae6649c45321d846a94169..5f3feb901b733dfc045733a61a20c05bcd22409f 100644 (file)
@@ -6,6 +6,7 @@
 #include "eacces-error.h"
 #include "unlink-old-files.h"
 #include "settings-parser.h"
+#include "master-service-settings.h"
 #include "mailbox-uidvalidity.h"
 #include "mailbox-list-private.h"
 #include "maildir-storage.h"
@@ -56,8 +57,12 @@ maildir_storage_create(struct mail_storage *_storage, struct mail_namespace *ns,
        struct mailbox_list *list = ns->list;
        const char *dir;
 
-       storage->set = settings_parser_get_root_set(_storage->user->set_parser,
-               maildir_get_setting_parser_info());
+       if (master_service_settings_parser_get(_storage->event,
+                       _storage->user->set_parser,
+                       maildir_get_setting_parser_info(),
+                       MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND,
+                       &storage->set, error_r) < 0)
+               return -1;
 
        storage->temp_prefix = p_strdup(_storage->pool,
                                        mailbox_list_get_temp_prefix(list));
@@ -77,6 +82,14 @@ maildir_storage_create(struct mail_storage *_storage, struct mail_namespace *ns,
        return 0;
 }
 
+static void maildir_storage_destroy(struct mail_storage *_storage)
+{
+       struct maildir_storage *storage = MAILDIR_STORAGE(_storage);
+
+       master_service_settings_free(storage->set);
+       index_storage_destroy(_storage);
+}
+
 static void maildir_storage_get_list_settings(const struct mail_namespace *ns,
                                              struct mailbox_list_settings *set)
 {
@@ -728,7 +741,7 @@ struct mail_storage maildir_storage = {
                 maildir_get_setting_parser_info,
                maildir_storage_alloc,
                maildir_storage_create,
-               index_storage_destroy,
+               maildir_storage_destroy,
                maildir_storage_add_list,
                maildir_storage_get_list_settings,
                maildir_storage_autodetect,
index 3b4bbdd51b3402da07b1cd78fa35b4995c1348cc..df327686074f21e975f5cb36f8876f1fb0de95e5 100644 (file)
@@ -43,6 +43,7 @@ static const struct setting_parser_info mbox_setting_parser_info = {
        .defaults = &mbox_default_settings,
 
        .struct_size = sizeof(struct mbox_settings),
+       .pool_offset1 = 1 + offsetof(struct mbox_settings, pool),
        .parent = &mail_user_setting_parser_info
 };
 
index eb99d82046ecb8a369d2e826b89d89eabb5d1364..1d48091ce74b68c938c0d1c589d70be1db32bfbe 100644 (file)
@@ -2,6 +2,7 @@
 #define MBOX_SETTINGS_H
 
 struct mbox_settings {
+       pool_t pool;
        const char *mbox_read_locks;
        const char *mbox_write_locks;
        unsigned int mbox_lock_timeout;
index 4413cf6292a7d0764a1f124f902efe1a25c8a405..444ace27fd47f115bf7578c2897334c1ee87d79a 100644 (file)
@@ -6,6 +6,7 @@
 #include "ostream.h"
 #include "restrict-access.h"
 #include "master-service.h"
+#include "master-service-settings.h"
 #include "settings-parser.h"
 #include "mailbox-list-private.h"
 #include "mbox-storage.h"
@@ -184,8 +185,12 @@ mbox_storage_create(struct mail_storage *_storage, struct mail_namespace *ns,
                return -1;
        }
 
-       storage->set = settings_parser_get_root_set(_storage->user->set_parser,
-               mbox_get_setting_parser_info());
+       if (master_service_settings_parser_get(_storage->event,
+                       _storage->user->set_parser,
+                       mbox_get_setting_parser_info(),
+                       MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND,
+                       &storage->set, error_r) < 0)
+               return -1;
 
        if (mailbox_list_get_root_path(ns->list, MAILBOX_LIST_PATH_TYPE_INDEX, &dir)) {
                _storage->temp_path_prefix = p_strconcat(_storage->pool, dir,
@@ -201,6 +206,14 @@ mbox_storage_create(struct mail_storage *_storage, struct mail_namespace *ns,
        return 0;
 }
 
+static void mbox_storage_destroy(struct mail_storage *_storage)
+{
+       struct mbox_storage *storage = MBOX_STORAGE(_storage);
+
+       master_service_settings_free(storage->set);
+       index_storage_destroy(_storage);
+}
+
 static void mbox_storage_get_list_settings(const struct mail_namespace *ns,
                                           struct mailbox_list_settings *set)
 {
@@ -826,7 +839,7 @@ struct mail_storage mbox_storage = {
                 mbox_get_setting_parser_info,
                mbox_storage_alloc,
                mbox_storage_create,
-               index_storage_destroy,
+               mbox_storage_destroy,
                mbox_storage_add_list,
                mbox_storage_get_list_settings,
                mbox_storage_autodetect,
index 868dc1eb263fbf4ea1796fc2d4748abf464022e2..093176ebeb8d9ff28b2399f07a660ff102484a0e 100644 (file)
@@ -3,6 +3,7 @@ noinst_LTLIBRARIES = libstorage_pop3c.la
 AM_CPPFLAGS = \
        -I$(top_srcdir)/src/lib \
        -I$(top_srcdir)/src/lib-settings \
+       -I$(top_srcdir)/src/lib-master \
        -I$(top_srcdir)/src/lib-dns \
        -I$(top_srcdir)/src/lib-ssl-iostream \
        -I$(top_srcdir)/src/lib-mail \
index 8a2c189555d5fe056203036e41f7d112af8574b6..4e1bd27f4160a3539705d536d6afe3f454e0e783 100644 (file)
@@ -102,6 +102,7 @@ static const struct setting_parser_info pop3c_setting_parser_info = {
        .defaults = &pop3c_default_settings,
 
        .struct_size = sizeof(struct pop3c_settings),
+       .pool_offset1 = 1 + offsetof(struct pop3c_settings, pool),
        .parent = &mail_user_setting_parser_info,
 
         .check_func = pop3c_settings_check
index bf44e24477d422a0d755d92e8b88d5ac3a167dc6..fb635ba04d15d5f85c3f6794518318f78273d343 100644 (file)
@@ -11,6 +11,7 @@ enum pop3c_features {
 
 
 struct pop3c_settings {
+       pool_t pool;
        const char *pop3c_host;
        in_port_t pop3c_port;
 
index e5ce89696b9bd3afba6c2b93559fb8de80b97b19..2a3822616b1c322939f9d5b8aa99f3043b81412b 100644 (file)
@@ -4,6 +4,7 @@
 #include "ioloop.h"
 #include "str.h"
 #include "settings-parser.h"
+#include "master-service-settings.h"
 #include "mail-copy.h"
 #include "mail-user.h"
 #include "mailbox-list-private.h"
@@ -41,8 +42,13 @@ pop3c_storage_create(struct mail_storage *_storage,
 {
        struct pop3c_storage *storage = POP3C_STORAGE(_storage);
 
-       storage->set = settings_parser_get_root_set(_storage->user->set_parser,
-               pop3c_get_setting_parser_info());
+       if (master_service_settings_parser_get(_storage->event,
+                       _storage->user->set_parser,
+                       pop3c_get_setting_parser_info(),
+                       MASTER_SERVICE_SETTINGS_GET_FLAG_NO_EXPAND,
+                       &storage->set, error_r) < 0)
+               return -1;
+
        if (storage->set->pop3c_host[0] == '\0') {
                *error_r = "missing pop3c_host";
                return -1;
@@ -58,6 +64,14 @@ pop3c_storage_create(struct mail_storage *_storage,
        return 0;
 }
 
+static void pop3c_storage_destroy(struct mail_storage *_storage)
+{
+       struct pop3c_storage *storage = POP3C_STORAGE(_storage);
+
+       master_service_settings_free(storage->set);
+       index_storage_destroy(_storage);
+}
+
 static struct pop3c_client *
 pop3c_client_create_from_set(struct mail_storage *storage,
                             const struct pop3c_settings *set)
@@ -313,7 +327,7 @@ struct mail_storage pop3c_storage = {
                pop3c_get_setting_parser_info,
                pop3c_storage_alloc,
                pop3c_storage_create,
-               index_storage_destroy,
+               pop3c_storage_destroy,
                NULL,
                pop3c_storage_get_list_settings,
                NULL,