]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dsync: Fully separate sync users' settings
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 29 Dec 2023 21:28:33 +0000 (16:28 -0500)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:11 +0000 (12:34 +0200)
When changing user2's settings the same changes were actually going into
user1's settings as well, since they both shared the same settings_instance.
Duplicate the service user to get the settings_instance separated as well.
This didn't really matter until now, because the changed settings weren't
used after the user initialization.

src/doveadm/doveadm-dsync.c

index 336909f9041a98f484fdf6a3fcbb80d9d0a9ceaf..2259cb7d475c8ee3aa5e5e6316f55df453dcff22 100644 (file)
@@ -470,9 +470,12 @@ cmd_dsync_run_local(struct dsync_cmd_context *ctx, struct mail_user *user,
 
        /* Create another user for the second location with its own
           storage settings. Override only the defaults, while preserving any
-          namespace-specific settings. */
+          namespace-specific settings. The service user needs to be duplicated
+          also to avoid updating the first user's settings. */
+       struct mail_storage_service_user *service_user2 =
+               mail_storage_service_user_dup(ctx->ctx.cur_service_user);
        struct settings_instance *set_instance =
-               mail_storage_service_user_get_settings_instance(ctx->ctx.cur_service_user);
+               mail_storage_service_user_get_settings_instance(service_user2);
        mail_storage_2nd_settings_reset(set_instance, "");
        for (unsigned int i = 0; ctx->destination_options[i] != NULL; i++) {
                const char *key, *value;
@@ -485,9 +488,9 @@ cmd_dsync_run_local(struct dsync_cmd_context *ctx, struct mail_user *user,
        settings_override(set_instance, "mail_path", mail_path,
                          SETTINGS_OVERRIDE_TYPE_2ND_CLI_PARAM);
 
-       ret = mail_storage_service_next(ctx->ctx.storage_service,
-                                       ctx->ctx.cur_service_user,
+       ret = mail_storage_service_next(ctx->ctx.storage_service, service_user2,
                                        &user2, &error);
+       mail_storage_service_user_unref(&service_user2);
        if (ret < 0) {
                e_error(ctx->ctx.cctx->event,
                        "Failed to initialize user: %s", error);