From ddb3069bf287af8f0a634110b7bb95203f147b51 Mon Sep 17 00:00:00 2001 From: manuel Date: Fri, 20 Nov 2020 01:03:21 +0100 Subject: Add X-UD-Smtp-Session to unauthed smtp session aswell --- qmail-qmqpd.c | 2 +- qmail-qmtpd.c | 2 +- qmail-smtpd.c | 7 +++++-- received.c | 28 ++++++++++++++-------------- received.h | 10 ++++++++-- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/qmail-qmqpd.c b/qmail-qmqpd.c index 8726ab0..3eb06e4 100644 --- a/qmail-qmqpd.c +++ b/qmail-qmqpd.c @@ -80,7 +80,7 @@ void identify() if (!local) local = env_get("TCPLOCALIP"); if (!local) local = "unknown"; - received(&qq,"QMQP",local,remoteip,remotehost,remoteinfo,(char *) 0); + received(&qq,"QMQP",local,remoteip,remotehost,remoteinfo,NULL,NULL); } char buf[1000]; diff --git a/qmail-qmtpd.c b/qmail-qmtpd.c index 1055274..77d36aa 100644 --- a/qmail-qmtpd.c +++ b/qmail-qmtpd.c @@ -144,7 +144,7 @@ int main() else if (ch == 13) flagdos = 1; else badproto(); - received(&qq,"QMTP",local,remoteip,remotehost,remoteinfo,(char *) 0); + received(&qq,"QMTP",local,remoteip,remotehost,remoteinfo,NULL,NULL); /* XXX: check for loops? only if len is big? */ diff --git a/qmail-smtpd.c b/qmail-smtpd.c index 1036eef..20027b0 100644 --- a/qmail-smtpd.c +++ b/qmail-smtpd.c @@ -63,6 +63,7 @@ char *remotehost; char *remoteinfo; char *local; char *relayclient; +static const stralloc *client_get_session_id(); #ifdef TLS # include @@ -346,6 +347,9 @@ void setup() else #endif dohelo(remotehost); + + /* generate session */ + (void)client_get_session_id(); } @@ -959,7 +963,7 @@ void smtp_data(arg) char *arg; { if (flagauth) received_authed(&qqt,protocol,local,remoteinfo,client_get_session_id()->s); else - received(&qqt,protocol,local,remoteip,remotehost,remoteinfo,fakehelo); + received(&qqt,protocol,local,remoteip,remotehost,remoteinfo,client_get_session_id()->s,fakehelo); qmail_put(&qqt,sppheaders.s,sppheaders.len); /* set in qmail-spp.c */ spp_rset(); blast(&hops); @@ -1244,7 +1248,6 @@ char *arg; switch (authcmds[i].fun(arg)) { case 0: - (void)client_get_session_id(); /* generate session */ if (!spp_auth(authcmds[i].text, user.s)) return; flagauth = 1; if (ssl) { diff --git a/received.c b/received.c index f38545e..0b51c39 100644 --- a/received.c +++ b/received.c @@ -36,15 +36,12 @@ static char buf[DATE822FMT]; /* "Received: from relay1.uu.net (HELO uunet.uu.net) (7@192.48.96.5)\n" */ /* " by silverton.berkeley.edu with SMTP; 26 Sep 1995 04:46:54 -0000\n" */ +/* "X-UD-Smtp-Session: sessionid */ -void received(qqt,protocol,local,remoteip,remotehost,remoteinfo,helo) -struct qmail *qqt; -char *protocol; -char *local; -char *remoteip; -char *remotehost; -char *remoteinfo; -char *helo; +void received(const struct qmail *qqt, + const char *protocol, const char *local, + const char *remoteip, const char *remotehost, const char *remoteinfo, + const char *remotesession, const char *helo) { struct datetime dt; @@ -68,17 +65,19 @@ char *helo; qmail_puts(qqt,"; "); datetime_tai(&dt,now()); qmail_put(qqt,buf,date822fmt(buf,&dt)); + + if (remotesession) { + qmail_puts(qqt,"X-UD-Smtp-Session: "); + qmail_puts(qqt,remotesession); + qmail_put(qqt,"\n",1); + } } /* "Received: by silverton.berkeley.edu with SMTP; 26 Sep 1995 04:46:54 -0000\n" * "X-UD-Smtp-Session: user@sessionid */ -void received_authed(qqt,protocol,local,remoteinfo,remotesession) -struct qmail *qqt; -char *protocol; -char *local; -char *remoteinfo; -char *remotesession; +void received_authed(const struct qmail *qqt, const char *protocol, + const char *local, const char *remoteinfo, const char *remotesession) { struct datetime dt; @@ -89,6 +88,7 @@ char *remotesession; qmail_puts(qqt,"; "); datetime_tai(&dt,now()); qmail_put(qqt,buf,date822fmt(buf,&dt)); + if (remoteinfo || remotesession) { qmail_puts(qqt,"X-UD-Smtp-Session: "); if (remoteinfo) { diff --git a/received.h b/received.h index 7c98c28..473c3ca 100644 --- a/received.h +++ b/received.h @@ -1,7 +1,13 @@ #ifndef RECEIVED_H #define RECEIVED_H -extern void received(); -extern void received_authed(); +#include "qmail.h" + +void received(const struct qmail *qqt, const char *protocol, + const char *local, const char *remoteip, const char *remotehost, + const char *remoteinfo, const char *remotesession, const char *helo +); +void received_authed(const struct qmail *qqt, const char *protocol, + const char *local, const char *remoteinfo, const char *remotesession); #endif -- cgit v1.2.3