]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: Remove command doveadm batch
authorMarco Bettini <marco.bettini@open-xchange.com>
Thu, 5 May 2022 08:37:25 +0000 (08:37 +0000)
committerMarco Bettini <marco.bettini@open-xchange.com>
Wed, 1 Jun 2022 10:00:46 +0000 (10:00 +0000)
No longer relevant and also in the way for next changes.

.gitignore
doc/man/Makefile.am
doc/man/doveadm-batch.1.in [deleted file]
doc/man/doveadm.1.in
src/doveadm/Makefile.am
src/doveadm/doveadm-mail-batch.c [deleted file]
src/doveadm/doveadm-mail.c
src/doveadm/doveadm-mail.h

index be1d3d11b387a8a71fe3e0ea09a1cbb764afacb0..d050eb9f30ee63d763961414d587802d764f9098 100644 (file)
@@ -69,7 +69,6 @@ doc/html
 doc/man/doveadm-acl.1
 doc/man/doveadm-altmove.1
 doc/man/doveadm-auth.1
-doc/man/doveadm-batch.1
 doc/man/doveadm-deduplicate.1
 doc/man/doveadm-director.1
 doc/man/doveadm-dump.1
index fb1f129de73314de24cef952377ab849b4c82341..37b5afc77f3b4ff60f1ca0f7615c601d6116b7b8 100644 (file)
@@ -18,7 +18,6 @@ nodist_man1_MANS = \
        doveadm-acl.1 \
        doveadm-altmove.1 \
        doveadm-auth.1 \
-       doveadm-batch.1 \
        doveadm-deduplicate.1 \
        doveadm-director.1 \
        doveadm-dump.1 \
@@ -71,7 +70,6 @@ EXTRA_DIST = \
        doveadm-acl.1.in \
        doveadm-altmove.1.in \
        doveadm-auth.1.in \
-       doveadm-batch.1.in \
        doveadm-deduplicate.1.in \
        doveadm-director.1.in \
        doveadm-dump.1.in \
