From: Timo Sirainen Date: Wed, 17 Feb 2021 17:33:03 +0000 (+0200) Subject: lib-storage: Replace i_error() and i_warning() with e_error() and e_warning() X-Git-Tag: 2.3.15~352 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b32b3f989db94a09a7c6e9b3758f8a2170f0d795;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Replace i_error() and i_warning() with e_error() and e_warning() This changes only the generic code. The driver-specific code still needs changing. --- diff --git a/src/lib-storage/list/mailbox-list-fs-iter.c b/src/lib-storage/list/mailbox-list-fs-iter.c index 585bf10659..45ce493b50 100644 --- a/src/lib-storage/list/mailbox-list-fs-iter.c +++ b/src/lib-storage/list/mailbox-list-fs-iter.c @@ -120,7 +120,8 @@ fs_list_rename_invalid(struct fs_list_iterate_context *ctx, (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 * diff --git a/src/lib-storage/list/mailbox-list-index-notify.c b/src/lib-storage/list/mailbox-list-index-notify.c index 35ee04e04f..dfbd1ef4ac 100644 --- a/src/lib-storage/list/mailbox-list-index-notify.c +++ b/src/lib-storage/list/mailbox-list-index-notify.c @@ -243,13 +243,15 @@ static void notify_update_stat(struct mailbox_list_notify_index *inotify, 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; } } @@ -394,7 +396,8 @@ mailbox_list_index_notify_read_next(struct mailbox_list_notify_index *inotify) 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; } @@ -817,7 +820,8 @@ mailbox_list_notify_inbox_get_events(struct mailbox_list_notify_index *inotify) 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; } diff --git a/src/lib-storage/list/mailbox-list-maildir-iter.c b/src/lib-storage/list/mailbox-list-maildir-iter.c index 6d799aff7e..df5fdd76d7 100644 --- a/src/lib-storage/list/mailbox-list-maildir-iter.c +++ b/src/lib-storage/list/mailbox-list-maildir-iter.c @@ -309,7 +309,8 @@ maildir_fill_readdir_entry(struct maildir_list_iterate_context *ctx, (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; diff --git a/src/lib-storage/list/mailbox-list-subscriptions.c b/src/lib-storage/list/mailbox-list-subscriptions.c index 9f46ac9fc0..2e27c961c1 100644 --- a/src/lib-storage/list/mailbox-list-subscriptions.c +++ b/src/lib-storage/list/mailbox-list-subscriptions.c @@ -161,7 +161,8 @@ int mailbox_list_subscriptions_refresh(struct mailbox_list *src_list, 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, diff --git a/src/lib-storage/mail-autoexpunge.c b/src/lib-storage/mail-autoexpunge.c index a38af80f9d..fe5fecf388 100644 --- a/src/lib-storage/mail-autoexpunge.c +++ b/src/lib-storage/mail-autoexpunge.c @@ -31,7 +31,7 @@ mailbox_autoexpunge_lock(struct mail_user *user, struct file_lock **lock) 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; @@ -176,8 +176,7 @@ mailbox_autoexpunge_set(struct mail_namespace *ns, const char *vname, 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); @@ -203,7 +202,8 @@ mailbox_autoexpunge_wildcards(struct mail_namespace *ns, 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)); } } diff --git a/src/lib-storage/mail-storage-service.c b/src/lib-storage/mail-storage-service.c index a19ac845c8..8f96fb1ae7 100644 --- a/src/lib-storage/mail-storage-service.c +++ b/src/lib-storage/mail-storage-service.c @@ -182,7 +182,7 @@ static int set_line(struct mail_storage_service_ctx *ctx, 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); } } @@ -283,11 +283,13 @@ user_reply_handle(struct mail_storage_service_ctx *ctx, #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=")) { @@ -743,18 +745,20 @@ mail_storage_service_init_post(struct mail_storage_service_ctx *ctx, 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"); } } diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index ce42ee038f..2bfe183537 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -890,7 +890,7 @@ struct mailbox *mailbox_alloc_guid(struct mailbox_list *list, /* 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)); @@ -2194,7 +2194,7 @@ int mailbox_sync_deinit(struct mailbox_sync_context **_ctx, 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) diff --git a/src/lib-storage/mail-user.c b/src/lib-storage/mail-user.c index 1e2546b208..df09edfefa 100644 --- a/src/lib-storage/mail-user.c +++ b/src/lib-storage/mail-user.c @@ -437,7 +437,8 @@ static bool mail_user_get_mail_home(struct mail_user *user) 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)); @@ -654,7 +655,7 @@ mail_user_get_storage_class(struct mail_user *user, const char *name) 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; } @@ -774,7 +775,7 @@ int mail_user_home_mkdir(struct mail_user *user) } /* 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; diff --git a/src/lib-storage/mailbox-guid-cache.c b/src/lib-storage/mailbox-guid-cache.c index d80aa2637a..8c15ac576d 100644 --- a/src/lib-storage/mailbox-guid-cache.c +++ b/src/lib-storage/mailbox-guid-cache.c @@ -3,7 +3,7 @@ #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" @@ -48,12 +48,13 @@ static void mailbox_guid_cache_add_mailbox(struct mailbox_list *list, 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 { diff --git a/src/lib-storage/mailbox-list.c b/src/lib-storage/mailbox-list.c index 173c0a7502..38290d96b3 100644 --- a/src/lib-storage/mailbox-list.c +++ b/src/lib-storage/mailbox-list.c @@ -1833,7 +1833,8 @@ int mailbox_list_dirent_is_alias_symlink(struct mailbox_list *list, } 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 @@ -1992,7 +1993,7 @@ void mailbox_list_set_critical(struct mailbox_list *list, const char *fmt, ...) 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. */ diff --git a/src/lib-storage/mailbox-uidvalidity.c b/src/lib-storage/mailbox-uidvalidity.c index 2dcb322abe..74a9dd22ba 100644 --- a/src/lib-storage/mailbox-uidvalidity.c +++ b/src/lib-storage/mailbox-uidvalidity.c @@ -6,6 +6,7 @@ #include "read-full.h" #include "write-full.h" #include "eacces-error.h" +#include "mail-user.h" #include "mailbox-list.h" #include "mailbox-uidvalidity.h" @@ -36,6 +37,7 @@ static uint32_t mailbox_uidvalidity_next_fallback(void) 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; @@ -47,17 +49,19 @@ static void mailbox_uidvalidity_write(struct mailbox_list *list, 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); } } @@ -65,14 +69,14 @@ static void mailbox_uidvalidity_write(struct mailbox_list *list, 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; @@ -102,7 +106,8 @@ mailbox_uidvalidity_rename(const char *path, uint32_t *uid_validity, /* 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; } @@ -137,7 +142,8 @@ mailbox_uidvalidity_next_rescan(struct mailbox_list *list, const char *path) 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); @@ -158,7 +164,8 @@ mailbox_uidvalidity_next_rescan(struct mailbox_list *list, const char *path) } } 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. */ @@ -176,7 +183,8 @@ mailbox_uidvalidity_next_rescan(struct mailbox_list *list, const char *path) 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); @@ -190,7 +198,7 @@ mailbox_uidvalidity_next_rescan(struct mailbox_list *list, const char *path) } 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; @@ -198,6 +206,7 @@ mailbox_uidvalidity_next_rescan(struct mailbox_list *list, const char *path) 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; @@ -205,12 +214,12 @@ uint32_t mailbox_uidvalidity_next(struct mailbox_list *list, const char *path) 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); } @@ -223,7 +232,7 @@ uint32_t mailbox_uidvalidity_next(struct mailbox_list *list, const char *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); } @@ -233,8 +242,8 @@ uint32_t mailbox_uidvalidity_next(struct mailbox_list *list, const char *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; }