]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage, global: mail_storage_service_lookup_next() - Remove service_user_r parameter
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 12 Jan 2023 20:07:04 +0000 (22:07 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 27 Jan 2023 11:08:35 +0000 (11:08 +0000)
Also change the callers to not bother storing it separately. Instead, they
can just use mail_user_r->service_user.

26 files changed:
src/doveadm/doveadm-auth-server.c
src/doveadm/doveadm-auth.c
src/doveadm/doveadm-mail-copymove.c
src/doveadm/doveadm-mail-import.c
src/imap-urlauth/imap-urlauth-worker.c
src/imap/imap-client.c
src/imap/imap-client.h
src/imap/main.c
src/imap/test-imap-client-hibernate.c
src/indexer/master-connection.c
src/lda/main.c
src/lib-storage/index/raw/raw-storage.c
src/lib-storage/index/shared/shared-storage.c
src/lib-storage/mail-storage-service.c
src/lib-storage/mail-storage-service.h
src/lib-storage/test-mail-storage-common.c
src/lib-storage/test-mail-storage-common.h
src/plugins/mail-crypt/doveadm-mail-crypt.c
src/plugins/mail-crypt/mail-crypt-acl-plugin.c
src/plugins/quota/quota-status.c
src/pop3/main.c
src/pop3/pop3-client.c
src/pop3/pop3-client.h
src/submission/main.c
src/submission/submission-client.c
src/submission/submission-client.h

index 518822585333485edb88638df4ca7e225d9a454c..01595cce540bb9199e92d6d13820e3fbc1facafa 100644 (file)
@@ -296,7 +296,6 @@ cmd_user_mail_input(struct mail_storage_service_ctx *storage_service,
                    const char *show_field, const char *expand_field)
 {
        struct mail_storage_service_input service_input;
-       struct mail_storage_service_user *service_user;
        struct mail_user *user;
        const char *error, *const *userdb_fields;
        pool_t pool;
@@ -317,8 +316,7 @@ cmd_user_mail_input(struct mail_storage_service_ctx *storage_service,
                                                &userdb_fields);
 
        if ((ret = mail_storage_service_lookup_next(storage_service, &service_input,
-                                                   &service_user, &user,
-                                                   &error)) <= 0) {
+                                                   &user, &error)) <= 0) {
                pool_unref(&pool);
                if (ret < 0)
                        return -1;
@@ -358,7 +356,6 @@ cmd_user_mail_input(struct mail_storage_service_ctx *storage_service,
        }
 
        mail_user_deinit(&user);
-       mail_storage_service_user_unref(&service_user);
        pool_unref(&pool);
        return 1;
 }
index 5105f777df98ae12e1688b69e6ca94035c5b2b27..030b88103b7134f40d23552564b204336c214280 100644 (file)
@@ -631,7 +631,6 @@ cmd_user_mail_input(struct mail_storage_service_ctx *storage_service,
                    struct event *event)
 {
        struct mail_storage_service_input service_input;
-       struct mail_storage_service_user *service_user;
        struct mail_user *user;
        const char *error, *const *userdb_fields;
        pool_t pool;
@@ -652,8 +651,7 @@ cmd_user_mail_input(struct mail_storage_service_ctx *storage_service,
                                                &userdb_fields);
 
        if ((ret = mail_storage_service_lookup_next(storage_service, &service_input,
-                                                   &service_user, &user,
-                                                   &error)) <= 0) {
+                                                   &user, &error)) <= 0) {
                pool_unref(&pool);
                if (ret < 0)
                        return -1;
@@ -678,7 +676,6 @@ cmd_user_mail_input(struct mail_storage_service_ctx *storage_service,
        }
 
        mail_user_deinit(&user);
-       mail_storage_service_user_unref(&service_user);
        pool_unref(&pool);
        return 1;
 }
index 261679bfadc5710ec5ea03118c42210ba63c5ca3..658ea29c953b1d79ce6dba93e1937131a4d74f3c 100644 (file)
@@ -14,7 +14,6 @@ struct copy_cmd_context {
        struct doveadm_mail_cmd_context ctx;
 
        const char *source_username;
-       struct mail_storage_service_user *source_service_user;
        struct mail_user *source_user;
 
        const char *destname;
@@ -88,11 +87,10 @@ cmd_copy_alloc_source_user(struct copy_cmd_context *ctx)
 
        mail_storage_service_io_deactivate_user(ctx->ctx.cur_service_user);
        if (mail_storage_service_lookup_next(ctx->ctx.storage_service, &input,
-                                            &ctx->source_service_user,
                                             &ctx->source_user,
                                             &error) < 0)
                i_fatal("Couldn't lookup user %s: %s", input.username, error);
-       mail_storage_service_io_deactivate_user(ctx->source_service_user);
+       mail_storage_service_io_deactivate_user(ctx->source_user->service_user);
        mail_storage_service_io_activate_user(ctx->ctx.cur_service_user);
 }
 
