summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/mta_session.c
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2012-09-21 12:33:33 +0000
committerEric Faurot <eric@cvs.openbsd.org>2012-09-21 12:33:33 +0000
commit780831e39df02df837f769cd972954e5130d26fa (patch)
tree4bd63d226a5f89e8da924af6ea1afce188b1a154 /usr.sbin/smtpd/mta_session.c
parenteddae9a25843931ff5ba7e0a2fcbd872d8c0446d (diff)
Add a log_envelope() function that log envelope status in a uniform way.
It automagically adds an rcpt=<user@domain> field if "dest" differs from the original "rcpt". The function takes an "extra" parameter that allows to add some specific info depending on the context. ok gilles@
Diffstat (limited to 'usr.sbin/smtpd/mta_session.c')
-rw-r--r--usr.sbin/smtpd/mta_session.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c
index 3ca6fc0cf95..029ddbb6ef8 100644
--- a/usr.sbin/smtpd/mta_session.c
+++ b/usr.sbin/smtpd/mta_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mta_session.c,v 1.16 2012/09/11 16:24:28 eric Exp $ */
+/* $OpenBSD: mta_session.c,v 1.17 2012/09/21 12:33:32 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -853,18 +853,17 @@ mta_status(struct mta_session *s, int connerr, const char *fmt, ...)
static void
mta_envelope_done(struct mta_task *task, struct envelope *e, const char *status)
{
- struct mta_host *host = TAILQ_FIRST(&task->session->hosts);
+ struct mta_host *host = TAILQ_FIRST(&task->session->hosts);
+ char relay[MAX_LINE_SIZE], stat[MAX_LINE_SIZE];
envelope_set_errormsg(e, "%s", status);
- log_info("%016" PRIx64 ": to=<%s@%s>, delay=%s, relay=%s [%s], stat=%s (%s)",
- e->id, e->dest.user,
- e->dest.domain,
- duration_to_text(time(NULL) - e->creation),
- host->fqdn,
- ss_to_text(&host->sa),
+ snprintf(relay, sizeof relay, "relay=%s [%s], ",
+ host->fqdn, ss_to_text(&host->sa));
+ snprintf(stat, sizeof stat, "%s (%s)",
mta_response_status(e->errorline),
mta_response_text(e->errorline));
+ log_envelope(e, relay, stat);
imsg_compose_event(env->sc_ievs[PROC_QUEUE],
mta_response_delivery(e->errorline), 0, 0, -1, e, sizeof(*e));