]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
pop3: Use mail_storage_settings from inbox namespace
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 22 Dec 2023 19:09:56 +0000 (14:09 -0500)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:11 +0000 (12:34 +0200)
src/pop3/main.c
src/pop3/pop3-client.c
src/pop3/pop3-client.h
src/pop3/pop3-commands.c

index 6d49689679acea6a87f22a75540f61cdc47d2f9f..7c3ac5a2d0166696f27909cb90affb50e346e80e 100644 (file)
@@ -187,9 +187,21 @@ static int lock_session(struct client *client)
 static int init_namespaces(struct client *client, bool already_logged_in)
 {
        const char *error;
+       int ret;
 
        /* finish initializing the user (see comment in main()) */
-       if (mail_namespaces_init(client->user, &error) < 0) {
+       ret = mail_namespaces_init(client->user, &error);
+       if (ret == 0) {
+               i_assert(client->inbox_ns == NULL);
+               client->inbox_ns = mail_namespace_find_inbox(client->user->namespaces);
+               i_assert(client->inbox_ns != NULL);
+
+               ret = settings_get(mail_namespace_get_event(client->inbox_ns),
+                        &mail_storage_setting_parser_info, 0,
+                        &client->mail_set, &error);
+       }
+
+       if (ret < 0) {
                if (!already_logged_in)
                        client_send_line(client, MSG_BYE_INTERNAL_ERROR);
 
@@ -197,11 +209,6 @@ static int init_namespaces(struct client *client, bool already_logged_in)
                client_destroy(client, error);
                return -1;
        }
-
-       i_assert(client->inbox_ns == NULL);
-       client->inbox_ns = mail_namespace_find_inbox(client->user->namespaces);
-       i_assert(client->inbox_ns != NULL);
-
        return 0;
 }
 
index 5ba210cc569cf79c35acff01b6e4da0f4270ba8e..33e695ff9a708c059d22dfdad716431da6c5ad32 100644 (file)
@@ -365,11 +365,9 @@ int pop3_lock_session(struct client *client)
        }
        path = t_strdup_printf("%s/"POP3_LOCK_FNAME, dir);
 
-       const struct mail_storage_settings *mail_set =
-               mail_user_set_get_storage_set(client->user);
        dotlock_set = session_dotlock_set;
-       dotlock_set.use_excl_lock = mail_set->dotlock_use_excl;
-       dotlock_set.nfs_flush = mail_set->mail_nfs_storage;
+       dotlock_set.use_excl_lock = client->mail_set->dotlock_use_excl;
+       dotlock_set.nfs_flush = client->mail_set->mail_nfs_storage;
 
        ret = file_dotlock_create(&dotlock_set, path, 0,
                                  &client->session_dotlock);
@@ -418,13 +416,6 @@ struct client *client_create(int fd_in, int fd_out,
 
        client->user = user;
 
-       const struct mail_storage_settings *mail_set =
-               mail_user_set_get_storage_set(client->user);
-       client->uidl_keymask =
-               parse_uidl_keymask(mail_set->pop3_uidl_format);
-       if (client->uidl_keymask == 0)
-               i_fatal("Invalid pop3_uidl_format");
-
        if (var_has_key(set->pop3_logout_format, 'u', "uidl_change")) {
                /* logging uidl_change. we need hashes of the UIDLs */
                client->message_uidls_save = TRUE;
@@ -460,6 +451,11 @@ int client_init_mailbox(struct client *client, const char **error_r)
        /* refresh proctitle before a potentially long-running init_mailbox() */
        pop3_refresh_proctitle();
 
+       client->uidl_keymask =
+               parse_uidl_keymask(client->mail_set->pop3_uidl_format);
+       if (client->uidl_keymask == 0)
+               i_fatal("Invalid pop3_uidl_format");
+
        flags = MAILBOX_FLAG_POP3_SESSION;
        if (!client->set->pop3_no_flag_updates)
                flags |= MAILBOX_FLAG_DROP_RECENT;
@@ -655,6 +651,7 @@ static void client_default_destroy(struct client *client, const char *reason)
        mail_user_autoexpunge(client->user);
        mail_user_deinit(&client->user);
        settings_free(client->set);
+       settings_free(client->mail_set);
 
        pop3_client_count--;
        DLLIST_REMOVE(&pop3_clients, client);
index 4369ce9027dc6b97ef983f67ca71381f22dd5c2d..c218d9cd298fba00001fbfa56bc35318560cdc05 100644 (file)
@@ -90,6 +90,7 @@ struct client {
 
        /* settings: */
        const struct pop3_settings *set;
+       const struct mail_storage_settings *mail_set;
        pool_t uidl_pool;
        enum uidl_keys uidl_keymask;
 
index 9c75e1a0c944a92ff96e05e805c706c9fbb2021c..9c6fac7ef6bf8cbec291f24dd4da7a294343de5b 100644 (file)
@@ -678,13 +678,11 @@ pop3_get_uid(struct client *client, struct mail *mail, string_t *str,
        };
        const char *error;
 
-       const struct mail_storage_settings *mail_set =
-               mail_user_set_get_storage_set(client->user);
-       if (var_expand(str, mail_set->pop3_uidl_format,
+       if (var_expand(str, client->mail_set->pop3_uidl_format,
                       tab, &error) <= 0) {
                e_error(client->event,
                        "UIDL: Failed to expand pop3_uidl_format=%s: %s",
-                       mail_set->pop3_uidl_format, error);
+                       client->mail_set->pop3_uidl_format, error);
                return -1;
        }
        return 0;