#include "ioloop-private.h"
#include "mail-namespace.h"
#include "mail-storage.h"
+#include "mail-storage-private.h"
#include "mail-storage-settings.h"
#include "mailbox-attribute.h"
#include "mail-crypt-common.h"
mail_storage_service_io_activate_user(user->_service_user);
if (ret <= 0) {
- i_error("Cannot initialize destination user %s: %s",
+ e_error(user->event, "Cannot initialize destination user %s: %s",
target_uid, error);
return ret;
} else {
if (mail_crypt_box_get_pvt_digests(box, pool_datastack_create(),
MAIL_ATTRIBUTE_TYPE_SHARED,
&ids, &error) < 0) {
- i_error("mail_crypt_box_get_pvt_digests(%s, /shared) failed: %s",
- mailbox_get_vname(box),
+ e_error(box->event, "mail_crypt_box_get_pvt_digests() failed: %s",
error);
return -1;
}
hex_to_binary(hexuid, uid);
if (mcp_update_shared_key(t, user, str_c(uid), key,
&error) < 0) {
- i_error("mcp_update_shared_key(%s, %s) failed: %s",
- mailbox_get_vname(box),
- str_c(uid),
- error);
+ e_error(box->event,
+ "mcp_update_shared_key(%s) failed: %s",
+ str_c(uid), error);
ret = -1;
break;
}
} else if (!found) {
found = TRUE;
- if (mail_crypt_box_set_shared_key(t, pubid, key,
- NULL, NULL,
- &error) < 0) {
- i_error("mail_crypt_box_set_shared_key(%s) failed: %s",
- mailbox_get_vname(box),
+ if (mail_crypt_box_set_shared_key(t, pubid, key, NULL,
+ NULL, &error) < 0) {
+ e_error(box->event,
+ "mail_crypt_box_set_shared_key() failed: %s",
error);
ret = -1;
break;
if (ret < 0) {
mailbox_transaction_rollback(&t);
} else if (mailbox_transaction_commit(&t) < 0) {
- i_error("mailbox_transaction_commit(%s) failed: %s",
- mailbox_get_vname(box),
- error);
+ e_error(box->event, "mailbox_transaction_commit() failed: %s", error);
ret = -1;
}
if ((ret = mail_crypt_box_get_public_key(box, &pair.pub, error_r)) < 0) {
ret = -1;
} else if (ret == 1 && !ctx->force) {
- i_info("Folder key exists. Use -f to generate a new one");
+ e_info(box->event, "Folder key exists. Use -f to generate a new one");
buffer_t *key_id = t_str_new(MAIL_CRYPT_HASH_BUF_SIZE);
const char *error;
if (!dcrypt_key_id_public(pair.pub,
MAIL_CRYPT_KEY_ID_ALGORITHM,
key_id, &error)) {
- i_error("dcrypt_key_id_public() failed: %s",
+ e_error(box->event, "dcrypt_key_id_public() failed: %s",
error);
return -1;
}
&error)) <= 0) {
struct dcrypt_keypair pair;
if (ret < 0) {
- i_error("mail_crypt_user_get_public_key(%s) failed: %s",
+ e_error(user->event,
+ "mail_crypt_user_get_public_key(%s) failed: %s",
user->username,
error);
} else if (mail_crypt_user_generate_keypair(user, &pair,
&pubid, &error) < 0) {
ret = -1;
- i_error("mail_crypt_user_generate_keypair(%s) failed: %s",
+ e_error(user->event,
+ "mail_crypt_user_generate_keypair(%s) failed: %s",
user->username,
error);
res = array_append_space(result);
}
if (ret == 1 && ctx->userkey_only && !user_key_generated) {
if (!ctx->force) {
- i_info("userkey exists. Use -f to generate a new one");
+ e_info(user->event,
+ "userkey exists. Use -f to generate a new one");
buffer_t *key_id = t_str_new(MAIL_CRYPT_HASH_BUF_SIZE);
if (!dcrypt_key_id_public(user_key,
MAIL_CRYPT_KEY_ID_ALGORITHM,
key_id, &error)) {
- i_error("dcrypt_key_id_public() failed: %s",
+ e_error(user->event,
+ "dcrypt_key_id_public() failed: %s",
error);
dcrypt_key_unref_public(&user_key);
return -1;
}
if (ctx->matched_keys == 0)
- i_warning("mailbox cryptokey generate: Nothing was matched. "
+ e_warning(user->event,
+ "mailbox cryptokey generate: Nothing was matched. "
"Use -U or specify mask?");
return ret;
}
if (mailbox_attribute_get(box, MAIL_ATTRIBUTE_TYPE_SHARED,
USER_CRYPT_PREFIX ACTIVE_KEY_NAME,
&value) < 0) {
- i_error("mailbox_get_attribute(%s, %s) failed: %s",
- mailbox_get_vname(box),
+ e_error(user->event,
+ "mailbox_get_attribute(%s) failed: %s",
USER_CRYPT_PREFIX ACTIVE_KEY_NAME,
mailbox_get_last_internal_error(box, NULL));
}
ctx->matched_keys++;
}
if (mailbox_attribute_iter_deinit(&iter) < 0)
- i_error("mailbox_attribute_iter_deinit(%s) failed: %s",
- mailbox_get_vname(box),
+ e_error(user->event,
+ "mailbox_attribute_iter_deinit failed: %s",
mailbox_get_last_internal_error(box, NULL));
mailbox_free(&box);
return;
if (mailbox_attribute_get(box, MAIL_ATTRIBUTE_TYPE_SHARED,
BOX_CRYPT_PREFIX ACTIVE_KEY_NAME,
&value) < 0) {
- i_error("mailbox_get_attribute(%s, %s) failed: %s",
- mailbox_get_vname(box),
+ e_error(user->event,
+ "mailbox_get_attribute(%s) failed: %s",
BOX_CRYPT_PREFIX ACTIVE_KEY_NAME,
mailbox_get_last_internal_error(box, NULL));
} else if (mail_crypt_box_get_pvt_digests(box, pool_datastack_create(),
MAIL_ATTRIBUTE_TYPE_PRIVATE,
&ids, &error) < 0) {
- i_error("mail_crypt_box_get_pvt_digests(%s) failed: %s",
- mailbox_get_vname(box),
+ e_error(user->event,
+ "mail_crypt_box_get_pvt_digests() failed: %s",
error);
} else {
const char *id;
}
if (ctx->matched_keys == 0)
- i_warning("mailbox cryptokey list: Nothing was matched. "
+ e_warning(user->event,
+ "mailbox cryptokey list: Nothing was matched. "
"Use -U or specify mask?");
return 0;
const char *error;
struct mail_crypt_acl_mailbox_list *mlist =
MAIL_CRYPT_ACL_LIST_CONTEXT(aclobj->backend->list);
+ struct event *event = aclobj->backend->event;
const char *username;
struct mail_user *dest_user;
struct mail_storage_service_user *dest_service_user;
ret = mail_crypt_acl_has_user_read_right(aclobj, username, &error);
if (ret < 0) {
- i_error("mail-crypt-acl-plugin: "
- "mail_crypt_acl_has_user_read_right(%s) failed: %s",
- username,
- error);
+ e_error(event,
+ "mail-crypt-acl-plugin: mail_crypt_acl_has_user_read_right(%s) failed: %s",
+ username, error);
break;
}
);
if (ret <= 0) {
- i_error("mail-crypt-acl-plugin: "
- "Cannot initialize destination user %s: %s",
+ e_error(event,
+ "mail-crypt-acl-plugin: Cannot initialize destination user %s: %s",
username, error);
break;
} else {
i_assert(dest_user != NULL);
if ((ret = mailbox_open(box)) < 0) {
- i_error("mail-crypt-acl-plugin: "
- "mailbox_open(%s) failed: %s",
+ e_error(event,
+ "mail-crypt-acl-plugin: mailbox_open(%s) failed: %s",
mailbox_get_vname(box),
mailbox_get_last_internal_error(box, NULL));
} else if ((ret = mail_crypt_acl_update_private_key(box, dest_user,
have_rights,
disallow_insecure,
&error)) < 0) {
- i_error("mail-crypt-acl-plugin: "
- "acl_update_private_key(%s, %s) failed: %s",
+ e_error(event,
+ "mail-crypt-acl-plugin: acl_update_private_key(%s, %s) failed: %s",
mailbox_get_vname(box),
username,
error);
case ACL_ID_GROUP:
case ACL_ID_GROUP_OVERRIDE:
if (disallow_insecure) {
- i_error("mail-crypt-acl-plugin: "
+ e_error(event, "mail-crypt-acl-plugin: "
"Secure key sharing is enabled -"
"Remove or set plugin { %s = no }",
MAIL_CRYPT_ACL_SECURE_SHARE_SETTING);
users belonging to the group would able to decrypt with
their private key, but that becomes quite complicated. */
if ((ret = mail_crypt_acl_has_nonuser_read_right(aclobj, &error)) < 0) {
- i_error("mail-crypt-acl-plugin: %s", error);
+ e_error(event, "mail-crypt-acl-plugin: %s", error);
} else if ((ret = mailbox_open(box)) < 0) {
- i_error("mail-crypt-acl-plugin: "
+ e_error(event, "mail-crypt-acl-plugin: "
"mailbox_open(%s) failed: %s",
mailbox_get_vname(box),
mailbox_get_last_internal_error(box, NULL));
TRUE,
disallow_insecure,
&error)) < 0) {
- i_error("mail-crypt-acl-plugin: "
+ e_error(event, "mail-crypt-acl-plugin: "
"acl_update_private_key(%s, %s) failed: %s",
- mailbox_get_vname(box),
- "",
- error);
+ mailbox_get_vname(box), "", error);
}
break;
case ACL_ID_TYPE_COUNT: