aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgilles <gilles@openbsd.org>2020-01-07 23:03:37 +0000
committergilles <gilles@openbsd.org>2020-01-07 23:03:37 +0000
commit96b0c8af1837250437d199a0dafe0db308f0e469 (patch)
tree895a562dbd9c80307d1a12dfeca1cab5eea87dda
parentgenerate link-auth reporting event for outgoing sessions (diff)
downloadOpenSMTPD-96b0c8af1837250437d199a0dafe0db308f0e469.tar.xz
OpenSMTPD-96b0c8af1837250437d199a0dafe0db308f0e469.zip
fix reporting of tx-mail and tx-rcpt for smtp-out
-rw-r--r--mta_session.c5
-rw-r--r--report_smtp.c24
-rw-r--r--smtp_session.c26
3 files changed, 29 insertions, 26 deletions
diff --git a/mta_session.c b/mta_session.c
index f0f2c59b..4400374e 100644
--- a/mta_session.c
+++ b/mta_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mta_session.c,v 1.126 2020/01/07 22:39:02 gilles Exp $ */
+/* $OpenBSD: mta_session.c,v 1.127 2020/01/07 23:03:37 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -812,6 +812,7 @@ again:
envid_sz ? e->dsn_envid : "");
} else
mta_send(s, "MAIL FROM:<%s>", s->task->sender);
+ mta_report_tx_begin(s, s->task->msgid);
break;
case MTA_RCPT:
@@ -1030,7 +1031,7 @@ mta_response(struct mta_session *s, char *line)
mta_enter_state(s, MTA_RSET);
return;
}
- mta_report_tx_begin(s, s->task->msgid);
+
mta_report_tx_mail(s, s->task->msgid, s->task->sender, 1);
mta_enter_state(s, MTA_RCPT);
break;
diff --git a/report_smtp.c b/report_smtp.c
index ab17901f..80f36fc7 100644
--- a/report_smtp.c
+++ b/report_smtp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: report_smtp.c,v 1.10 2019/09/19 14:40:53 gilles Exp $ */
+/* $OpenBSD: report_smtp.c,v 1.11 2020/01/07 23:03:37 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -174,15 +174,6 @@ void
report_smtp_tx_mail(const char *direction, uint64_t qid, uint32_t msgid, const char *address, int ok)
{
struct timeval tv;
- char buffer[SMTPD_MAXMAILADDRSIZE];
- char *p;
-
- if ((p = strchr(address, '<')) == NULL)
- return;
- (void)strlcpy(buffer, p + 1, sizeof buffer);
- if ((p = strchr(buffer, '>')) == NULL)
- return;
- *p = '\0';
gettimeofday(&tv, NULL);
@@ -191,7 +182,7 @@ report_smtp_tx_mail(const char *direction, uint64_t qid, uint32_t msgid, const c
m_add_timeval(p_lka, &tv);
m_add_id(p_lka, qid);
m_add_u32(p_lka, msgid);
- m_add_string(p_lka, buffer);
+ m_add_string(p_lka, address);
m_add_int(p_lka, ok);
m_close(p_lka);
}
@@ -200,15 +191,6 @@ void
report_smtp_tx_rcpt(const char *direction, uint64_t qid, uint32_t msgid, const char *address, int ok)
{
struct timeval tv;
- char buffer[SMTPD_MAXMAILADDRSIZE];
- char *p;
-
- if ((p = strchr(address, '<')) == NULL)
- return;
- (void)strlcpy(buffer, p + 1, sizeof buffer);
- if ((p = strchr(buffer, '>')) == NULL)
- return;
- *p = '\0';
gettimeofday(&tv, NULL);
@@ -217,7 +199,7 @@ report_smtp_tx_rcpt(const char *direction, uint64_t qid, uint32_t msgid, const c
m_add_timeval(p_lka, &tv);
m_add_id(p_lka, qid);
m_add_u32(p_lka, msgid);
- m_add_string(p_lka, buffer);
+ m_add_string(p_lka, address);
m_add_int(p_lka, ok);
m_close(p_lka);
}
diff --git a/smtp_session.c b/smtp_session.c
index e15ec2bf..20b83eeb 100644
--- a/smtp_session.c
+++ b/smtp_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp_session.c,v 1.419 2020/01/03 22:01:29 gilles Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.420 2020/01/07 23:03:37 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -3096,19 +3096,39 @@ smtp_report_tx_begin(struct smtp_session *s, uint32_t msgid)
static void
smtp_report_tx_mail(struct smtp_session *s, uint32_t msgid, const char *address, int ok)
{
+ char mailaddr[SMTPD_MAXMAILADDRSIZE];
+ char *p;
+
if (! SESSION_FILTERED(s))
return;
- report_smtp_tx_mail("smtp-in", s->id, msgid, address, ok);
+ if ((p = strchr(address, '<')) == NULL)
+ return;
+ (void)strlcpy(mailaddr, p + 1, sizeof mailaddr);
+ if ((p = strchr(mailaddr, '>')) == NULL)
+ return;
+ *p = '\0';
+
+ report_smtp_tx_mail("smtp-in", s->id, msgid, mailaddr, ok);
}
static void
smtp_report_tx_rcpt(struct smtp_session *s, uint32_t msgid, const char *address, int ok)
{
+ char mailaddr[SMTPD_MAXMAILADDRSIZE];
+ char *p;
+
if (! SESSION_FILTERED(s))
return;
- report_smtp_tx_rcpt("smtp-in", s->id, msgid, address, ok);
+ if ((p = strchr(address, '<')) == NULL)
+ return;
+ (void)strlcpy(mailaddr, p + 1, sizeof mailaddr);
+ if ((p = strchr(mailaddr, '>')) == NULL)
+ return;
+ *p = '\0';
+
+ report_smtp_tx_rcpt("smtp-in", s->id, msgid, mailaddr, ok);
}
static void