From 6373687fb1bf6d785ad18581126cc0df0dbc335b Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 4 Jun 2021 20:47:24 +0000 Subject: Doc, and some important optimizations --- doc/smtpd-starttls-proxy-io.html | 99 +++++++++++++++++++++- src/smtpd-starttls-proxy/smtpd-starttls-proxy-io.c | 9 +- 2 files changed, 101 insertions(+), 7 deletions(-) diff --git a/doc/smtpd-starttls-proxy-io.html b/doc/smtpd-starttls-proxy-io.html index 2bf20ca..d0e8d86 100644 --- a/doc/smtpd-starttls-proxy-io.html +++ b/doc/smtpd-starttls-proxy-io.html @@ -38,8 +38,103 @@ server, and interfaces with it. + +

Environment variables

+ +

+ smtpd-starttls-proxy-io expects to be run under a UCSPI-TLS server such as +s6-ucspitlsd or +sslserver -n. As a +consequence, it expects its environment to contain the following variables: +

+ + + +

+ smtpd-starttls-proxy-io will refuse to run if one of these variables +is nonexistent or contains invalid data. +

+ +

Usage example

+ +

+ You can run a STARTTLS-enabled qmail-smtpd mail receiver on +address hostip port port with the following steps: +

+ + + +
 s6-tcpserver -- hostip port \
+  s6-tcpserver-access -Dl0 -t5000 -- \
+  s6-ucspitlsd -K30000 -- \
+  s6-applyuidgid -Uz -- \
+  smtpd-starttls-proxy-io \
+  qmail-smtpd 
+ + + +

Notes

+ + diff --git a/src/smtpd-starttls-proxy/smtpd-starttls-proxy-io.c b/src/smtpd-starttls-proxy/smtpd-starttls-proxy-io.c index 950b987..74e97ae 100644 --- a/src/smtpd-starttls-proxy/smtpd-starttls-proxy-io.c +++ b/src/smtpd-starttls-proxy/smtpd-starttls-proxy-io.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -98,7 +97,7 @@ static int answer_forward (char const *s) static int answer_ehlo (char const *s) { static int needed = 1 ; - if (needed && s[0] == '2' && case_starts(s+4, "starttls")) + if (needed && s[0] == '2' && !strncasecmp(s+4, "starttls", 8)) { needed = 0 ; strerr_warni1x("server seems to support STARTTLS natively") ; @@ -161,7 +160,7 @@ static int do_forward (char const *s) static int do_badorder (char const *s) { (void)s ; - answer_enqueue("503 MAIL has to come first\r\n") ; + answer_enqueue("503 MAIL first. Are you like this with girls too?\r\n") ; return 0 ; } @@ -196,7 +195,7 @@ static int do_notls (char const *s) static int do_starttls (char const *s) { if (buffer_len(&io[0].in)) - answer_enqueue("503 STARTTLS must be the last command in a group\r\n") ; + answer_enqueue("503 Stop yammering after saying STARTTLS\r\n") ; else { command_enqueue("RSET\r\n", &trigger_starttls) ; @@ -233,7 +232,7 @@ static int process_client_line (char const *s) break ; } if (cmd->name) return (*cmd->f)(s) ; - answer_enqueue("500 SMTP mother!@#$er, do you speak it\r\n") ; + answer_enqueue("500 SMTP motherfucker, do you speak it?\r\n") ; return 0 ; } -- cgit v1.3.1