Mercurial > dovecot > core-2.2
comparison src/plugins/mail-crypt/doveadm-mail-crypt.c @ 22591:dafc46a5c6e5
doveadm-mail-crypt: Print existing userkey hash when aborting generate
author | Martti Rannanjärvi <martti.rannanjarvi@dovecot.fi> |
---|---|
date | Fri, 06 Oct 2017 11:07:23 +0300 |
parents | b0da9b8fdae8 |
children | 8dc7e629897a |
comparison
equal
deleted
inserted
replaced
22590:b0da9b8fdae8 | 22591:dafc46a5c6e5 |
---|---|
323 dcrypt_key_unref_private(&pair.priv); | 323 dcrypt_key_unref_private(&pair.priv); |
324 } | 324 } |
325 if (ret < 0) return ret; | 325 if (ret < 0) return ret; |
326 ctx->matched_keys++; | 326 ctx->matched_keys++; |
327 } | 327 } |
328 | 328 if (ret == 1 && ctx->userkey_only && !user_key_generated) { |
329 if (ret == 1 && ctx->force && | 329 if (!ctx->force) { |
330 ctx->userkey_only && !user_key_generated) { | 330 i_info("userkey exists. Use -f to generate a new one"); |
331 buffer_t *key_id = t_str_new(MAIL_CRYPT_HASH_BUF_SIZE); | |
332 if (!dcrypt_key_id_public(user_key, | |
333 MAIL_CRYPT_KEY_ID_ALGORITHM, | |
334 key_id, &error)) { | |
335 i_error("dcrypt_key_id_public() failed: %s", | |
336 error); | |
337 return -1; | |
338 } | |
339 const char *hash = binary_to_hex(key_id->data, | |
340 key_id->used); | |
341 res = array_append_space(result); | |
342 res->name = DOVEADM_MCP_USERKEY; | |
343 res->id = p_strdup(_ctx->pool, hash); | |
344 res->success = TRUE; | |
345 ctx->matched_keys++; | |
346 return 1; | |
347 } | |
331 struct dcrypt_keypair pair; | 348 struct dcrypt_keypair pair; |
332 dcrypt_key_unref_public(&user_key); | 349 dcrypt_key_unref_public(&user_key); |
333 /* regen user key */ | 350 /* regen user key */ |
334 res = array_append_space(result); | 351 res = array_append_space(result); |
335 res->name = DOVEADM_MCP_USERKEY; | 352 res->name = DOVEADM_MCP_USERKEY; |