@@ -173,10 +171,8 @@ static void cmd_copy_deinit(struct doveadm_mail_cmd_context *_ctx)
        struct copy_cmd_context *ctx =
                container_of(_ctx, struct copy_cmd_context, ctx);
 
-       if (ctx->source_user != NULL) {
-               mail_storage_service_user_unref(&ctx->source_service_user);
+       if (ctx->source_user != NULL)
                mail_user_deinit(&ctx->source_user);
-       }
 }
 
 static struct doveadm_mail_cmd_context *cmd_copy_alloc(void)
index 8ee0884dcd195e3f10b043408e1047acd2888941..6046df83ddd01e1e790d8e17e1ce9ce27ad79639 100644 (file)
@@ -161,7 +161,6 @@ cmd_import_box(struct import_cmd_context *ctx, struct mail_user *dest_user,
 static void cmd_import_init_source_user(struct import_cmd_context *ctx, struct mail_user *dest_user)
 {
        struct mail_storage_service_input input;
-       struct mail_storage_service_user *service_user;
        struct mail_user *user;
        const char *error;
 
@@ -176,14 +175,13 @@ static void cmd_import_init_source_user(struct import_cmd_context *ctx, struct m
        input.flags_override_add = MAIL_STORAGE_SERVICE_FLAG_NO_NAMESPACES |
                MAIL_STORAGE_SERVICE_FLAG_NO_RESTRICT_ACCESS;
        if (mail_storage_service_lookup_next(ctx->ctx.storage_service, &input,
-                                            &service_user, &user, &error) < 0)
+                                            &user, &error) < 0)
                i_fatal("Import user initialization failed: %s", error);
        if (mail_namespaces_init_location(user, ctx->src_location, &error) < 0)
                i_fatal("Import namespace initialization failed: %s", error);
 
        ctx->src_user = user;
-       mail_storage_service_io_deactivate_user(service_user);
-       mail_storage_service_user_unref(&service_user);
+       mail_storage_service_io_deactivate_user(user->service_user);
        mail_storage_service_io_activate_user(ctx->ctx.cur_service_user);
 }
 
