From: Timo Sirainen Date: Fri, 27 Oct 2023 09:12:14 +0000 (+0300) Subject: lib-storage: Replace VOLATILEDIR with mail_volatile_path setting X-Git-Tag: 2.4.1~1247 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c916cf2be6c4366facae030d743c37d59337fbfe;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Replace VOLATILEDIR with mail_volatile_path setting --- diff --git a/src/lib-storage/mail-storage-settings.c b/src/lib-storage/mail-storage-settings.c index cb5f68dbcc..73cc2c91c0 100644 --- a/src/lib-storage/mail-storage-settings.c +++ b/src/lib-storage/mail-storage-settings.c @@ -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 diff --git a/src/lib-storage/mail-storage-settings.h b/src/lib-storage/mail-storage-settings.h index c4d492badc..06d5a0f588 100644 --- a/src/lib-storage/mail-storage-settings.h +++ b/src/lib-storage/mail-storage-settings.h @@ -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; diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index dc25ca884b..3b37a69eec 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -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)); diff --git a/src/lib-storage/mail-user.c b/src/lib-storage/mail-user.c index b5155a7983..3951bec7a0 100644 --- a/src/lib-storage/mail-user.c +++ b/src/lib-storage/mail-user.c @@ -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); diff --git a/src/lib-storage/mailbox-list.c b/src/lib-storage/mailbox-list.c index 518a40b956..cfa4a903d0 100644 --- a/src/lib-storage/mailbox-list.c +++ b/src/lib-storage/mailbox-list.c @@ -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)) { diff --git a/src/lib-storage/mailbox-list.h b/src/lib-storage/mailbox-list.h index 0042c39460..0b3d37ca85 100644 --- a/src/lib-storage/mailbox-list.h +++ b/src/lib-storage/mailbox-list.h @@ -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;