From ae63d731e9c1d9a0403aac3ee0e680a6508dff07 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 4 Apr 2023 10:57:32 +0200 Subject: add NOSESSIONHEADER env variable --- qmail-qmqpd.c | 2 +- qmail-qmtpd.c | 2 +- qmail-smtpd.c | 6 ++++-- received.c | 35 ++++++++++++++++------------------- received.h | 6 ++++-- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/qmail-qmqpd.c b/qmail-qmqpd.c index 3eb06e4..38b6b67 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,NULL,NULL); + received(&qq,"QMQP",local,remoteip,remotehost,remoteinfo,NULL); } char buf[1000]; diff --git a/qmail-qmtpd.c b/qmail-qmtpd.c index 77d36aa..d6f6eba 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,NULL,NULL); + received(&qq,"QMTP",local,remoteip,remotehost,remoteinfo,NULL); /* XXX: check for loops? only if len is big? */ diff --git a/qmail-smtpd.c b/qmail-smtpd.c index f038314..5ea23dc 100644 --- a/qmail-smtpd.c +++ b/qmail-smtpd.c @@ -970,9 +970,11 @@ void smtp_data(arg) char *arg; { } if (flagauth) - received_authed(&qqt,protocol,local,remoteinfo,client_get_session_id()->s); + received_authed(&qqt,protocol,local); else - received(&qqt,protocol,local,remoteip,remotehost,remoteinfo,client_get_session_id()->s,fakehelo); + received(&qqt,protocol,local,remoteip,remotehost,remoteinfo,fakehelo); + if (!env_get("NOSESSIONHEADER")) + xsmtpsession(&qqt, (flagauth) ? remoteinfo : NULL, client_get_session_id()->s); qmail_put(&qqt,sppheaders.s,sppheaders.len); /* set in qmail-spp.c */ spp_rset(); blast(&hops); diff --git a/received.c b/received.c index 0b51c39..3d27bb0 100644 --- a/received.c +++ b/received.c @@ -41,7 +41,7 @@ static char buf[DATE822FMT]; 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) + const char *helo) { struct datetime dt; @@ -65,19 +65,12 @@ void received(const struct qmail *qqt, 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 */ +/* "Received: by silverton.berkeley.edu with SMTP; 26 Sep 1995 04:46:54 -0000\n" */ void received_authed(const struct qmail *qqt, const char *protocol, - const char *local, const char *remoteinfo, const char *remotesession) + const char *local) { struct datetime dt; @@ -88,15 +81,19 @@ void received_authed(const struct qmail *qqt, const char *protocol, qmail_puts(qqt,"; "); datetime_tai(&dt,now()); qmail_put(qqt,buf,date822fmt(buf,&dt)); +} + +/* "X-UD-Smtp-Session: sessionid */ +/* "X-UD-Smtp-Session: user@sessionid */ - if (remoteinfo || remotesession) { - qmail_puts(qqt,"X-UD-Smtp-Session: "); - if (remoteinfo) { - safeput(qqt,remoteinfo); - qmail_puts(qqt,"@"); - } - if (remotesession) - qmail_puts(qqt,remotesession); - qmail_put(qqt,"\n",1); +void xsmtpsession(const struct qmail *qqt, + const char *remoteinfo, const char *remotesession) +{ + qmail_puts(qqt,"X-UD-Smtp-Session: "); + if (remoteinfo) { + safeput(qqt,remoteinfo); + qmail_puts(qqt,"@"); } + qmail_puts(qqt,remotesession); + qmail_put(qqt,"\n",1); } diff --git a/received.h b/received.h index 473c3ca..2476454 100644 --- a/received.h +++ b/received.h @@ -5,9 +5,11 @@ 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 + const char *remoteinfo, const char *helo ); void received_authed(const struct qmail *qqt, const char *protocol, - const char *local, const char *remoteinfo, const char *remotesession); + const char *local); +void xsmtpsession(const struct qmail *qqt, + const char *remoteinfo, const char *remotesession); #endif -- cgit v1.2.3