summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2020-01-07 23:03:38 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2020-01-07 23:03:38 +0000
commit955279139b7b0d1365b89f120738fe591054be09 (patch)
treeb9bf9c8a3e6e0cc47c346ae63d55f680f4df5ed5 /usr.sbin/smtpd
parent70217fff28fb4b2b8e4d07e0ba806f901a26790e (diff)
fix reporting of tx-mail and tx-rcpt for smtp-out
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r--usr.sbin/smtpd/mta_session.c5
-rw-r--r--usr.sbin/smtpd/report_smtp.c24
-rw-r--r--usr.sbin/smtpd/smtp_session.c26
3 files changed, 29 insertions, 26 deletions
diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c
index f0f2c59b3c0..4400374ee5c 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.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/usr.sbin/smtpd/report_smtp.c b/usr.sbin/smtpd/report_smtp.c
index ab17901f30c..80f36fc7203 100644
--- a/usr.sbin/smtpd/report_smtp.c
+++ b/usr.sbin/smtpd/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/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index e15ec2bfa53..20b83eeb82f 100644
--- a/usr.sbin/smtpd/smtp_session.c
+++ b/usr.sbin/smtpd/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