nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 73f34b3ae4d0f840cee68b08ad28386c2c141ffc
parent 22845837cc1b8397c859dc5e9d530c66a17f5dec
Author: Ellenor Malik <ellenor@umbrellix.net>
Date:   Thu,  6 Oct 2022 21:33:30 +0000

add some minor changes

Diffstat:
Minclude/ipme.h | 2++
Msrc/control.c | 35++++++++++++++++++-----------------
Msrc/getln.c | 7++++++-
Msrc/getln2.c | 6++++++
Msrc/ipme.c | 4++++
Msrc/qmail-rspawn.c | 3+++
Msrc/qmail-send.c | 1+
Msrc/qmail-smtpd.c | 40+++++++++++++++++++++-------------------
8 files changed, 61 insertions(+), 37 deletions(-)

diff --git a/include/ipme.h b/include/ipme.h @@ -8,6 +8,8 @@ extern ipalloc ipme; extern ip6alloc ip6me; extern int ipme_init(); +extern int ip6me_init(); extern int ipme_is(); +extern int ip6me_is(); #endif diff --git a/src/control.c b/src/control.c @@ -3,12 +3,13 @@ #include "readwrite.h" #include "open.h" #include "getln.h" +#include "substdio.h" #ifdef USING_SKALIBS #include <skalibs/stralloc.h> +//#include <skalibs/buffer.h> #else #include "stralloc.h" #endif -#include "substdio.h" #include "error.h" #include "alloc.h" #include "scan.h" @@ -56,22 +57,22 @@ int control_rldef(stralloc *sa, char *fn, int flagme, char *def) int control_readline(stralloc *sa, char *fn) { -#ifdef USING_SKALIBS - buffer ss; -#else +//#ifdef USING_SKALIBS +// buffer ss; +//#else substdio ss; -#endif +//#endif int fd; int match; fd = open_read(fn); if (fd == -1) { if (errno == error_noent) return 0; return -1; } -#ifdef USING_SKALIBS - buffer_init(&ss,buffer_read,fd,inbuf,sizeof(inbuf)); -#else +//#ifdef USING_SKALIBS +// buffer_init(&ss,buffer_read,fd,inbuf,sizeof(inbuf)); +//#else substdio_fdbuf(&ss,read,fd,inbuf,sizeof(inbuf)); -#endif +//#endif if (getln(&ss,sa,&match,'\n') == -1) { close(fd); return -1; } @@ -96,11 +97,11 @@ int control_readint(int *i, char *fn) int control_readfile(stralloc *sa, char *fn, int flagme) { -#ifdef USING_SKALIBS - buffer ss; -#else +//#ifdef USING_SKALIBS +// buffer ss; +//#else substdio ss; -#endif +//#endif int fd; int match; @@ -122,11 +123,11 @@ int control_readfile(stralloc *sa, char *fn, int flagme) return -1; } -#ifdef USING_SKALIBS - buffer_init(&ss,buffer_read,fd,inbuf,sizeof(inbuf)); -#else +//#ifdef USING_SKALIBS +// buffer_init(&ss,buffer_read,fd,inbuf,sizeof(inbuf)); +//#else substdio_fdbuf(&ss,read,fd,inbuf,sizeof(inbuf)); -#endif +//#endif for (;;) { if (getln(&ss,&line,&match,'\n') == -1) break; diff --git a/src/getln.c b/src/getln.c @@ -1,8 +1,13 @@ #include "getln.h" -#include "substdio.h" #include "byte.h" +#include "substdio.h" +#ifdef USING_SKALIBS +//#include <skalibs/buffer.h> +#include <skalibs/stralloc.h> +#else #include "stralloc.h" +#endif int getln(substdio *ss, stralloc *sa, int *match, int sep) { diff --git a/src/getln2.c b/src/getln2.c @@ -1,8 +1,14 @@ #include "substdio.h" +#ifdef USING_SKALIBS +//#include <skalibs/buffer.h> +#include <skalibs/stralloc.h> +#else #include "stralloc.h" +#endif #include "byte.h" #include "getln.h" + int getln2(substdio *ss, stralloc *sa, /*@out@*/char **cont, /*@out@*/unsigned int *clen, int sep) diff --git a/src/ipme.c b/src/ipme.c @@ -15,7 +15,11 @@ #include "byte.h" #include "ip.h" #include "ipalloc.h" +#ifdef USING_SKALIBS +#include <skalibs/stralloc.h> +#else #include "stralloc.h" +#endif static int ipmeok = 0; static int ip6meok = 0; diff --git a/src/qmail-rspawn.c b/src/qmail-rspawn.c @@ -44,10 +44,12 @@ int len; { substdio_puts(ss,"Zqmail-remote produced no output.\n"); return; } result = -1; + info = 0; j = 0; for (k = 0;k < len;++k) if (!s[k]) { + if (s[j] == 'I') { result = -2; break; }; // Informational reports have no use to rspawn. In future, they should probably be posted upchain. if (s[j] == 'K') { result = 1; break; } if (s[j] == 'Z') { result = 0; break; } if (s[j] == 'D') break; @@ -66,6 +68,7 @@ int len; case 1: substdio_put(ss,"K",1); break; case 0: substdio_put(ss,"Z",1); break; case -1: substdio_put(ss,"D",1); break; + case -2: return; // Informational reports have no use to rspawn. In future, they should probably be posted upchain. } for (k = 1;k < len;) diff --git a/src/qmail-send.c b/src/qmail-send.c @@ -709,6 +709,7 @@ Hi. This is the qmail-send (NightmareMail queue manager) program at "); I'm afraid I wasn't able to deliver your message to the following addresses.\n\ This is a permanent error. I've given up. Sorry it didn't work out.\n\ For further assistance, mail the postmaster.\n\ +NB: If you're the postmaster, these errors should mean something to you.\n\ \n\ " : ".\n\ I tried to deliver a bounce message to this address, but the bounce bounced!\n\ diff --git a/src/qmail-smtpd.c b/src/qmail-smtpd.c @@ -40,24 +40,24 @@ void flush() { substdio_flush(&ssout); } void out(s) char *s; { substdio_puts(&ssout,s); } void die_read() { _exit(1); } -void die_alarm() { out("451 Timeout (#4.4.2)\r\n"); flush(); _exit(1); } -void die_nomem() { out("421 Out of memory (#4.3.0)\r\n"); flush(); _exit(1); } -void die_control() { out("421 Unable to read controls (#4.3.0)\r\n"); flush(); _exit(1); } -void die_ipme() { out("421 Unable to figure out my IP addresses (#4.3.0)\r\n"); flush(); _exit(1); } -void die_ip6me() { out("421 Unable to figure out my IPv6 addresses (#4.3.0)\r\n"); flush(); _exit(1); } +void die_alarm() { out("451 4.4.2 Timeout\r\n"); flush(); _exit(1); } +void die_nomem() { out("421 4.3.0 Out of memory\r\n"); flush(); _exit(1); } +void die_control() { out("421 4.3.0 Unable to read controls\r\n"); flush(); _exit(1); } +void die_ipme() { out("421 4.3.0 Unable to figure out my IP addresses\r\n"); flush(); _exit(1); } +void die_ip6me() { out("421 4.3.0 Unable to figure out my IPv6 addresses\r\n"); flush(); _exit(1); } void straynewline() { out("451 You sent a stray newline. See https://cr.yp.to/docs/smtplf.html.\r\n"); flush(); _exit(1); } -void err_bmf() { out("553 Sorry, your envelope sender is in my badmailfrom list. (#5.7.1)\r\n"); } -void err_nogateway() { out("553 Sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)\r\n"); } -void err_unimpl(char *arg) { out("502 Unimplemented (#5.5.1)\r\n"); } -void err_syntax() { out("555 Syntax error (#5.5.4)\r\n"); } -void err_wantmail() { out("503 You must execute MAIL first (#5.5.1)\r\n"); } -void err_wantrcpt() { out("503 You must execute RCPT first (#5.5.1)\r\n"); } -void die_cdb() { out("421 Unable to read cdb user database (#4.3.0)\r\n"); flush(); _exit(1); } -void die_sys() { out("421 Unable to read system user database (#4.3.0)\r\n"); flush(); _exit(1); } +void err_bmf() { out("553 5.7.1 Sorry, your envelope sender is in my badmailfrom list.\r\n"); } +void err_nogateway() { out("553 5.7.1 Sorry, that domain isn't in my list of allowed rcpthosts\r\n"); } +void err_unimpl(char *arg) { out("502 5.5.1 Unimplemented\r\n"); } +void err_syntax() { out("555 5.5.4 Syntax error\r\n"); } +void err_wantmail() { out("503 5.5.1 You must execute MAIL first\r\n"); } +void err_wantrcpt() { out("503 5.5.1 You must execute RCPT first\r\n"); } +void die_cdb() { out("421 4.3.0 Unable to read cdb user database\r\n"); flush(); _exit(1); } +void die_sys() { out("421 4.3.0 Unable to read system user database\r\n"); flush(); _exit(1); } void err_noop(char *arg) { out("250 As requested, no operation performed.\r\n"); } void err_vrfy(char *arg) { out("252 Send something and we'll give it a shot.\r\n"); } -void err_qqt() { out("451 qqt failure (#4.3.0)\r\n"); } +void err_qqt() { out("451 4.3.0 qqt failure\r\n"); } void die_dnsbl(char *arg) { out("421 your ip is currently blacklisted, try to auth first ("); out(arg); out(")\r\n"); @@ -285,7 +285,9 @@ void smtp_helo(char *arg) } void smtp_ehlo(char *arg) { - smtp_greet("250-"); out("\r\n250-PIPELINING\r\n250 8BITMIME\r\n"); + smtp_greet("250-"); out("\r\n250-PIPELINING\r\n250-ENHANCEDSTATUSCODES\r\n"); + // TODO: add startTLS cutover support + out("250 8BITMIME\r\n"); seenmail = 0; dohelo(arg); } void smtp_rset(char *arg) @@ -316,7 +318,7 @@ void smtp_rcpt(char *arg) { else if (!addrallowed()) { err_nogateway(); return; } if (!realrcptto(addr.s)) { - out("550 That user has elected not to receive emails. (#5.1.1)\r\n"); + out("550 5.1.1 That user has elected not to receive emails.\r\n"); return; } if (!(relayclient || dnsblskip || flagdnsbl)) @@ -435,7 +437,7 @@ void smtp_data(char *arg) { if (!seenmail) { err_wantmail(); return; } if (!rcptto.len) { err_wantrcpt(); return; } - if (realrcptto_deny()) { out("554 sorry, no mailbox here by that name. (#5.1.1)\r\n"); return; } + if (realrcptto_deny()) { out("554 5.1.1 sorry, no mailbox here by that name.\r\n"); return; } seenmail = 0; if (databytes) bytestooverflow = databytes + 1; if (qmail_open(&qqt) == -1) { err_qqt(); return; } @@ -451,8 +453,8 @@ void smtp_data(char *arg) { qqx = qmail_close(&qqt); if (!*qqx) { acceptmessage(qp); return; } - if (hops) { out("554 too many hops, this message is looping (#5.4.6)\r\n"); return; } - if (databytes) if (!bytestooverflow) { out("552 sorry, that message size exceeds my databytes limit (#5.3.4)\r\n"); return; } + if (hops) { out("554 5.4.6 too many hops, this message is looping\r\n"); return; } + if (databytes) if (!bytestooverflow) { out("552 5.3.4 sorry, that message size exceeds my databytes limit\r\n"); return; } if (*qqx == 'D') out("554 "); else out("451 "); out(qqx + 1); out("\r\n");