]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Replace VOLATILEDIR with mail_volatile_path setting
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 27 Oct 2023 09:12:14 +0000 (12:12 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:10 +0000 (12:34 +0200)
src/lib-storage/mail-storage-settings.c
src/lib-storage/mail-storage-settings.h
src/lib-storage/mail-storage.c
src/lib-storage/mail-user.c
src/lib-storage/mailbox-list.c
src/lib-storage/mailbox-list.h

index cb5f68dbccccaa52c9ecdd9c27525ae32897038e..73cc2c91c025e2a8b3391437bf7c5495df61ece0 100644 (file)
@@ -80,6 +80,7 @@ static const struct setting_define mail_storage_setting_defines[] = {
        DEF(BOOL_HIDDEN, mailbox_list_iter_from_index_dir),
        DEF(BOOL_HIDDEN, mailbox_list_drop_noselect),
        DEF(BOOL_HIDDEN, mailbox_list_validate_fs_names),
+       DEF(STR, mail_volatile_path),
        DEF(BOOL_HIDDEN, mail_full_filesystem_access),
        DEF(BOOL, maildir_stat_dirs),
        DEF(BOOL, mail_shared_explicit_inbox),
@@ -144,6 +145,7 @@ const struct mail_storage_settings mail_storage_default_settings = {
        .mailbox_list_iter_from_index_dir = FALSE,
        .mailbox_list_drop_noselect = TRUE,
        .mailbox_list_validate_fs_names = TRUE,
+       .mail_volatile_path = "",
        .mail_full_filesystem_access = FALSE,
        .maildir_stat_dirs = FALSE,
        .mail_shared_explicit_inbox = FALSE,
@@ -972,6 +974,7 @@ static const size_t mail_storage_2nd_reset_offsets[] = {
        OFFSET(mail_location),
        OFFSET(mailbox_list_index_prefix),
        OFFSET(mailbox_list_iter_from_index_dir),
+       OFFSET(mail_volatile_path),
 };
 
 static void
index c4d492badcfb4d6e20fc99eb103bda5476adfdd2..06d5a0f588ab80cf48819066cfbc0922fe160b6d 100644 (file)
@@ -60,6 +60,7 @@ struct mail_storage_settings {
        bool mailbox_list_iter_from_index_dir;
        bool mailbox_list_drop_noselect;
        bool mailbox_list_validate_fs_names;
+       const char *mail_volatile_path;
        bool mail_full_filesystem_access;
        bool maildir_stat_dirs;
        bool mail_shared_explicit_inbox;
index dc25ca884b11f42c7c024ff755b3f74c4122a481..3b37a69eecdaa1b8d4d49830815601260e324534 100644 (file)
@@ -3538,7 +3538,7 @@ int mailbox_lock_file_create(struct mailbox *box, const char *lock_fname,
        set.gid = perm->file_create_gid;
        set.gid_origin = perm->file_create_gid_origin;
 
-       if (box->list->set.volatile_dir == NULL)
+       if (box->list->mail_set->mail_volatile_path[0] == '\0')
                lock_path = t_strdup_printf("%s/%s", box->index->dir, lock_fname);
        else {
                unsigned char box_name_sha1[SHA1_RESULTLEN];
@@ -3550,7 +3550,7 @@ int mailbox_lock_file_create(struct mailbox *box, const char *lock_fname,
                   structure would be pretty troublesome. It would also make
                   it more difficult to perform the automated deletion of empty
                   lock directories. */
-               str_printfa(str, "%s/%s.", box->list->set.volatile_dir,
+               str_printfa(str, "%s/%s.", box->list->mail_set->mail_volatile_path,
                            lock_fname);
                sha1_get_digest(box->name, strlen(box->name), box_name_sha1);
                binary_to_hex_append(str, box_name_sha1, sizeof(box_name_sha1));
index b5155a7983808c203b28bdc511c8f3dc2f2dbcea..3951bec7a0e21477610072ef8ac7f673d382e1ee 100644 (file)
@@ -588,7 +588,8 @@ const char *mail_user_get_volatile_dir(struct mail_user *user)
        struct mailbox_list *inbox_list =
                mail_namespace_find_inbox(user->namespaces)->list;
 
-       return inbox_list->set.volatile_dir;
+       const char *path = inbox_list->mail_set->mail_volatile_path;
+       return path[0] == '\0' ? NULL : path;
 }
 
 int mail_user_lock_file_create(struct mail_user *user, const char *lock_fname,
@@ -620,11 +621,12 @@ int mail_user_lock_file_create(struct mail_user *user, const char *lock_fname,
        };
        struct mailbox_list *inbox_list =
                mail_namespace_find_inbox(user->namespaces)->list;
-       if (inbox_list->set.volatile_dir == NULL)
+       if (inbox_list->mail_set->mail_volatile_path[0] == '\0')
                path = t_strdup_printf("%s/%s", home, lock_fname);
        else {
-               path = t_strdup_printf("%s/%s", inbox_list->set.volatile_dir,
-                                      lock_fname);
+               path = t_strdup_printf("%s/%s",
+                               inbox_list->mail_set->mail_volatile_path,
+                               lock_fname);
                lock_set.mkdir_mode = 0700;
        }
        return mail_storage_lock_create(path, &lock_set, mail_set, lock_r, error_r);
index 518a40b9567f6331b24afcab73b72dde8890eef7..cfa4a903d0ebec1d946b2f68d451766ec13734fb 100644 (file)
@@ -182,7 +182,6 @@ int mailbox_list_create(const char *driver, struct event *event,
                p_strdup(list->pool, set->mailbox_dir_name);
        list->set.alt_dir = p_strdup(list->pool, set->alt_dir);
        list->set.alt_dir_nocheck = set->alt_dir_nocheck;
-       list->set.volatile_dir = p_strdup(list->pool, set->volatile_dir);
        list->set.index_control_use_maildir_name =
                set->index_control_use_maildir_name;
 
@@ -345,8 +344,6 @@ mailbox_list_settings_parse_full(struct mail_user *user, const char *data,
                        dest = &set_r->maildir_name;
                else if (strcmp(key, "MAILBOXDIR") == 0)
                        dest = &set_r->mailbox_dir_name;
-               else if (strcmp(key, "VOLATILEDIR") == 0)
-                       dest = &set_r->volatile_dir;
                else if (strcmp(key, "FULLDIRNAME") == 0) {
                        set_r->index_control_use_maildir_name = TRUE;
                        dest = &set_r->maildir_name;
@@ -2132,16 +2129,16 @@ int mailbox_list_lock(struct mailbox_list *list)
        set.gid_origin = perm.file_create_gid_origin;
 
        lock_fname = MAILBOX_LIST_LOCK_FNAME;
-       if (list->set.volatile_dir != NULL) {
-               /* Use VOLATILEDIR. It's shared with all mailbox_lists, so use
-                  hash of the namespace prefix as a way to make this lock name
-                  unique across the namespaces. */
+       if (list->mail_set->mail_volatile_path[0] != '\0') {
+               /* Use volatile directory. It's shared with all mailbox_lists,
+                  so use hash of the namespace prefix as a way to make this
+                  lock name unique across the namespaces. */
                unsigned char ns_prefix_hash[SHA1_RESULTLEN];
                sha1_get_digest(list->ns->prefix, list->ns->prefix_len,
                                ns_prefix_hash);
                lock_fname = t_strconcat(MAILBOX_LIST_LOCK_FNAME,
                        binary_to_hex(ns_prefix_hash, sizeof(ns_prefix_hash)), NULL);
-               lock_dir = list->set.volatile_dir;
+               lock_dir = list->mail_set->mail_volatile_path;
                set.mkdir_mode = 0700;
        } else if (mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_INDEX,
                                              &lock_dir)) {
index 0042c39460a23c017a8952a8d9e8f3f67133c5fb..0b3d37ca8581f7f9f9c3ecd88e77777dad57a7cd 100644 (file)
@@ -119,11 +119,6 @@ struct mailbox_list_settings {
        const char *index_cache_dir;
        const char *control_dir;
        const char *alt_dir; /* FIXME: dbox-specific.. */
-       /* Backend-local directory where volatile data, such as lock files,
-          can be temporarily created. This setting allows specifying a
-          separate directory for them to reduce disk I/O on the real storage.
-          The volatile_dir can point to an in-memory filesystem. */
-       const char *volatile_dir;
 
        const char *inbox_path;
        const char *subscription_fname;