]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mail-crypt: Fix key generation handling
authorAki Tuomi <aki.tuomi@dovecot.fi>
Thu, 5 Oct 2017 12:40:45 +0000 (15:40 +0300)
committerTimo Sirainen <tss@dovecot.fi>
Thu, 5 Oct 2017 14:51:18 +0000 (17:51 +0300)
Userkey generation would not set all required fields.

src/plugins/mail-crypt/doveadm-mail-crypt.c

index 99b99e7856d9a87ddcb9028c31597ca7661e0028..cafe5952d9a4963fe31356f2bd91471a98925254 100644 (file)
@@ -322,9 +322,11 @@ static int mcp_keypair_generate_run(struct doveadm_mail_cmd_context *_ctx,
                if (mail_crypt_user_generate_keypair(user, &pair, &pubid,
                                                     &error) < 0) {
                        res->success = FALSE;
-                       res->id = p_strdup(_ctx->pool, error);
+                       res->error = p_strdup(_ctx->pool, error);
                        return -1;
                }
+               res->success = TRUE;
+               res->id = p_strdup(_ctx->pool, pubid);
                user_key = pair.pub;
                dcrypt_key_unref_private(&pair.priv);
        }
@@ -412,6 +414,7 @@ static int cmd_mcp_keypair_generate_run(struct doveadm_mail_cmd_context *_ctx,
                if (res->success)
                        doveadm_print("\xE2\x9C\x93");
                else {
+                       _ctx->exit_code = EX_DATAERR;
                        ret = -1;
                        doveadm_print("x");
                }