]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: doveadm-mail - Require user, user-file or all-users option in mail commands
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 15 Aug 2022 07:16:08 +0000 (10:16 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 2 Sep 2022 06:22:32 +0000 (06:22 +0000)
src/doveadm/doveadm-mail.c

index 7f76c3561c222a26ef7976497315c4a2ab4b4b27..b0c6cc1106ce47f0d385de254ae370e81ce6f9d3 100644 (file)
@@ -815,13 +815,10 @@ doveadm_cmdv2_wrapper_parse_common_options(struct doveadm_mail_cmd_context *mctx
        if (doveadm_cmd_param_flag(cctx, "all-users")) {
                mctx->service_flags |= MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
                *wildcard_user_r = "*";
-       }
-       if (doveadm_cmd_param_istream(cctx, "user-file", &mctx->users_list_input)) {
+       } else if (doveadm_cmd_param_istream(cctx, "user-file", &mctx->users_list_input)) {
                i_stream_ref(mctx->users_list_input);
                mctx->service_flags |= MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
-       }
-
-       if (doveadm_cmd_param_str(cctx, "user", &value_str)) {
+       } else if (doveadm_cmd_param_str(cctx, "user", &value_str)) {
                mctx->service_flags |= MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
                if (!tcp_server)
                        cctx->username = value_str;
@@ -833,6 +830,11 @@ doveadm_cmdv2_wrapper_parse_common_options(struct doveadm_mail_cmd_context *mctx
                                cctx->username = NULL;
                        }
                }
+       } else if (doveadm_server) {
+               /* Protocol sets this in correct place, don't require a
+                  command line parameter */
+       } else {
+               i_fatal("One of -u, -F, or -A must be provided");
        }
 
        if (doveadm_cmd_param_str(cctx, "socket-path",