summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/mda.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/mda.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/mda.c')
-rw-r--r--usr.sbin/smtpd/mda.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c
index 8dcaafbb314..b949a54c2ec 100644
--- a/usr.sbin/smtpd/mda.c
+++ b/usr.sbin/smtpd/mda.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mda.c,v 1.74 2012/09/20 09:27:49 eric Exp $ */
+/* $OpenBSD: mda.c,v 1.75 2012/09/21 12:33:32 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -55,10 +55,10 @@ static void
mda_imsg(struct imsgev *iev, struct imsg *imsg)
{
char output[128], *error, *parent_error;
+ char stat[MAX_LINE_SIZE];
struct deliver deliver;
struct mda_session *s;
struct delivery_mda *d_mda;
- struct mailaddr *maddr;
struct envelope *ep;
FILE *fp;
uint16_t msg;
@@ -215,30 +215,12 @@ mda_imsg(struct imsgev *iev, struct imsg *imsg)
if (error) {
msg = IMSG_QUEUE_DELIVERY_TEMPFAIL;
envelope_set_errormsg(&s->msg, "%s", error);
+ snprintf(stat, sizeof stat, "Error (%s)", error);
}
imsg_compose_event(env->sc_ievs[PROC_QUEUE], msg,
0, 0, -1, &s->msg, sizeof s->msg);
- /*
- * XXX: which struct path gets used for logging depends
- * on whether lka did aliases or .forward processing;
- * lka may need to be changed to present data in more
- * unified way.
- */
- if (s->msg.rule.r_action == A_MAILDIR ||
- s->msg.rule.r_action == A_MBOX)
- maddr = &s->msg.dest;
- else
- maddr = &s->msg.rcpt;
-
- /* log status */
- if (error && asprintf(&error, "Error (%s)", error) < 0)
- fatal("mda: asprintf");
- log_info("%016" PRIx64 ": to=<%s@%s>, delay=%s, stat=%s",
- s->msg.id, maddr->user, maddr->domain,
- duration_to_text(time(NULL) - s->msg.creation),
- error ? error : "Sent");
- free(error);
+ log_envelope(&s->msg, NULL, error ? stat : "Delivered");
/* destroy session */
LIST_REMOVE(s, entry);