diff --git a/doc/man/doveadm-batch.1.in b/doc/man/doveadm-batch.1.in
deleted file mode 100644 (file)
index 778c3fa..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-.\" Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file
-.TH DOVEADM\-BATCH 1 "2015-05-09" "Dovecot v2.3" "Dovecot"
-.SH NAME
-doveadm\-batch \- Execute multiple commands for multiple users
-.\"------------------------------------------------------------------------
-.SH SYNOPSIS
-.BR doveadm " [" \-Dv "] " batch " [" \-S
-.IR socket_path "] "
-.BI \-A " sep command sep command"
-[...]
-.br
-.\"-------------------------------------
-.BR doveadm " [" \-Dv "] " batch " [" \-S
-.IR socket_path "] "
-.BI \-F " file sep command sep command"
-[...]
-.br
-.\"-------------------------------------
-.BR doveadm " [" \-Dv "] " batch " [" \-S
-.IR socket_path "] "
-.BI \-u " usermask sep command sep command"
-[...]
-.\"------------------------------------------------------------------------
-.SH DESCRIPTION
-The command
-.B doveadm batch
-is used to execute multiple
-.BR doveadm (1)
-.IR command s
-sequentially for multiple users.
-This is primarily an optimization where Dovecot can do all the mailbox
-operations for the same user at once, instead of having to go through
-the users multiple times.
-.PP
-In the first form
-.BR doveadm (1)
-will loop over all users, defined in the configured
-.IR user_db (s),
-and execute the sequence of
-.IR command s
-for each of them.
-.PP
-In the second form
-.BR doveadm (1)
-will loop over all users, listed in the given
-.IR file .
-.PP
-In the third form the
-.IR command s
-will be executed for each user matching the given
-.IR usermask .
-.\"------------------------------------------------------------------------
-@INCLUDE:global-options@
-.\" --- command specific options --- "/.
-.PP
-Command specific
-.IR options :
-.\"-------------------------------------
-@INCLUDE:option-A@
-.\"-------------------------------------
-@INCLUDE:option-F-file@
-.\"-------------------------------------
-@INCLUDE:option-S-socket@
-.\"-------------------------------------
-@INCLUDE:option-u-user@
-.\"------------------------------------------------------------------------
-.SH ARGUMENTS
-.TP
-.I command
-Any
-.BR doveadm (1)
-command, with arguments and options \(em except for the
-.BR \-A ", " \-S " and " \-u " options."
-.\"-------------------------------------
-.TP
-.I sep
-A single character used as command separator, e.g. \(aq:\(aq.
-Be careful, unquoted characters, like
-.BR ; " or " & ,
-may be interpreted by your shell and
-.BR doveadm (1)
-will never see them.
-.\"------------------------------------------------------------------------
-.SH EXAMPLE
-In this example we move seen mails, older than one month, for all
-example.net users to the alternative storage under /nfsmount:
-.br
-.nf
-mail_location = mdbox:~/mdbox:ALT=/nfsmount/%h/mdbox
-.fi
-The second command will remove messages with refcount=0 from the
-primary storage.
-.PP
-.nf
-.ft B
-doveadm batch \-u \(rs*@example.net : altmove seen savedbefore 30d : purge
-.ft P
-.fi
-.\"------------------------------------------------------------------------
-@INCLUDE:reporting-bugs@
-.\"------------------------------------------------------------------------
-.SH SEE ALSO
-.BR doveadm (1)
\ No newline at end of file
index ae5acbada53588ce93099d3ddd397f639a4c7df9..212be760a6fc804858e1e29dc32f109850d4c515 100644 (file)
@@ -117,11 +117,6 @@ Move matching mails to the alternative storage.
 Dovecot\(aqs one\-way mailbox synchronization utility.
 .\"-------------------------------------
 .TP
-.B doveadm batch
-.BR doveadm\-batch (1),
-Execute multiple commands for multiple users.
-.\"-------------------------------------
-.TP
 .B doveadm copy
 .BR doveadm\-copy (1),
 Copy messages matching the given search query into another mailbox.
index 2c06862e7cbe66a028c6e9e9a13a1baa7823331a..7ec204c88f779eca68a9bddd08ee5075ee13efa9 100644 (file)
@@ -94,7 +94,6 @@ doveadm_common_mail_cmds = \
        doveadm-dsync.c \
        doveadm-mail.c \
        doveadm-mail-altmove.c \
-       doveadm-mail-batch.c \
        doveadm-mail-deduplicate.c \
        doveadm-mail-expunge.c \
        doveadm-mail-fetch.c \
diff --git a/src/doveadm/doveadm-mail-batch.c b/src/doveadm/doveadm-mail-batch.c
deleted file mode 100644 (file)
index c0a63ef..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/* Copyright (c) 2012-2018 Dovecot authors, see the included COPYING file */
-
-#include "lib.h"
-#include "array.h"
-#include "doveadm-mail.h"
-
-#include <unistd.h>
-
-struct batch_cmd_context {
-       struct doveadm_mail_cmd_context ctx;
-       ARRAY(struct doveadm_mail_cmd_context *) commands;
-};
-
-static int cmd_batch_prerun(struct doveadm_mail_cmd_context *_ctx,
-                           struct mail_storage_service_user *service_user,
-                           const char **error_r)
-{
-       struct batch_cmd_context *ctx = (struct batch_cmd_context *)_ctx;
-       struct doveadm_mail_cmd_context *cmd;
-       int ret = 0;
-
-       array_foreach_elem(&ctx->commands, cmd) {
-               if (cmd->v.prerun != NULL &&
-                   cmd->v.prerun(cmd, service_user, error_r) < 0) {
-                       ret = -1;
-                       break;
-               }
-       }
-       return ret;
-}
-
-static int cmd_batch_run(struct doveadm_mail_cmd_context *_ctx,
-                        struct mail_user *user)
-{
-       struct batch_cmd_context *ctx = (struct batch_cmd_context *)_ctx;
-       struct doveadm_mail_cmd_context *cmd;
-       int ret = 0;
-
-       array_foreach_elem(&ctx->commands, cmd) {
-               cmd->cur_mail_user = user;
-               const char *reason_code =
-                       event_reason_code_prefix("doveadm", "cmd_",
-                                                cmd->cmd->name);
-               struct event_reason *reason = event_reason_begin(reason_code);
-               ret = cmd->v.run(cmd, user);
-               event_reason_end(&reason);
-               if (ret < 0) {
-                       i_assert(cmd->exit_code != 0);
-                       _ctx->exit_code = cmd->exit_code;
-                       break;
-               }
-               cmd->cur_mail_user = NULL;
-       }
-       return ret;
-}
-
-static void
-cmd_batch_add(struct batch_cmd_context *batchctx,
-             int argc, const char *const *argv)
-{
-       struct doveadm_mail_cmd_context *subctx;
-       const struct doveadm_cmd_ver2 *cmd_ver2;
-       const struct doveadm_mail_cmd *cmd;
-       const char *getopt_args;
-       int c;
-
-       cmd_ver2 = doveadm_cmdline_find_with_args(argv[0], &argc, &argv);
-       if (cmd_ver2 == NULL)
-               i_fatal_status(EX_USAGE, "doveadm batch: '%s' mail command doesn't exist", argv[0]);
-
-       struct doveadm_mail_cmd *dyncmd =
-               p_new(batchctx->ctx.pool, struct doveadm_mail_cmd, 1);
-       dyncmd->usage_args = cmd_ver2->usage;
-       dyncmd->name = cmd_ver2->name;
-       dyncmd->alloc = cmd_ver2->mail_cmd;
-       cmd = dyncmd;
-
-       subctx = doveadm_mail_cmd_init(cmd, doveadm_settings);
-       subctx->full_args = argv + 1;
-       subctx->service_flags |= batchctx->ctx.service_flags;
-
-       i_getopt_reset();
-       getopt_args = subctx->getopt_args != NULL ? subctx->getopt_args : "";
-       while ((c = getopt(argc, (void *)argv, getopt_args)) > 0) {
-               if (subctx->v.parse_arg == NULL ||
-                   !subctx->v.parse_arg(subctx, c))
-                       doveadm_mail_help(cmd);
-       }
-       argv += optind;
-       if (argv[0] != NULL && cmd->usage_args == NULL) {
-               i_fatal_status(EX_USAGE, "doveadm %s: Unknown parameter: %s",
-                              cmd->name, argv[0]);
-       }
-       subctx->args = argv;
-       if (subctx->v.preinit != NULL)
-               subctx->v.preinit(subctx);
-       array_push_back(&batchctx->commands, &subctx);
-}
-
-static void
-cmd_batch_preinit(struct doveadm_mail_cmd_context *_ctx)
-{
-       const char *const *args = _ctx->args;
-       struct batch_cmd_context *ctx = (struct batch_cmd_context *)_ctx;
-       ARRAY_TYPE(const_string) sep_args;
-       const char *sep = args[0];
-       unsigned int i, start;
-       int argc;
-       const char *const *argv;
-
-       if (sep == NULL || args[1] == NULL)
-               doveadm_mail_help_name("batch");
-       args++;
-
-       p_array_init(&ctx->commands, _ctx->pool, 8);
-       p_array_init(&sep_args, _ctx->pool, 16);
-       for (i = start = 0;; i++) {
-               if (args[i] != NULL && strcmp(args[i], sep) != 0) {
-                       array_push_back(&sep_args, &args[i]);
-                       continue;
-               }
-               if (i > start) {
-                       (void)array_append_space(&sep_args);
-                       argc = i - start;
-                       argv = array_idx(&sep_args, start);
-                       cmd_batch_add(ctx, argc, argv);
-                       start = i+1;
-               }
-               if (args[i] == NULL)
-                       break;
-       }
-       (void)array_append_space(&sep_args);
-}
-
-static void
-cmd_batch_init(struct doveadm_mail_cmd_context *_ctx,
-              const char *const args[] ATTR_UNUSED)
-{
-       struct batch_cmd_context *ctx = (struct batch_cmd_context *)_ctx;
-       struct doveadm_mail_cmd_context *cmd;
-       struct batch_cmd_context *subctx;
-
-       array_foreach_elem(&ctx->commands, cmd) {
-               subctx = (struct batch_cmd_context *)cmd;
-               subctx->ctx.storage_service = _ctx->storage_service;
-               if (subctx->ctx.v.init != NULL)
-                       subctx->ctx.v.init(&subctx->ctx, subctx->ctx.args);
-       }
-}
-
-static void cmd_batch_deinit(struct doveadm_mail_cmd_context *_ctx)
-{
-       struct batch_cmd_context *ctx = (struct batch_cmd_context *)_ctx;
-       struct doveadm_mail_cmd_context *cmd;
-
-       array_foreach_elem(&ctx->commands, cmd) {
-               doveadm_mail_cmd_deinit(cmd);
-               doveadm_mail_cmd_free(cmd);
-       }
-}
-
-static struct doveadm_mail_cmd_context *cmd_batch_alloc(void)
-{
-       struct batch_cmd_context *ctx;
-
-       ctx = doveadm_mail_cmd_alloc(struct batch_cmd_context);
-       ctx->ctx.getopt_args = "+"; /* disable processing -args in the middle */
-       ctx->ctx.v.preinit = cmd_batch_preinit;
-       ctx->ctx.v.init = cmd_batch_init;
-       ctx->ctx.v.prerun = cmd_batch_prerun;
-       ctx->ctx.v.run = cmd_batch_run;
-       ctx->ctx.v.deinit = cmd_batch_deinit;
-       return &ctx->ctx;
-}
-
-struct doveadm_cmd_ver2 doveadm_cmd_batch = {
-       .name = "batch",
-       .mail_cmd = cmd_batch_alloc,
-       .usage = "<sep> <cmd1> [<sep> <cmd2> [..]]",
-       .flags = CMD_FLAG_NO_UNORDERED_OPTIONS,
-DOVEADM_CMD_PARAMS_START
-DOVEADM_CMD_MAIL_COMMON
-DOVEADM_CMD_PARAM('\0', "separator", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL)
-DOVEADM_CMD_PARAM('\0', "args", CMD_PARAM_ARRAY, CMD_PARAM_FLAG_POSITIONAL)
-DOVEADM_CMD_PARAMS_END
-};
index 7f45e90d934ef1253be261f96dc1a6ad2b616df4..28022adcb16b8aeeecdad1021a493822c97a4d6d 100644 (file)
@@ -744,7 +744,6 @@ DOVEADM_CMD_PARAMS_END
 };
 
 static struct doveadm_cmd_ver2 *mail_commands_ver2[] = {
-       &doveadm_cmd_batch,
        &doveadm_cmd_dsync_backup,
        &doveadm_cmd_dsync_mirror,
        &doveadm_cmd_dsync_server,
index 255f6e368d80d8bd3076a3fed4ca70effee1bd38..c143aec5ac1b43531ef334b3e670c6b8403e5a48 100644 (file)
@@ -167,7 +167,6 @@ void doveadm_mail_failed_mailbox(struct doveadm_mail_cmd_context *ctx,
 void doveadm_mail_failed_list(struct doveadm_mail_cmd_context *ctx,
                              struct mailbox_list *list);
 
-extern struct doveadm_cmd_ver2 doveadm_cmd_batch;
 extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_metadata_set_ver2;
 extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_metadata_unset_ver2;
 extern struct doveadm_cmd_ver2 doveadm_cmd_mailbox_metadata_get_ver2;