From: Siavash Tavakoli Date: Tue, 10 Aug 2021 11:26:14 +0000 (+0100) Subject: mail-crypt: Add password confirmation for doveadm cryptokey password command X-Git-Tag: 2.3.17~212 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a0c1fe343ec93632ad97983b69bf30ee6c025f8f;p=thirdparty%2Fdovecot%2Fcore.git mail-crypt: Add password confirmation for doveadm cryptokey password command To prevent setting wrong passwords by accident. --- diff --git a/src/plugins/mail-crypt/doveadm-mail-crypt.c b/src/plugins/mail-crypt/doveadm-mail-crypt.c index 7af2ecb629..a4322ed310 100644 --- a/src/plugins/mail-crypt/doveadm-mail-crypt.c +++ b/src/plugins/mail-crypt/doveadm-mail-crypt.c @@ -735,8 +735,14 @@ static int cmd_mcp_key_password_run(struct doveadm_mail_cmd_context *_ctx, _ctx->exit_code = EX_USAGE; return -1; } - ctx->new_password = - p_strdup(_ctx->pool, t_askpass("New password: ")); + const char *passw; + passw = t_askpass("New password: "); + if (strcmp(passw, t_askpass("Confirm new password: ")) != 0) { + doveadm_print("Passwords don't match, aborting"); + _ctx->exit_code = EX_USAGE; + return -1; + } + ctx->new_password = p_strdup(_ctx->pool, passw); } if (ctx->clear_password &&