]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dsync: Remove -d (default-destination) parameter
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 28 Nov 2023 14:12:33 +0000 (16:12 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:11 +0000 (12:34 +0200)
The replication plugin was already removed, so this shouldn't be necessary
either. Also with the mail_location setting split, this feature couldn't
work the same way anyway.

src/doveadm/doveadm-dsync.c

index c83258c0517c8d93275131b928924e6d6c0d0bda..550081417992c184ad5ed6fc416957e0c77677f9 100644 (file)
@@ -76,7 +76,6 @@ struct dsync_cmd_context {
        unsigned int io_timeout_secs;
 
        const char *remote_name;
-       const char *local_location;
        pid_t remote_pid;
        const char *const *remote_cmd_args;
        struct child_wait *child_wait;
@@ -102,13 +101,11 @@ struct dsync_cmd_context {
        bool lock:1;
        bool purge_remote:1;
        bool sync_visible_namespaces:1;
-       bool default_replica_location:1;
        bool oneway:1;
        bool backup:1;
        bool reverse_backup:1;
        bool remote_user_prefix:1;
        bool no_mail_sync:1;
-       bool local_location_from_arg:1;
        bool exited:1;
        bool empty_hdr_workaround:1;
        bool no_header_hashes:1;
@@ -457,27 +454,20 @@ cmd_dsync_run_local(struct dsync_cmd_context *ctx, struct mail_user *user,
        struct dsync_brain *brain2;
        struct mail_user *user2;
        struct mail_namespace *ns, *ns2;
-       const char *location, *error;
+       const char *error;
        bool brain1_running, brain2_running, changed1, changed2;
        bool remote_only_changes;
        int ret;
 
        *mail_error_r = 0;
 
-       if (ctx->local_location_from_arg)
-               location = ctx->destination[0];
-       else {
-               i_assert(ctx->local_location != NULL);
-               location = ctx->local_location;
-       }
-
        i_set_failure_prefix("dsync(%s): ", user->username);
 
        /* update mail_location and create another user for the
           second location. */
        struct settings_instance *set_instance =
                mail_storage_service_user_get_settings_instance(ctx->ctx.cur_service_user);
-       settings_override(set_instance, "mail_location", location,
+       settings_override(set_instance, "mail_location", ctx->destination[0],
                          SETTINGS_OVERRIDE_TYPE_CODE);
        ret = mail_storage_service_next(ctx->ctx.storage_service,
                                        ctx->ctx.cur_service_user,
@@ -1006,26 +996,9 @@ parse_location(struct dsync_cmd_context *ctx,
 }
 
 static int
-get_default_replica_location(struct dsync_cmd_context *ctx,
-                            struct mail_storage_service_user *service_user,
-                            const char **error_r)
-{
-       const struct mail_storage_settings *mail_set;
-       if (settings_get(mail_storage_service_user_get_event(service_user),
-                        &mail_storage_setting_parser_info,
-                        SETTINGS_GET_FLAG_NO_CHECK |
-                        SETTINGS_GET_FLAG_NO_EXPAND,
-                        &mail_set, error_r) < 0)
-               return -1;
-       ctx->local_location = p_strdup(ctx->ctx.pool,
-               mail_user_set_plugin_getenv(mail_set, "mail_replica"));
-       settings_free(mail_set);
-       return 0;
-}
-
-static int cmd_dsync_prerun(struct doveadm_mail_cmd_context *_ctx,
-                           struct mail_storage_service_user *service_user,
-                           const char **error_r)
+cmd_dsync_prerun(struct doveadm_mail_cmd_context *_ctx,
+                struct mail_storage_service_user *service_user ATTR_UNUSED,
+                const char **error_r)
 {
        struct doveadm_cmd_context *cctx = _ctx->cctx;
        struct dsync_cmd_context *ctx =
@@ -1040,33 +1013,15 @@ static int cmd_dsync_prerun(struct doveadm_mail_cmd_context *_ctx,
        ctx->run_type = DSYNC_RUN_TYPE_LOCAL;
        ctx->remote_name = "remote";
 
-       if (ctx->default_replica_location) {
-               if (get_default_replica_location(ctx, service_user, error_r) < 0)
-                       return -1;
-
-               if (ctx->local_location == NULL ||
-                   *ctx->local_location == '\0') {
-                       *error_r = "User has no mail_replica in userdb";
-                       _ctx->exit_code = DOVEADM_EX_NOTFOUND;
-                       return -1;
-               }
-       } else {
-               /* if we're executing remotely, give -u parameter if we also
-                  did a userdb lookup. */
-               if ((_ctx->service_flags & MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP) != 0)
-                       username = cctx->username;
-
-               if (!mirror_get_remote_cmd(ctx, username, cctx->event, &remote_cmd_args)) {
-                       /* it's a mail_location */
-                       if (ctx->destination[1] != NULL)
-                               doveadm_mail_help_name(_ctx->cmd->name);
-                       ctx->local_location = ctx->destination[0];
-                       ctx->local_location_from_arg = TRUE;
-               }
-       }
+       /* if we're executing remotely, give -u parameter if we also
+          did a userdb lookup. */
+       if ((_ctx->service_flags & MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP) != 0)
+               username = cctx->username;
 
-       if (remote_cmd_args == NULL && ctx->local_location != NULL) {
-               if (parse_location(ctx, ctx->local_location,
+       if (!mirror_get_remote_cmd(ctx, username, cctx->event, &remote_cmd_args)) {
+               if (ctx->destination[1] != NULL)
+                       doveadm_mail_help_name(_ctx->cmd->name);
+               if (parse_location(ctx, ctx->destination[0],
                                   &remote_cmd_args, error_r) < 0)
                        return -1;
        }
@@ -1089,15 +1044,8 @@ static void cmd_dsync_init(struct doveadm_mail_cmd_context *_ctx)
        struct dsync_cmd_context *ctx =
                container_of(_ctx, struct dsync_cmd_context, ctx);
 
-       if (ctx->default_replica_location) {
-               if (*ctx->destination != NULL) {
-                       e_error(ctx->ctx.cctx->event,
-                               "Don't give mail location with -d parameter");
-               }
-       } else {
-               if (*ctx->destination == NULL)
-                       doveadm_mail_help_name(_ctx->cmd->name);
-       }
+       if (*ctx->destination == NULL)
+               doveadm_mail_help_name(_ctx->cmd->name);
        if (array_count(&ctx->exclude_mailboxes) > 0)
                array_append_zero(&ctx->exclude_mailboxes);
 
@@ -1117,8 +1065,6 @@ static void cmd_dsync_preinit(struct doveadm_mail_cmd_context *_ctx)
                ctx->oneway = ctx->backup = TRUE;
 
        (void)doveadm_cmd_param_str(cctx, "all-mailbox", &ctx->virtual_all_box);
-       ctx->default_replica_location =
-               doveadm_cmd_param_flag(cctx, "default-destination");
        if (doveadm_cmd_param_flag(cctx, "legacy-dsync"))
                legacy_dsync = TRUE;
 
@@ -1341,7 +1287,6 @@ DOVEADM_CMD_PARAM('e', "sync-until-time", CMD_PARAM_STR, 0) \
 DOVEADM_CMD_PARAM('O', "sync-flags", CMD_PARAM_STR, 0) \
 DOVEADM_CMD_PARAM('I', "sync-max-size", CMD_PARAM_STR, 0) \
 DOVEADM_CMD_PARAM('T', "timeout", CMD_PARAM_INT64, CMD_PARAM_FLAG_UNSIGNED) \
-DOVEADM_CMD_PARAM('d', "default-destination", CMD_PARAM_BOOL, 0) \
 DOVEADM_CMD_PARAM('E', "legacy-dsync", CMD_PARAM_BOOL, 0) \
 DOVEADM_CMD_PARAM('\0', "destination", CMD_PARAM_ARRAY, CMD_PARAM_FLAG_POSITIONAL)
 
@@ -1350,7 +1295,7 @@ DOVEADM_CMD_PARAM('\0', "destination", CMD_PARAM_ARRAY, CMD_PARAM_FLAG_POSITIONA
        "[-m <mailbox>] [-g <mailbox guid>] [-n <namespace> | -N] " \
        "[-x <exclude>] [-a <all mailbox>] [-s <state>] [-T <secs>] " \
        "[-t <start date>] [-e <end date>] [-O <sync flag>] [-I <max size>] " \
-       "-d|<dest>"
+       "<dest>"
 
 struct doveadm_cmd_ver2 doveadm_cmd_dsync_mirror = {
        .mail_cmd = cmd_dsync_alloc,