index 9b31c61703ab76e7b6e2af41efbc427ab7ae6b77..c1f324a0e85ff9f4f942bb3e1fd3467e9784e00c 100644 (file)
@@ -57,7 +57,6 @@ struct client {
        char *access_user, *access_service;
        ARRAY_TYPE(string) access_apps;
 
-       struct mail_storage_service_user *service_user;
        struct mail_user *mail_user;
 
        struct imap_urlauth_context *urlauth_ctx;
@@ -254,8 +253,6 @@ static void client_destroy(struct client *client)
        if (client->fd_ctrl >= 0)
                net_disconnect(client->fd_ctrl);
 
-       if (client->service_user != NULL)
-               mail_storage_service_user_unref(&client->service_user);
        i_free(client->access_user);
        i_free(client->access_service);
        array_foreach_elem(&client->access_apps, app)
@@ -539,7 +536,6 @@ client_handle_user_command(struct client *client, const char *cmd,
 {
        struct mail_storage_service_input input;
        struct imap_urlauth_worker_settings *set;
-       struct mail_storage_service_user *user;
        struct imap_urlauth_config config;
        struct mail_user *mail_user;
        const char *error;
@@ -571,7 +567,7 @@ client_handle_user_command(struct client *client, const char *cmd,
        e_debug(client->event, "Looking up user %s", input.username);
 
        ret = mail_storage_service_lookup_next(storage_service, &input,
-                                              &user, &mail_user, &error);
+                                              &mail_user, &error);
        if (ret < 0) {
                e_error(client->event,
                        "Failed to lookup user %s: %s", input.username, error);
@@ -596,7 +592,6 @@ client_handle_user_command(struct client *client, const char *cmd,
                imap_urlauth_worker_refresh_proctitle();
        }
 
-       client->service_user = user;
        client->mail_user = mail_user;
        client->set = set;
 
index 05fe135975524f5763a86e2591262a3c5525a69e..16a6b397ef9e84e23197564047d0b613c42358b2 100644 (file)
@@ -114,7 +114,6 @@ static bool user_has_special_use_mailboxes(struct mail_user *user)
 
 struct client *client_create(int fd_in, int fd_out, bool unhibernated,
                             struct event *event, struct mail_user *user,
-                            struct mail_storage_service_user *service_user,
                             const struct imap_settings *set,
                             const struct smtp_submit_settings *smtp_set)
 {
@@ -135,7 +134,6 @@ struct client *client_create(int fd_in, int fd_out, bool unhibernated,
        client->unhibernated = unhibernated;
        client->set = set;
        client->smtp_set = smtp_set;
-       client->service_user = service_user;
        client->fd_in = fd_in;
        client->fd_out = fd_out;
        client->input = i_stream_create_fd(fd_in,
@@ -547,7 +545,6 @@ static void client_default_destroy(struct client *client, const char *reason)
        if (array_is_created(&client->search_updates))
                array_free(&client->search_updates);
        pool_unref(&client->command_pool);
-       mail_storage_service_user_unref(&client->service_user);
 
        imap_client_count--;
        DLLIST_REMOVE(&imap_clients, client);
@@ -1670,7 +1667,7 @@ void clients_init(void)
 
 void client_kick(struct client *client)
 {
-       mail_storage_service_io_activate_user(client->service_user);
+       mail_storage_service_io_activate_user(client->user->service_user);
        if (client->output_cmd_lock == NULL) {
                client_send_line(client,
                                 "* BYE "MASTER_SERVICE_SHUTTING_DOWN_MSG".");
index e5bdc2b23fdc592513ee79676e9e14ab307454f9..d3d4a9323398bbffd3b48e62cce755a0869ff6a8 100644 (file)
@@ -167,7 +167,6 @@ struct client {
        guid_128_t anvil_conn_guid;
 
        pool_t pool;
-       struct mail_storage_service_user *service_user;
        const struct imap_settings *set;
        const struct smtp_submit_settings *smtp_set;
        string_t *capability_string;
@@ -270,7 +269,6 @@ extern unsigned int imap_feature_qresync;
    if the handle is a socket. */
 struct client *client_create(int fd_in, int fd_out, bool unhibernated,
                             struct event *event, struct mail_user *user,
-                            struct mail_storage_service_user *service_user,
                             const struct imap_settings *set,
                             const struct smtp_submit_settings *smtp_set);
 void client_create_finish_io(struct client *client);
index da8bf3648ca2cd04628a289f4218f3c51cd75ae8..b972ec49b9a67dc5abae826ef44d97b337664d5c 100644 (file)
@@ -125,7 +125,7 @@ static void client_kill_idle(struct client *client)
        if (client->output_cmd_lock != NULL)
                return;
 
-       mail_storage_service_io_activate_user(client->service_user);
+       mail_storage_service_io_activate_user(client->user->service_user);
        client_send_line(client, "* BYE "MASTER_SERVICE_SHUTTING_DOWN_MSG".");
        client_destroy(client, MASTER_SERVICE_SHUTTING_DOWN_MSG);
 }
@@ -242,7 +242,6 @@ int client_create_from_input(const struct mail_storage_service_input *input,
                             struct client **client_r, const char **error_r)
 {
        struct mail_storage_service_input service_input;
-       struct mail_storage_service_user *user;
        struct mail_user *mail_user;
        struct client *client;
        struct imap_settings *imap_set;
@@ -267,7 +266,7 @@ int client_create_from_input(const struct mail_storage_service_input *input,
        service_input = *input;
        service_input.event_parent = event;
        if (mail_storage_service_lookup_next(storage_service, &service_input,
-                                            &user, &mail_user, error_r) <= 0) {
+                                            &mail_user, error_r) <= 0) {
                event_unref(&event);
                return -1;
        }
@@ -285,7 +284,7 @@ int client_create_from_input(const struct mail_storage_service_input *input,
                verbose_proctitle = TRUE;
 
        client = client_create(fd_in, fd_out, unhibernated,
-                              event, mail_user, user, imap_set, smtp_set);
+                              event, mail_user, imap_set, smtp_set);
        client->userdb_fields = input->userdb_fields == NULL ? NULL :
                p_strarray_dup(client->pool, input->userdb_fields);
        event_unref(&event);
index 4b43c65acfb614e698c4eb21e0e5f902c2c2d76a..3f90d43d224e8366e5886c6c26cf05b9f32d8b1f 100644 (file)
@@ -140,7 +140,6 @@ static void test_imap_client_hibernate(void)
 {
        struct client *client;
        struct smtp_submit_settings smtp_set;
-       struct mail_storage_service_user *service_user;
        struct mail_user *mail_user;
        struct test_imap_client_hibernate ctx;
        const char *error;
@@ -165,7 +164,7 @@ static void test_imap_client_hibernate(void)
        test_assert(net_addr2ip("127.0.0.1", &input.local_ip) == 0);
        test_assert(net_addr2ip("127.0.0.2", &input.remote_ip) == 0);
        test_assert(mail_storage_service_lookup_next(storage_service, &input,
-               &service_user, &mail_user, &error) == 1);
+                                                    &mail_user, &error) == 1);
        mail_user->set->base_dir = tmpdir;
        mail_user->set->mail_log_prefix = EVILSTR"%u";
        mail_user->session_id = EVILSTR"session";
@@ -174,8 +173,7 @@ static void test_imap_client_hibernate(void)
 
        struct event *event = event_create(NULL);
        int client_fd = dup(dev_null_fd);
-       client = client_create(client_fd, client_fd, FALSE, event,
-                              mail_user, service_user,
+       client = client_create(client_fd, client_fd, FALSE, event, mail_user,
                               imap_setting_parser_info.defaults, &smtp_set);
        ctx.client = client;
 
index 897e95d4fd9f53f8c33b1a0a108bbd61ac41a1ec..57e8b7115d18985d6d9cceccbff84c2a636fd775 100644 (file)
@@ -257,7 +257,6 @@ master_connection_cmd_index(struct master_connection *conn,
                            unsigned int max_recent_msgs, const char *what)
 {
        struct mail_storage_service_input input;
-       struct mail_storage_service_user *service_user;
        struct mail_user *user;
        const char *error;
        int ret;
@@ -274,7 +273,7 @@ master_connection_cmd_index(struct master_connection *conn,
                input.session_id_prefix = session_id;
 
        if (mail_storage_service_lookup_next(conn->storage_service, &input,
-                                            &service_user, &user, &error) <= 0) {
+                                            &user, &error) <= 0) {
                e_error(conn->conn.event, "User %s lookup failed: %s",
                        username, error);
                return -1;
@@ -303,7 +302,6 @@ master_connection_cmd_index(struct master_connection *conn,
        }
 
        mail_user_deinit(&user);
-       mail_storage_service_user_unref(&service_user);
        indexer_worker_refresh_proctitle(NULL, NULL, 0, 0);
        return ret;
 }
index a95f194a8ad79f6aa742c0af43746897043a3ad8..5ba6ddd996ddcdbae3801d4e1c0b36f1ae6d8b93 100644 (file)
@@ -349,7 +349,6 @@ int main(int argc, char *argv[])
        const char *user, *errstr, *path;
        struct smtp_address *rcpt_to, *final_rcpt_to, *mail_from;
        struct mail_storage_service_ctx *storage_service;
-       struct mail_storage_service_user *service_user;
        struct mail_storage_service_input service_input;
        struct event *event;
        const char *user_source = "", *rcpt_to_source = "", *mail_from_error;
@@ -533,7 +532,7 @@ int main(int argc, char *argv[])
           _lookup() and _next(), but don't bother) */
        dinput.delivery_time_started = ioloop_timeval;
        ret = mail_storage_service_lookup_next(storage_service,
-                                              &service_input, &service_user,
+                                              &service_input,
                                               &dinput.rcpt_user,
                                               &errstr);
        if (ret <= 0) {
@@ -567,7 +566,6 @@ int main(int argc, char *argv[])
                mailbox_free(&box);
 
                mail_user_deinit(&dinput.rcpt_user);
-               mail_storage_service_user_unref(&service_user);
        }
 
        mail_deliver_session_deinit(&dinput.session);
index 70786797d52e3139fafc317a6a93522d08363dbe..5505e57b09f1d5e19bca8d06fc542ebd510f0813 100644 (file)
@@ -19,7 +19,6 @@ struct mail_user *
 raw_storage_create_from_set(struct mail_storage_service_ctx *ctx,
                            struct setting_parser_context *unexpanded_set_parser)
 {
-       struct mail_storage_service_user *service_user;
        struct mail_user *user;
        struct mail_namespace *ns;
        struct mail_namespace_settings *ns_set;
@@ -57,7 +56,7 @@ raw_storage_create_from_set(struct mail_storage_service_ctx *ctx,
                        MAIL_STORAGE_SERVICE_FLAG_NO_PLUGINS |
                        MAIL_STORAGE_SERVICE_FLAG_NO_NAMESPACES,
        };
-       if (mail_storage_service_lookup_next(ctx, &input, &service_user,
+       if (mail_storage_service_lookup_next(ctx, &input,
                                             &user, &error) < 0)
                i_fatal("Raw user initialization failed: %s", error);
        event_unref(&event);
@@ -82,8 +81,7 @@ raw_storage_create_from_set(struct mail_storage_service_ctx *ctx,
        if (old_ioloop_ctx != NULL)
                io_loop_context_switch(old_ioloop_ctx);
        else
-               mail_storage_service_io_deactivate_user(service_user);
-       mail_storage_service_user_unref(&service_user);
+               mail_storage_service_io_deactivate_user(user->service_user);
        return user;
 }
 
index 5c6d39f8a18e1f224bd3dd3271ab5711d658d62f..c0cc33e83ea41589d2314b1f58a596328c2ddfcd 100644 (file)
@@ -273,21 +273,17 @@ int shared_storage_get_namespace(struct mail_namespace **_ns,
                        MAIL_STORAGE_SERVICE_FLAG_NO_PLUGINS |
                        MAIL_STORAGE_SERVICE_FLAG_NO_NAMESPACES,
        };
-       struct mail_storage_service_user *service_user;
        if (mail_storage_service_lookup_next(storage_service, &input,
-                                            &service_user, &owner,
-                                            &error) < 0) {
+                                            &owner, &error) < 0) {
                if (owner != NULL && !owner->nonexistent) {
                        mailbox_list_set_critical(list,
                                "Couldn't create namespace '%s' for user %s: %s",
                                ns->prefix, owner->username, error);
                        mail_user_deinit(&owner);
-                       mail_storage_service_user_unref(&service_user);
                        io_loop_context_switch(old_ioloop_ctx);
                        return -1;
                }
        }
-       mail_storage_service_user_unref(&service_user);
 
        owner->creator = user;
        int ret = shared_mail_user_init(_storage, user, owner, &ns, tab,
index f55304769b44822b0fb0421dc55562391ad7e6ca..855163a224f23945a02d16171e4f81d539eb81f1 100644 (file)
@@ -1636,26 +1636,21 @@ void mail_storage_service_restrict_setenv(struct mail_storage_service_ctx *ctx,
 
 int mail_storage_service_lookup_next(struct mail_storage_service_ctx *ctx,
                                     const struct mail_storage_service_input *input,
-                                    struct mail_storage_service_user **user_r,
                                     struct mail_user **mail_user_r,
                                     const char **error_r)
 {
+       struct mail_storage_service_user *user;
        int ret;
 
-       ret = mail_storage_service_lookup(ctx, input, user_r, error_r);
+       ret = mail_storage_service_lookup(ctx, input, &user, error_r);
        if (ret <= 0) {
-               *user_r = NULL;
                *mail_user_r = NULL;
                return ret;
        }
 
-       ret = mail_storage_service_next(ctx, *user_r, mail_user_r, error_r);
-       if (ret < 0) {
-               if (*mail_user_r == NULL)
-                       mail_storage_service_user_unref(user_r);
-               return ret;
-       }
-       return 1;
+       ret = mail_storage_service_next(ctx, user, mail_user_r, error_r);
+       mail_storage_service_user_unref(&user);
+       return ret < 0 ? -1 : 1;
 }
 
 void mail_storage_service_user_ref(struct mail_storage_service_user *user)
index 8474d3b16f1ae9acb09c28e7922b831b38d949fe..a6c4ea615932a7ceb4aca9ee5274b0aee7bd7d73 100644 (file)
@@ -128,7 +128,6 @@ void mail_storage_service_restrict_setenv(struct mail_storage_service_ctx *ctx,
 /* Combine lookup() and next() into one call. */
 int mail_storage_service_lookup_next(struct mail_storage_service_ctx *ctx,
                                     const struct mail_storage_service_input *input,
-                                    struct mail_storage_service_user **user_r,
                                     struct mail_user **mail_user_r,
                                     const char **error_r);
 void mail_storage_service_user_ref(struct mail_storage_service_user *user);
index 6c77ec1c02999789d062daba7a4b87fde2b39daf..55d8544dcaa8cab54d2136ba108c49a1cd0cdef5 100644 (file)
@@ -104,8 +104,7 @@ void test_mail_storage_init_user(struct test_mail_storage_ctx *ctx,
        };
 
        if (mail_storage_service_lookup_next(ctx->storage_service, &input,
-                                            &ctx->service_user, &ctx->user,
-                                            &error) < 0) {
+                                            &ctx->user, &error) < 0) {
                 i_fatal("mail_storage_service_lookup_next(%s) failed: %s",
                         username, error);
        }
@@ -114,5 +113,4 @@ void test_mail_storage_init_user(struct test_mail_storage_ctx *ctx,
 void test_mail_storage_deinit_user(struct test_mail_storage_ctx *ctx)
 {
        mail_user_deinit(&ctx->user);
-       mail_storage_service_user_unref(&ctx->service_user);
 }
index 161fb3f92714fa8e31d0b3b8a77ec2e83ed45913..109fa688f9c4233e05004b0f15b49165f58effcc 100644 (file)
@@ -7,7 +7,6 @@ struct test_mail_storage_ctx {
        pool_t pool;
        struct mail_storage_service_ctx *storage_service;
        struct mail_user *user;
-       struct mail_storage_service_user *service_user;
        struct ioloop *ioloop;
        const char *home_root;
 };
index 24af6fcb9e586c0ac96e2cdb78a92a61a1138754..817d2522a27a8c3755db3cf2f52dba8eb4688a74 100644 (file)
@@ -72,7 +72,6 @@ p_as_null_terminated_array(pool_t pool, const char *value)
 static int
 mcp_user_create(struct mail_user *user, const char *dest_username,
                struct mail_user **dest_user_r,
-               struct mail_storage_service_user **dest_service_user_r,
                const char **error_r)
 {
        const struct mail_storage_service_input *old_input;
@@ -97,7 +96,6 @@ mcp_user_create(struct mail_user *user, const char *dest_username,
                                   MAIL_STORAGE_SERVICE_FLAG_NO_LOG_INIT;
 
        ret = mail_storage_service_lookup_next(service_ctx, &input,
-                                               dest_service_user_r,
                                                dest_user_r, error_r);
 
        if (ret == 0)
@@ -113,7 +111,6 @@ mcp_update_shared_key(struct mailbox_transaction_context *t,
 {
        const char *error;
        struct mail_user *dest_user;
-       struct mail_storage_service_user *dest_service_user;
        struct ioloop_context *cur_ioloop_ctx;
        struct dcrypt_public_key *pkey;
        const char *dest_username;
@@ -122,12 +119,11 @@ mcp_update_shared_key(struct mailbox_transaction_context *t,
        bool disallow_insecure =
                mail_user_plugin_getenv_bool(user, MAIL_CRYPT_ACL_SECURE_SHARE_SETTING);
 
-       ret = mcp_user_create(user, target_uid, &dest_user,
-                             &dest_service_user, &error);
+       ret = mcp_user_create(user, target_uid, &dest_user, &error);
 
        /* to make sure we get correct logging context */
        if (ret > 0)
-               mail_storage_service_io_deactivate_user(dest_service_user);
+               mail_storage_service_io_deactivate_user(dest_user->service_user);
        mail_storage_service_io_activate_user(user->service_user);
 
        if (ret <= 0) {
@@ -166,10 +162,9 @@ mcp_update_shared_key(struct mailbox_transaction_context *t,
 
        /* logging context swap again */
        mail_storage_service_io_deactivate_user(user->service_user);
-       mail_storage_service_io_activate_user(dest_service_user);
+       mail_storage_service_io_activate_user(dest_user->service_user);
 
        mail_user_deinit(&dest_user);
-       mail_storage_service_user_unref(&dest_service_user);
 
        if ((cur_ioloop_ctx = io_loop_get_current_context(current_ioloop)) != NULL)
                io_loop_context_deactivate(cur_ioloop_ctx);
index 656efe99139c1fae2ed296cd7516dec89f83b6f2..7a13170c9944857c03ec4383dd5a179d27e4406b 100644 (file)
@@ -141,7 +141,6 @@ mail_crypt_acl_unset_private_keys(struct mailbox *src_box,
 static int
 mail_crypt_acl_user_create(struct mail_user *user, const char *dest_username,
                           struct mail_user **dest_user_r,
-                          struct mail_storage_service_user **dest_service_user_r,
                           const char **error_r)
 {
        const struct mail_storage_service_input *old_input;
@@ -167,7 +166,6 @@ mail_crypt_acl_user_create(struct mail_user *user, const char *dest_username,
        input.flags_override_remove = MAIL_STORAGE_SERVICE_FLAG_NO_NAMESPACES;
 
        ret = mail_storage_service_lookup_next(service_ctx, &input,
-                                               dest_service_user_r,
                                                dest_user_r, error_r);
 
        return ret;
@@ -246,7 +244,6 @@ static int mail_crypt_acl_object_update(struct acl_object *aclobj,
        struct event *event = aclobj->backend->event;
        const char *username;
        struct mail_user *dest_user;
-       struct mail_storage_service_user *dest_service_user;
        struct ioloop_context *cur_ioloop_ctx;
        bool have_rights;
        int ret = 0;
@@ -279,12 +276,11 @@ static int mail_crypt_acl_object_update(struct acl_object *aclobj,
                have_rights = ret > 0;
 
                ret = mail_crypt_acl_user_create(aclobj->backend->list->ns->user,
-                                                username, &dest_user,
-                                                &dest_service_user, &error);
+                                                username, &dest_user, &error);
 
                /* to make sure we get correct logging context */
                if (ret > 0)
-                       mail_storage_service_io_deactivate_user(dest_service_user);
+                       mail_storage_service_io_deactivate_user(dest_user->service_user);
                mail_storage_service_io_activate_user(
                        aclobj->backend->list->ns->user->service_user
                );
@@ -317,10 +313,9 @@ static int mail_crypt_acl_object_update(struct acl_object *aclobj,
                mail_storage_service_io_deactivate_user(
                        aclobj->backend->list->ns->user->service_user
                );
-               mail_storage_service_io_activate_user(dest_service_user);
+               mail_storage_service_io_activate_user(dest_user->service_user);
 
                mail_user_deinit(&dest_user);
-               mail_storage_service_user_unref(&dest_service_user);
 
                if ((cur_ioloop_ctx = io_loop_get_current_context(current_ioloop)) != NULL)
                        io_loop_context_deactivate(cur_ioloop_ctx);
index d9cfdf3fb8448e161015b9dd285caf95cfdee3ea..6f4b460d7b09dc6b7ac54b5ce89dc858a9924c3e 100644 (file)
@@ -116,7 +116,6 @@ static int client_check_mta_state(struct quota_client *client)
 static void client_handle_request(struct quota_client *client)
 {
        struct mail_storage_service_input input;
-       struct mail_storage_service_user *service_user;
        struct mail_user *user;
        struct smtp_address *rcpt;
        const char *value = NULL, *error;
@@ -150,7 +149,7 @@ static void client_handle_request(struct quota_client *client)
                                       rcpt, &input.username, &delim,
                                       &detail);
        ret = mail_storage_service_lookup_next(storage_service, &input,
-                                              &service_user, &user, &error);
+                                              &user, &error);
        restrict_access_allow_coredumps(TRUE);
        if (ret == 0) {
                e_debug(client->event, "User `%s' not found", input.username);
@@ -193,7 +192,6 @@ static void client_handle_request(struct quota_client *client)
                }
                value = t_strdup(value); /* user's pool is being freed */
                mail_user_deinit(&user);
-               mail_storage_service_user_unref(&service_user);
        } else {
                e_error(client->event,
                        "Failed to lookup user %s: %s", input.username, error);
index 1df8950ce99e8a5cd7956aa7740ab532fa7046aa..b8b3b7601b9bcd84db15cf9bf02461e2f4084b01 100644 (file)
@@ -116,7 +116,6 @@ client_create_from_input(const struct mail_storage_service_input *input,
 {
        const char *lookup_error_str =
                "-ERR [SYS/TEMP] "MAIL_ERRSTR_CRITICAL_MSG"\r\n";
-       struct mail_storage_service_user *user;
        struct mail_user *mail_user;
        struct pop3_settings *set;
 
@@ -139,7 +138,7 @@ client_create_from_input(const struct mail_storage_service_input *input,
        service_input.event_parent = event;
 
        if (mail_storage_service_lookup_next(storage_service, &service_input,
-                                            &user, &mail_user, error_r) <= 0) {
+                                            &mail_user, error_r) <= 0) {
                if (write(fd_out, lookup_error_str, strlen(lookup_error_str)) < 0) {
                        /* ignored */
                }
@@ -152,7 +151,7 @@ client_create_from_input(const struct mail_storage_service_input *input,
        if (set->verbose_proctitle)
                verbose_proctitle = TRUE;
 
-       *client_r = client_create(fd_in, fd_out, event, mail_user, user, set);
+       *client_r = client_create(fd_in, fd_out, event, mail_user, set);
        event_unref(&event);
        return 0;
 }
index edb8727e6166885699f34037cd96268cda967c50..c7787b1ca84d5445242c09a46732f05a7461dfc9 100644 (file)
@@ -338,7 +338,7 @@ static void pop3_lock_session_refresh(struct client *client)
 int pop3_lock_session(struct client *client)
 {
        const struct mail_storage_settings *mail_set =
-               mail_storage_service_user_get_mail_set(client->service_user);
+               mail_storage_service_user_get_mail_set(client->user->service_user);
        struct dotlock_settings dotlock_set;
        enum mailbox_list_path_type type;
        const char *dir, *path;
@@ -383,7 +383,6 @@ int pop3_lock_session(struct client *client)
 
 struct client *client_create(int fd_in, int fd_out,
                             struct event *event, struct mail_user *user,
-                            struct mail_storage_service_user *service_user,
                             const struct pop3_settings *set)
 {
        struct client *client;
@@ -398,7 +397,6 @@ struct client *client_create(int fd_in, int fd_out,
        client->pool = pool;
        client->event = event;
        event_ref(client->event);
-       client->service_user = service_user;
        client->v = pop3_client_vfuncs;
        client->set = set;
        client->fd_in = fd_in;
@@ -645,7 +643,6 @@ static void client_default_destroy(struct client *client, const char *reason)
        pop3_refresh_proctitle();
        mail_user_autoexpunge(client->user);
        mail_user_deinit(&client->user);
-       mail_storage_service_user_unref(&client->service_user);
 
        pop3_client_count--;
        DLLIST_REMOVE(&pop3_clients, client);
@@ -862,7 +859,7 @@ static int client_output(struct client *client)
 
 void client_kick(struct client *client)
 {
-       mail_storage_service_io_activate_user(client->service_user);
+       mail_storage_service_io_activate_user(client->user->service_user);
        if (client->cmd == NULL) {
                client_send_line(client,
                        "-ERR [SYS/TEMP] "MASTER_SERVICE_SHUTTING_DOWN_MSG".");
index faa92e9d94ce2bd043e14b3ca0f844957c0e8e5b..fee0d99d4e49302d3745a2210416833a7b65a508 100644 (file)
@@ -48,7 +48,6 @@ struct client {
        void *cmd_context;
 
        pool_t pool;
-       struct mail_storage_service_user *service_user;
        struct mail_user *user;
        struct mail_namespace *inbox_ns;
        struct mailbox *mailbox;
@@ -125,7 +124,6 @@ extern unsigned int pop3_client_count;
    if the handle is a socket. */
 struct client *client_create(int fd_in, int fd_out,
                             struct event *event, struct mail_user *user,
-                            struct mail_storage_service_user *service_user,
                             const struct pop3_settings *set);
 void client_create_finish(struct client *client);
 int client_init_mailbox(struct client *client, const char **error_r);
index d138a0e48b0b3fcfb16b3231f4975095039326b2..4aeaa5076f3c5b06d5289977a49714ed3b146f14 100644 (file)
@@ -150,7 +150,6 @@ client_create_from_input(const struct mail_storage_service_input *input,
                         const char **error_r)
 {
        struct mail_storage_service_input service_input;
-       struct mail_storage_service_user *user;
        struct mail_user *mail_user;
        struct submission_settings *set;
        bool no_greeting = HAS_ALL_BITS(login_flags,
@@ -179,7 +178,7 @@ client_create_from_input(const struct mail_storage_service_input *input,
        service_input = *input;
        service_input.event_parent = event;
        if (mail_storage_service_lookup_next(storage_service, &service_input,
-                                            &user, &mail_user, error_r) <= 0) {
+                                            &mail_user, error_r) <= 0) {
                send_error(fd_out, event, my_hostname,
                        "4.7.0", MAIL_ERRSTR_CRITICAL_MSG);
                event_unref(&event);
@@ -203,7 +202,6 @@ client_create_from_input(const struct mail_storage_service_input *input,
                send_error(fd_out, event, set->hostname,
                           "4.3.5", MAIL_ERRSTR_CRITICAL_MSG);
                mail_user_deinit(&mail_user);
-               mail_storage_service_user_unref(&user);
                event_unref(&event);
                return -1;
        }
@@ -228,7 +226,7 @@ client_create_from_input(const struct mail_storage_service_input *input,
        }
 
        (void)client_create(fd_in, fd_out, event, mail_user,
-                           user, set, helo, &proxy_data, data, data_len,
+                           set, helo, &proxy_data, data, data_len,
                            no_greeting);
        event_unref(&event);
        return 0;
index 689f93b81619662bf1208bc999023ead2b782c19..3204734f55d508134e57fe46194eb649a3c7def1 100644 (file)
@@ -178,7 +178,6 @@ static void client_init_urlauth(struct client *client)
 struct client *
 client_create(int fd_in, int fd_out, struct event *event,
              struct mail_user *user,
-             struct mail_storage_service_user *service_user,
              const struct submission_settings *set, const char *helo,
              const struct smtp_proxy_data *proxy_data,
              const unsigned char *pdata, unsigned int pdata_len,
@@ -202,7 +201,6 @@ client_create(int fd_in, int fd_out, struct event *event,
        client->event = event;
        event_ref(client->event);
        client->user = user;
-       client->service_user = service_user;
        client->set = set;
 
        i_array_init(&client->pending_backends, 4);
@@ -328,7 +326,6 @@ client_default_destroy(struct client *client)
                imap_urlauth_deinit(&client->urlauth_ctx);
 
        mail_user_deinit(&client->user);
-       mail_storage_service_user_unref(&client->service_user);
 
        client_state_reset(client);
 
@@ -504,7 +501,7 @@ void client_add_extra_capability(struct client *client, const char *capability,
 
 void client_kick(struct client *client)
 {
-       mail_storage_service_io_activate_user(client->service_user);
+       mail_storage_service_io_activate_user(client->user->service_user);
        client_destroy(&client, "4.3.2", MASTER_SERVICE_SHUTTING_DOWN_MSG);
 }
 
index 681495b77ab5c39ec11b1a0db03945a0c0472c34..74b6058b39fca64e000d9de7e39cf164de8504f8 100644 (file)
@@ -94,7 +94,6 @@ struct client {
        ARRAY(struct submission_recipient *) rcpt_to;
        ARRAY(struct submission_backend *) rcpt_backends;
 
-       struct mail_storage_service_user *service_user;
        struct mail_user *user;
 
        /* IMAP URLAUTH context (RFC4467) for BURL (RFC4468) */
@@ -138,7 +137,6 @@ extern unsigned int submission_client_count;
 struct client *
 client_create(int fd_in, int fd_out, struct event *event,
              struct mail_user *user,
-             struct mail_storage_service_user *service_user,
              const struct submission_settings *set, const char *helo,
              const struct smtp_proxy_data *proxy_data,
              const unsigned char *pdata, unsigned int pdata_len,