} while (mailbox_save_continue(ctx->save_ctx) == 0 && ret != -1);
if (mpresult.input->stream_errno != 0) {
- mail_storage_set_critical(ctx->box->storage,
+ mailbox_set_critical(ctx->box,
"read(%s) failed: %s (for CATENATE URL %s)",
i_stream_get_name(mpresult.input),
i_stream_get_error(mpresult.input), caturl);
return;
}
}
- mail_storage_set_critical(state->cur_mail->box->storage,
- "read(%s) failed: %s (FETCH %s for mailbox %s UID %u)",
+ mail_set_critical(state->cur_mail,
+ "read(%s) failed: %s (FETCH %s)",
i_stream_get_name(state->cur_input),
i_stream_get_error(state->cur_input),
- state->cur_human_name,
- mailbox_get_vname(state->cur_mail->box), state->cur_mail->uid);
+ state->cur_human_name);
*disconnect_reason_r = "FETCH read() failed";
}
}
if (message_get_header_size(input, &hdr_size, &has_nuls) < 0) {
- mail_storage_set_critical(mail->box->storage,
+ mail_set_critical(mail,
"read(%s) failed: %s", i_stream_get_name(input),
i_stream_get_error(input));
i_stream_unref(&input);
if (errno == ENOENT)
mail_set_expunged(mail);
else {
- mail_storage_set_critical(mail->box->storage,
- "stat(%s) failed: %m", path);
+ mail_set_critical(mail, "stat(%s) failed: %m", path);
}
return -1;
}
if (errno == ENOENT)
mail_set_expunged(_mail);
else {
- mail_storage_set_critical(_mail->box->storage,
- "open(%s) failed: %m", path);
+ mail_set_critical(_mail, "open(%s) failed: %m",
+ path);
}
return -1;
}
o_stream_set_name(_ctx->data.output, path);
o_stream_cork(_ctx->data.output);
} else {
- mail_storage_set_critical(trans->box->storage,
- "open(%s) failed: %m", path);
+ mailbox_set_critical(trans->box, "open(%s) failed: %m",
+ path);
ctx->failed = TRUE;
}
} T_END;
static int cydir_save_flush(struct cydir_save_context *ctx, const char *path)
{
struct mail_storage *storage = &ctx->mbox->storage->storage;
+ struct mailbox *box = &ctx->mbox->box;
struct stat st;
int ret = 0;
if (o_stream_finish(ctx->ctx.data.output) < 0) {
- mail_storage_set_critical(storage, "write(%s) failed: %s", path,
+ mailbox_set_critical(box, "write(%s) failed: %s", path,
o_stream_get_error(ctx->ctx.data.output));
ret = -1;
}
if (storage->set->parsed_fsync_mode != FSYNC_MODE_NEVER) {
if (fsync(ctx->fd) < 0) {
- mail_storage_set_critical(storage,
- "fsync(%s) failed: %m", path);
+ mailbox_set_critical(box, "fsync(%s) failed: %m", path);
ret = -1;
}
}
if (fstat(ctx->fd, &st) == 0)
ctx->ctx.data.received_date = st.st_mtime;
else {
- mail_storage_set_critical(storage,
- "fstat(%s) failed: %m", path);
+ mailbox_set_critical(box, "fstat(%s) failed: %m", path);
ret = -1;
}
} else {
ut.actime = ioloop_time;
ut.modtime = ctx->ctx.data.received_date;
if (utime(path, &ut) < 0) {
- mail_storage_set_critical(storage,
- "utime(%s) failed: %m", path);
+ mailbox_set_critical(box, "utime(%s) failed: %m", path);
ret = -1;
}
}
o_stream_destroy(&ctx->ctx.data.output);
if (close(ctx->fd) < 0) {
- mail_storage_set_critical(storage,
- "close(%s) failed: %m", path);
+ mailbox_set_critical(box, "close(%s) failed: %m", path);
ret = -1;
}
ctx->fd = -1;
str_printfa(dest_path, "%u.", uid);
if (rename(str_c(src_path), str_c(dest_path)) < 0) {
- mail_storage_set_critical(&ctx->mbox->storage->storage,
+ mailbox_set_critical(&ctx->mbox->box,
"rename(%s, %s) failed: %m",
str_c(src_path), str_c(dest_path));
ctx->failed = TRUE;
T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname));
return -1;
} else if (errno == EACCES) {
- mail_storage_set_critical(box->storage, "%s",
+ mailbox_set_critical(box, "%s",
mail_error_eacces_msg("stat", box_path));
return -1;
} else {
- mail_storage_set_critical(box->storage, "stat(%s) failed: %m",
- box_path);
+ mailbox_set_critical(box, "stat(%s) failed: %m", box_path);
return -1;
}
if (index_storage_mailbox_open(box, FALSE) < 0)
o_stream_cork(ctx->dbox_output);
if (o_stream_send(ctx->dbox_output, &dbox_msg_hdr,
sizeof(dbox_msg_hdr)) < 0) {
- mail_storage_set_critical(_storage, "write(%s) failed: %s",
- o_stream_get_name(ctx->dbox_output),
- o_stream_get_error(ctx->dbox_output));
+ mail_set_critical(_ctx->dest_mail, "write(%s) failed: %s",
+ o_stream_get_name(ctx->dbox_output),
+ o_stream_get_error(ctx->dbox_output));
ctx->failed = TRUE;
}
_ctx->data.output = ctx->dbox_output;
ret = o_stream_flush(mdata->output);
}
if (ret < 0) {
- mail_storage_set_critical(ctx->ctx.transaction->box->storage,
- "write(%s) failed: %s",
- o_stream_get_name(mdata->output),
- o_stream_get_error(mdata->output));
+ mail_set_critical(ctx->ctx.dest_mail,
+ "write(%s) failed: %s",
+ o_stream_get_name(mdata->output),
+ o_stream_get_error(mdata->output));
ctx->failed = TRUE;
}
if (mdata->output != dbox_output) {
T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname));
return -1;
} else if (errno == EACCES) {
- mail_storage_set_critical(box->storage, "%s",
+ mailbox_set_critical(box, "%s",
mail_error_eacces_msg("stat", box_path));
return -1;
} else {
- mail_storage_set_critical(box->storage,
- "stat(%s) failed: %m", box_path);
+ mailbox_set_critical(box, "stat(%s) failed: %m", box_path);
return -1;
}
}
if (ret < 0)
return -1;
if (ret == 0) {
- mail_storage_set_critical(&storage->storage,
- "Mailbox %s has existing files in alt path, "
- "rebuilding storage to avoid losing messages",
- box->vname);
+ mailbox_set_critical(box,
+ "Existing files in alt path, "
+ "rebuilding storage to avoid losing messages");
storage->v.set_mailbox_corrupted(box);
return -1;
}
dbox_rec = data;
if (dbox_rec == NULL || dbox_rec->map_uid == 0) {
mail_index_lookup_uid(view, seq, &uid);
- mail_storage_set_critical(&mbox->storage->storage.storage,
- "mdbox %s: map uid lost for uid %u",
- mailbox_get_path(&mbox->box), uid);
+ mailbox_set_critical(&mbox->box,
+ "mdbox: map uid lost for uid %u", uid);
mdbox_storage_set_corrupted(mbox->storage);
return -1;
}
cur_map_uid_validity = mdbox_map_get_uid_validity(mbox->storage->map);
if (cur_map_uid_validity != mbox->map_uid_validity) {
- mail_storage_set_critical(&mbox->storage->storage.storage,
- "mdbox %s: map uidvalidity mismatch (%u vs %u)",
- mailbox_get_path(&mbox->box), mbox->map_uid_validity,
- cur_map_uid_validity);
+ mailbox_set_critical(&mbox->box,
+ "mdbox: map uidvalidity mismatch (%u vs %u)",
+ mbox->map_uid_validity, cur_map_uid_validity);
mdbox_storage_set_corrupted(mbox->storage);
return -1;
}
const char *box_path = mailbox_get_path(&ctx->mbox->box);
if (fdatasync_path(box_path) < 0) {
- mail_storage_set_critical(storage,
+ mail_set_critical(_ctx->dest_mail,
"fdatasync_path(%s) failed: %m", box_path);
}
}
&data, &data_size);
if (data_size < MDBOX_INDEX_HEADER_MIN_SIZE &&
(!mbox->creating || data_size != 0)) {
- mail_storage_set_critical(&mbox->storage->storage.storage,
- "mdbox %s: Invalid dbox header size: %"PRIuSIZE_T,
- mailbox_get_path(&mbox->box), data_size);
+ mailbox_set_critical(&mbox->box,
+ "mdbox: Invalid dbox header size: %"PRIuSIZE_T,
+ data_size);
mdbox_storage_set_corrupted(mbox->storage);
return -1;
}
memcmp(data, guid_128, GUID_128_SIZE) == 0)
return 0;
- mail_storage_set_critical(&ctx->mbox->storage->storage.storage,
- "Mailbox %s: Expunged GUID mismatch for UID %u: %s vs %s",
- ctx->mbox->box.vname, uid,
- guid_128_to_string(data), guid_128_to_string(guid_128));
+ mailbox_set_critical(&ctx->mbox->box,
+ "Expunged GUID mismatch for UID %u: %s vs %s",
+ uid, guid_128_to_string(data), guid_128_to_string(guid_128));
mdbox_storage_set_corrupted(ctx->mbox->storage);
return -1;
}
return -1;
return 1;
}
- mail_storage_set_critical(box->storage,
- "Mailbox %s: Broken index: missing UIDVALIDITY",
- box->vname);
+ mailbox_set_critical(box, "Broken index: missing UIDVALIDITY");
return 0;
}
struct mdbox_map_atomic_context *atomic,
struct mdbox_sync_context **ctx_r)
{
- struct mail_storage *storage = mbox->box.storage;
const struct mail_index_header *hdr =
mail_index_get_header(mbox->box.view);
struct mdbox_sync_context *ctx;
/* corrupted */
if (storage_rebuilt) {
- mail_storage_set_critical(storage,
- "mdbox %s: Storage keeps breaking",
- mailbox_get_path(&mbox->box));
+ mailbox_set_critical(&mbox->box,
+ "mdbox: Storage keeps breaking");
return -1;
}
try again from the beginning. */
mdbox_storage_set_corrupted(mbox->storage);
if ((flags & MDBOX_SYNC_FLAG_NO_REBUILD) != 0) {
- mail_storage_set_critical(storage,
- "mdbox %s: Can't rebuild storage",
- mailbox_get_path(&mbox->box));
+ mailbox_set_critical(&mbox->box,
+ "mdbox: Can't rebuild storage");
return -1;
}
return mdbox_sync_begin(mbox, flags, atomic, ctx_r);
pool = pool_alloconly_create("sdbox attachments copy", 1024);
p_array_init(&extrefs, pool, 16);
if (!index_attachment_parse_extrefs(extrefs_line, pool, &extrefs)) {
- mail_storage_set_critical(&dest_storage->storage,
+ mailbox_set_critical(&dest_file->mbox->box,
"Can't copy %s with corrupted extref metadata: %s",
src_file->file.cur_path, extrefs_line);
pool_unref(&pool);
dest_fsfile = fs_file_init(dest_storage->attachment_fs, dest,
FS_OPEN_MODE_READONLY);
if (fs_copy(src_fsfile, dest_fsfile) < 0) {
- mail_storage_set_critical(&dest_storage->storage, "%s",
+ mailbox_set_critical(&dest_file->mbox->box, "%s",
fs_last_error(dest_storage->attachment_fs));
ret = -1;
} else {
stream open) */
ret = 0;
} else {
- mail_storage_set_critical(
- _ctx->transaction->box->storage,
- "link(%s, %s) failed: %m", src_path, dest_path);
+ mail_set_critical(mail, "link(%s, %s) failed: %m",
+ src_path, dest_path);
}
dbox_file_unref(&src_file);
dbox_file_unref(&dest_file);
p = strchr(srcpath, '-');
if (p == NULL) {
- mail_storage_set_critical(file->mbox->box.storage,
+ mailbox_set_critical(&file->mbox->box,
"sdbox attachment path in invalid format: %s", srcpath);
} else {
p = strchr(p+1, '-');
dest_file = fs_file_init(storage->attachment_fs, dest,
FS_OPEN_MODE_READONLY);
if (fs_rename(src_file, dest_file) < 0) {
- mail_storage_set_critical(&storage->storage, "%s",
+ mailbox_set_critical(&file->mbox->box, "%s",
fs_last_error(storage->attachment_fs));
ret = -1;
}
new_path = t_strdup_printf("%s/%s", dir, new_fname);
if (!ignore_if_exists && stat(new_path, &st) == 0) {
- mail_storage_set_critical(&file->file.storage->storage,
+ mailbox_set_critical(&file->mbox->box,
"sdbox: %s already exists, rebuilding index", new_path);
sdbox_set_mailbox_corrupted(&file->mbox->box);
return -1;
}
if (rename(old_path, new_path) < 0) {
- mail_storage_set_critical(&file->file.storage->storage,
- "rename(%s, %s) failed: %m",
- old_path, new_path);
+ mailbox_set_critical(&file->mbox->box,
+ "rename(%s, %s) failed: %m",
+ old_path, new_path);
return -1;
}
sdbox_file_init_paths(file, new_fname);
fs_file = fs_file_init(fs, path, FS_OPEN_MODE_READONLY);
if (fs_delete(fs_file) < 0 &&
errno != ENOENT) {
- mail_storage_set_critical(&storage->storage, "%s",
- fs_last_error(fs));
+ mailbox_set_critical(&file->mbox->box, "%s",
+ fs_last_error(fs));
ret = -1;
}
fs_file_deinit(&fs_file);
fs_file = fs_file_init(fs, path, FS_OPEN_MODE_READONLY);
if (fs_delete(fs_file) < 0 &&
errno != ENOENT) {
- mail_storage_set_critical(&storage->storage, "%s",
- fs_last_error(fs));
+ mailbox_set_critical(&file->mbox->box, "%s",
+ fs_last_error(fs));
ret = -1;
}
fs_file_deinit(&fs_file);
int ret = 0;
if (unlink(file->file.cur_path) < 0) {
- mail_storage_set_critical(file->mbox->box.storage,
+ mailbox_set_critical(&file->mbox->box,
"unlink(%s) failed: %m", file->file.cur_path);
ret = -1;
}
perm->file_create_gid,
perm->file_create_gid_origin) < 0 &&
errno != EEXIST) {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"mkdir_parents(%s) failed: %m", dir);
return -1;
}
umask(old_mask);
}
if (fd == -1) {
- mail_storage_set_critical(box->storage,
- "open(%s, O_CREAT) failed: %m", path);
+ mailbox_set_critical(box, "open(%s, O_CREAT) failed: %m", path);
} else if (perm->file_create_gid == (gid_t)-1) {
/* no group change */
} else if (fchown(fd, (uid_t)-1, perm->file_create_gid) < 0) {
if (errno == EPERM) {
- mail_storage_set_critical(box->storage, "%s",
+ mailbox_set_critical(box, "%s",
eperm_error_get_chgrp("fchown", path,
perm->file_create_gid,
perm->file_create_gid_origin));
} else {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"fchown(%s, -1, %ld) failed: %m",
path, (long)perm->file_create_gid);
}
return;
}
- mail_storage_set_critical(_mail->box->storage,
- "dbox %s: Unexpectedly lost uid=%u",
- mailbox_get_path(_mail->box), _mail->uid);
+ mail_set_critical(_mail, "dbox: Unexpectedly lost uid");
sdbox_set_mailbox_corrupted(_mail->box);
}
/* it doesn't have input stream yet */
ret = dbox_file_open(mail->open_file, &deleted);
if (ret <= 0) {
- mail_storage_set_critical(_mail->box->storage,
- "dbox %s: Unexpectedly lost mail being saved",
- mailbox_get_path(_mail->box));
+ mail_set_critical(_mail,
+ "dbox: Unexpectedly lost mail being saved");
sdbox_set_mailbox_corrupted(_mail->box);
return -1;
}
const char *box_path = mailbox_get_path(&ctx->mbox->box);
if (fdatasync_path(box_path) < 0) {
- mail_storage_set_critical(storage,
+ mail_set_critical(_ctx->dest_mail,
"fdatasync_path(%s) failed: %m", box_path);
}
}
if (data_size < SDBOX_INDEX_HEADER_MIN_SIZE &&
(!mbox->box.creating || data_size != 0)) {
if (log_error) {
- mail_storage_set_critical(
- &mbox->storage->storage.storage,
- "sdbox %s: Invalid dbox header size",
- mailbox_get_path(&mbox->box));
+ mailbox_set_critical(&mbox->box,
+ "sdbox: Invalid dbox header size");
}
ret = -1;
} else {
/* another process just created the mailbox. read the mailbox_guid. */
if (sdbox_read_header(mbox, &hdr, FALSE, &need_resize) < 0) {
- mail_storage_set_critical(box->storage,
- "sdbox %s: Failed to read newly created dbox header",
- mailbox_get_path(&mbox->box));
+ mailbox_set_critical(box,
+ "sdbox: Failed to read newly created dbox header");
return -1;
}
memcpy(mbox->mailbox_guid, hdr.mailbox_guid,
static int sdbox_sync_index_rebuild_dir(struct index_rebuild_context *ctx,
const char *path, bool primary)
{
- struct mail_storage *storage = ctx->box->storage;
DIR *dir;
struct dirent *d;
int ret = 0;
}
return index_mailbox_fix_inconsistent_existence(ctx->box, path);
}
- mail_storage_set_critical(storage,
- "opendir(%s) failed: %m", path);
+ mailbox_set_critical(ctx->box, "opendir(%s) failed: %m", path);
return -1;
}
do {
ret = sdbox_sync_add_file(ctx, d->d_name, primary);
} while (ret >= 0);
if (errno != 0) {
- mail_storage_set_critical(storage,
- "readdir(%s) failed: %m", path);
+ mailbox_set_critical(ctx->box, "readdir(%s) failed: %m", path);
ret = -1;
}
if (closedir(dir) < 0) {
- mail_storage_set_critical(storage,
- "closedir(%s) failed: %m", path);
+ mailbox_set_critical(ctx->box, "closedir(%s) failed: %m", path);
ret = -1;
}
return ret;
sdbox_sync_set_uidvalidity(ctx);
if (sdbox_sync_index_rebuild_dir(ctx, path, TRUE) < 0) {
- mail_storage_set_critical(ctx->box->storage,
- "sdbox: Rebuilding failed on path %s",
- mailbox_get_path(ctx->box));
+ mailbox_set_critical(ctx->box, "sdbox: Rebuilding failed");
ret = -1;
} else if (alt_path != NULL) {
if (sdbox_sync_index_rebuild_dir(ctx, alt_path, FALSE) < 0) {
- mail_storage_set_critical(ctx->box->storage,
+ mailbox_set_critical(ctx->box,
"sdbox: Rebuilding failed on alt path %s",
alt_path);
ret = -1;
i_warning("sdbox %s: Rebuilding index", mailbox_get_path(&mbox->box));
if (dbox_verify_alt_storage(mbox->box.list) < 0) {
- mail_storage_set_critical(mbox->box.storage,
- "sdbox %s: Alt storage not mounted, "
- "aborting index rebuild", mailbox_get_path(&mbox->box));
+ mailbox_set_critical(&mbox->box,
+ "sdbox: Alt storage not mounted, "
+ "aborting index rebuild");
return -1;
}
return -1;
return 1;
}
- mail_storage_set_critical(box->storage,
- "sdbox %s: Broken index: missing UIDVALIDITY",
- mailbox_get_path(box));
+ mailbox_set_critical(box,
+ "sdbox: Broken index: missing UIDVALIDITY");
sdbox_set_mailbox_corrupted(box);
return 0;
}
int sdbox_sync_begin(struct sdbox_mailbox *mbox, enum sdbox_sync_flags flags,
struct sdbox_sync_context **ctx_r)
{
- struct mail_storage *storage = mbox->box.storage;
const struct mail_index_header *hdr =
mail_index_get_header(mbox->box.view);
struct sdbox_sync_context *ctx;
rebuild. */
if (ret == 0) {
if (i >= SDBOX_REBUILD_COUNT) {
- mail_storage_set_critical(storage,
- "sdbox %s: Index keeps breaking",
- mailbox_get_path(&ctx->mbox->box));
+ mailbox_set_critical(&ctx->mbox->box,
+ "sdbox: Index keeps breaking");
ret = -1;
} else {
/* do a full resync and try again. */
/* The disconnection message was already logged */
mail_storage_set_internal_error(&mbox->storage->storage);
} else {
- mail_storage_set_critical(&mbox->storage->storage,
+ mailbox_set_critical(&mbox->box,
"imapc: Mail FETCH failed: %s", reply->text_full);
}
imapc_client_stop(mbox->storage->client->client);
pool_t pool;
if (!imap_arg_get_list(list_arg, &args)) {
- mail_storage_set_critical(mail->imail.mail.mail.box->storage,
+ mail_set_critical(&mail->imail.mail.mail,
"imapc: Server sent invalid BODYSTRUCTURE parameters");
return NULL;
}
pool = pool_alloconly_create("imap bodystructure", 1024);
if (imap_bodystructure_parse_args(args, pool, &parts, &error) < 0) {
- mail_storage_set_critical(mail->imail.mail.mail.box->storage,
+ mail_set_critical(&mail->imail.mail.mail,
"imapc: Server sent invalid BODYSTRUCTURE: %s", error);
ret = NULL;
} else {
mailbox. This seems to be fixed in newer versions.
*/
fix_broken_mail = imail->fetch_ignore_if_missing;
- mail_storage_set_critical(mail->box->storage,
- "imapc: Remote server didn't send %s for UID %u in %s%s (FETCH replied: %s)",
- field, mail->uid, mail->box->vname,
- fix_broken_mail ? " - treating it as empty" : "",
+ mail_set_critical(mail,
+ "imapc: Remote server didn't send %s%s (FETCH replied: %s)",
+ field, fix_broken_mail ? " - treating it as empty" : "",
imail->last_fetch_reply);
}
return fix_broken_mail ? 0 : -1;
&data->physical_size);
if (ret <= 0) {
i_assert(ret != 0);
- mail_storage_set_critical(_mail->box->storage,
- "imapc: stat(%s) failed: %m",
- i_stream_get_name(data->stream));
+ mail_set_critical(_mail, "imapc: stat(%s) failed: %m",
+ i_stream_get_name(data->stream));
return -1;
}
*size_r = data->physical_size;
if (imapc_mail_get_guid(_mail, value_r) < 0)
return -1;
if (str_to_uint64(*value_r, &num) < 0) {
- mail_storage_set_critical(_mail->box->storage,
+ mail_set_critical(_mail,
"X-GM-MSGID not 64bit integer as expected for POP3 UIDL generation: %s", *value_r);
return -1;
}
int imapc_save_begin(struct mail_save_context *_ctx, struct istream *input)
{
struct imapc_save_context *ctx = IMAPC_SAVECTX(_ctx);
- struct mail_storage *storage = _ctx->transaction->box->storage;
const char *path;
i_assert(ctx->fd == -1);
ctx->fd = imapc_client_create_temp_fd(ctx->mbox->storage->client->client,
&path);
if (ctx->fd == -1) {
- mail_storage_set_critical(storage,
- "Couldn't create temp file %s", path);
+ mail_set_critical(_ctx->dest_mail,
+ "Couldn't create temp file %s", path);
ctx->failed = TRUE;
return -1;
}
MAIL_ERROR_PARAMS, reply);
ctx->ret = -1;
} else {
- mail_storage_set_critical(&ctx->ctx->mbox->storage->storage,
+ mailbox_set_critical(&ctx->ctx->mbox->box,
"imapc: APPEND failed: %s", reply->text_full);
ctx->ret = -1;
}
if (!ctx->failed) {
if (o_stream_finish(_ctx->data.output) < 0) {
if (!mail_storage_set_error_from_errno(storage)) {
- mail_storage_set_critical(storage,
+ mail_set_critical(_ctx->dest_mail,
"write(%s) failed: %s", ctx->temp_path,
o_stream_get_error(_ctx->data.output));
}
MAIL_ERROR_PARAMS, reply);
ctx->ret = -1;
} else {
- mail_storage_set_critical(&ctx->ctx->mbox->storage->storage,
+ mailbox_set_critical(&ctx->ctx->mbox->box,
"imapc: COPY failed: %s", reply->text_full);
ctx->ret = -1;
}
} else if (reply->state == IMAPC_COMMAND_STATE_DISCONNECTED) {
mail_storage_set_internal_error(mbox->box.storage);
} else {
- mail_storage_set_critical(mbox->box.storage,
+ mailbox_set_critical(&mbox->box,
"imapc: Command failed: %s", reply->text_full);
}
imapc_client_stop(mbox->storage->client->client);
ctx->mbox->selected = TRUE;
if (reply->state == IMAPC_COMMAND_STATE_OK) {
if (!imapc_mailbox_verify_select(ctx->mbox, &error)) {
- mail_storage_set_critical(ctx->mbox->box.storage,
- "imapc: Opening mailbox '%s' failed: %s",
- ctx->mbox->box.name, error);
+ mailbox_set_critical(&ctx->mbox->box,
+ "imapc: Opening mailbox failed: %s", error);
ctx->ret = -1;
} else {
ctx->ret = 0;
ctx->ret = -1;
mail_storage_set_internal_error(ctx->mbox->box.storage);
} else {
- mail_storage_set_critical(ctx->mbox->box.storage,
- "imapc: Opening mailbox '%s' failed: %s",
- ctx->mbox->box.name, reply->text_full);
+ mailbox_set_critical(&ctx->mbox->box,
+ "imapc: Opening mailbox failed: %s", reply->text_full);
ctx->ret = -1;
}
imapc_client_stop(ctx->mbox->storage->client->client);
mail_storage_set_internal_error(&ctx->mbox->storage->storage);
ctx->failed = TRUE;
} else {
- mail_storage_set_critical(&ctx->mbox->storage->storage,
- "imapc: Sync command '%s' failed: %s",
- cmd->cmd_str, reply->text_full);
+ mailbox_set_critical(&ctx->mbox->box,
+ "imapc: Sync command '%s' failed: %s",
+ cmd->cmd_str, reply->text_full);
ctx->failed = TRUE;
}
mail_index_sync_rollback(&ctx->index_sync_ctx);
}
if (ctx->mbox->sync_gmail_pop3_search_tag != NULL) {
- mail_storage_set_critical(&ctx->mbox->storage->storage,
+ mailbox_set_critical(&ctx->mbox->box,
"gmail-pop3 search not successful");
i_free_and_null(ctx->mbox->sync_gmail_pop3_search_tag);
ret = -1;
mail_user_set_get_temp_prefix(temp_path, storage->user->set);
fd = safe_mkstemp_hostpid(temp_path, 0600, (uid_t)-1, (gid_t)-1);
if (fd == -1) {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(ctx->transaction->box,
"safe_mkstemp(%s) failed: %m", str_c(temp_path));
return -1;
}
if (unlink(str_c(temp_path)) < 0) {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(ctx->transaction->box,
"unlink(%s) failed: %m", str_c(temp_path));
i_close_fd(&fd);
return -1;
return 0;
if (!mail_storage_set_error_from_errno(storage)) {
- mail_storage_set_critical(storage, "write(%s) failed: %s",
+ mail_set_critical(ctx->dest_mail, "write(%s) failed: %s",
o_stream_get_name(output), o_stream_get_error(output));
}
return -1;
int index_attachment_save_continue(struct mail_save_context *ctx)
{
- struct mail_storage *storage = ctx->transaction->box->storage;
struct mail_save_attachment *attach = ctx->data.attach;
const unsigned char *data;
size_t size;
} while (ret != -1);
if (attach->input->stream_errno != 0) {
- mail_storage_set_critical(storage, "read(%s) failed: %s",
+ mail_set_critical(ctx->dest_mail, "read(%s) failed: %s",
i_stream_get_name(attach->input),
i_stream_get_error(attach->input));
return -1;
key_get_prefixed(type, mailbox_prefix, key),
&value_r->value, &error);
if (ret < 0) {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"Failed to set attribute %s: %s", key, error);
return -1;
}
ret = iter->dict_disabled ? 0 : -1;
} else {
if ((ret = dict_iterate_deinit(&iter->diter, &error)) < 0) {
- mail_storage_set_critical(_iter->box->storage,
+ mailbox_set_critical(_iter->box,
"dict_iterate(%s) failed: %s",
iter->prefix, error);
}
message_parse_header_deinit(&parser);
if (ctx->input->stream_errno != 0) {
- mail_storage_set_critical(ctx->mail->box->storage,
+ mail_set_critical(ctx->mail,
"read(%s) failed: %s", i_stream_get_name(ctx->input),
i_stream_get_error(ctx->input));
return -1;
MAIL_ERROR_INVALIDDATA,
"Invalid data in MIME part");
} else {
- mail_storage_set_critical(_mail->box->storage,
- "read(%s) failed: %s",
- i_stream_get_name(is),
- i_stream_get_error(is));
+ mail_set_critical(_mail, "read(%s) failed: %s",
+ i_stream_get_name(is),
+ i_stream_get_error(is));
}
i_stream_unref(&is);
binary_streams_free(&ctx);
if (_mail->expunged)
return;
}
- mail_storage_set_critical(_mail->box->storage,
- "read(%s) failed: %s (uid=%u, box=%s, read reason=%s)",
+ mail_set_critical(_mail,
+ "read(%s) failed: %s (read reason=%s)",
i_stream_get_name(input), i_stream_get_error(input),
- _mail->uid, mailbox_get_vname(_mail->box),
mail->mail.get_stream_reason == NULL ? "" :
mail->mail.get_stream_reason);
}
imail->data.forced_no_caching = TRUE;
if (mail->saving) {
- mail_storage_set_critical(mail->box->storage,
- "BUG: Broken %s found in mailbox %s while saving a new mail: %s",
- field_name, mail->box->vname, reason);
+ mail_set_critical(mail,
+ "BUG: Broken %s found while saving a new mail: %s",
+ field_name, reason);
} else if (reason[0] == '\0') {
mail_set_mail_cache_corrupted(mail,
"Broken %s in mailbox %s",
memcpy(&update->vsize_hdr, data, sizeof(update->vsize_hdr));
else {
if (size != 0) {
- mail_storage_set_critical(update->box->storage,
+ mailbox_set_critical(update->box,
"vsize-hdr has invalid size: %"PRIuSIZE_T,
size);
}
if (update->vsize_hdr.message_count != seq2) {
if (update->vsize_hdr.message_count < seq2) {
- mail_storage_set_critical(update->box->storage,
+ mailbox_set_critical(update->box,
"vsize-hdr has invalid message-count (%u < %u)",
update->vsize_hdr.message_count, seq2);
} else {
/* don't log lock timeouts, because we're somewhat expecting
them. Especially when lock_secs is 0. */
if (ret < 0)
- mail_storage_set_critical(box->storage, "%s", error);
+ mailbox_set_critical(box, "%s", error);
update->lock_failed = TRUE;
return FALSE;
}
"/"INDEXER_SOCKET_NAME, NULL);
fd = net_connect_unix(path);
if (fd == -1) {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"Can't start vsize building on background: "
"net_connect_unix(%s) failed: %m", path);
return;
str_append_c(str, '\n');
if (write_full(fd, str_data(str), str_len(str)) < 0) {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"Can't start vsize building on background: "
"write(%s) failed: %m", path);
}
if (uid > update->vsize_hdr.highest_uid)
return;
if (update->vsize_hdr.message_count == 0) {
- mail_storage_set_critical(update->box->storage,
+ mailbox_set_critical(update->box,
"vsize-hdr's message_count shrank below 0");
i_zero(&update->vsize_hdr);
return;
}
update->vsize_hdr.message_count--;
if (update->vsize_hdr.vsize < vsize) {
- mail_storage_set_critical(update->box->storage,
+ mailbox_set_critical(update->box,
"vsize-hdr's vsize shrank below 0");
i_zero(&update->vsize_hdr);
return;
i_assert(ret >= 0 || ctx->input->stream_errno != 0);
}
if (ctx->input->stream_errno != 0) {
- mail_storage_set_critical(ctx->index_ctx->box->storage,
+ mailbox_set_critical(ctx->index_ctx->box,
"read(%s) failed: %s", i_stream_get_name(ctx->input),
i_stream_get_error(ctx->input));
}
message_parse_header(input, NULL, hdr_parser_flags,
search_header, &hdr_ctx);
if (input->stream_errno != 0) {
- mail_storage_set_critical(ctx->box->storage,
+ mailbox_set_critical(ctx->box,
"read(%s) failed: %s",
i_stream_get_name(input),
i_stream_get_error(input));
struct mailbox *box = ctx->program->t->box;
struct mail_sort_node *node;
- mail_storage_set_critical(box->storage,
- "%s: Broken %s indexes, resetting: %s",
- box->name, ctx->primary_sort_name, reason);
+ mailbox_set_critical(box, "Broken %s indexes, resetting: %s",
+ ctx->primary_sort_name, reason);
array_clear(&ctx->zero_nodes);
array_append_array(&ctx->zero_nodes,
return 0;
}
if (!ENOTFOUND(errno) && errno != EACCES) {
- mail_storage_set_critical(box->storage,
- "stat(%s) failed: %m", path);
+ mailbox_set_critical(box, "stat(%s) failed: %m", path);
return -1;
}
}
if ((index_flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) != 0) {
if (mail_index_is_in_memory(box->index)) {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"Couldn't create index file");
mail_index_close(box->index);
return -1;
break;
case OSTREAM_SEND_ISTREAM_RESULT_ERROR_OUTPUT:
if (!mail_storage_set_error_from_errno(storage)) {
- mail_storage_set_critical(storage,
+ mail_set_critical(ctx->dest_mail,
"save: write(%s) failed: %s",
o_stream_get_name(ctx->data.output),
o_stream_get_error(ctx->data.output));
} while (i_stream_read(input) > 0);
if (input->stream_errno != 0) {
- mail_storage_set_critical(storage, "save: read(%s) failed: %s",
+ mail_set_critical(ctx->dest_mail, "save: read(%s) failed: %s",
i_stream_get_name(input), i_stream_get_error(input));
return -1;
}
} else if (errno == ENOENT) {
/* race condition - mailbox was just deleted */
} else {
- mail_storage_set_critical(box->storage,
- "stat(%s) failed: %m", index_path);
+ mailbox_set_critical(box, "stat(%s) failed: %m", index_path);
return -1;
}
mailbox_set_deleted(box);
mail_index_expunge(ctx->trans_pvt, seq_pvt);
seq_pvt++;
} else {
- mail_storage_set_critical(ctx->box->storage,
+ mailbox_set_critical(ctx->box,
"%s: Message UID=%u unexpectedly inserted to mailbox",
ctx->box->index_pvt->filepath, uid_shared);
return -1;
hdr = mail_index_get_header(box->view);
if (hdr->first_recent_uid < ibox->recent_flags_prev_first_recent_uid) {
- mail_storage_set_critical(box->storage,
- "Mailbox %s: first_recent_uid unexpectedly shrank: %u -> %u",
- box->vname, ibox->recent_flags_prev_first_recent_uid,
+ mailbox_set_critical(box,
+ "first_recent_uid unexpectedly shrank: %u -> %u",
+ ibox->recent_flags_prev_first_recent_uid,
hdr->first_recent_uid);
mailbox_recent_flags_reset(box);
}
if (stat(path, &st) < 0) {
if (errno == ENOENT)
return INDEX_STORAGE_LIST_CHANGE_NOT_IN_FS;
- mail_storage_set_critical(box->storage,
- "stat(%s) failed: %m", path);
+ mailbox_set_critical(box, "stat(%s) failed: %m", path);
return INDEX_STORAGE_LIST_CHANGE_ERROR;
}
if (rec->size != (st.st_size & 0xffffffffU))
path = t_strconcat(dir, "/", box->index_prefix, ".log", NULL);
if (stat(path, &st) < 0) {
- mail_storage_set_critical(box->storage,
- "stat(%s) failed: %m", path);
+ mailbox_set_critical(box, "stat(%s) failed: %m", path);
return;
}
if (msgid == NULL) {
/* shouldn't have happened, probably corrupted */
- mail_storage_set_critical(mail->box->storage,
- "Corrupted thread index for mailbox %s: "
- "UID %u lost Message ID %u",
- mail->box->vname, mail->uid, rec->ref_index);
+ mail_set_critical(mail,
+ "Corrupted thread index: lost Message ID %u",
+ rec->ref_index);
ctx->failed = TRUE;
ctx->corrupted = TRUE;
return -1;
if (t->attr_pvt_trans != NULL) {
if (dict_transaction_commit(&t->attr_pvt_trans, &error) < 0) {
- mail_storage_set_critical(t->box->storage,
+ mailbox_set_critical(t->box,
"Dict private transaction commit failed: %s", error);
ret = -1;
}
}
if (t->attr_shared_trans != NULL) {
if (dict_transaction_commit(&t->attr_shared_trans, &error) < 0) {
- mail_storage_set_critical(t->box->storage,
+ mailbox_set_critical(t->box,
"Dict shared transaction commit failed: %s", error);
ret = -1;
}
if (errno == EACCES || ECANTLINK(errno) || errno == EEXIST)
return 1;
- mail_storage_set_critical(&mbox->storage->storage,
- "link(%s, %s) failed: %m",
- path, ctx->dest_path);
+ mailbox_set_critical(&mbox->box, "link(%s, %s) failed: %m",
+ path, ctx->dest_path);
return -1;
}
mk->synced = TRUE;
return 0;
}
- mail_storage_set_critical(mk->storage,
- "stat(%s) failed: %m", mk->path);
+ mailbox_set_critical(&mk->mbox->box,
+ "stat(%s) failed: %m", mk->path);
return -1;
}
mk->synced = TRUE;
return 0;
}
- mail_storage_set_critical(mk->storage,
- "open(%s) failed: %m", mk->path);
+ mailbox_set_critical(&mk->mbox->box,
+ "open(%s) failed: %m", mk->path);
return -1;
}
i_stream_destroy(&input);
if (close(fd) < 0) {
- mail_storage_set_critical(mk->storage,
- "close(%s) failed: %m", mk->path);
+ mailbox_set_critical(&mk->mbox->box,
+ "close(%s) failed: %m", mk->path);
return -1;
}
str_printfa(str, "%u %s\n", i, keywords[i]);
}
if (write_full(fd, str_data(str), str_len(str)) < 0) {
- mail_storage_set_critical(mk->storage,
- "write_full(%s) failed: %m", path);
+ mailbox_set_critical(&mk->mbox->box,
+ "write_full(%s) failed: %m", path);
return -1;
}
if (fstat(fd, &st) < 0) {
- mail_storage_set_critical(mk->storage,
- "fstat(%s) failed: %m", path);
+ mailbox_set_critical(&mk->mbox->box,
+ "fstat(%s) failed: %m", path);
return -1;
}
perm->file_create_gid != (gid_t)-1) {
if (fchown(fd, (uid_t)-1, perm->file_create_gid) < 0) {
if (errno == EPERM) {
- mail_storage_set_critical(mk->storage, "%s",
+ mailbox_set_critical(&mk->mbox->box, "%s",
eperm_error_get_chgrp("fchown", path,
perm->file_create_gid,
perm->file_create_gid_origin));
} else {
- mail_storage_set_critical(mk->storage,
+ mailbox_set_critical(&mk->mbox->box,
"fchown(%s) failed: %m", path);
}
}
ut.actime = ioloop_time;
ut.modtime = mk->synced_mtime;
if (utime(path, &ut) < 0) {
- mail_storage_set_critical(mk->storage,
+ mailbox_set_critical(&mk->mbox->box,
"utime(%s) failed: %m", path);
return -1;
}
}
if (fsync(fd) < 0) {
- mail_storage_set_critical(mk->storage,
+ mailbox_set_critical(&mk->mbox->box,
"fsync(%s) failed: %m", path);
return -1;
}
break;
if (errno != ENOENT || i == MAILDIR_DELETE_RETRY_COUNT) {
- mail_storage_set_critical(mk->storage,
+ mailbox_set_critical(&mk->mbox->box,
"file_dotlock_open(%s) failed: %m", mk->path);
return -1;
}
}
if (file_dotlock_replace(&dotlock, 0) < 0) {
- mail_storage_set_critical(mk->storage,
+ mailbox_set_critical(&mk->mbox->box,
"file_dotlock_replace(%s) failed: %m", mk->path);
return -1;
}
return 0;
if (errno == EACCES) {
- mail_storage_set_critical(&mbox->storage->storage, "%s",
+ mailbox_set_critical(&mbox->box, "%s",
mail_error_eacces_msg("open", path));
} else {
- mail_storage_set_critical(&mbox->storage->storage,
- "open(%s) failed: %m", path);
+ mailbox_set_critical(&mbox->box,
+ "open(%s) failed: %m", path);
}
return -1;
}
return 0;
if (errno == EACCES) {
- mail_storage_set_critical(&mbox->storage->storage, "%s",
+ mailbox_set_critical(&mbox->box, "%s",
mail_error_eacces_msg("stat", path));
} else {
- mail_storage_set_critical(&mbox->storage->storage,
- "stat(%s) failed: %m", path);
+ mailbox_set_critical(&mbox->box, "stat(%s) failed: %m", path);
}
return -1;
}
(fd = i_stream_get_fd(imail->data.stream)) != -1) {
mail->transaction->stats.fstat_lookup_count++;
if (fstat(fd, st_r) < 0) {
- mail_storage_set_critical(mail->box->storage,
- "fstat(%s) failed: %m",
+ mail_set_critical(mail, "fstat(%s) failed: %m",
i_stream_get_name(imail->data.stream));
return -1;
}
mail->transaction->stats.stat_lookup_count++;
path = maildir_save_file_get_path(mail->transaction, mail->seq);
if (stat(path, st_r) < 0) {
- mail_storage_set_critical(mail->box->storage,
- "stat(%s) failed: %m", path);
+ mail_set_critical(mail, "stat(%s) failed: %m", path);
return -1;
}
}
path = maildir_save_file_get_path(_mail->transaction,
_mail->seq);
if (stat(path, &st) < 0) {
- mail_storage_set_critical(_mail->box->storage,
- "stat(%s) failed: %m", path);
+ mail_set_critical(_mail, "stat(%s) failed: %m", path);
return -1;
}
}
return 0;
}
- mail_storage_set_critical(_mail->box->storage,
- "Maildir %s: Corrupted dovecot-uidlist: "
- "UID %u had empty GUID, clearing it",
- mailbox_get_path(_mail->box), _mail->uid);
+ mail_set_critical(_mail,
+ "Maildir: Corrupted dovecot-uidlist: "
+ "UID had empty GUID, clearing it");
maildir_uidlist_unset_ext(mbox->uidlist, _mail->uid,
MAILDIR_UIDLIST_REC_EXT_GUID);
}
if (stat(path, &st) < 0) {
if (errno == ENOENT)
return 0;
- mail_storage_set_critical(&mbox->storage->storage,
- "stat(%s) failed: %m", path);
+ mailbox_set_critical(&mbox->box,
+ "stat(%s) failed: %m", path);
return -1;
}
ctx->physical_size = st.st_size;
ctx->physical_size, info);
if (rename(path, newpath) == 0) {
- mail_storage_set_critical(mbox->box.storage,
+ mailbox_set_critical(&mbox->box,
"Maildir filename has wrong %c value, "
"renamed the file from %s to %s",
ctx->wrong_key, path, newpath);
if (errno == ENOENT)
return 0;
- mail_storage_set_critical(&mbox->storage->storage,
- "rename(%s, %s) failed: %m", path, newpath);
+ mailbox_set_critical(&mbox->box, "rename(%s, %s) failed: %m",
+ path, newpath);
return -1;
}
MAIL_ERRSTR_NO_QUOTA);
return -1;
} else {
- mail_storage_set_critical(storage, "rename(%s, %s) failed: %m",
- tmp_path, new_path);
+ mail_set_critical(ctx->ctx.dest_mail,
+ "rename(%s, %s) failed: %m",
+ tmp_path, new_path);
return -1;
}
}
mail_storage_set_error(box->storage,
MAIL_ERROR_NOQUOTA, MAIL_ERRSTR_NO_QUOTA);
} else {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"open(%s) failed: %m", str_c(path));
}
} else if (perm->file_create_gid != (gid_t)-1) {
if (fchown(fd, (uid_t)-1, perm->file_create_gid) < 0) {
if (errno == EPERM) {
- mail_storage_set_critical(box->storage, "%s",
+ mailbox_set_critical(box, "%s",
eperm_error_get_chgrp("fchown",
str_c(path),
perm->file_create_gid,
perm->file_create_gid_origin));
} else {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"fchown(%s) failed: %m", str_c(path));
}
}
static int maildir_save_finish_received_date(struct maildir_save_context *ctx,
const char *path)
{
- struct mail_storage *storage = &ctx->mbox->storage->storage;
struct utimbuf buf;
struct stat st;
buf.modtime = ctx->ctx.data.received_date;
if (utime(path, &buf) < 0) {
- mail_storage_set_critical(storage,
- "utime(%s) failed: %m", path);
+ mail_set_critical(ctx->ctx.dest_mail,
+ "utime(%s) failed: %m", path);
return -1;
}
} else if (ctx->fd != -1) {
if (fstat(ctx->fd, &st) == 0)
ctx->ctx.data.received_date = st.st_mtime;
else {
- mail_storage_set_critical(storage,
- "fstat(%s) failed: %m", path);
+ mail_set_critical(ctx->ctx.dest_mail,
+ "fstat(%s) failed: %m", path);
return -1;
}
} else {
if (stat(path, &st) == 0)
ctx->ctx.data.received_date = st.st_mtime;
else {
- mail_storage_set_critical(storage,
- "stat(%s) failed: %m", path);
+ mail_set_critical(ctx->ctx.dest_mail,
+ "stat(%s) failed: %m", path);
return -1;
}
}
path = t_strconcat(ctx->tmpdir, "/", ctx->file_last->tmp_name, NULL);
if (!ctx->failed && o_stream_finish(_ctx->data.output) < 0) {
if (!mail_storage_set_error_from_errno(storage)) {
- mail_storage_set_critical(storage,
+ mail_set_critical(_ctx->dest_mail,
"write(%s) failed: %s", path,
o_stream_get_error(_ctx->data.output));
}
!ctx->failed) {
if (fsync(ctx->fd) < 0) {
if (!mail_storage_set_error_from_errno(storage)) {
- mail_storage_set_critical(storage,
+ mail_set_critical(_ctx->dest_mail,
"fsync(%s) failed: %m", path);
}
ctx->failed = TRUE;
}
real_size = lseek(ctx->fd, 0, SEEK_END);
if (real_size == (off_t)-1) {
- mail_storage_set_critical(storage,
- "lseek(%s) failed: %m", path);
+ mail_set_critical(_ctx->dest_mail, "lseek(%s) failed: %m", path);
} else if (real_size != (off_t)ctx->file_last->size &&
(!maildir_filename_get_size(ctx->file_last->dest_basename,
MAILDIR_EXTRA_FILE_SIZE, &size) ||
}
if (close(ctx->fd) < 0) {
if (!mail_storage_set_error_from_errno(storage)) {
- mail_storage_set_critical(storage,
- "close(%s) failed: %m", path);
+ mail_set_critical(_ctx->dest_mail,
+ "close(%s) failed: %m", path);
}
ctx->failed = TRUE;
}
mail_storage_set_error(storage,
MAIL_ERROR_NOQUOTA, MAIL_ERRSTR_NO_QUOTA);
} else if (output_errno != 0) {
- mail_storage_set_critical(storage,
+ mail_set_critical(_ctx->dest_mail,
"write(%s) failed: %s", path, output_errstr);
}
if (new_changed) {
if (fdatasync_path(ctx->newdir) < 0) {
- mail_storage_set_critical(storage,
+ mail_set_critical(ctx->ctx.dest_mail,
"fdatasync_path(%s) failed: %m", ctx->newdir);
return -1;
}
}
if (cur_changed) {
if (fdatasync_path(ctx->curdir) < 0) {
- mail_storage_set_critical(storage,
+ mail_set_critical(ctx->ctx.dest_mail,
"fdatasync_path(%s) failed: %m", ctx->curdir);
return -1;
}
return 0;
if (errno != ENOENT) {
- mail_storage_set_critical(box->storage,
- "stat(%s) failed: %m", dir);
+ mailbox_set_critical(box, "stat(%s) failed: %m", dir);
return -1;
}
}
MAIL_ERRSTR_NO_PERMISSION);
return -1;
}
- mail_storage_set_critical(box->storage, "%s",
+ mailbox_set_critical(box, "%s",
mail_error_create_eacces_msg("mkdir", dir));
} else {
- mail_storage_set_critical(box->storage,
- "mkdir(%s) failed: %m", dir);
+ mailbox_set_critical(box, "mkdir(%s) failed: %m", dir);
}
return -1;
}
T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname));
return -1;
} else {
- mail_storage_set_critical(box->storage,
- "stat(%s) failed: %m", box_path);
+ mailbox_set_critical(box, "stat(%s) failed: %m", box_path);
return -1;
}
}
umask(old_mask);
if (fd == -1) {
- mail_storage_set_critical(box->storage, "open(%s) failed: %m",
- path);
+ mailbox_set_critical(box, "open(%s) failed: %m", path);
return -1;
}
if (fchown(fd, (uid_t)-1, perm->file_create_gid) < 0) {
if (errno == EPERM) {
- mail_storage_set_critical(box->storage, "%s",
+ mailbox_set_critical(box, "%s",
eperm_error_get_chgrp("fchown", path,
perm->file_create_gid,
perm->file_create_gid_origin));
} else {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"fchown(%s) failed: %m", path);
}
}
"Mailbox was deleted while it was being created");
return -1;
} else {
- mail_storage_set_critical(box->storage,
- "open(%s, O_CREAT) failed: %m", path);
+ mailbox_set_critical(box, "open(%s, O_CREAT) failed: %m", path);
return -1;
}
if (fchown(fd, (uid_t)-1, perm->file_create_gid) == 0) {
/* ok */
} else if (errno == EPERM) {
- mail_storage_set_critical(box->storage, "%s",
+ mailbox_set_critical(box, "%s",
eperm_error_get_chgrp("fchown", path,
perm->file_create_gid,
perm->file_create_gid_origin));
} else {
- mail_storage_set_critical(box->storage,
- "fchown(%s) failed: %m", path);
+ mailbox_set_critical(box, "fchown(%s) failed: %m", path);
}
}
i_close_fd(&fd);
if (memcmp(guid_128, expunged_guid_128, sizeof(guid_128)) == 0)
return TRUE;
- mail_storage_set_critical(&ctx->mbox->storage->storage,
- "Mailbox %s: Expunged GUID mismatch for UID %u: %s vs %s",
- ctx->mbox->box.vname, ctx->uid,
- guid_128_to_string(guid_128),
+ mailbox_set_critical(&ctx->mbox->box,
+ "Expunged GUID mismatch for UID %u: %s vs %s",
+ ctx->uid, guid_128_to_string(guid_128),
guid_128_to_string(expunged_guid_128));
return FALSE;
}
if (UNLINK_EISDIR(errno))
return maildir_lose_unexpected_dir(box->storage, path);
- mail_storage_set_critical(&mbox->storage->storage,
- "unlink(%s) failed: %m", path);
+ mailbox_set_critical(&mbox->box, "unlink(%s) failed: %m", path);
return -1;
}
if (stat(path, &st) < 0) {
if (errno == ENOENT)
return 0;
- mail_storage_set_critical(box->storage,
- "stat(%s) failed: %m", path);
+ mailbox_set_critical(box, "stat(%s) failed: %m", path);
return -1;
}
} else {
if (errno == ENOENT)
return 0;
if (!ENOSPACE(errno) && errno != EACCES) {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"rename(%s, %s) failed: %m",
path, newpath);
}
/* check if new/ changed */
new_dir = t_strconcat(root_dir, "/new", NULL);
if (stat(new_dir, &st) < 0) {
- mail_storage_set_critical(box->storage,
- "stat(%s) failed: %m", new_dir);
+ mailbox_set_critical(box, "stat(%s) failed: %m", new_dir);
return -1;
}
if ((time_t)rec->new_mtime != st.st_mtime)
/* check if cur/ changed */
cur_dir = t_strconcat(root_dir, "/cur", NULL);
if (stat(cur_dir, &st) < 0) {
- mail_storage_set_critical(box->storage,
- "stat(%s) failed: %m", cur_dir);
+ mailbox_set_critical(box, "stat(%s) failed: %m", cur_dir);
return -1;
}
if ((time_t)rec->cur_mtime != st.st_mtime)
if (rename(path2, new_path) == 0)
i_warning("Fixed a duplicate: %s -> %s", path2, new_fname);
else if (errno != ENOENT) {
- mail_storage_set_critical(&ctx->mbox->storage->storage,
+ mailbox_set_critical(&ctx->mbox->box,
"Couldn't fix a duplicate: rename(%s, %s) failed: %m",
path2, new_path);
return -1;
if (rename(old_path, new_path) == 0)
i_warning("Fixed broken filename: %s -> %s", old_path, new_fname);
else if (errno != ENOENT) {
- mail_storage_set_critical(&ctx->mbox->storage->storage,
+ mailbox_set_critical(&ctx->mbox->box,
"Couldn't fix a broken filename: rename(%s, %s) failed: %m",
old_path, new_path);
return -1;
/* try again */
}
- mail_storage_set_critical(box->storage, "stat(%s) failed: %m", path);
+ mailbox_set_critical(box, "stat(%s) failed: %m", path);
return -1;
}
maildir_scan_dir(struct maildir_sync_context *ctx, bool new_dir, bool final,
enum maildir_scan_why why)
{
- struct mail_storage *storage = &ctx->mbox->storage->storage;
const char *path;
DIR *dirp;
string_t *src, *dest;
if (errno != ENOENT || i == MAILDIR_DELETE_RETRY_COUNT) {
if (errno == EACCES) {
- mail_storage_set_critical(storage, "%s",
+ mailbox_set_critical(&ctx->mbox->box, "%s",
eacces_error_get("opendir", path));
} else {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(&ctx->mbox->box,
"opendir(%s) failed: %m", path);
}
return -1;
#ifdef HAVE_DIRFD
if (fstat(dirfd(dirp), &st) < 0) {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(&ctx->mbox->box,
"fstat(%s) failed: %m", path);
(void)closedir(dirp);
return -1;
move_new = FALSE;
} else {
flags |= MAILDIR_UIDLIST_REC_FLAG_NEW_DIR;
- mail_storage_set_critical(storage,
+ mailbox_set_critical(&ctx->mbox->box,
"rename(%s, %s) failed: %m",
str_c(src), str_c(dest));
}
#endif
if (errno != 0) {
- mail_storage_set_critical(storage,
- "readdir(%s) failed: %m", path);
+ mailbox_set_critical(&ctx->mbox->box,
+ "readdir(%s) failed: %m", path);
ret = -1;
}
if (closedir(dirp) < 0) {
- mail_storage_set_critical(storage,
- "closedir(%s) failed: %m", path);
+ mailbox_set_critical(&ctx->mbox->box,
+ "closedir(%s) failed: %m", path);
ret = -1;
}
}
if (errno != ENOENT || i == MAILDIR_DELETE_RETRY_COUNT) {
if (errno == EACCES) {
- mail_storage_set_critical(box->storage, "%s",
+ mailbox_set_critical(box, "%s",
eacces_error_get_creating("file_dotlock_create", path));
} else {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"file_dotlock_create(%s) failed: %m",
path);
}
static void maildir_uidlist_close(struct maildir_uidlist *uidlist)
{
- struct mail_storage *storage = uidlist->box->storage;
-
if (uidlist->fd != -1) {
if (close(uidlist->fd) < 0) {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(uidlist->box,
"close(%s) failed: %m", uidlist->path);
}
uidlist->fd = -1;
maildir_uidlist_set_corrupted(struct maildir_uidlist *uidlist,
const char *fmt, ...)
{
- struct mail_storage *storage = uidlist->box->storage;
va_list args;
va_start(args, fmt);
if (uidlist->retry_rewind) {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(uidlist->box,
"Broken or unexpectedly changed file %s "
"line %u: %s - re-reading from beginning",
uidlist->path, uidlist->read_line_count,
t_strdup_vprintf(fmt, args));
} else {
- mail_storage_set_critical(storage, "Broken file %s line %u: %s",
+ mailbox_set_critical(uidlist->box, "Broken file %s line %u: %s",
uidlist->path, uidlist->read_line_count,
t_strdup_vprintf(fmt, args));
}
maildir_uidlist_update_read(struct maildir_uidlist *uidlist,
bool *retry_r, bool try_retry)
{
- struct mail_storage *storage = uidlist->box->storage;
const char *line;
uint32_t orig_next_uid, orig_uid_validity;
struct istream *input;
}
if (fd == -1) {
if (errno != ENOENT) {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(uidlist->box,
"open(%s) failed: %m", uidlist->path);
return -1;
}
*retry_r = TRUE;
return -1;
}
- mail_storage_set_critical(storage,
+ mailbox_set_critical(uidlist->box,
"lseek(%s) failed: %m", uidlist->path);
return -1;
}
*retry_r = TRUE;
return -1;
}
- mail_storage_set_critical(storage,
+ mailbox_set_critical(uidlist->box,
"fstat(%s) failed: %m", uidlist->path);
return -1;
}
orig_uid_validity != 0) {
uidlist->recreate = TRUE;
} else if (ret > 0 && uidlist->next_uid < orig_next_uid) {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(uidlist->box,
"%s: next_uid was lowered (%u -> %u, hdr=%u)",
uidlist->path, orig_next_uid,
uidlist->next_uid, uidlist->hdr_next_uid);
if (input->stream_errno == ESTALE && try_retry)
*retry_r = TRUE;
else {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(uidlist->box,
"read(%s) failed: %s", uidlist->path,
i_stream_get_error(input));
}
i_stream_destroy(&input);
if (ret <= 0) {
if (close(fd) < 0) {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(uidlist->box,
"close(%s) failed: %m", uidlist->path);
}
}
}
if (nfs_safe_stat(uidlist->path, st_r) < 0) {
if (errno != ENOENT) {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(uidlist->box,
"stat(%s) failed: %m", uidlist->path);
return -1;
}
*recreated_r = TRUE;
return 1;
}
- mail_storage_set_critical(storage,
+ mailbox_set_critical(uidlist->box,
"fstat(%s) failed: %m", uidlist->path);
return -1;
}
uidlist->recreate_on_change = TRUE;
}
if (uidlist->fd == -1 && errno != ENOENT) {
- mail_storage_set_critical(uidlist->box->storage,
+ mailbox_set_critical(uidlist->box,
"open(%s) failed: %m", uidlist->path);
return -1;
}
maildir_uidlist_iter_deinit(&iter);
if (o_stream_finish(output) < 0) {
- mail_storage_set_critical(storage, "write(%s) failed: %s", path,
- o_stream_get_error(output));
+ mailbox_set_critical(uidlist->box, "write(%s) failed: %s",
+ path, o_stream_get_error(output));
o_stream_unref(&output);
return -1;
}
if (storage->set->parsed_fsync_mode != FSYNC_MODE_NEVER) {
if (fdatasync(fd) < 0) {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(uidlist->box,
"fdatasync(%s) failed: %m", path);
return -1;
}
break;
if (errno != ENOENT || i == MAILDIR_DELETE_RETRY_COUNT) {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"open(%s, O_CREAT) failed: %m", temp_path);
return -1;
}
if (perm->file_create_gid != (gid_t)-1 &&
fchown(fd, (uid_t)-1, perm->file_create_gid) < 0) {
if (errno == EPERM) {
- mail_storage_set_critical(box->storage, "%s",
+ mailbox_set_critical(box, "%s",
eperm_error_get_chgrp("fchown", temp_path,
perm->file_create_gid,
perm->file_create_gid_origin));
} else {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"fchown(%s) failed: %m", temp_path);
}
}
ret = maildir_uidlist_write_fd(uidlist, fd, temp_path, 0, &file_size);
if (ret == 0) {
if (rename(temp_path, uidlist->path) < 0) {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"rename(%s, %s) failed: %m",
temp_path, uidlist->path);
ret = -1;
if (ret < 0)
i_unlink(temp_path);
else if (fstat(fd, &st) < 0) {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"fstat(%s) failed: %m", temp_path);
ret = -1;
} else if (file_size != (uoff_t)st.st_size) {
i_assert(!file_dotlock_is_locked(uidlist->dotlock));
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"Maildir uidlist dotlock overridden: %s",
uidlist->path);
ret = -1;
static int maildir_uidlist_sync_update(struct maildir_uidlist_sync_ctx *ctx)
{
struct maildir_uidlist *uidlist = ctx->uidlist;
- struct mail_storage *storage = uidlist->box->storage;
struct stat st;
uoff_t file_size;
i_assert(ctx->first_unwritten_pos != UINT_MAX);
if (lseek(uidlist->fd, 0, SEEK_END) < 0) {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(uidlist->box,
"lseek(%s) failed: %m", uidlist->path);
return -1;
}
return -1;
if (fstat(uidlist->fd, &st) < 0) {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(uidlist->box,
"fstat(%s) failed: %m", uidlist->path);
return -1;
}
}
if (uid != 0) {
if (rec->uid != uid && rec->uid != (uint32_t)-1) {
- mail_storage_set_critical(uidlist->box->storage,
+ mailbox_set_critical(uidlist->box,
"Maildir: %s changed UID %u -> %u",
filename, rec->uid, uid);
return -1;
ret = lstat(path, &st);
if (ret == 0 && (st.st_mode & S_IFMT) == S_IFLNK) {
/* most likely a symlink pointing to a nonexistent file */
- mail_storage_set_critical(&mbox->storage->storage,
+ mailbox_set_critical(&mbox->box,
"Maildir: Symlink destination doesn't exist for UID=%u: %s", *uidp, path);
return -2;
} else if (ret < 0 && errno != ENOENT) {
- mail_storage_set_critical(&mbox->storage->storage,
- "lstat(%s) failed: %m", path);
+ mailbox_set_critical(&mbox->box, "lstat(%s) failed: %m", path);
return -1;
} else {
/* success or ENOENT, either way we're done */
- mail_storage_set_critical(&mbox->storage->storage,
+ mailbox_set_critical(&mbox->box,
"maildir_file_do(%s): Filename keeps changing for UID=%u", path, *uidp);
return -1;
}
/* should work now, try again */
return maildir_create_path(box, path, type, FALSE);
default:
- mail_storage_set_critical(box->storage,
- "mkdir(%s) failed: %m", path);
+ mailbox_set_critical(box, "mkdir(%s) failed: %m", path);
return -1;
}
}
if (stat(path, &st) == 0)
continue;
if (errno != ENOENT) {
- mail_storage_set_critical(box->storage,
- "stat(%s) failed: %m", path);
+ mailbox_set_critical(box, "stat(%s) failed: %m", path);
break;
}
if (maildir_create_path(box, path, types[i], TRUE) < 0)
if (errno == ENOENT)
mailbox_set_deleted(box);
else {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"stat(%s) failed: %m", mailbox_get_path(box));
}
return FALSE;
return -1;
if (data == NULL) {
- mail_storage_set_critical(&mbox->storage->storage,
- "Cached message offset lost for seq %u in mbox file %s",
- seq, mailbox_get_path(&mbox->box));
+ mailbox_set_critical(&mbox->box,
+ "Cached message offset lost for seq %u in mbox", seq);
mbox->mbox_hdr.dirty_flag = 1;
mbox->mbox_broken_offsets = TRUE;
return 0;
if (mbox->mbox_hdr.dirty_flag != 0)
return 0;
- mail_storage_set_critical(&mbox->storage->storage,
- "Cached message offset %s is invalid for mbox file %s",
- dec2str(offset), mailbox_get_path(&mbox->box));
+ mailbox_set_critical(&mbox->box,
+ "Cached message offset %s is invalid for mbox",
+ dec2str(offset));
mbox->mbox_hdr.dirty_flag = 1;
mbox->mbox_broken_offsets = TRUE;
return 0;
orig_dir_fd = open(".", O_RDONLY);
if (orig_dir_fd == -1) {
- mail_storage_set_critical(&mbox->storage->storage,
- "open(.) failed: %m");
+ mailbox_set_critical(&mbox->box, "open(.) failed: %m");
return -1;
}
} else {
dir = t_strdup_until(box_path, fname);
if (chdir(dir) < 0) {
- mail_storage_set_critical(&mbox->storage->storage,
+ mailbox_set_critical(&mbox->box,
"chdir(%s) failed: %m", dir);
i_close_fd(&orig_dir_fd);
return -1;
}
if (op == MBOX_DOTLOCK_OP_LOCK) {
if (access(fname, R_OK) < 0) {
- mail_storage_set_critical(&mbox->storage->storage,
+ mailbox_set_critical(&mbox->box,
"access(%s) failed: %m", box_path);
i_close_fd(&orig_dir_fd);
return -1;
const char *errmsg =
eacces_error_get_creating("file_dotlock_create",
fname);
- mail_storage_set_critical(&mbox->storage->storage,
- "%s", errmsg);
+ mailbox_set_critical(&mbox->box, "%s", errmsg);
} else {
mbox_set_syscall_error(mbox, "file_dotlock_create()");
}
restrict_access_drop_priv_gid();
if (fchdir(orig_dir_fd) < 0) {
- mail_storage_set_critical(&mbox->storage->storage,
- "fchdir() failed: %m");
+ mailbox_set_critical(&mbox->box, "fchdir() failed: %m");
}
i_close_fd(&orig_dir_fd);
errno = orig_errno;
b) another user's shared INBOX, and
c) anything called INBOX (in inbox=no namespace) */
if (!mbox->box.inbox_any && strcmp(mbox->box.name, "INBOX") != 0) {
- mail_storage_set_critical(&mbox->storage->storage,
+ mailbox_set_critical(&mbox->box,
"%s (not INBOX -> no privileged locking)", errmsg);
} else if (!mbox->mbox_privileged_locking) {
dir = mailbox_list_get_root_forced(mbox->box.list,
MAILBOX_LIST_PATH_TYPE_DIR);
- mail_storage_set_critical(&mbox->storage->storage,
+ mailbox_set_critical(&mbox->box,
"%s (under root dir %s -> no privileged locking)",
errmsg, dir);
} else if (stat(dir, &st) == 0 &&
name = dec2str(st.st_gid);
else
name = group.gr_name;
- mail_storage_set_critical(&mbox->storage->storage,
+ mailbox_set_critical(&mbox->box,
"%s (set mail_privileged_group=%s)", errmsg, name);
} else {
- mail_storage_set_critical(&mbox->storage->storage,
+ mailbox_set_critical(&mbox->box,
"%s (nonstandard permissions in %s)", errmsg, dir);
}
errno = orig_errno;
mbox_set_syscall_error(ctx->mbox, "fcntl()");
return -1;
}
- mail_storage_set_critical(&ctx->mbox->storage->storage,
+ mailbox_set_critical(&ctx->mbox->box,
"fcntl() failed with mbox file %s: "
"File is locked by another process (EACCES)",
mailbox_get_path(&ctx->mbox->box));
sync_flags |= MBOX_SYNC_UNDIRTY | MBOX_SYNC_FORCE_SYNC;
}
if (ret == 0) {
- mail_storage_set_critical(&mbox->storage->storage,
- "Losing sync for mail uid=%u in mbox file %s",
- _mail->uid, mailbox_get_path(&mbox->box));
+ mail_set_critical(_mail, "mbox: Losing sync");
}
return 0;
}
/* our header size varies, so don't do any caching */
if (istream_raw_mbox_get_body_offset(mbox->mbox_stream, &body_offset) < 0) {
- mail_storage_set_critical(_mail->box->storage,
- "mbox %s: Couldn't get body offset for uid=%u",
- mailbox_get_path(&mbox->box), mail->mail.mail.uid);
+ mail_set_critical(_mail, "mbox: Couldn't get body offset");
return -1;
}
/* verify that the calculated body size is correct */
if (istream_raw_mbox_get_body_size(mbox->mbox_stream,
body_size, &body_size) < 0) {
- mail_storage_set_critical(_mail->box->storage,
- "mbox %s: Couldn't get body size for uid=%u",
- mailbox_get_path(&mbox->box), mail->mail.mail.uid);
+ mail_set_critical(_mail, "mbox: Couldn't get body size");
return -1;
}
raw_stream = mbox->mbox_stream;
if (istream_raw_mbox_get_header_offset(raw_stream, &hdr_offset) < 0) {
- mail_storage_set_critical(mbox->box.storage,
- "mbox %s: Couldn't get header offset for uid=%u",
- mailbox_get_path(&mbox->box), mail->mail.mail.uid);
+ mail_set_critical(&mail->mail.mail,
+ "mbox: Couldn't get header offset");
return -1;
}
i_stream_seek(raw_stream, hdr_offset);
} else {
const char *toobig_error = errno != EFBIG ? "" :
" (process was started with ulimit -f limit)";
- mail_storage_set_critical(&mbox->storage->storage,
- "%s failed with mbox file %s: %m%s", function,
- mailbox_get_path(&mbox->box), toobig_error);
+ mailbox_set_critical(&mbox->box,
+ "%s failed with mbox: %m%s", function, toobig_error);
}
}
} else if (mail_storage_set_error_from_errno(box->storage)) {
return -1;
} else {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"stat(%s) failed: %m", mailbox_get_path(box));
return -1;
}
i_close_fd(&fd);
return 0;
} else if (errno == EACCES) {
- mail_storage_set_critical(box->storage, "%s",
+ mailbox_set_critical(box, "%s",
mail_error_create_eacces_msg("open", inbox_path));
return -1;
} else if (errno == EEXIST) {
"Mailbox already exists");
return -1;
} else {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"open(%s, O_CREAT) failed: %m", inbox_path);
return -1;
}
i_assert(ret > 0);
if (stat(path, &st) < 0) {
- mail_storage_set_critical(box->storage,
- "stat(%s) failed: %m", path);
+ mailbox_set_critical(box, "stat(%s) failed: %m", path);
return -1;
}
if ((time_t)rec->mtime != st.st_mtime ||
input = i_stream_create_limit(sync_ctx->file_input, size);
(void)o_stream_send_istream(output, input);
if (input->stream_errno != 0) {
- mail_storage_set_critical(&mbox->storage->storage,
- "read() failed with mbox file %s: %s",
- mailbox_get_path(&mbox->box), i_stream_get_error(input));
+ mailbox_set_critical(&mbox->box,
+ "read() failed with mbox: %s",
+ i_stream_get_error(input));
ret = -1;
} else if (output->stream_errno != 0) {
- mail_storage_set_critical(&mbox->storage->storage,
- "write() failed with mbox file %s: %s",
- mailbox_get_path(&mbox->box), o_stream_get_error(output));
+ mailbox_set_critical(&mbox->box,
+ "write() failed with mbox: %s",
+ o_stream_get_error(output));
ret = -1;
} else if (input->v_offset != size) {
mbox_sync_set_critical(sync_ctx,
sync_ctx->errors = TRUE;
if (sync_ctx->ext_modified) {
- mail_storage_set_critical(&sync_ctx->mbox->storage->storage,
- "mbox file %s was modified while we were syncing, "
- "check your locking settings",
- mailbox_get_path(&sync_ctx->mbox->box));
+ mailbox_set_critical(&sync_ctx->mbox->box,
+ "mbox was modified while we were syncing, "
+ "check your locking settings");
}
va_start(va, fmt);
- mail_storage_set_critical(&sync_ctx->mbox->storage->storage,
- "Sync failed for mbox file %s: %s",
- mailbox_get_path(&sync_ctx->mbox->box),
- t_strdup_vprintf(fmt, va));
+ mailbox_set_critical(&sync_ctx->mbox->box,
+ "Sync failed for mbox: %s",
+ t_strdup_vprintf(fmt, va));
va_end(va);
}
/* oh no, we're out of UIDs. this shouldn't
happen normally, so just try to get it fixed
without crashing. */
- mail_storage_set_critical(
- &sync_ctx->mbox->storage->storage,
- "Out of UIDs, renumbering them in mbox "
- "file %s",
- mailbox_get_path(&sync_ctx->mbox->box));
+ mailbox_set_critical(&sync_ctx->mbox->box,
+ "Out of UIDs, renumbering them in mbox");
sync_ctx->renumber_uids = TRUE;
return 0;
}
}
break;
case POP3C_COMMAND_STATE_DISCONNECTED:
- mail_storage_set_critical(mbox->box.storage,
+ mailbox_set_critical(&mbox->box,
"pop3c: Disconnected from remote server");
break;
}
if (pop3c_client_cmd_stream(mbox->client, "UIDL\r\n",
&input, &error) < 0) {
- mail_storage_set_critical(mbox->box.storage,
- "UIDL failed: %s", error);
+ mailbox_set_critical(&mbox->box, "UIDL failed: %s", error);
return -1;
}
seq++;
p = strchr(line, ' ');
if (p == NULL) {
- mail_storage_set_critical(mbox->box.storage,
+ mailbox_set_critical(&mbox->box,
"Invalid UIDL line: %s", line);
break;
}
*p++ = '\0';
if (str_to_uint(line, &line_seq) < 0 || line_seq != seq) {
- mail_storage_set_critical(mbox->box.storage,
+ mailbox_set_critical(&mbox->box,
"Unexpected UIDL seq: %s != %u", line, seq);
break;
}
if (pop3c_client_cmd_stream(mbox->client, "LIST\r\n",
&input, &error) < 0) {
- mail_storage_set_critical(mbox->box.storage,
- "LIST failed: %s", error);
+ mailbox_set_critical(&mbox->box, "LIST failed: %s", error);
return -1;
}
mbox->msg_sizes = i_new(uoff_t, mbox->msg_count); seq = 0;
while ((line = i_stream_read_next_line(input)) != NULL) {
if (++seq > mbox->msg_count) {
- mail_storage_set_critical(mbox->box.storage,
+ mailbox_set_critical(&mbox->box,
"Too much data in LIST: %s", line);
break;
}
p = strchr(line, ' ');
if (p == NULL) {
- mail_storage_set_critical(mbox->box.storage,
+ mailbox_set_critical(&mbox->box,
"Invalid LIST line: %s", line);
break;
}
*p++ = '\0';
if (str_to_uint(line, &line_seq) < 0 || line_seq != seq) {
- mail_storage_set_critical(mbox->box.storage,
+ mailbox_set_critical(&mbox->box,
"Unexpected LIST seq: %s != %u", line, seq);
break;
}
if (str_to_uoff(p, &mbox->msg_sizes[seq-1]) < 0) {
- mail_storage_set_critical(mbox->box.storage,
+ mailbox_set_critical(&mbox->box,
"Invalid LIST size: %s", p);
break;
}
mail->transaction->stats.fstat_lookup_count++;
if (i_stream_stat(mail->box->input, TRUE, &st) < 0) {
- mail_storage_set_critical(mail->box->storage,
- "stat(%s) failed: %m",
- i_stream_get_name(mail->box->input));
+ mail_set_critical(mail, "stat(%s) failed: %m",
+ i_stream_get_name(mail->box->input));
return -1;
}
MAIL_ERROR_NOTFOUND,
T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname));
} else if (!mail_storage_set_error_from_errno(box->storage)) {
- mail_storage_set_critical(box->storage,
- "open(%s) failed: %m", path);
+ mailbox_set_critical(box, "open(%s) failed: %m", path);
}
return -1;
}
T_MAIL_ERR_MAILBOX_NOT_FOUND(box->name));
return -1;
} else {
- mail_storage_set_critical(box->storage,
- "rename(%s, %s) failed: %m",
- old_path, new_path);
+ mailbox_set_critical(box, "rename(%s, %s) failed: %m",
+ old_path, new_path);
return -1;
}
}
} while (ret != -1);
if (input->stream_errno != 0) {
- mail_storage_set_critical(ctx->transaction->box->storage,
+ mailbox_set_critical(ctx->transaction->box,
"copy: i_stream_read(%s) failed: %s",
i_stream_get_name(input), i_stream_get_error(input));
return -1;
if (mailbox_create(box, NULL, FALSE) < 0) {
errstr = mailbox_get_last_internal_error(box, &error);
if (error != MAIL_ERROR_EXISTS) {
- mail_storage_set_critical(box->storage,
- "Failed to autocreate mailbox %s: %s",
- box->vname, errstr);
+ mailbox_set_critical(box,
+ "Failed to autocreate mailbox: %s",
+ errstr);
return -1;
}
} else if (mailbox_is_autosubscribed(box)) {
if (mailbox_set_subscribed(box, TRUE) < 0) {
- mail_storage_set_critical(box->storage,
- "Failed to autosubscribe to mailbox %s: %s",
- box->vname,
+ mailbox_set_critical(box,
+ "Failed to autosubscribe to mailbox: %s",
mailbox_get_last_internal_error(box, NULL));
return -1;
}
if (ret < 0 && box->inbox_user &&
!box->storage->user->inbox_open_error_logged) {
box->storage->user->inbox_open_error_logged = TRUE;
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"Opening INBOX failed: %s",
mailbox_get_last_internal_error(box, NULL));
}
if (input != NULL) {
if ((box->storage->class_flags &
MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS) == 0) {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"Storage doesn't support streamed mailboxes");
return -1;
}
} else if (mail_storage_set_error_from_errno(box->storage)) {
return -1;
} else {
- mail_storage_set_critical(box->storage,
- "open(%s, O_CREAT) failed: %m", path);
+ mailbox_set_critical(box, "open(%s, O_CREAT) failed: %m", path);
return -1;
}
if (fchown(fd, (uid_t)-1, perm->file_create_gid) == 0) {
/* ok */
} else if (errno == EPERM) {
- mail_storage_set_critical(box->storage, "%s",
+ mailbox_set_critical(box, "%s",
eperm_error_get_chgrp("fchown", path,
perm->file_create_gid,
perm->file_create_gid_origin));
} else {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"fchown(%s) failed: %m", path);
}
}
} else if (mail_storage_set_error_from_errno(box->storage)) {
return -1;
} else {
- mail_storage_set_critical(box->storage,
- "mkdir_parents(%s) failed: %m", path);
+ mailbox_set_critical(box, "mkdir_parents(%s) failed: %m", path);
return -1;
}
}
if (seq_range_exists(&box->recent_flags, uid))
return;
- mail_storage_set_critical(box->storage,
- "Recent flags state corrupted for mailbox %s",
- box->vname);
+ mailbox_set_critical(box, "Recent flags state corrupted");
array_clear(&box->recent_flags);
box->recent_flags_count = 0;
}
acl_rights_get_id(&update->rights));
aclobj = acl_mailbox_get_aclobj(t->box);
if (acl_object_update(aclobj, update) < 0) {
- mail_storage_set_critical(t->box->storage, "Failed to set ACL");
+ mailbox_set_critical(t->box, "Failed to set ACL");
return -1;
}
if (optimize) {
if (fts_backend_optimize(flist->backend) < 0) {
- mail_storage_set_critical(box->storage,
- "FTS optimize for mailbox %s failed",
- box->vname);
+ mailbox_set_critical(box, "FTS optimize failed");
ret = -1;
}
}
/* already expunged - just ignore it */
return 0;
}
- mail_storage_set_critical(_mail->box->storage,
+ mail_set_critical(_mail,
"lazy_expunge: Couldn't lookup message's refcount: %s",
errstr);
return -1;
/* already expunged - just ignore it */
return 0;
}
- mail_storage_set_critical(_mail->box->storage,
+ mail_set_critical(_mail,
"lazy_expunge: Couldn't lookup message's GUID: %s", errstr);
return -1;
}
if (*value == '\0') {
/* GUIDs not supported by backend, but refcounts are?
not with our current backends. */
- mail_storage_set_critical(_mail->box->storage,
+ mail_set_critical(_mail,
"lazy_expunge: Message unexpectedly has no GUID");
return -1;
}
lt->dest_box = mailbox_open_or_create(luser->lazy_ns->list,
_mail->box, &error);
if (lt->dest_box == NULL) {
- mail_storage_set_critical(_mail->box->storage,
+ mail_set_critical(_mail,
"lazy_expunge: Couldn't open expunge mailbox: "
"%s", error);
lazy_expunge_set_error(lt, _mail->box->storage);
return;
}
if (mailbox_sync(lt->dest_box, 0) < 0) {
- mail_storage_set_critical(_mail->box->storage,
+ mail_set_critical(_mail,
"lazy_expunge: Couldn't sync expunge mailbox");
lazy_expunge_set_error(lt, lt->dest_box->storage);
mailbox_free(<->dest_box);
mbox->super.transaction_rollback(ctx);
ret = -1;
} else {
- mail_storage_set_critical(ctx->box->storage,
+ mailbox_set_critical(ctx->box,
"Lazy-expunge transaction failed: %s",
lt->delayed_internal_errstr);
mbox->super.transaction_rollback(ctx);
"Mailbox already exists");
return -1;
}
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"symlink(%s, %s) failed: %m", fname, new_path);
return -1;
}
break;
case QUOTA_ALLOC_RESULT_TEMPFAIL:
case QUOTA_ALLOC_RESULT_BACKGROUND_CALC:
- mail_storage_set_critical(storage, "quota: %s", internal_err);
+ mailbox_set_critical(box, "quota: %s", internal_err);
break;
case QUOTA_ALLOC_RESULT_OK:
i_unreached();
fd = open(path, O_RDONLY);
if (fd == -1) {
if (errno == EACCES) {
- mail_storage_set_critical(storage, "%s",
+ mailbox_set_critical(&mbox->box, "%s",
mail_error_eacces_msg("open", path));
} else if (errno != ENOENT) {
- mail_storage_set_critical(storage,
- "open(%s) failed: %m", path);
+ mailbox_set_critical(&mbox->box,
+ "open(%s) failed: %m", path);
} else if (errno == ENOENT) {
mail_storage_set_error(storage, MAIL_ERROR_NOTFOUND,
T_MAIL_ERR_MAILBOX_NOT_FOUND(mbox->box.vname));
} else {
- mail_storage_set_critical(storage,
+ mailbox_set_critical(&mbox->box,
"stat(%s) failed: %m", box_path);
}
return -1;
else
ret = virtual_config_parse_line(&ctx, line, &error);
if (ret < 0) {
- mail_storage_set_critical(storage,
- "%s: Error at line %u: %s",
- path, linenum, error);
+ mailbox_set_critical(&mbox->box,
+ "%s: Error at line %u: %s",
+ path, linenum, error);
break;
}
}
if (ret == 0) {
ret = virtual_config_add_rule(&ctx, &error);
if (ret < 0) {
- mail_storage_set_critical(storage,
- "%s: Error at line %u: %s",
- path, linenum, error);
+ mailbox_set_critical(&mbox->box,
+ "%s: Error at line %u: %s",
+ path, linenum, error);
}
}
if (ret == 0 && ctx.have_wildcards) {
ret = virtual_config_expand_wildcards(&ctx, &error);
if (ret < 0)
- mail_storage_set_critical(storage, "%s: %s", path, error);
+ mailbox_set_critical(&mbox->box, "%s: %s", path, error);
}
if (ret == 0 && !ctx.have_mailbox_defines) {
- mail_storage_set_critical(storage,
- "%s: No mailboxes defined", path);
+ mailbox_set_critical(&mbox->box,
+ "%s: No mailboxes defined", path);
ret = -1;
}
if (ret == 0)
int ret = 0;
if (virtual_mailbox_is_in_open_stack(mbox->storage, box->name)) {
- mail_storage_set_critical(box->storage,
+ mailbox_set_critical(box,
"Virtual mailbox loops: %s", box->name);
return -1;
}
mail_index_update_header_ext(t, mbox->virtual_guid_ext_id,
0, mbox->guid, GUID_128_SIZE);
if (mail_index_transaction_commit(&t) < 0) {
- mail_storage_set_critical(box->storage,
- "Cannot write GUID for virtual mailbox %s to index",
- mailbox_get_vname(box));
+ mailbox_set_critical(box,
+ "Cannot write GUID for virtual mailbox to index");
virtual_mailbox_close_internal(mbox);
index_storage_mailbox_close(box);
return -1;
since this could be called from
mailbox_get_open_status() and it would panic.
So just log the error and skip the mailbox. */
- mail_storage_set_critical(mbox->box.storage,
- "Virtual mailbox %s: Failed to get have_guid existence for backend mailbox %s: %s",
- mailbox_get_vname(&mbox->box),
+ mailbox_set_critical(&mbox->box,
+ "Virtual mailbox: Failed to get have_guid existence for backend mailbox %s: %s",
mailbox_get_vname(bboxes[i]->box), errstr);
continue;
}
i_assert(box->opened);
if ((items & MAILBOX_METADATA_GUID) != 0) {
if (guid_128_is_empty(mbox->guid)) {
- mail_storage_set_critical(box->storage, "GUID missing for virtual folder %s",
- mailbox_get_vname(box));
+ mailbox_set_critical(box, "GUID missing for virtual folder");
return -1;
}
guid_128_copy(metadata_r->guid, mbox->guid);
handler = compression_detect_handler(*stream);
if (handler != NULL) {
if (handler->create_istream == NULL) {
- mail_storage_set_critical(_mail->box->storage,
+ mail_set_critical(_mail,
"zlib plugin: Detected %s compression "
"but support not compiled in", handler->ext);
return -1;