From: Sergey Kitov Date: Tue, 20 Mar 2018 09:05:13 +0000 (+0200) Subject: lib-storage: Replace "if(mail_debug){i_debug}" "e_debug" X-Git-Tag: 2.3.3.rc1~172 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1fa6289e1838e5c3007ededfc6583234704ba310;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Replace "if(mail_debug){i_debug}" "e_debug" --- diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index 3b223d5cf7..f349377b05 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -1238,11 +1238,10 @@ int index_mail_init_stream(struct index_mail *mail, bool has_nuls, body_size_from_stream = FALSE; int ret; - if (_mail->box->storage->user->mail_debug && - mail->mail.get_stream_reason != NULL && + if (mail->mail.get_stream_reason != NULL && mail->mail.get_stream_reason[0] != '\0') { - i_debug("Mailbox %s: Opened mail UID=%u because: %s", - _mail->box->vname, _mail->uid, + e_debug(_mail->event, + "Opened mail because: %s", mail->mail.get_stream_reason); } _mail->mail_stream_opened = TRUE; diff --git a/src/lib-storage/index/index-status.c b/src/lib-storage/index/index-status.c index 89edf5cb4d..c7559e7042 100644 --- a/src/lib-storage/index/index-status.c +++ b/src/lib-storage/index/index-status.c @@ -260,8 +260,9 @@ static void get_metadata_precache_fields(struct mailbox *box, cache |= MAIL_FETCH_GUID; else if (strcmp(name, "flags") == 0) { /* just ignore for now at least.. */ - } else if (box->storage->set->mail_debug) - i_debug("Ignoring unknown cache field: %s", name); + } else + e_debug(box->event, + "Ignoring unknown cache field: %s", name); } metadata_r->precache_fields = cache; } diff --git a/src/lib-storage/index/index-storage.c b/src/lib-storage/index/index-storage.c index 6c92832223..218b624141 100644 --- a/src/lib-storage/index/index-storage.c +++ b/src/lib-storage/index/index-storage.c @@ -395,7 +395,7 @@ void index_storage_mailbox_alloc(struct mailbox *box, const char *vname, mail_storage_settings_to_index_flags(box->storage->set); if ((box->flags & MAILBOX_FLAG_SAVEONLY) != 0) ibox->index_flags |= MAIL_INDEX_OPEN_FLAG_SAVEONLY; - if (box->storage->user->mail_debug) + if (event_want_debug(box->event)) ibox->index_flags |= MAIL_INDEX_OPEN_FLAG_DEBUG; ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL; MODULE_CONTEXT_SET(box, index_storage_module, ibox); diff --git a/src/lib-storage/index/mbox/mbox-storage.c b/src/lib-storage/index/mbox/mbox-storage.c index 8cd8058416..71e7f2c6ff 100644 --- a/src/lib-storage/index/mbox/mbox-storage.c +++ b/src/lib-storage/index/mbox/mbox-storage.c @@ -185,8 +185,7 @@ static void mbox_storage_get_list_settings(const struct mail_namespace *ns, if (set->inbox_path == NULL) { set->inbox_path = t_strconcat(set->root_dir, "/inbox", NULL); - if (ns->mail_set->mail_debug) - i_debug("mbox: INBOX defaulted to %s", set->inbox_path); + e_debug(ns->user->event, "mbox: INBOX defaulted to %s", set->inbox_path); } } diff --git a/src/lib-storage/index/shared/shared-storage.c b/src/lib-storage/index/shared/shared-storage.c index b5092528aa..a7168f5b4c 100644 --- a/src/lib-storage/index/shared/shared-storage.c +++ b/src/lib-storage/index/shared/shared-storage.c @@ -303,10 +303,9 @@ int shared_storage_get_namespace(struct mail_namespace **_ns, if (ret <= 0) { get_nonexistent_user_location(storage, userdomain, location); new_ns->flags |= NAMESPACE_FLAG_UNUSABLE; - if (ns->user->mail_debug) { - i_debug("shared: Tried to access mails of " - "nonexistent user %s", userdomain); - } + e_debug(ns->user->event, + "shared: Tried to access mails of " + "nonexistent user %s", userdomain); } ns_set = p_new(user->pool, struct mail_namespace_settings, 1); diff --git a/src/lib-storage/mail-namespace.c b/src/lib-storage/mail-namespace.c index 1ea4ec78f1..2c0340e45c 100644 --- a/src/lib-storage/mail-namespace.c +++ b/src/lib-storage/mail-namespace.c @@ -155,17 +155,15 @@ int mail_namespaces_init_add(struct mail_user *user, if (*ns_set->location == '\0') ns_set->location = mail_set->mail_location; - if (mail_set->mail_debug) { - i_debug("Namespace %s: type=%s, prefix=%s, sep=%s, " - "inbox=%s, hidden=%s, list=%s, subscriptions=%s " - "location=%s", - ns_set->name, ns_set->type, ns_set->prefix, - ns_set->separator == NULL ? "" : ns_set->separator, - ns_set->inbox ? "yes" : "no", - ns_set->hidden ? "yes" : "no", - ns_set->list, - ns_set->subscriptions ? "yes" : "no", ns_set->location); - } + e_debug(user->event, "Namespace %s: type=%s, prefix=%s, sep=%s, " + "inbox=%s, hidden=%s, list=%s, subscriptions=%s " + "location=%s", + ns_set->name, ns_set->type, ns_set->prefix, + ns_set->separator == NULL ? "" : ns_set->separator, + ns_set->inbox ? "yes" : "no", + ns_set->hidden ? "yes" : "no", + ns_set->list, + ns_set->subscriptions ? "yes" : "no", ns_set->location); if ((ret = mail_namespace_alloc(user, user->set, ns_set, unexpanded_ns_set, @@ -452,7 +450,6 @@ int mail_namespaces_init_finish(struct mail_namespace *namespaces, int mail_namespaces_init(struct mail_user *user, const char **error_r) { - const struct mail_storage_settings *mail_set; struct mail_namespace_settings *const *ns_set; struct mail_namespace_settings *const *unexpanded_ns_set; struct mail_namespace *namespaces, **ns_p; @@ -462,7 +459,6 @@ int mail_namespaces_init(struct mail_user *user, const char **error_r) namespaces = NULL; ns_p = &namespaces; - mail_set = mail_user_set_get_storage_set(user); if (array_is_created(&user->set->namespaces)) { ns_set = array_get(&user->set->namespaces, &count); unexpanded_ns_set = @@ -483,10 +479,8 @@ int mail_namespaces_init(struct mail_user *user, const char **error_r) mail_namespaces_deinit(&namespaces); return -1; } - if (mail_set->mail_debug) { - i_debug("Skipping namespace %s: %s", - ns_set[i]->prefix, *error_r); - } + e_debug(user->event, "Skipping namespace %s: %s", + ns_set[i]->prefix, *error_r); } else { ns_p = &(*ns_p)->next; } diff --git a/src/lib-storage/mail-storage-service.c b/src/lib-storage/mail-storage-service.c index afba1a91fc..d05351b8ef 100644 --- a/src/lib-storage/mail-storage-service.c +++ b/src/lib-storage/mail-storage-service.c @@ -122,11 +122,9 @@ static void set_keyval(struct mail_storage_service_ctx *ctx, if (master_service_set_has_config_override(ctx->service, key)) { /* this setting was already overridden with -o parameter */ - if (mail_user_set_get_mail_debug(user->user_info, - user->user_set)) { - i_debug("Ignoring overridden (-o) userdb setting: %s", - key); - } + e_debug(user->event, + "Ignoring overridden (-o) userdb setting: %s", + key); return; } @@ -141,13 +139,10 @@ static int set_line(struct mail_storage_service_ctx *ctx, const char *line) { struct setting_parser_context *set_parser = user->set_parser; - bool mail_debug; const char *key, *orig_key, *append_value = NULL; size_t len; int ret; - mail_debug = mail_user_set_get_mail_debug(user->user_info, - user->user_set); if (strchr(line, '=') == NULL) line = t_strconcat(line, "=yes", NULL); orig_key = key = t_strcut(line, '='); @@ -167,10 +162,8 @@ static int set_line(struct mail_storage_service_ctx *ctx, if (master_service_set_has_config_override(ctx->service, key)) { /* this setting was already overridden with -o parameter */ - if (mail_debug) { - i_debug("Ignoring overridden (-o) userdb setting: %s", - key); - } + e_debug(user->event, "Ignoring overridden (-o) userdb setting: %s", + key); return 1; } @@ -191,13 +184,13 @@ static int set_line(struct mail_storage_service_ctx *ctx, } ret = settings_parse_line(set_parser, line); - if (mail_debug && ret >= 0) { + if (ret >= 0) { if (strstr(key, "pass") != NULL) { /* possibly a password field (e.g. imapc_password). hide the value. */ line = t_strconcat(key, "=", NULL); } - i_debug(ret == 0 ? + e_debug(user->event, ret == 0 ? "Unknown userdb setting: %s" : "Added userdb setting: %s", line); } @@ -661,7 +654,6 @@ mail_storage_service_init_post(struct mail_storage_service_ctx *ctx, struct mail_user **mail_user_r, const char **error_r) { - const struct mail_storage_settings *mail_set; const char *home = priv->home; struct mail_user_connection_data conn_data; struct mail_user *mail_user; @@ -714,17 +706,13 @@ mail_storage_service_init_post(struct mail_storage_service_ctx *ctx, mail_user->userdb_fields = user->input.userdb_fields == NULL ? NULL : p_strarray_dup(mail_user->pool, user->input.userdb_fields); - mail_set = mail_user_set_get_storage_set(mail_user); + string_t *str = t_str_new(64); - if (mail_set->mail_debug) { - string_t *str = t_str_new(64); - - str_printfa(str, "Effective uid=%s, gid=%s, home=%s", - dec2str(geteuid()), dec2str(getegid()), home); - if (*priv->chroot != '\0') - str_printfa(str, ", chroot=%s", priv->chroot); - i_debug("%s", str_c(str)); - } + str_printfa(str, "Effective uid=%s, gid=%s, home=%s", + dec2str(geteuid()), dec2str(getegid()), home); + if (*priv->chroot != '\0') + str_printfa(str, ", chroot=%s", priv->chroot); + e_debug(mail_user->event, "%s", str_c(str)); if ((user->flags & MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP) != 0 && (user->flags & MAIL_STORAGE_SERVICE_FLAG_ENABLE_CORE_DUMPS) == 0) { @@ -751,8 +739,8 @@ mail_storage_service_init_post(struct mail_storage_service_ctx *ctx, t_strconcat(chdir_path, "/", NULL))); } else if (errno != ENOENT) i_error("chdir(%s) failed: %m", chdir_path); - else if (mail_set->mail_debug) - i_debug("Home dir not found: %s", chdir_path); + else + e_debug(mail_user->event, "Home dir not found: %s", chdir_path); if (chdir("/") < 0) i_error("chdir(/) failed: %m"); diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index c8d76e02a5..c651c887e7 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -291,7 +291,8 @@ mail_storage_create_root(struct mailbox_list *list, /* we don't need to verify, but since debugging is enabled, check and log if the root doesn't exist */ if (mail_storage_verify_root(root_dir, type_name, &error) < 0) { - i_debug("Namespace %s: Creating storage despite: %s", + e_debug(list->ns->user->event, + "Namespace %s: Creating storage despite: %s", list->ns->prefix, error); } return 0; @@ -1253,9 +1254,10 @@ mailbox_open_full(struct mailbox *box, struct istream *input) if (box->opened) return 0; - if (box->storage->set->mail_debug && box->reason != NULL) { - i_debug("%s: Mailbox opened because: %s", - box->vname, box->reason); + if (box->reason != NULL) { + e_debug(box->event, + "Mailbox opened because: %s", + box->reason); } switch (box->open_error) { @@ -1811,10 +1813,9 @@ int mailbox_rename(struct mailbox *src, struct mailbox *dest) dest->storage, &error) || !mailbox_lists_rename_compatible(src->list, dest->list, &error)) { - if (src->storage->set->mail_debug) { - i_debug("Can't rename '%s' to '%s': %s", - src->vname, dest->vname, error); - } + e_debug(src->event, + "Can't rename '%s' to '%s': %s", + src->vname, dest->vname, error); mail_storage_set_error(src->storage, MAIL_ERROR_NOTPOSSIBLE, "Can't rename mailboxes across specified storages."); return -1; diff --git a/src/lib-storage/mailbox-list.c b/src/lib-storage/mailbox-list.c index 43c4ac2bfe..f482dab14e 100644 --- a/src/lib-storage/mailbox-list.c +++ b/src/lib-storage/mailbox-list.c @@ -209,18 +209,17 @@ int mailbox_list_create(const char *driver, struct mail_namespace *ns, } } - if (ns->mail_set->mail_debug) { - i_debug("%s: root=%s, index=%s, indexpvt=%s, control=%s, inbox=%s, alt=%s", - list->name, - list->set.root_dir == NULL ? "" : list->set.root_dir, - list->set.index_dir == NULL ? "" : list->set.index_dir, - list->set.index_pvt_dir == NULL ? "" : list->set.index_pvt_dir, - list->set.control_dir == NULL ? - "" : list->set.control_dir, - list->set.inbox_path == NULL ? - "" : list->set.inbox_path, - list->set.alt_dir == NULL ? "" : list->set.alt_dir); - } + e_debug(ns->user->event, + "%s: root=%s, index=%s, indexpvt=%s, control=%s, inbox=%s, alt=%s", + list->name, + list->set.root_dir == NULL ? "" : list->set.root_dir, + list->set.index_dir == NULL ? "" : list->set.index_dir, + list->set.index_pvt_dir == NULL ? "" : list->set.index_pvt_dir, + list->set.control_dir == NULL ? + "" : list->set.control_dir, + list->set.inbox_path == NULL ? + "" : list->set.inbox_path, + list->set.alt_dir == NULL ? "" : list->set.alt_dir); if ((flags & MAILBOX_LIST_FLAG_SECONDARY) == 0) mail_namespace_finish_list_init(ns, list); @@ -937,8 +936,9 @@ mailbox_list_get_permissions_stat(struct mailbox_list *list, const char *path, } else if (!ENOTFOUND(errno)) { mailbox_list_set_critical(list, "stat(%s) failed: %m", path); - } else if (list->mail_set->mail_debug) { - i_debug("Namespace %s: %s doesn't exist yet, " + } else { + e_debug(list->ns->user->event, + "Namespace %s: %s doesn't exist yet, " "using default permissions", list->ns->prefix, path); } @@ -1055,8 +1055,9 @@ mailbox_list_get_permissions_internal(struct mailbox_list *list, list->pool); } - if (list->mail_set->mail_debug && name == NULL) { - i_debug("Namespace %s: Using permissions from %s: " + if (name == NULL) { + e_debug(list->ns->user->event, + "Namespace %s: Using permissions from %s: " "mode=0%o gid=%s", list->ns->prefix, path != NULL ? path : "", (int)permissions_r->dir_create_mode,