summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2009-01-29 15:20:35 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2009-01-29 15:20:35 +0000
commite2b18f0d5ff0167bc4b80dcf25048e540c91bdf2 (patch)
treefe409b0dbed0973526b5cbcc13e17c99b6a40b28
parent35cc60cd8cea267c000de42a3b430ac40a4148eb (diff)
Received header line was incomplete for mail submitted through the enqueuer
as well as for some outgoing messages, this is fixed now
-rw-r--r--usr.sbin/smtpd/enqueue.c6
-rw-r--r--usr.sbin/smtpd/mta.c20
-rw-r--r--usr.sbin/smtpd/smtp_session.c5
-rw-r--r--usr.sbin/smtpd/smtpd.h6
-rw-r--r--usr.sbin/smtpd/store.c29
5 files changed, 41 insertions, 25 deletions
diff --git a/usr.sbin/smtpd/enqueue.c b/usr.sbin/smtpd/enqueue.c
index 1f356891b52..0a693a72501 100644
--- a/usr.sbin/smtpd/enqueue.c
+++ b/usr.sbin/smtpd/enqueue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: enqueue.c,v 1.7 2009/01/29 10:18:27 gilles Exp $ */
+/* $OpenBSD: enqueue.c,v 1.8 2009/01/29 15:20:34 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -92,6 +92,9 @@ enqueue(int argc, char *argv[])
argv += optind;
bzero(&message, sizeof(struct message));
+
+ strlcpy(message.session_helo, "localhost", MAXHOSTNAMELEN);
+ strlcpy(message.session_hostname, hostname, MAXHOSTNAMELEN);
/* build sender */
if (! recipient_to_path(&message.sender, sender))
@@ -165,6 +168,7 @@ enqueue_add_recipient(struct message *messagep, char *recipient)
if (inet_pton(AF_INET, "127.0.0.1", &ssin->sin_addr) != 1)
return 0;
}
+ message.session_ss = mr.ss;
mr.path = message.recipient;
mr.id = message.session_id;
diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c
index a45feefedb6..db5c089a73e 100644
--- a/usr.sbin/smtpd/mta.c
+++ b/usr.sbin/smtpd/mta.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mta.c,v 1.24 2009/01/29 14:50:27 gilles Exp $ */
+/* $OpenBSD: mta.c,v 1.25 2009/01/29 15:20:34 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -266,6 +266,10 @@ mta_dispatch_runner(int sig, short event, void *p)
if (batchp == NULL)
fatalx("mta_dispatch_runner: internal inconsistency.");
+ batchp->session_ss = messagep->session_ss;
+ strlcpy(batchp->session_hostname, messagep->session_hostname, MAXHOSTNAMELEN);
+ strlcpy(batchp->session_helo, messagep->session_helo, MAXHOSTNAMELEN);
+
TAILQ_INSERT_TAIL(&batchp->messages, messagep, entry);
break;
@@ -724,10 +728,20 @@ mta_reply_handler(struct bufferevent *bev, void *arg)
}
case S_DATA: {
+/*
+ if (fprintf(fp, "Received: from %s (%s [%s%s])\n"
+ "\tby %s with ESMTP id %s\n"
+ "\tfor <%s@%s>; %s\n\n",
+ messagep->session_helo, messagep->session_hostname,
+ messagep->session_ss.ss_family == PF_INET ? "" : "IPv6:", addrbuf,
+ batchp->env->sc_hostname, messagep->message_id,
+ messagep->sender.user, messagep->sender.domain, ctimebuf) == -1) {
+*/
session_respond(sessionp, "Received: from %s (%s [%s])",
- "localhost", "localhost", "127.0.0.1");
+ batchp->session_helo, batchp->session_hostname, "127.0.0.1");
+
session_respond(sessionp, "\tby %s with ESMTP id %s",
- "", batchp->message_id);
+ batchp->env->sc_hostname, batchp->message_id);
if (sessionp->s_flags & F_SECURE) {
session_respond(sessionp, "X-OpenSMTPD-Cipher: %s",
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index 5055386dec9..3eb08c31304 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.43 2009/01/28 18:10:19 jacekm Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.44 2009/01/29 15:20:34 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -372,6 +372,9 @@ session_rfc5321_ehlo_handler(struct session *s, char *args)
session_respond(s, "250 HELP");
+
+ log_debug("messagep->helo: %s / args", s->s_msg.session_helo, args);
+
return 1;
}
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index c3a588594f5..0199cbbfc1e 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.59 2009/01/29 14:25:55 gilles Exp $ */
+/* $OpenBSD: smtpd.h,v 1.60 2009/01/29 15:20:34 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -490,6 +490,10 @@ struct batch {
char hostname[MAXHOSTNAMELEN];
char errorline[MAX_LINE_SIZE];
+ char session_helo[MAXHOSTNAMELEN];
+ char session_hostname[MAXHOSTNAMELEN];
+ struct sockaddr_storage session_ss;
+
int8_t getaddrinfo_error;
struct mxhost mxarray[MXARRAYSIZE*2];
u_int8_t mx_cnt;
diff --git a/usr.sbin/smtpd/store.c b/usr.sbin/smtpd/store.c
index 7fef9b677d4..4d1ac9b1751 100644
--- a/usr.sbin/smtpd/store.c
+++ b/usr.sbin/smtpd/store.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: store.c,v 1.11 2009/01/28 12:28:25 jacekm Exp $ */
+/* $OpenBSD: store.c,v 1.12 2009/01/29 15:20:34 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -113,33 +113,24 @@ store_write_header(struct batch *batchp, struct message *messagep, FILE *fp)
inet_ntop(messagep->session_ss.ss_family, p, addrbuf, sizeof (addrbuf));
if (batchp->type & T_DAEMON_BATCH) {
-
if (fprintf(fp, "From %s@%s %s\n", "MAILER-DAEMON",
batchp->env->sc_hostname, timebuf) == -1) {
return 0;
}
-
- if (fprintf(fp, "Received: from %s (%s [%s%s])\n"
- "\tby %s with ESMTP id %s\n"
- "\tfor <%s@%s>; %s\n\n",
- messagep->session_helo, messagep->session_hostname,
- messagep->session_ss.ss_family == PF_INET ? "" : "IPv6:", addrbuf,
- batchp->env->sc_hostname, messagep->message_id,
- messagep->sender.user, messagep->sender.domain, ctimebuf) == -1) {
+ }
+ else {
+ if (fprintf(fp, "From %s@%s %s\n",
+ messagep->sender.user, messagep->sender.domain, timebuf) == -1)
return 0;
- }
- return 1;
}
-
- if (fprintf(fp, "From %s@%s %s\n"
- "Received: from %s (%s [%s%s])\n"
+
+ if (fprintf(fp, "Received: from %s (%s [%s%s])\n"
"\tby %s with ESMTP id %s\n"
- "\tfor <%s@%s>; %s\n",
- messagep->sender.user, messagep->sender.domain, timebuf,
+ "\tfor <%s@%s>; %s\n\n",
messagep->session_helo, messagep->session_hostname,
messagep->session_ss.ss_family == PF_INET ? "" : "IPv6:", addrbuf,
- batchp->env->sc_hostname, batchp->message_id,
- messagep->recipient.user, messagep->recipient.domain, ctimebuf) == -1) {
+ batchp->env->sc_hostname, messagep->message_id,
+ messagep->sender.user, messagep->sender.domain, ctimebuf) == -1) {
return 0;
}
return 1;