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;
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;
}
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);
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);
}
}
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);
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,
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;
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 =
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;
}
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;
}
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, '=');
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;
}
}
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, "=<hidden>", NULL);
}
- i_debug(ret == 0 ?
+ e_debug(user->event, ret == 0 ?
"Unknown userdb setting: %s" :
"Added userdb setting: %s", line);
}
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;
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) {
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");
/* 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;
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) {
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;
}
}
- 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);
} 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);
}
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,