From 25f74781424d5e13f0211c08cce8c2a1d60b9aec Mon Sep 17 00:00:00 2001 From: Jannis Hoffmann Date: Thu, 18 Jul 2024 14:55:05 +0200 Subject: update to 4.3.08 --- INSTALL | 6 +-- conf-cc | 2 + conf-ldap | 3 ++ man/qmail-qmaint.8 | 17 +++++-- src/Makefile | 16 +++++-- src/auto-gid.c | 4 +- src/auto-int.c | 2 +- src/auto-int8.c | 2 +- src/auto-uid.c | 4 +- src/columnt.c | 7 ++- src/control.c | 3 +- src/dkimverify.cpp | 16 +++---- src/fastforward.c | 4 +- src/matchup.c | 3 +- src/newaliases.c | 3 +- src/newinclude.c | 5 ++- src/predate.c | 3 +- src/qbiff.c | 3 +- src/qmail-authuser.c | 0 src/qmail-badloadertypes.c | 3 +- src/qmail-badmimetypes.c | 3 +- src/qmail-dksign.c | 4 +- src/qmail-dkverify.c | 4 +- src/qmail-ldapam.c | 1 + src/qmail-mfrules.c | 5 ++- src/qmail-mrtg.c | 3 +- src/qmail-newmrh.c | 3 +- src/qmail-newu.c | 3 +- src/qmail-qmaint.c | 110 ++++++++++++++++++++++++++++++++++++++------- src/qmail-qread.c | 3 +- src/qmail-recipients.c | 3 +- src/qmail-remote.c | 42 +++++++++-------- src/qmail-send.c | 32 ++++++------- src/qmail-smtpam.c | 5 ++- src/qmail-smtpd.c | 6 +-- src/qmail-start.c | 18 ++++---- src/qmail-tcpok.c | 3 +- src/qmail-tcpto.c | 3 +- src/qmail-todo.c | 11 +++-- src/recipients.c | 4 +- src/sendmail.c | 3 +- src/setmaillist.c | 3 +- src/smtpdlog.c | 4 +- src/spawn.c | 11 +++-- src/spfdnsip.c | 0 src/srsforward.c | 3 +- src/srsreverse.c | 16 +++++-- src/tai64nfrac.c | 5 ++- src/tcpto.c | 3 +- src/tcpto_clean.c | 3 +- 50 files changed, 286 insertions(+), 137 deletions(-) create mode 100644 conf-ldap mode change 100755 => 100644 src/qmail-authuser.c mode change 100755 => 100644 src/qmail-dksign.c mode change 100755 => 100644 src/qmail-smtpam.c mode change 100755 => 100644 src/qmail-smtpd.c mode change 100755 => 100644 src/smtpdlog.c mode change 100755 => 100644 src/spfdnsip.c diff --git a/INSTALL b/INSTALL index a51c6d7..1b60aa6 100644 --- a/INSTALL +++ b/INSTALL @@ -68,7 +68,6 @@ B) CONFIGURATION -DHIDEVIRTUALUSER -DDEFERREDBOUNCES -DSHOWLOG - -DBARELF b) conf-ld: Adjust architecture of executables. If you use OpenSSL/LibreSSL from sources outside the default, you need to include the link path (-L). @@ -186,9 +185,6 @@ C) INSTALLATION - DKIM private key names used for signing are shown in qmail-remote logs via option -DSHOWLOG. - - Strict RF 5821 conformance for can be - relaxed by -DBARELF (=> 'SMTP smuggling' still not possible). - - Check conf-cc for more restrictive settings. @@ -250,4 +246,4 @@ E) MISCELLANEOUS Visit https://www.fehcom.de/sqmail/sqmail.html to access online man-pages and documentation. -Date: January, 14th 2024 (feh) +Date: June, 18th 2023 (feh) diff --git a/conf-cc b/conf-cc index 307ccfc..e6d003d 100644 --- a/conf-cc +++ b/conf-cc @@ -3,6 +3,8 @@ cc -O2 -Wall -Wno-narrowing -Iinclude -I`head -1 ../conf-qlibs`/include `head -1 # This will work for both i386 and AMD64 architecture enabling INET6 support. # IDN2 support is NOT enabled by default. You do not have 'libidns2' installed and set: -DIDN2 +# Bare 'Line Feeds' (LF) are accepted by qmail-smtpd setting: -DBARELF in the first line. + # For obfuscation, you can hide the virtual user's local part for VERP addresses; inappropriate for VPOPMAIL: cc -O2 -Wall -Wno-narrowing -Iinclude -I`head -1 ../conf-qlibs`/include `head -1 ../conf-ssl` -DHIDEVIRTUALUSER diff --git a/conf-ldap b/conf-ldap new file mode 100644 index 0000000..c831149 --- /dev/null +++ b/conf-ldap @@ -0,0 +1,3 @@ +/usr/ports/net/openldap25-client/work/openldap-2.5.8/libraries/libldap/.libs + +# This is the location of the libldap.a diff --git a/man/qmail-qmaint.8 b/man/qmail-qmaint.8 index 54342b4..64694a9 100644 --- a/man/qmail-qmaint.8 +++ b/man/qmail-qmaint.8 @@ -10,6 +10,9 @@ qmail-qmaint \- queue maintenance [ .I -d messid ] +[ +.I -D +] .SH DESCRIPTION .B qmail-qmaint inspects @@ -29,6 +32,11 @@ as given by Here, only pre-processed and bounce messages are taken into consideration. +Giving +.I -D +advices a bulk removal of remnat pre- or post-processed +DKIM files in the staging area. + .B qmail-qmaint must be run either as root or with user id .I qmails @@ -51,9 +59,12 @@ It exits it has successfully inspected the queue or the message has been deleted. It may exit -99 in case of a warning, or -100 if an operation can not be completed, or -110 if a directory can not be accessed. +.I 99 +in case of a warning, or +.I 100 +if an operation can not be completed, or +.I 110 +if a directory can not be accessed. .SH "SEE ALSO" qmail-qstat(8), qmail-qread(8), diff --git a/src/Makefile b/src/Makefile index ae4801b..d560613 100644 --- a/src/Makefile +++ b/src/Makefile @@ -79,6 +79,14 @@ auto_qmail.o: \ compile auto_qmail.c ./compile auto_qmail.c +auto_queue.c: \ +auto-str ../conf-home + ./auto-str auto_queue `head -1 ../conf-home` > auto_queue.c + +auto_queue.o: \ +compile auto_queue.c + ./compile auto_queue.c + auto_spawn.c: \ auto-int ../conf-spawn ./auto-int auto_spawn `head -1 ../conf-spawn` > auto_spawn.c @@ -601,8 +609,8 @@ qmail-getpw qmail-newu qmail-pw2u qmail-newmrh ldap.lib: \ tryldap.c compile load ( ( ./compile tryldap.c && \ - ./load tryldap `head -2 ../conf-ldap | tail -1` ) >/dev/null 2>&1 \ - && echo "`head -2 ../conf-ldap | tail -1` -lldap" || exit 0 ) > ldap.lib + ./load tryldap -L`head -1 ../conf-ldap` -lldap ) >/dev/null 2>&1 \ + && echo "-L`head -1 ../conf-ldap` -lldap" || exit 0 ) > ldap.lib # rm -f tryldap.o tryldap load: \ @@ -1057,9 +1065,9 @@ compile qmail-queue.c qmail-qmaint: \ load qmail-qmaint.o auto_qmail.o auto_split.o auto_uids.o fifo.o \ -fmtqfn.o readsubdir.o qlibs.lib +fmtqfn.o readsubdir.o date822fmt.o datetime.a qlibs.lib ./load qmail-qmaint auto_qmail.o auto_split.o auto_uids.o fifo.o \ - fmtqfn.o readsubdir.o `cat qlibs.lib` + fmtqfn.o readsubdir.o date822fmt.o datetime.a `cat qlibs.lib` qmail-qmaint.o: \ compile qmail-qmaint.c diff --git a/src/auto-gid.c b/src/auto-gid.c index c5a39df..a9ac240 100644 --- a/src/auto-gid.c +++ b/src/auto-gid.c @@ -6,7 +6,7 @@ #include "scan.h" #include "fmt.h" -char inbuf[256]; +char inbuf[BUFFER_SMALL]; buffer b = BUFFER_INIT(write,1,inbuf,sizeof(inbuf)); void outs(char *s) @@ -14,7 +14,7 @@ void outs(char *s) if (buffer_puts(&b,s) == -1) _exit(111); } -int main(int argc, char **argv) +int main(int argc,char **argv) { char *name; char *value; diff --git a/src/auto-int.c b/src/auto-int.c index 58f44b2..1e6766c 100644 --- a/src/auto-int.c +++ b/src/auto-int.c @@ -5,7 +5,7 @@ #include "scan.h" #include "fmt.h" -char inbuf[256]; +char inbuf[BUFFER_SMALL]; buffer b = BUFFER_INIT(write,1,inbuf,sizeof(inbuf)); void out(char *s) diff --git a/src/auto-int8.c b/src/auto-int8.c index fd5ead6..a3580ba 100644 --- a/src/auto-int8.c +++ b/src/auto-int8.c @@ -4,7 +4,7 @@ #include "scan.h" #include "fmt.h" -char inbuf[256]; +char inbuf[BUFFER_SMALL]; buffer b = BUFFER_INIT(write,1,inbuf,sizeof(inbuf)); void out(char *s) diff --git a/src/auto-uid.c b/src/auto-uid.c index 21f469b..6d1f444 100644 --- a/src/auto-uid.c +++ b/src/auto-uid.c @@ -6,7 +6,7 @@ #include "scan.h" #include "fmt.h" -char inbuf[256]; +char inbuf[BUFFER_SMALL]; buffer b = BUFFER_INIT(write,1,inbuf,sizeof(inbuf)); void outs(char *s) /* was named puts, but Solaris pwd.h includes stdio.h. dorks. */ @@ -14,7 +14,7 @@ void outs(char *s) /* was named puts, but Solaris pwd.h includes stdio.h. dorks. if (buffer_puts(&b,s) == -1) _exit(111); } -int main(int argc, char **argv) +int main(int argc,char **argv) { char *name; char *value; diff --git a/src/columnt.c b/src/columnt.c index 9e4cf0e..b82f970 100644 --- a/src/columnt.c +++ b/src/columnt.c @@ -5,12 +5,11 @@ #include "stralloc.h" #include "exit.h" #include "readclose.h" +#include "qmail.h" #define WHO "columnt" -#define BSIZE 4096 - -char outbuf[BSIZE]; +char outbuf[BUFSIZE_MESS]; buffer bo = BUFFER_INIT(write,1,outbuf,sizeof(outbuf)); void nomem() { logmsg(WHO,111,FATAL,"out of memory"); } @@ -89,7 +88,7 @@ void split(void (*dofield)(), void (*doline)()) int main() { - if (readclose_append(0,&file,BSIZE) == -1) die_read(); + if (readclose_append(0,&file,BUFSIZE_MESS) == -1) die_read(); if (!file.len) _exit(0); if (file.s[file.len - 1] != '\n') if (!stralloc_append(&file,"\n")) nomem(); diff --git a/src/control.c b/src/control.c index 2558225..728e94b 100644 --- a/src/control.c +++ b/src/control.c @@ -8,8 +8,9 @@ #include "alloc.h" #include "scan.h" #include "error.h" +#include "qmail.h" -static char inbuf[2048]; +static char inbuf[BUFSIZE_MESS]; static stralloc line = {0}; static stralloc me = {0}; static int meok = 0; diff --git a/src/dkimverify.cpp b/src/dkimverify.cpp index c9f1003..405e4da 100644 --- a/src/dkimverify.cpp +++ b/src/dkimverify.cpp @@ -377,14 +377,14 @@ void DecodeQuotedPrintable(char* ptr) unsigned DecodeBase64(char *ptr) { static const char base64_table[256] = { - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1, - -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1, - -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255, 62,255,255,255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,255,255,255,255,255,255, + 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,255,255,255,255,255, + 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255 }; unsigned char* s = (unsigned char* )ptr; unsigned char* d = (unsigned char* )ptr; diff --git a/src/fastforward.c b/src/fastforward.c index f8a7d55..0c055cd 100644 --- a/src/fastforward.c +++ b/src/fastforward.c @@ -51,7 +51,7 @@ static void printsafe(char *s) struct qmail qq; char qp[FMT_ULONG]; -char qqbuf[1]; +char qqbuf[BUFSIZE_LINE]; ssize_t qqwrite(int fd,char *buf,int len) { @@ -93,7 +93,7 @@ void dofile(char *fn) logmsg(WHO,111,FATAL,B("unable to read: ",fn)); if ((st.st_mode & 0444) != 0444) logmsg(WHO,111,FATAL,B(fn," is not world-readable")); - if (readclose_append(fd,&mailinglist,1024) == -1) + if (readclose_append(fd,&mailinglist,BUFSIZE_LINE) == -1) logmsg(WHO,111,FATAL,B("unable to read: ",fn)); i = 0; diff --git a/src/matchup.c b/src/matchup.c index 047ea65..1dd0c51 100644 --- a/src/matchup.c +++ b/src/matchup.c @@ -11,6 +11,7 @@ #include "fmt.h" #include "scan.h" #include "case.h" +#include "qmail.h" #define WHO "matchup" @@ -28,7 +29,7 @@ void outs(char *buf) if (buffer_puts(buffer_1,buf) == -1) die_write(); } -char buf5[512]; +char buf5[BUFSIZE_AUTH]; buffer bo5 = BUFFER_INIT(write,5,buf5,sizeof(buf5)); void out5(char *buf,int len) diff --git a/src/newaliases.c b/src/newaliases.c index 98aa095..c525e5b 100644 --- a/src/newaliases.c +++ b/src/newaliases.c @@ -12,6 +12,7 @@ #include "case.h" #include "cdbmake.h" #include "byte.h" +#include "qmail.h" #define WHO "newaliases" @@ -248,7 +249,7 @@ void parseline() if (tokaddr.len) gotaddr(); } -char inbuf[1024]; +char inbuf[BUFSIZE_LINE]; buffer bi; struct cdb_make cdb; stralloc key = {0}; diff --git a/src/newinclude.c b/src/newinclude.c index 746b6a4..b1cac80 100644 --- a/src/newinclude.c +++ b/src/newinclude.c @@ -12,6 +12,7 @@ #include "auto_qmail.h" #include "byte.h" #include "env.h" +#include "qmail.h" #define WHO "newinclude" @@ -27,14 +28,14 @@ void usage() } char *fnlist; -char listbuf[1024]; +char listbuf[BUFSIZE_LINE]; buffer bi; stralloc bin = {0}; #define fnbin bin.s stralloc tmp = {0}; #define fntmp tmp.s -char tmpbuf[1024]; +char tmpbuf[BUFSIZE_LINE]; buffer bt; diff --git a/src/predate.c b/src/predate.c index f6007b3..864acc2 100644 --- a/src/predate.c +++ b/src/predate.c @@ -9,6 +9,7 @@ #include "buffer.h" #include "exit.h" #include "sig.h" +#include "qmail.h" #define WHO "predate" @@ -17,7 +18,7 @@ static char *montab[12] = { }; char num[FMT_ULONG]; -char outbuf[1024]; +char outbuf[BUFSIZE_LINE]; int main(int argc, char **argv) { diff --git a/src/qbiff.c b/src/qbiff.c index b9b55bf..92198e0 100644 --- a/src/qbiff.c +++ b/src/qbiff.c @@ -23,13 +23,14 @@ #include "hfield.h" #include "env.h" #include "exit.h" +#include "qmail.h" buffer b; #ifdef HASUTMP char bufutmp[sizeof(struct utmp) * 16]; int fdutmp; #endif -char buftty[1024]; +char buftty[BUFSIZE_LINE]; int fdtty; #ifdef HASUTMP diff --git a/src/qmail-authuser.c b/src/qmail-authuser.c old mode 100755 new mode 100644 diff --git a/src/qmail-badloadertypes.c b/src/qmail-badloadertypes.c index 3472fd5..6edbbfb 100644 --- a/src/qmail-badloadertypes.c +++ b/src/qmail-badloadertypes.c @@ -9,6 +9,7 @@ #include "open.h" #include "auto_qmail.h" #include "cdbmake.h" +#include "qmail.h" #define WHO "qmail-badloadertypes" #define LOADER_LEN 5 @@ -24,7 +25,7 @@ void die_write() logmsg(WHO,111,FATAL,"unable to write to control/badloadertypes.tmp"); } -char inbuf[1024]; +char inbuf[BUFSIZE_LINE]; buffer b; int fd; diff --git a/src/qmail-badmimetypes.c b/src/qmail-badmimetypes.c index a75ad4c..40de4a3 100644 --- a/src/qmail-badmimetypes.c +++ b/src/qmail-badmimetypes.c @@ -8,6 +8,7 @@ #include "open.h" #include "auto_qmail.h" #include "cdbmake.h" +#include "qmail.h" #define WHO "qmail-badmimetypes" #define MIMETYPE_LEN 9 @@ -23,7 +24,7 @@ void die_write() logmsg(WHO,111,FATAL,"unable to write to control/badmimetypes.tmp"); } -char inbuf[1024]; +char inbuf[BUFSIZE_LINE]; buffer b; int fd; diff --git a/src/qmail-dksign.c b/src/qmail-dksign.c old mode 100755 new mode 100644 index 406afc1..f5d4895 --- a/src/qmail-dksign.c +++ b/src/qmail-dksign.c @@ -200,7 +200,7 @@ void dkim_stage() int fd; int in, out; struct stat st; - unsigned char tmpbuf[BUFSIZE_MESS + 2]; // intermediate write buffer + char tmpbuf[BUFSIZE_MESS + 2]; // intermediate write buffer if (!stralloc_ready(&fndkin,FMTQFN)) temp_nomem(); if (!stralloc_ready(&fndkout,FMTQFN)) temp_nomem(); @@ -213,7 +213,7 @@ void dkim_stage() buffer_init(&bi,read,0,inbuf,sizeof(inbuf)); buffer_init(&bo,write,fd,outbuf,sizeof(outbuf)); - while((r = buffer_get(&bi,inbuf,sizeof(inbuf)))) { // read into buffer + while ((r = buffer_get(&bi,inbuf,sizeof(inbuf)))) { // read into buffer if (r == -1) temp_read(); for (in = out = 0; in < r; in++) { diff --git a/src/qmail-dkverify.c b/src/qmail-dkverify.c index 2cfe00a..be73a80 100644 --- a/src/qmail-dkverify.c +++ b/src/qmail-dkverify.c @@ -122,7 +122,7 @@ void dkim_stage() buffer_init(&bi,read,0,inbuf,sizeof(inbuf)); buffer_init(&bo,write,fd,outbuf,sizeof(outbuf)); - while((r = buffer_get(&bi,inbuf,sizeof(inbuf)))) { // read into buffer + while ((r = buffer_get(&bi,inbuf,sizeof(inbuf)))) { // read into buffer if (r == -1) temp_read(); for (in = out = 0; in < r; in++) { // reconstruct CRLF (ok) @@ -274,7 +274,7 @@ int qmail_queue() int wstat; int pi[2]; char *(args[2]); - char tmpbuf[BUFSIZE_MESS]; + char tmpbuf[BUFSIZE_MESS + 2]; int in, out; if (pipe(pi) == -1) die_pipe(fndkin.s); diff --git a/src/qmail-ldapam.c b/src/qmail-ldapam.c index 2d5b78f..624b39e 100644 --- a/src/qmail-ldapam.c +++ b/src/qmail-ldapam.c @@ -1,3 +1,4 @@ +#define LDAP_DEPRECATE 1 #include #include #include diff --git a/src/qmail-mfrules.c b/src/qmail-mfrules.c index e8cfc94..572313f 100644 --- a/src/qmail-mfrules.c +++ b/src/qmail-mfrules.c @@ -1,11 +1,11 @@ #include #include // rename +#include #include "logmsg.h" #include "stralloc.h" #include "buffer.h" #include "getln.h" #include "exit.h" -#include #include "open.h" #include "auto_qmail.h" #include "cdbmake.h" @@ -13,6 +13,7 @@ #include "scan.h" #include "byte.h" #include "case.h" +#include "qmail.h" #define WHO "qmail-mfrules" @@ -23,7 +24,7 @@ stralloc data = {0}; stralloc key = {0}; stralloc line = {0}; -char inbuf[1024]; +char inbuf[BUFSIZE_LINE]; buffer bi; int fd; diff --git a/src/qmail-mrtg.c b/src/qmail-mrtg.c index c956196..1583052 100644 --- a/src/qmail-mrtg.c +++ b/src/qmail-mrtg.c @@ -11,6 +11,7 @@ #include "str.h" #include "datetime.h" #include "logmsg.h" +#include "qmail.h" #define WHO "qmail-mrtg" #define TAI64NLEN 24 @@ -93,7 +94,7 @@ static void out(int i) if (buffer_flush(&bo) == -1) _exit(1); } -char bufspace[1024]; +char bufspace[BUFSIZE_LINE]; buffer bi = BUFFER_INIT(read,0,bufspace,sizeof(bufspace)); void mrtg_results(char flag) diff --git a/src/qmail-newmrh.c b/src/qmail-newmrh.c index 4a74698..eaeac5f 100644 --- a/src/qmail-newmrh.c +++ b/src/qmail-newmrh.c @@ -10,6 +10,7 @@ #include "auto_qmail.h" #include "cdbmake.h" #include "case.h" +#include "qmail.h" #define WHO "qmail-newmrh" @@ -24,7 +25,7 @@ void die_write() logmsg(WHO,111,ERROR,"unable to write to control/morercpthosts.tmp"); } -char inbuf[1024]; +char inbuf[BUFSIZE_LINE]; buffer bi; int fd; diff --git a/src/qmail-newu.c b/src/qmail-newu.c index d5e9baa..db410c5 100644 --- a/src/qmail-newu.c +++ b/src/qmail-newu.c @@ -11,6 +11,7 @@ #include "case.h" #include "byte.h" #include "auto_qmail.h" +#include "qmail.h" #define WHO "qmail-newu" @@ -53,7 +54,7 @@ struct cdb_make cdb; stralloc key = {0}; stralloc data = {0}; -char inbuf[1024]; +char inbuf[BUFSIZE_LINE]; buffer bi; int fd; diff --git a/src/qmail-qmaint.c b/src/qmail-qmaint.c index e83ab6f..02304e7 100644 --- a/src/qmail-qmaint.c +++ b/src/qmail-qmaint.c @@ -22,6 +22,8 @@ #include "auto_qmail.h" #include "auto_split.h" #include "auto_uids.h" +#include "datetime.h" +#include "date822fmt.h" #define WHO "qmail-qmaint" @@ -32,7 +34,9 @@ stralloc temp_filename = {0}; /*temporary used for checking individuals*/ stralloc old_name = {0}; /*used in rename*/ stralloc new_name = {0}; /*used in rename*/ stralloc mess_dir = {0}; /*used for renaming in mess dir*/ +stralloc dkim_dir = {0}; /*used for cleaning up dkim dir*/ stralloc query = {0}; /*used in interactive query function*/ +stralloc birth_date = {0}; /*used to display dkim messages*/ char strnum[FMT_ULONG]; int flag_interactive = 0; @@ -78,6 +82,18 @@ void die_nomem() logmsg(WHO,110,ERROR,"Out of memory."); } +void err_unlink(unsigned long id) +{ + char foo[FMT_ULONG]; + foo[fmt_ulong(foo,id)] = 0; + logmsg(WHO,100,ERROR,B("trouble with unlinking #",foo)); +} + +void err_chdir() +{ + logmsg(WHO,110,FATAL,"unable to chdir"); +} + /*returns 1==yes, 0==no*/ int confirm() @@ -321,6 +337,72 @@ int rename_mess(char *dir, char *part, char *new_part, char *old_filename, char return 0; } +unsigned int datefmt(char *s,datetime_sec when) +{ + unsigned int i; + unsigned int len; + struct datetime dt; + datetime_tai(&dt,when); + len = 0; + i = fmt_str(s," Date: "); len += i; if (s) s += i; + i = date822fmt(s,&dt); len += i; if (s) s += i; + return len; +} + +int date_make(datetime_sec when) +{ + if (!stralloc_ready(&birth_date,datefmt(FMT_LEN,when))) return 0; + birth_date.len = datefmt(birth_date.s,when); + return 1; +} + +int cleanup_dkim() +{ + DIR *dir; + direntry *d; + struct stat st; + int deleted = 0; + unsigned long id; + + if (chdir(auto_qmail) == -1) err_chdir(); + if (chdir("queue") == -1) err_chdir(); + if (chdir("dkim") == -1) return 0; + + if (!stralloc_copy(&dkim_dir,&queue_dir)) die_nomem(); + if (!stralloc_cats(&dkim_dir,"dkim/")) die_nomem(); + + for (int i = 0; i < split_num; i++) { + strnum[fmt_uint(strnum,i)] = 0; + if (!stralloc_copy(&temp_dirname,&dkim_dir)) die_nomem(); + if (!stralloc_cats(&temp_dirname,strnum)) die_nomem(); + if (!stralloc_append(&temp_dirname,"/")) die_nomem(); + + dir = opendir(temp_dirname.s); + if (!dir) continue; + + while ((d = readdir(dir))) { + if (d->d_name[0] == '.') continue; + /*check for dkim remnant */ + if (!stralloc_copy(&temp_filename,&temp_dirname)) die_nomem(); + if (!stralloc_cats(&temp_filename,d->d_name)) die_nomem(); + if (!stralloc_0(&temp_filename)) die_nomem(); + + if (stat(temp_filename.s,&st) == -1) continue; + date_make(st.st_mtime); + // message + logmsg(WHO,0,INFO,B("Deleting DKIM remnant message: ",temp_filename.s,birth_date.s)); + // delete + if (unlink(temp_filename.s) == -1) { + logmsg(WHO,111,ERROR,B("Can't remove file: ",temp_filename.s)); + } + // counter + ++deleted; + } + } + + return deleted; +} + int fix_part(char *part) { DIR *dir; @@ -359,6 +441,7 @@ int fix_part(char *part) /*rename*/ inode[fmt_ulong(inode,st.st_ino)] = 0; new_part[fmt_ulong(new_part,correct_part_num)] = 0; + if (rename_mess("dkim/",part,new_part,d->d_name,inode)) { closedir(dir); return -1; } if (rename_mess("mess/",part,new_part,d->d_name,inode)) { closedir(dir); return -1; } if (rename_mess("info/",part,new_part,d->d_name,inode)) { closedir(dir); return -1; } if (rename_mess("local/",part,new_part,d->d_name,inode)) { closedir(dir); return -1; } @@ -497,18 +580,6 @@ void warn_unlink(unsigned long id) logmsg(WHO,99,WARN,B("no such file to unlink #",foo)); } -void err_unlink(unsigned long id) -{ - char foo[FMT_ULONG]; - foo[fmt_ulong(foo,id)] = 0; - logmsg(WHO,100,ERROR,B("trouble with unlinking #",foo)); -} - -void err_chdir() -{ - logmsg(WHO,110,FATAL,"unable to chdir"); -} - int delete_msg(unsigned long id) { struct stat st; @@ -553,16 +624,21 @@ int main(int argc, char **argv) { char *mess = 0; unsigned long id = 0; + unsigned int n; + if (argc > 1) { if (!str_diff(argv[1],"-i")) { flag_interactive = 1; } else if (!str_diff(argv[1],"-d")) { - if (!argv[2]) logmsg(WHO,111,USAGE,"qmail-qmaint [-i] || [-d messid]"); + if (!argv[2]) logmsg(WHO,111,USAGE,"qmail-qmaint [-i] || [-d messid] || [-D]"); mess = argv[2]; flag_delete = 1; scan_ulong(mess,&id); - } + } else if (!str_diff(argv[1],"-D")) { + flag_delete = 2; + } else + logmsg(WHO,111,USAGE,"qmail-qmaint [-i] || [-d messid] || [-D]"); } if (!stralloc_copys(&queue_dir,auto_qmail)) die_nomem(); @@ -582,9 +658,13 @@ int main(int argc, char **argv) if (check_dirs()) die_check(); - if (flag_delete) { + if (flag_delete == 1) { if (!delete_msg(id)) logmsg(WHO,0,INFO,B("file ",mess," from queue deleted.")); + } else if (flag_delete == 2) { + n = cleanup_dkim(); + strnum[fmt_uint(strnum,n)] = 0; + logmsg(WHO,0,INFO,B(strnum," DKIM staging files from queue deleted.")); } else if (fix_names()) die_check(); diff --git a/src/qmail-qread.c b/src/qmail-qread.c index 888c14a..664bde2 100644 --- a/src/qmail-qread.c +++ b/src/qmail-qread.c @@ -13,6 +13,7 @@ #include "date822fmt.h" #include "error.h" #include "exit.h" +#include "qmail.h" readsubdir rs; @@ -46,7 +47,7 @@ char fnlocal[FMTQFN]; char fnremote[FMTQFN]; char fnbounce[FMTQFN]; -char inbuf[1024]; +char inbuf[BUFSIZE_LINE]; stralloc sender = {0}; unsigned long id; diff --git a/src/qmail-recipients.c b/src/qmail-recipients.c index 058994a..7fbf996 100644 --- a/src/qmail-recipients.c +++ b/src/qmail-recipients.c @@ -9,6 +9,7 @@ #include "case.h" #include "auto_qmail.h" #include "cdbmake.h" +#include "qmail.h" #define WHO "qmail-recipients" @@ -23,7 +24,7 @@ void die_write() logmsg(WHO,111,ERROR,"unable to write to users/recipients.tmp"); } -char inbuf[1024]; +char inbuf[BUFSIZE_LINE]; buffer b; int fd; diff --git a/src/qmail-remote.c b/src/qmail-remote.c index d2f08dd..fc90cd4 100644 --- a/src/qmail-remote.c +++ b/src/qmail-remote.c @@ -42,7 +42,7 @@ #include "uint_t.h" #define WHO "qmail-remote" - + #define QMTP_MAX 200000000 /* 190 MB for QMTP */ #define HUGESMTPTEXT 1000 /* RFC 5322; was 5000 chars/line */ #define PORT_SMTP 25 /* silly rabbit, /etc/services is for users */ @@ -166,14 +166,14 @@ void temp_osip() } void temp_noconn() { - out("ZSorry, I wasn't able to establish an SMTP connection: "); + out("ZSorry, I wasn't able to establish a SMTP connection: "); outsafe(&canonhost); out(". (#4.3.0)\n"); zerodie(); } void temp_qmtpnoc() { - out("ZSorry, I wasn't able to establish an QMTP connection: "); + out("ZSorry, I wasn't able to establish a QMTP connection: "); outsafe(&canonhost); out(". (#4.3.1)\n"); zerodie(); @@ -313,7 +313,7 @@ ssize_t safewrite(int fd,char *buf,int len) char inbuf[BUFSIZE_LINE]; buffer bi = BUFFER_INIT(read,0,inbuf,sizeof(inbuf)); -char outbuf[BUFSIZE_MESS]; +char outbuf[BUFSIZE_LINE]; buffer bo = BUFFER_INIT(safewrite,-1,outbuf,sizeof(outbuf)); char frombuf[BUFFER_SMALL]; buffer bf = BUFFER_INIT(saferead,-1,frombuf,sizeof(frombuf)); @@ -478,9 +478,10 @@ int starttls_peer() { int i = 0; - if (smtptext.len > 16) - for (i = 0; i < smtptext.len - 8; ++i) - if (case_starts(smtptext.s + i,"STARTTLS")) return 1; + while ((i += str_chr(smtptext.s + i,'\n') + 1) && + (i + 8 < smtptext.len) ) { + if (!str_diffn(smtptext.s + i + 4,"STARTTLS",8)) return 1; + } return 0; } @@ -489,7 +490,7 @@ void tls_peercheck() { X509 *cert; STACK_OF(X509) *certs; - + cert = SSL_get_peer_certificate(ssl); if (!cert) { flagtls = 100; return; } @@ -597,10 +598,12 @@ int flagsize = 0; int smtp_size() { int i; - if (smtptext.len > 10) - for (i = 0; i < smtptext.len; ++i) { - if (case_starts(smtptext.s + i,"SIZE ")) return 1; - } + + while ((i += str_chr(smtptext.s + i,'\n') + 1) && + (i + 8 <= smtptext.len) ) { + if (!str_diffn(smtptext.s + i + 4,"SIZE",4)) return 1; + } + return 0;; } @@ -814,15 +817,18 @@ void smtp_auth() { int i; - if (smtptext.len > 8) - for (i = 4; i < smtptext.len - 5; ++i) { - if (case_starts(smtptext.s + i,"CRAM")) + while ((i += str_chr(smtptext.s + i,'\n') + 1) && + (i + 8 < smtptext.len) ) { + if (!case_diffb(smtptext.s + i + 4,"AUTH",4)) { + if (case_starts(smtptext.s + i + 9,"CRAM")) if (mailfrom_cram() >= 0) return; - if (case_starts(smtptext.s + i,"LOGIN")) + if (case_starts(smtptext.s + i + 9,"LOGIN")) if (mailfrom_login() >= 0) return; - if (case_starts(smtptext.s + i,"PLAIN")) + if (case_starts(smtptext.s + i + 9,"PLAIN")) if (mailfrom_plain() >= 0) return; } + } + err_authprot(); mailfrom(); } @@ -899,7 +905,7 @@ void smtp() if (code >= 400) quit("Z"," failed on DATA command"); buffer_putflush(&bo,header.s,header.len); - + blast(); code = smtpcode(); flagcritical = 0; diff --git a/src/qmail-send.c b/src/qmail-send.c index fa241bf..026161f 100644 --- a/src/qmail-send.c +++ b/src/qmail-send.c @@ -69,17 +69,17 @@ int flagreadasap = 0; void sighup() { flagreadasap = 1; } void cleandied() { - log1s("alert: lost connection to qmail-clean ... exiting\n"); - flagexitasap = 1; + log1s("alert: lost connection to qmail-clean ... exiting\n"); + flagexitasap = 1; } int flagspawnalive[CHANNELS]; void spawndied(int c) { - log1s("alert: oh no! lost spawn connection! dying...\n"); - flagspawnalive[c] = 0; - flagexitasap = 1; + log1s("alert: oh no! lost spawn connection! dying...\n"); + flagspawnalive[c] = 0; + flagexitasap = 1; } #define REPORTMAX 10000 @@ -95,8 +95,8 @@ char fnmake_strnum[FMT_ULONG]; void fnmake_init() { - while (!stralloc_ready(&fn,FMTQFN)) nomem(); - while (!stralloc_ready(&fn2,FMTQFN)) nomem(); + while (!stralloc_ready(&fn,FMTQFN)) nomem(); + while (!stralloc_ready(&fn2,FMTQFN)) nomem(); } void fnmake_info(unsigned long id) { fn.len = fmtqfn(fn.s,"info/",id,1); } @@ -144,7 +144,7 @@ int getinfo(stralloc *sa,datetime_sec *dt,unsigned long id) struct stat st; static stralloc line = {0}; int match; - char buf[128]; + char buf[BUFFER_SMALL]; buffer b; fnmake_info(id); @@ -166,8 +166,10 @@ int getinfo(stralloc *sa,datetime_sec *dt,unsigned long id) /* this file is too long ------------------------------------- COMMUNICATION */ -buffer toqc; char toqcbuf[1024]; -buffer fromqc; char fromqcbuf[1024]; +buffer toqc; +char toqcbuf[BUFSIZE_LINE]; +buffer fromqc; +char fromqcbuf[BUFSIZE_LINE]; stralloc comm_buf[CHANNELS] = { {0}, {0} }; int comm_pos[CHANNELS]; @@ -573,8 +575,8 @@ int injectbounce(unsigned long id) int r; int fd; buffer bi; - char buf[128]; - char inbuf[128]; + char buf[BUFFER_SMALL]; + char inbuf[BUFFER_SMALL]; static stralloc sender = {0}; static stralloc quoted = {0}; datetime_sec birth; @@ -719,7 +721,7 @@ unsigned int concurrency[CHANNELS] = { 10, 20 }; unsigned int concurrencyused[CHANNELS] = { 0, 0 }; struct del *d[CHANNELS]; stralloc dline[CHANNELS]; -char delbuf[2048]; +char delbuf[BUFSIZE_MESS]; void del_status() { @@ -921,7 +923,7 @@ struct int fd; /* defined if id; reading from {local,remote} */ seek_pos mpos; /* defined if id; mark position */ buffer b; - char buf[128]; + char buf[BUFFER_SMALL]; } pass[CHANNELS]; @@ -1137,7 +1139,7 @@ void pass_do() /* this file is too long ------------------------------------- EXTERNAL TODO */ stralloc todoline = {0}; -char todobuf[2048]; +char todobuf[BUFSIZE_MESS]; int todofdin; int todofdout; int flagtodoalive; diff --git a/src/qmail-smtpam.c b/src/qmail-smtpam.c old mode 100755 new mode 100644 index e9566e0..f5247dc --- a/src/qmail-smtpam.c +++ b/src/qmail-smtpam.c @@ -33,6 +33,7 @@ #include "tls_errors.h" #include "tls_timeoutio.h" #include "uint_t.h" +#include "qmail.h" #define MAX_SIZE 200000000 #define HUGESMTPTEXT 5000 @@ -209,9 +210,9 @@ ssize_t safewrite(int fd,char *buf,int len) return r; } -char outbuf[1450]; +char outbuf[BUFSIZE_LINE]; buffer bo = BUFFER_INIT(safewrite,-1,outbuf,sizeof(outbuf)); -char frombuf[128]; +char frombuf[BUFFER_SMALL]; buffer bi = BUFFER_INIT(saferead,-1,frombuf,sizeof(frombuf)); stralloc smtptext = {0}; diff --git a/src/qmail-smtpd.c b/src/qmail-smtpd.c old mode 100755 new mode 100644 index b629948..3ca302c --- a/src/qmail-smtpd.c +++ b/src/qmail-smtpd.c @@ -78,7 +78,7 @@ ssize_t saferead(int fd,char *buf,int len) return r; } -char inbuf[BUFSIZE_LINE]; +char inbuf[BUFSIZE_MESS]; buffer bi = BUFFER_INIT(saferead,FDIN,inbuf,sizeof(inbuf)); char outbuf[BUFSIZE_LINE]; @@ -677,7 +677,7 @@ int bmfcheck() if (!stralloc_append(&eddr,"=")) die_nomem(); if (!stralloc_0(&eddr)) die_nomem(); case_lowerb(eddr.s,eddr.len); - if (str_diffn(remotehost + rlen - dlen,eddr.s + at + 1,dlen)) + if (case_diffb(remotehost + rlen - dlen,eddr.s + at + 1,dlen)) if (constmap(&mapbmf,eddr.s + at,eddr.len - at - 1)) return -3; /* '~' extended address for MISMATCHED Domains */ @@ -798,7 +798,7 @@ int localaddr(char *mf) case_lowerb(localmfcheck,str_len(localmfcheck)); at = byte_rchr(mf,mflen,'@'); if (at < mflen) - if (!str_diffn(localmfcheck,mf + at + 1,mflen - at - 1)) return 2; + if (!case_diffb(localmfcheck,mf + at + 1,mflen - at - 1)) return 2; } if (addrallowed(mf)) return 3; return -2; diff --git a/src/qmail-start.c b/src/qmail-start.c index 7a7342c..4ff0f23 100644 --- a/src/qmail-start.c +++ b/src/qmail-start.c @@ -7,7 +7,7 @@ char *(qsargs[]) = { "qmail-send", 0 }; char *(qcargs[]) = { "qmail-clean", 0 }; -char *(qlargs[]) = { "qmail-lspawn", "./Mailbox", 0 }; +char *(qlargs[]) = { "qmail-lspawn", "./Maildir/", 0 }; char *(qrargs[]) = { "qmail-rspawn", 0 }; char *(qtargs[]) = { "qmail-todo", 0}; @@ -55,7 +55,7 @@ int main(int argc,char **argv) if (fd_copy(8,0) == -1) die(); if (argv[1]) { - qlargs[1] = argv[1]; + qlargs[1] = argv[1]; // Mailbox or Maildir ++argv; } @@ -70,7 +70,7 @@ int main(int argc,char **argv) close(pi0[1]); if (fd_move(0,pi0[0]) == -1) die(); closefds(); - execvp(argv[1],argv + 1); + execvp(argv[1],argv + 1); // logger die(); } close(pi0[0]); @@ -95,7 +95,7 @@ int main(int argc,char **argv) if (fd_copy(1,pi2[1]) == -1) die(); closefds(); closepipes(); - execvp(*qlargs,qlargs); + execvp(*qlargs,qlargs); // qmail-lspawn die(); } @@ -107,7 +107,7 @@ int main(int argc,char **argv) if (fd_copy(1,pi4[1]) == -1) die(); closefds(); closepipes(); - execvp(*qrargs,qrargs); + execvp(*qrargs,qrargs); // qmail-respawn die(); } @@ -119,7 +119,7 @@ int main(int argc,char **argv) if (fd_copy(1,pi6[1]) == -1) die(); closefds(); closepipes(); - execvp(*qcargs,qcargs); + execvp(*qcargs,qcargs); // qmail-clean die(); } @@ -133,7 +133,7 @@ int main(int argc,char **argv) if (fd_copy(2,pi9[1]) == -1) die(); if (fd_copy(3,pi10[0]) == -1) die(); closepipes(); - execvp(*qtargs,qtargs); + execvp(*qtargs,qtargs); // qmail-todo die(); } @@ -145,7 +145,7 @@ int main(int argc,char **argv) if (fd_copy(1,pi10[1]) == -1) die(); closefds(); closepipes(); - execvp(*qcargs,qcargs); + execvp(*qcargs,qcargs); // qmail-clean die(); } @@ -160,6 +160,6 @@ int main(int argc,char **argv) if (fd_copy(7,pi7[1]) == -1) die(); if (fd_copy(8,pi8[0]) == -1) die(); closepipes(); - execvp(*qsargs,qsargs); + execvp(*qsargs,qsargs); // qmail-send die(); } diff --git a/src/qmail-tcpok.c b/src/qmail-tcpok.c index 2935f17..9447844 100644 --- a/src/qmail-tcpok.c +++ b/src/qmail-tcpok.c @@ -5,10 +5,11 @@ #include #include "auto_qmail.h" #include "exit.h" +#include "qmail.h" #define WHO "qmail-tcpok" -char buf[1024]; /* XXX: must match size in tcpto_clean.c, tcpto.c */ +char buf[BUFSIZE_LINE]; /* XXX: must match size in tcpto_clean.c, tcpto.c */ buffer bo; int main() diff --git a/src/qmail-tcpto.c b/src/qmail-tcpto.c index e148c55..c735479 100644 --- a/src/qmail-tcpto.c +++ b/src/qmail-tcpto.c @@ -14,6 +14,7 @@ #include "stralloc.h" #include "open.h" #include "logmsg.h" +#include "qmail.h" #define WHO "qmail-tcpto" @@ -34,7 +35,7 @@ void die_open() { logmsg(WHO,112,FATAL,"unable to open tcpto"); } void die_lock() { logmsg(WHO,112,FATAL,"unable to lock tcpto"); } void die_read() { logmsg(WHO,112,FATAL,"unable to read tcpto"); } -char tcpto_buf[1024]; +char tcpto_buf[BUFSIZE_LINE]; char tmp[FMT_ULONG + IPFMT]; diff --git a/src/qmail-todo.c b/src/qmail-todo.c index 6b6e1d4..0abb10e 100644 --- a/src/qmail-todo.c +++ b/src/qmail-todo.c @@ -39,6 +39,7 @@ char strnum[FMT_ULONG]; /* XXX not good, if qmail-send.c changes this has to be updated */ #define CHANNELS 2 +#define BUF_CHANNELS 1024 char *chanaddr[CHANNELS] = { "local/", "remote/" }; datetime_sec recent; @@ -137,8 +138,10 @@ int rewrite(char *recip) /* this file is not so long --------------------------------- COMMUNICATION */ -buffer toqc; char toqcbuf[1024]; -buffer fromqc; char fromqcbuf[1024]; +buffer toqc; +char toqcbuf[BUFSIZE_LINE]; +buffer fromqc; +char fromqcbuf[BUFSIZE_LINE]; stralloc comm_buf = {0}; int comm_pos; int fdout = -1; @@ -187,7 +190,7 @@ void comm_init(void) /* this is so stupid: NDELAY semantics should be default on write */ senddied(); /* drastic, but better than risking deadlock */ - while (!stralloc_ready(&comm_buf,1024)) nomem(); + while (!stralloc_ready(&comm_buf,BUF_CHANNELS)) nomem(); } int comm_canwrite(void) @@ -337,7 +340,7 @@ readsubdir todosubdir; stralloc todoline = {0}; char todobuf[BUFSIZE_MESS]; char todobufinfo[BUFSIZE_MESS]; -char todobufchan[CHANNELS][1024]; +char todobufchan[CHANNELS][BUF_CHANNELS]; void todo_init(void) { diff --git a/src/recipients.c b/src/recipients.c index 955dbd0..40d7ffe 100644 --- a/src/recipients.c +++ b/src/recipients.c @@ -13,6 +13,8 @@ #include "case.h" #include "buffer.h" #include "auto_break.h" +#include "qmail.h" + #define FDAUTH 3 static stralloc key = {0}; @@ -50,7 +52,7 @@ int recipients_init() return 0; } -char rcptbuf[512]; +char rcptbuf[BUFSIZE_AUTH]; buffer br = BUFFER_INIT(safewrite,FDAUTH,rcptbuf,sizeof(rcptbuf)); int callapam(char *pam,char *addr) diff --git a/src/sendmail.c b/src/sendmail.c index 69971e3..523bea7 100644 --- a/src/sendmail.c +++ b/src/sendmail.c @@ -17,7 +17,7 @@ void nomem() void die_usage() { - logmsg(WHO,100,USAGE,"sendmail [ -t ] [ -fsender ] [ -Fname ] [ -bp ] [ -bs ] [ arg ... ]\n"); + logmsg(WHO,100,USAGE,"sendmail [ -t ] [ -fsender ] [ -Fname ] [ -bp ] [ -ba ] [ -bs ] [ arg ... ]\n"); } char *smtpdarg[] = { "bin/qmail-smtpd", 0 }; @@ -122,6 +122,7 @@ int main(int argc, char **argv) case 'b': switch (optarg[0]) { case 'm': break; + case 'a': mailq(); case 'p': mailq(); case 's': smtpd(); default: die_usage(); diff --git a/src/setmaillist.c b/src/setmaillist.c index f7ac89b..cd820b3 100644 --- a/src/setmaillist.c +++ b/src/setmaillist.c @@ -6,6 +6,7 @@ #include "getln.h" #include "open.h" #include "byte.h" +#include "qmail.h" #define WHO "setmaillist" @@ -22,7 +23,7 @@ int match; char *fnbin; char *fntmp; int fd; -char buf[1024]; +char buf[BUFSIZE_LINE]; buffer bo; void writeerr() diff --git a/src/smtpdlog.c b/src/smtpdlog.c old mode 100755 new mode 100644 index 1b44af1..dd9911d --- a/src/smtpdlog.c +++ b/src/smtpdlog.c @@ -6,6 +6,8 @@ #include "fmt.h" #include "exit.h" #include "smtpdlog.h" +#include "qmail.h" + #define FDLOG 2 char *reply421pgl; @@ -20,7 +22,7 @@ char *reply553inv; char *reply554cnt; static char strnum[FMT_ULONG]; -static char logbuf[512]; +static char logbuf[BUFSIZE_LINE]; buffer bo2 = BUFFER_INIT(write,FDLOG,logbuf,sizeof(logbuf)); void smtpdlog_init() diff --git a/src/spawn.c b/src/spawn.c index effcb26..f7f6f93 100644 --- a/src/spawn.c +++ b/src/spawn.c @@ -16,6 +16,9 @@ #include "auto_qmail.h" #include "auto_uids.h" #include "auto_spawn.h" +#include "qmail.h" + +#define BUF_COMMANDS 1024 extern int truncreport; extern int spawn(); @@ -64,7 +67,7 @@ ssize_t okwrite(int fd,char *buf,int n) } int flagreading = 1; -char outbuf[1024]; +char outbuf[BUFSIZE_LINE]; buffer bo; int stage = 0; /* reading 0:delnum 1:messid 2:sender 3:recip */ @@ -148,7 +151,7 @@ void docmd() d[delnum].used = 1; } -char cmdbuf[1024]; +char cmdbuf[BUF_COMMANDS]; void getcmd() { @@ -188,7 +191,7 @@ void getcmd() } } -char inbuf[128]; +char inbuf[BUFFER_SMALL]; int main(int argc,char **argv) { @@ -248,7 +251,7 @@ int main(int argc,char **argv) if (d[i].used) if (FD_ISSET(d[i].fdin,&rfds)) { - r = read(d[i].fdin,inbuf,128); + r = read(d[i].fdin,inbuf,BUFFER_SMALL); if (r == -1) continue; /* read error on a readable pipe? be serious */ if (r == 0) { diff --git a/src/spfdnsip.c b/src/spfdnsip.c old mode 100755 new mode 100644 diff --git a/src/srsforward.c b/src/srsforward.c index 46176b5..37b4fe1 100644 --- a/src/srsforward.c +++ b/src/srsforward.c @@ -14,6 +14,7 @@ #include "stralloc.h" #include "logmsg.h" #include "srs2.h" +#include "qmail.h" #define WHO "srsforward" @@ -62,7 +63,7 @@ int main(int argc,char **argv) srs_t *srs; stralloc cookie = {0}; char separator = '='; - char srssender[512]; + char srssender[BUFSIZE_AUTH]; char *host = 0; char *sender = 0; char *dtline = 0; diff --git a/src/srsreverse.c b/src/srsreverse.c index d9b57db..fd089f4 100644 --- a/src/srsreverse.c +++ b/src/srsreverse.c @@ -16,6 +16,7 @@ #include "stralloc.h" #include "logmsg.h" #include "srs2.h" +#include "qmail.h" #define WHO "srsreverse" @@ -53,7 +54,7 @@ ssize_t mywrite(int fd,char *buf,int len) return len; } -char inbuf[BUFSIZE_LINE]; +char inbuf[BUFSIZE_MESS]; char outbuf[BUFSIZE_LINE]; buffer bi = BUFFER_INIT(read,0,inbuf,sizeof(inbuf)); buffer bo = BUFFER_INIT(mywrite,-1,outbuf,sizeof(outbuf)); @@ -64,12 +65,13 @@ int main() { int i, j, r; char *recipient; + char *sender; char *dtline; char *qqx; srs_t *srs; stralloc cookie = {0}; char separator = '='; - char srsrecipient[512]; + char srsrecipient[BUFSIZE_AUTH]; char *host = 0; sig_pipeignore(); @@ -77,6 +79,9 @@ int main() recipient = env_get("RECIPIENT"); if (!recipient) logmsg(WHO,100,FATAL,"RECIPIENT not set"); + sender = env_get("SENDER"); + if (!sender) + logmsg(WHO,100,FATAL,"SENDER not set"); dtline = env_get("DTLINE"); if (!dtline) logmsg(WHO,100,FATAL,"DTLINE not set"); @@ -150,8 +155,11 @@ int main() } } - if ((r = srs_reverse(srs,srsrecipient,sizeof(srsrecipient),recipient)) != SRS_SUCCESS) { - logmsg(WHO,100,FATAL,B("unable to reverse: ",recipient," ",srs_strerror(r))); + switch ((r = srs_reverse(srs,srsrecipient,sizeof(srsrecipient),recipient))) { + case SRS_SUCCESS: break; + case SRS_ENOTSRSADDRESS: + logmsg(WHO,99,INFO,B("unable to reverse and mail bounced to: ",sender)); break; + default: logmsg(WHO,100,FATAL,B("unable to reverse: ",recipient," ",srs_strerror(r))); } if (qmail_open(&qqt) == -1) diff --git a/src/tai64nfrac.c b/src/tai64nfrac.c index f3db977..c93f7d6 100644 --- a/src/tai64nfrac.c +++ b/src/tai64nfrac.c @@ -6,6 +6,7 @@ #include "scan.h" #include "fmt.h" #include "getln.h" +#include "qmail.h" #define TAI64NLEN 24 @@ -15,7 +16,7 @@ Return the characters after the timestamp. */ -char outbuf[64]; +char outbuf[BUFFER_SMALL]; buffer bo = BUFFER_INIT(write,1,outbuf,sizeof(outbuf)); static void outs(char *s) @@ -32,7 +33,7 @@ static void outi(int i) if (buffer_flush(&bo) == -1) _exit(1); } -char inbuf[1024]; +char inbuf[BUFSIZE_LINE]; buffer bi = BUFFER_INIT(read,0,inbuf,sizeof(inbuf)); int main(void) diff --git a/src/tcpto.c b/src/tcpto.c index 92c33ea..82b102f 100644 --- a/src/tcpto.c +++ b/src/tcpto.c @@ -9,8 +9,9 @@ #include "ipalloc.h" #include "byte.h" #include "datetime.h" +#include "qmail.h" -char tcpto_buf[1024]; +char tcpto_buf[BUFSIZE_LINE]; static int flagwasthere; static int fdlock; diff --git a/src/tcpto_clean.c b/src/tcpto_clean.c index e0b6969..c68be2f 100644 --- a/src/tcpto_clean.c +++ b/src/tcpto_clean.c @@ -2,8 +2,9 @@ #include "tcpto.h" #include "open.h" #include "buffer.h" +#include "qmail.h" -char tcpto_cleanbuf[1024]; +char tcpto_cleanbuf[BUFSIZE_LINE]; void tcpto_clean() /* running from queue/mess */ { -- cgit v1.2.3