(void)imap_utf8_to_utf7(str_c(destname), dest);
if (rename(src, str_c(dest)) < 0 && errno != ENOENT)
- i_error("rename(%s, %s) failed: %m", src, str_c(dest));
+ e_error(ctx->ctx.list->ns->user->event,
+ "rename(%s, %s) failed: %m", src, str_c(dest));
}
static const char *
if (stat_list &&
stat(inotify->list_log_path, &inotify->list_last_st) < 0 &&
errno != ENOENT) {
- i_error("stat(%s) failed: %m", inotify->list_log_path);
+ e_error(inotify->notify.list->ns->user->event,
+ "stat(%s) failed: %m", inotify->list_log_path);
call = TRUE;
}
if (inotify->inbox_log_path != NULL && stat_inbox) {
if (stat(inotify->inbox_log_path, &inotify->inbox_last_st) < 0 &&
errno != ENOENT) {
- i_error("stat(%s) failed: %m", inotify->inbox_log_path);
+ e_error(inotify->notify.list->ns->user->event,
+ "stat(%s) failed: %m", inotify->inbox_log_path);
call = TRUE;
}
}
unsigned int i, record_size;
if (inotify->cur_ext == ILIST_EXT_NONE) {
- i_error("%s: Missing ext-intro for ext-rec-update",
+ e_error(ilist->index->event,
+ "%s: Missing ext-intro for ext-rec-update",
ilist->index->filepath);
break;
}
mailbox_get_open_status(inotify->inbox, notify_status_items, &old_status);
if (mailbox_sync(inotify->inbox, MAILBOX_SYNC_FLAG_FAST) < 0) {
- i_error("Mailbox list index notify: Failed to sync INBOX: %s",
+ e_error(inotify->notify.list->ns->user->event,
+ "Mailbox list index notify: Failed to sync INBOX: %s",
mailbox_get_last_internal_error(inotify->inbox, NULL));
return 0;
}
(void)imap_utf8_to_utf7(str_c(destvname), dest);
if (rename(src, str_c(dest)) < 0 && errno != ENOENT)
- i_error("rename(%s, %s) failed: %m", src, str_c(dest));
+ e_error(ctx->ctx.list->ns->user->event,
+ "rename(%s, %s) failed: %m", src, str_c(dest));
/* just skip this in this iteration, we'll see it on the
next list */
return 0;
src_list, name);
} T_END;
if (ret < 0) {
- i_warning("Subscriptions file %s: "
+ e_warning(dest_list->ns->user->event,
+ "Subscriptions file %s: "
"Removing invalid entry: %s",
path, name);
(void)subsfile_set_subscribed(src_list, path,
ret = mail_user_lock_file_create(user, AUTOEXPUNGE_LOCK_FNAME,
0, lock, &error);
if (ret < 0) {
- i_error("autoexpunge: Couldn't create %s lock: %s",
+ e_error(user->event, "autoexpunge: Couldn't create %s lock: %s",
AUTOEXPUNGE_LOCK_FNAME, error);
/* do autoexpunging anyway */
return TRUE;
mailbox_set_reason(box, "autoexpunge");
if (mailbox_autoexpunge(box, autoexpunge, autoexpunge_max_mails,
expunged_count) < 0) {
- i_error("Failed to autoexpunge mailbox '%s': %s",
- mailbox_get_vname(box),
+ e_error(box->event, "Failed to autoexpunge: %s",
mailbox_get_last_internal_error(box, NULL));
}
mailbox_free(&box);
expunged_count);
} T_END;
if (mailbox_list_iter_deinit(&iter) < 0) {
- i_error("Failed to iterate autoexpunge mailboxes '%s': %s",
+ e_error(ns->user->event,
+ "Failed to iterate autoexpunge mailboxes '%s': %s",
iter_name, mailbox_list_get_last_internal_error(ns->list, NULL));
}
}
line = t_strdup_printf("%s=%s%s",
key, *strp, append_value);
} else {
- i_error("Ignoring %s userdb setting. "
+ e_error(user->event, "Ignoring %s userdb setting. "
"'+' can only be used for strings.", orig_key);
}
}
#ifdef HAVE_SETPRIORITY
int n;
if (str_to_int(line + 5, &n) < 0) {
- i_error("userdb returned invalid nice value %s",
+ e_error(user->event,
+ "userdb returned invalid nice value %s",
line + 5);
} else if (n != 0) {
if (setpriority(PRIO_PROCESS, 0, n) < 0)
- i_error("setpriority(%d) failed: %m", n);
+ e_error(user->event,
+ "setpriority(%d) failed: %m", n);
}
#endif
} else if (str_begins(line, "auth_mech=")) {
if (chdir_path[0] == '\0') {
if (chdir("/") < 0)
- i_error("chdir(/) failed: %m");
+ e_error(user->event, "chdir(/) failed: %m");
} else if (chdir(chdir_path) < 0) {
if (errno == EACCES) {
- i_error("%s", eacces_error_get("chdir",
+ e_error(user->event, "%s",
+ eacces_error_get("chdir",
t_strconcat(chdir_path, "/", NULL)));
} else if (errno != ENOENT)
- i_error("chdir(%s) failed: %m", chdir_path);
+ e_error(user->event, "chdir(%s) failed: %m",
+ chdir_path);
else
e_debug(mail_user->event, "Home dir not found: %s", chdir_path);
if (chdir("/") < 0)
- i_error("chdir(/) failed: %m");
+ e_error(user->event, "chdir(/) failed: %m");
}
}
/* successfully opened the correct mailbox */
return box;
}
- i_error("mailbox_alloc_guid(%s): "
+ e_error(list->ns->user->event, "mailbox_alloc_guid(%s): "
"Couldn't verify mailbox GUID: %s",
guid_128_to_string(guid),
mailbox_get_last_internal_error(box, NULL));
errormsg = mailbox_get_last_internal_error(box, &error);
if (error == MAIL_ERROR_NOTPOSSIBLE) {
box->storage->user->inbox_open_error_logged = TRUE;
- i_error("Syncing INBOX failed: %s", errormsg);
+ e_error(box->event, "Syncing INBOX failed: %s", errormsg);
}
}
if (ret == 0)
mail_user_var_expand_table(user),
mail_user_var_expand_func_table, user,
&error) <= 0) {
- i_error("Failed to expand mail_home=%s: %s", home, error);
+ e_error(user->event, "Failed to expand mail_home=%s: %s",
+ home, error);
return FALSE;
}
user->_home = p_strdup(user->pool, str_c(str));
storage = mail_storage_find_class(name);
if (storage != NULL && storage->v.alloc == NULL) {
- i_error("Storage driver '%s' exists as a stub, "
+ e_error(user->event, "Storage driver '%s' exists as a stub, "
"but its plugin couldn't be loaded", name);
return NULL;
}
}
/* fallback to a safe mkdir() with 0700 mode */
if (mkdir_parents(home, 0700) < 0 && errno != EEXIST) {
- i_error("mkdir_parents(%s) failed: %m", home);
+ e_error(user->event, "mkdir_parents(%s) failed: %m", home);
return -1;
}
return 0;
#include "lib.h"
#include "ioloop.h"
#include "hash.h"
-#include "mail-storage.h"
+#include "mail-storage-private.h"
#include "mailbox-list-private.h"
#include "mailbox-guid-cache.h"
box = mailbox_alloc(list, info->vname, 0);
if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID,
&metadata) < 0) {
- i_error("Couldn't get mailbox %s GUID: %s",
- info->vname, mailbox_get_last_internal_error(box, NULL));
+ e_error(box->event, "Couldn't get mailbox GUID: %s",
+ mailbox_get_last_internal_error(box, NULL));
list->guid_cache_errors = TRUE;
} else if ((rec = hash_table_lookup(list->guid_cache,
(const uint8_t *)metadata.guid)) != NULL) {
- i_warning("Mailbox %s has duplicate GUID with %s: %s",
+ e_warning(list->ns->user->event,
+ "Mailbox %s has duplicate GUID with %s: %s",
info->vname, rec->vname,
guid_128_to_string(metadata.guid));
} else {
} else if (!S_ISLNK(st.st_mode)) {
ret = 0;
} else if (t_readlink(path, &linkpath, &error) < 0) {
- i_error("t_readlink(%s) failed: %s", path, error);
+ e_error(list->ns->user->event,
+ "t_readlink(%s) failed: %s", path, error);
ret = -1;
} else {
/* it's an alias only if it points to the same
list->last_internal_error = i_strdup_vprintf(fmt, va);
va_end(va);
list->last_error_is_internal = TRUE;
- i_error("%s", list->last_internal_error);
+ e_error(list->ns->user->event, "%s", list->last_internal_error);
/* free the old_error and old_internal_error only after the new error
is generated, because they may be one of the parameters. */
#include "read-full.h"
#include "write-full.h"
#include "eacces-error.h"
+#include "mail-user.h"
#include "mailbox-list.h"
#include "mailbox-uidvalidity.h"
static void mailbox_uidvalidity_write(struct mailbox_list *list,
const char *path, uint32_t uid_validity)
{
+ struct mail_user *user = mailbox_list_get_user(list);
char buf[8+1];
int fd;
struct mailbox_permissions perm;
fd = open(path, O_RDWR | O_CREAT, 0666);
umask(old_mask);
if (fd == -1) {
- i_error("open(%s) failed: %m", path);
+ e_error(user->event, "open(%s) failed: %m", path);
return;
}
if (perm.file_create_gid != (gid_t)-1 &&
fchown(fd, (uid_t)-1, perm.file_create_gid) < 0) {
if (errno == EPERM) {
- i_error("%s", eperm_error_get_chgrp("fchown", path,
+ e_error(user->event, "%s",
+ eperm_error_get_chgrp("fchown", path,
perm.file_create_gid,
perm.file_create_gid_origin));
} else {
- i_error("fchown(%s, -1, %ld) failed: %m",
+ e_error(mailbox_list_get_user(list)->event,
+ "fchown(%s, -1, %ld) failed: %m",
path, (long)perm.file_create_gid);
}
}
if (i_snprintf(buf, sizeof(buf), "%08x", uid_validity) < 0)
i_unreached();
if (pwrite_full(fd, buf, strlen(buf), 0) < 0)
- i_error("write(%s) failed: %m", path);
+ e_error(user->event, "write(%s) failed: %m", path);
if (close(fd) < 0)
- i_error("close(%s) failed: %m", path);
+ e_error(user->event, "close(%s) failed: %m", path);
}
static int
-mailbox_uidvalidity_rename(const char *path, uint32_t *uid_validity,
- bool log_enoent)
+mailbox_uidvalidity_rename(struct mailbox_list *list, const char *path,
+ uint32_t *uid_validity, bool log_enoent)
{
string_t *src, *dest;
unsigned int i;
/* possibly a race condition. try the next value. */
}
if (ret < 0 && (errno != ENOENT || log_enoent))
- i_error("rename(%s, %s) failed: %m", str_c(src), str_c(dest));
+ e_error(mailbox_list_get_user(list)->event,
+ "rename(%s, %s) failed: %m", str_c(src), str_c(dest));
return ret;
}
d = opendir(dir);
}
if (d == NULL) {
- i_error("opendir(%s) failed: %m", dir);
+ e_error(mailbox_list_get_user(list)->event,
+ "opendir(%s) failed: %m", dir);
return mailbox_uidvalidity_next_fallback();
}
prefix = t_strconcat(fname, ".", NULL);
}
}
if (closedir(d) < 0)
- i_error("closedir(%s) failed: %m", dir);
+ e_error(mailbox_list_get_user(list)->event,
+ "closedir(%s) failed: %m", dir);
if (max_value == 0) {
/* no uidvalidity files. create one. */
a duplicate file.. */
}
if (fd == -1) {
- i_error("creat(%s) failed: %m", tmp);
+ e_error(mailbox_list_get_user(list)->event,
+ "creat(%s) failed: %m", tmp);
return cur_value;
}
i_close_fd(&fd);
}
cur_value = max_value;
- if (mailbox_uidvalidity_rename(path, &cur_value, TRUE) < 0)
+ if (mailbox_uidvalidity_rename(list, path, &cur_value, TRUE) < 0)
return mailbox_uidvalidity_next_fallback();
mailbox_uidvalidity_write(list, path, cur_value);
return cur_value;
uint32_t mailbox_uidvalidity_next(struct mailbox_list *list, const char *path)
{
+ struct mail_user *user = mailbox_list_get_user(list);
char buf[8+1];
uint32_t cur_value;
int fd, ret;
fd = open(path, O_RDWR);
if (fd == -1) {
if (errno != ENOENT)
- i_error("open(%s) failed: %m", path);
+ e_error(user->event, "open(%s) failed: %m", path);
return mailbox_uidvalidity_next_rescan(list, path);
}
ret = read_full(fd, buf, sizeof(buf)-1);
if (ret < 0) {
- i_error("read(%s) failed: %m", path);
+ e_error(user->event, "read(%s) failed: %m", path);
i_close_fd(&fd);
return mailbox_uidvalidity_next_rescan(list, path);
}
}
/* we now have the current uidvalidity value that's hopefully correct */
- if (mailbox_uidvalidity_rename(path, &cur_value, FALSE) < 0) {
+ if (mailbox_uidvalidity_rename(list, path, &cur_value, FALSE) < 0) {
i_close_fd(&fd);
return mailbox_uidvalidity_next_rescan(list, path);
}
if (i_snprintf(buf, sizeof(buf), "%08x", cur_value) < 0)
i_unreached();
if (pwrite_full(fd, buf, strlen(buf), 0) < 0)
- i_error("write(%s) failed: %m", path);
+ e_error(user->event, "write(%s) failed: %m", path);
if (close(fd) < 0)
- i_error("close(%s) failed: %m", path);
+ e_error(user->event, "close(%s) failed: %m", path);
return cur_value;
}