diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 8 | ||||
-rw-r--r-- | src/condredirect.c | 2 | ||||
-rw-r--r-- | src/datetime.c | 34 | ||||
-rw-r--r-- | src/datetime_un.c | 35 | ||||
-rw-r--r-- | src/headerbody.c | 6 | ||||
-rw-r--r-- | src/include/commands.h | 3 | ||||
-rw-r--r-- | src/include/constmap.h | 4 | ||||
-rw-r--r-- | src/include/datetime.h | 4 | ||||
-rw-r--r-- | src/include/qmail.h | 2 | ||||
-rw-r--r-- | src/include/rcpthosts.h | 4 | ||||
-rw-r--r-- | src/qmail-authuser.c | 4 | ||||
-rw-r--r-- | src/qmail-dksign.c | 2 | ||||
-rw-r--r-- | src/qmail-qmqpd.c | 10 | ||||
-rw-r--r-- | src/qmail-qmtpd.c | 26 | ||||
-rw-r--r-- | src/qmail-queue.c | 2 | ||||
-rw-r--r-- | src/qmail-remote.c | 13 | ||||
-rw-r--r-- | src/qmail-send.c | 12 | ||||
-rw-r--r-- | src/qmail-smtpd.c | 19 | ||||
-rw-r--r-- | src/qmail-todo.c | 2 | ||||
-rw-r--r-- | src/rcpthosts.c | 4 | ||||
-rw-r--r-- | src/tls_timeoutio.c | 5 | ||||
-rw-r--r-- | src/trycrypt.c | 4 |
22 files changed, 102 insertions, 103 deletions
diff --git a/src/Makefile b/src/Makefile index 2dc256e..1821978 100644 --- a/src/Makefile +++ b/src/Makefile @@ -235,17 +235,13 @@ warn-auto.sh datemail.sh ../conf-home ../conf-break ../conf-split chmod 755 datemail datetime.a: \ -makelib datetime.o datetime_un.o - ./makelib datetime.a datetime.o datetime_un.o +makelib datetime.o + ./makelib datetime.a datetime.o datetime.o: \ compile datetime.c ./compile datetime.c -datetime_un.o: \ -compile datetime_un.c - ./compile datetime_un.c - ddist: \ warn-auto.sh ddist.sh ../conf-home cat warn-auto.sh ddist.sh \ diff --git a/src/condredirect.c b/src/condredirect.c index 2e5cc11..92397bc 100644 --- a/src/condredirect.c +++ b/src/condredirect.c @@ -77,5 +77,5 @@ int main(int argc,char **argv) qmail_to(&qqt,argv[1]); qqx = qmail_close(&qqt); if (*qqx) logmsg(WHO,*qqx == 'D' ? 100 : 111,FATAL,qqx + 1); - logmsg(WHO,0,LOG,B("qp ",num)); + logmsg(WHO,99,INFO,B("qp ",num)); } diff --git a/src/datetime.c b/src/datetime.c index 3db5f7f..9048822 100644 --- a/src/datetime.c +++ b/src/datetime.c @@ -51,3 +51,37 @@ void datetime_tai(struct datetime *dt,datetime_sec t) dt->mon = mon; dt->mday = day + 1; } + +/* roughly 100x faster than mktime() */ + +datetime_sec datetime_untai(struct datetime *dt) +{ + int year; + int day; + int mon; + + year = dt->year + 1900; + + mon = dt->mon; + if (mon >= 2) { mon -= 2; } + else { mon += 10; --year; } + + day = (dt->mday - 1) * 10 + 5 + 306 * mon; + day /= 10; + + if (day == 365) { year -= 3; day = 1460; } + else { day += 365 * (year % 4); } + year /= 4; + + day += 1461 * (year % 25); + year /= 25; + + if (day == 36524) { year -= 3; day = 146096; } + else { day += 36524 * (year % 4); } + year /= 4; + + day += 146097 * (year - 5); + day += 11017; + + return ((day * 24 + dt->hour) * 60 + dt->min) * 60 + dt->sec; +} diff --git a/src/datetime_un.c b/src/datetime_un.c deleted file mode 100644 index e84806d..0000000 --- a/src/datetime_un.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "datetime.h" - -/* roughly 100x faster than mktime() */ - -datetime_sec datetime_untai(struct datetime *dt) -{ - int year; - int day; - int mon; - - year = dt->year + 1900; - - mon = dt->mon; - if (mon >= 2) { mon -= 2; } - else { mon += 10; --year; } - - day = (dt->mday - 1) * 10 + 5 + 306 * mon; - day /= 10; - - if (day == 365) { year -= 3; day = 1460; } - else { day += 365 * (year % 4); } - year /= 4; - - day += 1461 * (year % 25); - year /= 25; - - if (day == 36524) { year -= 3; day = 146096; } - else { day += 36524 * (year % 4); } - year /= 4; - - day += 146097 * (year - 5); - day += 11017; - - return ((day * 24 + dt->hour) * 60 + dt->min) * 60 + dt->sec; -} diff --git a/src/headerbody.c b/src/headerbody.c index 82c5684..069b0e7 100644 --- a/src/headerbody.c +++ b/src/headerbody.c @@ -18,11 +18,7 @@ static int getsa(buffer *b,stralloc *sa,int *match) static stralloc line = {0}; static stralloc nextline = {0}; -int headerbody(b,dohf,hdone,dobl) -buffer *b; -void (*dohf)(); -void (*hdone)(); -void (*dobl)(); +int headerbody(buffer *b,void (*dohf)(),void (*hdone)(),void (*dobl)()) { int match; int flaglineok; diff --git a/src/include/commands.h b/src/include/commands.h index 3fd2cb8..d16a4ea 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -1,5 +1,6 @@ #ifndef COMMANDS_H #define COMMANDS_H +#include "buffer.h" struct commands { char *text; @@ -7,6 +8,6 @@ struct commands { void (*flush)(); } ; -int commands(); +int commands(buffer *,struct commands *); #endif diff --git a/src/include/constmap.h b/src/include/constmap.h index 750702e..30bfde6 100644 --- a/src/include/constmap.h +++ b/src/include/constmap.h @@ -15,7 +15,7 @@ struct constmap { int constmap_init(struct constmap *,char *,int,int); int constmap_init_char(struct constmap *,char *,int,int,char); -void constmap_free(); -char *constmap(); +void constmap_free(struct constmap *); +char *constmap(struct constmap *,char *,int); #endif diff --git a/src/include/datetime.h b/src/include/datetime.h index 68d1618..5f53b36 100644 --- a/src/include/datetime.h +++ b/src/include/datetime.h @@ -14,7 +14,7 @@ struct datetime { typedef long datetime_sec; -void datetime_tai(); -datetime_sec datetime_untai(); +void datetime_tai(struct datetime *,datetime_sec); +datetime_sec datetime_untai(struct datetime *); #endif diff --git a/src/include/qmail.h b/src/include/qmail.h index dd44816..ef68ddb 100644 --- a/src/include/qmail.h +++ b/src/include/qmail.h @@ -7,7 +7,9 @@ #define BUFSIZE_MESS 4096 #define BUFSIZE_LINE 1024 // RFC 5322: 998 chars - why? - SMTP Line #define BUFSIZE_AUTH 512 +#define BUFSIZE_OUT 512 #define BUFSIZE_LOG 256 +#define BUFSIZE_SMALL 128 struct qmail { int flagerr; diff --git a/src/include/rcpthosts.h b/src/include/rcpthosts.h index 0c58797..8ab93a5 100644 --- a/src/include/rcpthosts.h +++ b/src/include/rcpthosts.h @@ -1,7 +1,7 @@ #ifndef RCPTHOSTS_H #define RCPTHOSTS_H -int rcpthosts_init(); -int rcpthosts(); +int rcpthosts_init(void); +int rcpthosts(char *,int); #endif diff --git a/src/qmail-authuser.c b/src/qmail-authuser.c index ff0891b..dea5647 100644 --- a/src/qmail-authuser.c +++ b/src/qmail-authuser.c @@ -78,7 +78,7 @@ stralloc shell = {0}; cram-md5/apop: (1,5) **/ -void exit(int fail) +static void exit(int fail) { int i; @@ -150,7 +150,7 @@ int auth_unix(char *user,char* response) { char *encrypted = 0; char *stored = 0; - int r = -1; + int r = 111; pw = getpwnam(user); if (pw) { diff --git a/src/qmail-dksign.c b/src/qmail-dksign.c index 8a2a2b7..4eef40e 100644 --- a/src/qmail-dksign.c +++ b/src/qmail-dksign.c @@ -503,7 +503,7 @@ int main(int argc,char **args) fdin = open_read(fndkout.s); if (fdin == -1) die_read(); } else { - fdin = fndkin.s; // DKIM key failed to sign + fdin = open_read(fndkin.s); // DKIM key failed to sign } } else temp_nosignkey(); diff --git a/src/qmail-qmqpd.c b/src/qmail-qmqpd.c index 4a2bc66..fc994c9 100644 --- a/src/qmail-qmqpd.c +++ b/src/qmail-qmqpd.c @@ -101,7 +101,6 @@ void identify() } char buf[BUFSIZE_LINE]; // sender/recipient buffer -char bufd[BUFSIZE_MESS]; // temporary data buffer char strnum[FMT_ULONG]; int getbuf() @@ -130,7 +129,7 @@ int main() char *result; unsigned long qp; unsigned long len; - unsigned long dlen; + char ch; sig_pipeignore(); sig_alarmcatch(resources); @@ -146,10 +145,9 @@ int main() identify(); while (len > 0) { /* XXX: could speed this up; done */ - dlen = (len < BUFSIZE_LINE) ? len : BUFSIZE_LINE; - buffer_get(&bi,bufd,dlen); - qmail_put(&qq,bufd,dlen); - len -= dlen; + getbyte(&ch); + --len; + qmail_put(&qq,&ch,1); } getcomma(); diff --git a/src/qmail-qmtpd.c b/src/qmail-qmtpd.c index 6478e21..b4a1c17 100644 --- a/src/qmail-qmtpd.c +++ b/src/qmail-qmtpd.c @@ -16,22 +16,25 @@ #include "received.h" #include "ip.h" #include "byte.h" +#include "timeout.h" +#include "error.h" #define PORT_QMTPS "6209" // string compare -#define QMTP_SIZE 200000000 // 190 MB transfer limit +#define QMTP_SIZE 200000000 // 23 MB transfer limit #define QMTP_TIMEOUT 3600 // 1 hour /** @file qmail-qmtpd.c -- QMTP/QMTPS server @brief requires sslserver */ +int timeout = QMTP_TIMEOUT; void badproto() { _exit(100); } void resources() { _exit(111); } ssize_t safewrite(int fd,char *buf,int len) { int r; - r = write(fd,buf,len); - if (r <= 0) _exit(0); + r = timeoutwrite(timeout,fd,buf,len); + if (r <= 0) _exit(1); return r; } @@ -42,8 +45,9 @@ ssize_t saferead(int fd,char *buf,int len) { int r; buffer_flush(&bo); - r = read(fd,buf,len); - if (r <= 0) _exit(0); + r = timeoutread(timeout,fd,buf,len); + if (r == -1) if (errno == ETIMEDOUT) { buffer_flush(&bo); _exit(1); } + if (r <= 0) _exit(1); return r; } @@ -75,8 +79,7 @@ unsigned int bytestooverflow = 0; struct qmail qq; char buf[BUFSIZE_LINE]; // sender/recipient buffer -char bufd[2 * BUFSIZE_MESS]; // temporary data buffer -char buf2[BUFFER_SMALL]; // QMTP message buffer +char buf2[BUFFER_SMALL]; char *remotehost; char *remoteinfo; @@ -149,7 +152,6 @@ int main() char ch; int i; unsigned long biglen; - unsigned long dlen; unsigned long len; int flagdos; int flagsenderok; @@ -243,11 +245,11 @@ int main() qmail_fail(&qq); } while (len > 0) { /* XXX: DJB: could speed this up, obviously; FEH: done */ - dlen = (len < BUFSIZE_LINE) ? len : BUFSIZE_LINE; - buffer_get(&bi,bufd,dlen); - qmail_put(&qq,bufd,dlen); - len -= dlen; + buffer_get(&bi,&ch,1); + --len; + qmail_put(&qq,&ch,1); } + } getcomma(); diff --git a/src/qmail-queue.c b/src/qmail-queue.c index 57f1224..a430f0e 100644 --- a/src/qmail-queue.c +++ b/src/qmail-queue.c @@ -248,7 +248,7 @@ int main() switch (buffer_copy(&bo,&bi)) { case -2: die_read(); - case -3: die_write(); + case -3: die_write(); // usual suspicious } if (buffer_flush(&bo) == -1) die_write(); if (fsync(messfd) == -1) die_write(); diff --git a/src/qmail-remote.c b/src/qmail-remote.c index a6ef155..5440a22 100644 --- a/src/qmail-remote.c +++ b/src/qmail-remote.c @@ -389,13 +389,13 @@ void blast() while ((r = buffer_get(&bi,inbuf,sizeof(inbuf)))) { // read into buffer if (r == -1) temp_read(); - for (in = out = 0; in < r;) { + for (in = out = 0; in <= r;) { if (eom && inbuf[in] == '.') { tmpbuf[out++] = '.'; tmpbuf[out++] = inbuf[in++]; } eom = 0; - while (in < r) { + while (in <= r) { if (inbuf[in] == '\r') { in++; continue; } // CR is DKIM input if (inbuf[in] == '\n') { eom = 1; @@ -946,7 +946,12 @@ void qmtp() /* the following code was substantially taken from serialmail's serialqmtp.c */ - scan_ulong(msgsize,&len); + if (msize) + len = msize; + else { + out("DMessage for: "); outhost(); out(" has zero bytes. Giving up.\n"); + } + buffer_put(&bo,num,fmt_ulong(num,len + 1)); buffer_put(&bo,":\n",2); while (len > 0) { @@ -1339,7 +1344,7 @@ int main(int argc,char **argv) if (port == PORT_QMTPS) flagtls += 20; } - if (flagtls == 8) flagverify = -1; + if (flagtls == 8 || flagtls == 18 || flagtls == 28) flagverify = -1; /* no TLSA */ if (!flagtls && qmtpsend == 2) flagtls = 20; /* QMTPS */ diff --git a/src/qmail-send.c b/src/qmail-send.c index e8b9de6..b58a727 100644 --- a/src/qmail-send.c +++ b/src/qmail-send.c @@ -147,7 +147,7 @@ int getinfo(stralloc *sa,datetime_sec *dt,unsigned long id) struct stat st; static stralloc line = {0}; int match; - char buf[BUFFER_SMALL]; + char buf[BUFSIZE_SMALL]; buffer b; fnmake_info(id); @@ -578,8 +578,8 @@ int injectbounce(unsigned long id) int r; int fd; buffer bi; - char buf[BUFFER_SMALL]; - char inbuf[BUFFER_SMALL]; + char buf[BUFSIZE_SMALL]; + char inbuf[BUFSIZE_SMALL]; static stralloc sender = {0}; static stralloc quoted = {0}; datetime_sec birth; @@ -724,7 +724,7 @@ unsigned int concurrency[CHANNELS] = { 10, 20 }; unsigned int concurrencyused[CHANNELS] = { 0, 0 }; struct del *d[CHANNELS]; stralloc dline[CHANNELS]; -char delbuf[BUFSIZE_MESS]; +char delbuf[2048]; void del_status() { @@ -926,7 +926,7 @@ struct int fd; /* defined if id; reading from {local,remote} */ seek_pos mpos; /* defined if id; mark position */ buffer b; - char buf[BUFFER_SMALL]; + char buf[BUFSIZE_SMALL]; } pass[CHANNELS]; @@ -1142,7 +1142,7 @@ void pass_do() /* this file is too long ------------------------------------- EXTERNAL TODO */ stralloc todoline = {0}; -char todobuf[BUFSIZE_MESS]; +char todobuf[2048]; int todofdin; int todofdout; int flagtodoalive; diff --git a/src/qmail-smtpd.c b/src/qmail-smtpd.c index f01cbee..ba6a69d 100644 --- a/src/qmail-smtpd.c +++ b/src/qmail-smtpd.c @@ -157,6 +157,7 @@ char *local; char *localport; char *relayclient; int flagutf8 = 0; +int flaglf = 0; stralloc protocol = {0}; stralloc helohost = {0}; @@ -454,6 +455,10 @@ void setup() x = env_get("UTF8"); if (x) flagutf8 = 1; + x = env_get("BARELF"); + if (x) flaglf = 1; + if (flaglf && !case_diffs(x,"-")) flaglf = 0; + if (!stralloc_copys(&helohost,"")) die_nomem(); // helohost is initially empty if (!stralloc_0(&helohost)) die_nomem(); fakehelo = 0; @@ -1294,9 +1299,7 @@ void blast(int *hops) int flagmaybex; /* 1 if this line might match RECEIVED, if fih */ int flagmaybey; /* 1 if this line might match \r\n, if fih */ int flagmaybez; /* 1 if this line might match DELIVERED, if fih */ -#ifdef BARELF - int seencr = 0; -#endif + int seencr = 0; /* only required if flaglf is set */ state = 1; *hops = 0; @@ -1304,12 +1307,12 @@ void blast(int *hops) pos = 0; flagmaybex = flagmaybey = flagmaybez = 1; for (;;) { buffer_get(&bi,&ch,1); -#ifdef BARELF - if (ch == '\n') { - if (seencr == 0) { buffer_seek(&bi,-1); ch = '\r'; } + if (flaglf) { + if (ch == '\n') { + if (seencr == 0) { buffer_seek(&bi,-1); ch = '\r'; } + } + if (ch == '\r') seencr = 1; else seencr = 0; } - if (ch == '\r') seencr = 1; else seencr = 0; -#endif if (flaginheader) { if (pos < 9) { if (ch != "delivered"[pos]) if (ch != "DELIVERED"[pos]) flagmaybez = 0; diff --git a/src/qmail-todo.c b/src/qmail-todo.c index 09a5006..05a34c9 100644 --- a/src/qmail-todo.c +++ b/src/qmail-todo.c @@ -342,7 +342,7 @@ int flagtododir; /* if 0, have to opendir again */ readsubdir todosubdir; stralloc todoline = {0}; char todobuf[BUFSIZE_MESS]; -char todobufinfo[BUFSIZE_MESS]; +char todobufinfo[BUFSIZE_OUT]; char todobufchan[CHANNELS][BUF_CHANNELS]; void todo_init(void) diff --git a/src/rcpthosts.c b/src/rcpthosts.c index 2242249..d4a5c27 100644 --- a/src/rcpthosts.c +++ b/src/rcpthosts.c @@ -19,7 +19,7 @@ static int fdmrh; static struct cdb cdb; -int rcpthosts_init() +int rcpthosts_init(void) { flagrh = control_readfile(&rh,"control/rcpthosts",0); if (flagrh != 1) return flagrh; @@ -32,7 +32,7 @@ int rcpthosts_init() static stralloc host = {0}; -int rcpthosts(char *buf, int len) +int rcpthosts(char *buf,int len) { int j; int r; diff --git a/src/tls_timeoutio.c b/src/tls_timeoutio.c index c5f40a2..87aaec0 100644 --- a/src/tls_timeoutio.c +++ b/src/tls_timeoutio.c @@ -7,8 +7,9 @@ #include "ucspissl.h" #include "tls_timeoutio.h" -int tls_timeoutio(int (*fun)(), - int t, int rfd, int wfd, SSL *ssl, char *buf, int len) +// this function pointer needs to be replaced + +int tls_timeoutio(int (*fun)(),int t,int rfd,int wfd,SSL *ssl,char *buf,int len) { int n; const datetime_sec end = (datetime_sec)t + now(); diff --git a/src/trycrypt.c b/src/trycrypt.c deleted file mode 100644 index c32bd40..0000000 --- a/src/trycrypt.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() -{ - ; -} |