2008-2-01 10:30:09 * ¼¯³ÉSPAMCONTROL Version 2.4.18,ʵÏÖÆäËùÓзÀÀ¬»øÓʼþ¹¦ÄÜ http://www.fehcom.de/qmail/spamcontrol.html * ¼¯³Éqmail taps,ʵÏÖÓʼþ¼à¿Ø¹¦ÄÜ http://www.inter7.com/index.php?page=qmailtap * ¼¯³Éqmail-date-localtime.patch, ½«ÓʼþÍ·ÖÐÈÕÆÚ¸ÄΪϵͳ±¾µØÊ±¼ä. diff -uN /home/pkg/netqmail-1.05/qmail-1.03/base64.c /home/pkg/netqmail-1.05/qmail-xuki-patch/base64.c --- /home/pkg/netqmail-1.05/qmail-1.03/base64.c 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/base64.c 2008-01-31 18:09:48.309206352 +0800 @@ -0,0 +1,124 @@ +#include "base64.h" +#include "stralloc.h" +#include "substdio.h" +#include "str.h" + +static char *b64alpha = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +#define B64PAD '=' + +/* returns 0 ok, 1 illegal, -1 problem */ + +int b64decode(in,l,out) +const unsigned char *in; +int l; +stralloc *out; /* not null terminated */ +{ + int p = 0; + int n; + unsigned int x; + int i, j; + char *s; + unsigned char b[3]; + + if (l == 0) + { + if (!stralloc_copys(out,"")) return -1; + return 0; + } + + while(in[l-1] == B64PAD) { + p ++; + l--; + } + + n = (l + p) / 4; + i = (n * 3) - p; + if (!stralloc_ready(out,i)) return -1; + out->len = i; + s = out->s; + + for(i = 0; i < n - 1 ; i++) { + x = 0; + for(j = 0; j < 4; j++) { + if(in[j] >= 'A' && in[j] <= 'Z') + x = (x << 6) + (unsigned int)(in[j] - 'A' + 0); + else if(in[j] >= 'a' && in[j] <= 'z') + x = (x << 6) + (unsigned int)(in[j] - 'a' + 26); + else if(in[j] >= '0' && in[j] <= '9') + x = (x << 6) + (unsigned int)(in[j] - '0' + 52); + else if(in[j] == '+') + x = (x << 6) + 62; + else if(in[j] == '/') + x = (x << 6) + 63; + else if(in[j] == '=') + x = (x << 6); + } + + s[2] = (unsigned char)(x & 255); x >>= 8; + s[1] = (unsigned char)(x & 255); x >>= 8; + s[0] = (unsigned char)(x & 255); x >>= 8; + s += 3; in += 4; + } + + x = 0; + for(j = 0; j < 4; j++) { + if(in[j] >= 'A' && in[j] <= 'Z') + x = (x << 6) + (unsigned int)(in[j] - 'A' + 0); + else if(in[j] >= 'a' && in[j] <= 'z') + x = (x << 6) + (unsigned int)(in[j] - 'a' + 26); + else if(in[j] >= '0' && in[j] <= '9') + x = (x << 6) + (unsigned int)(in[j] - '0' + 52); + else if(in[j] == '+') + x = (x << 6) + 62; + else if(in[j] == '/') + x = (x << 6) + 63; + else if(in[j] == '=') + x = (x << 6); + } + + b[2] = (unsigned char)(x & 255); x >>= 8; + b[1] = (unsigned char)(x & 255); x >>= 8; + b[0] = (unsigned char)(x & 255); x >>= 8; + + for(i = 0; i < 3 - p; i++) + s[i] = b[i]; + + return 0; +} + +int b64encode(in,out) +stralloc *in; +stralloc *out; /* not null terminated */ +{ + unsigned char a, b, c; + int i; + char *s; + + if (in->len == 0) + { + if (!stralloc_copys(out,"")) return -1; + return 0; + } + + i = in->len / 3 * 4 + 4; + if (!stralloc_ready(out,i)) return -1; + s = out->s; + + for (i = 0;i < in->len;i += 3) { + a = in->s[i]; + b = i + 1 < in->len ? in->s[i + 1] : 0; + c = i + 2 < in->len ? in->s[i + 2] : 0; + + *s++ = b64alpha[a >> 2]; + *s++ = b64alpha[((a & 3 ) << 4) | (b >> 4)]; + + if (i + 1 >= in->len) *s++ = B64PAD; + else *s++ = b64alpha[((b & 15) << 2) | (c >> 6)]; + + if (i + 2 >= in->len) *s++ = B64PAD; + else *s++ = b64alpha[c & 63]; + } + out->len = s - out->s; + return 0; +} diff -uN /home/pkg/netqmail-1.05/qmail-1.03/base64.h /home/pkg/netqmail-1.05/qmail-xuki-patch/base64.h --- /home/pkg/netqmail-1.05/qmail-1.03/base64.h 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/base64.h 2008-01-31 18:09:48.309206352 +0800 @@ -0,0 +1,7 @@ +#ifndef BASE64_H +#define BASE64_H + +extern int b64decode(); +extern int b64encode(); + +#endif diff -uN /home/pkg/netqmail-1.05/qmail-1.03/buffer.h /home/pkg/netqmail-1.05/qmail-xuki-patch/buffer.h --- /home/pkg/netqmail-1.05/qmail-1.03/buffer.h 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/buffer.h 2008-01-31 18:09:48.310206200 +0800 @@ -0,0 +1,56 @@ +#ifndef BUFFER_H +#define BUFFER_H + +typedef struct buffer { + char *x; + unsigned int p; + unsigned int n; + int fd; + int (*op)(); +} buffer; + +#define BUFFER_INIT(op,fd,buf,len) { (buf), 0, (len), (fd), (op) } +#define BUFFER_INSIZE 8192 +#define BUFFER_OUTSIZE 8192 + +extern void buffer_init(buffer *,int (*)(),int,char *,unsigned int); + +extern int buffer_flush(buffer *); +extern int buffer_put(buffer *,char *,unsigned int); +extern int buffer_putalign(buffer *,char *,unsigned int); +extern int buffer_putflush(buffer *,char *,unsigned int); +extern int buffer_puts(buffer *,char *); +extern int buffer_putsalign(buffer *,char *); +extern int buffer_putsflush(buffer *,char *); + +#define buffer_PUTC(s,c) \ + ( ((s)->n != (s)->p) \ + ? ( (s)->x[(s)->p++] = (c), 0 ) \ + : buffer_put((s),&(c),1) \ + ) + +extern int buffer_get(buffer *,char *,unsigned int); +extern int buffer_bget(buffer *,char *,unsigned int); +extern int buffer_feed(buffer *); + +extern char *buffer_peek(buffer *); +extern void buffer_seek(buffer *,unsigned int); + +#define buffer_PEEK(s) ( (s)->x + (s)->n ) +#define buffer_SEEK(s,len) ( ( (s)->p -= (len) ) , ( (s)->n += (len) ) ) + +#define buffer_GETC(s,c) \ + ( ((s)->p > 0) \ + ? ( *(c) = (s)->x[(s)->n], buffer_SEEK((s),1), 1 ) \ + : buffer_get((s),(c),1) \ + ) + +extern int buffer_copy(buffer *,buffer *); + +extern buffer *buffer_0; +extern buffer *buffer_0small; +extern buffer *buffer_1; +extern buffer *buffer_1small; +extern buffer *buffer_2; + +#endif diff -uN /home/pkg/netqmail-1.05/qmail-1.03/case_startb.c /home/pkg/netqmail-1.05/qmail-xuki-patch/case_startb.c --- /home/pkg/netqmail-1.05/qmail-1.03/case_startb.c 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/case_startb.c 2008-01-31 18:09:48.310206200 +0800 @@ -0,0 +1,21 @@ +#include "case.h" + +int case_startb(s,len,t) +register char *s; +unsigned int len; +register char *t; +{ + register unsigned char x; + register unsigned char y; + + for (;;) { + y = *t++ - 'A'; + if (y <= 'Z' - 'A') y += 'a'; else y += 'A'; + if (!y) return 1; + if (!len) return 0; + --len; + x = *s++ - 'A'; + if (x <= 'Z' - 'A') x += 'a'; else x += 'A'; + if (x != y) return 0; + } +} diff -uN /home/pkg/netqmail-1.05/qmail-1.03/cdb.c /home/pkg/netqmail-1.05/qmail-xuki-patch/cdb.c --- /home/pkg/netqmail-1.05/qmail-1.03/cdb.c 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/cdb.c 2008-01-31 18:09:48.310206200 +0800 @@ -0,0 +1,136 @@ +/* Public domain. */ + +#include +#include +#include +#include "readwrite.h" +#include "error.h" +#include "seek.h" +#include "byte.h" +#include "cdb.h" + +void cdb_free(struct cdb *c) +{ + if (c->map) { + munmap(c->map,c->size); + c->map = 0; + } +} + +void cdb_findstart(struct cdb *c) +{ + c->loop = 0; +} + +void cdb_init(struct cdb *c,int fd) +{ + struct stat st; + char *x; + + cdb_free(c); + cdb_findstart(c); + c->fd = fd; + + if (fstat(fd,&st) == 0) + if (st.st_size <= 0xffffffff) { + x = mmap(0,st.st_size,PROT_READ,MAP_SHARED,fd,0); + if (x + 1) { + c->size = st.st_size; + c->map = x; + } + } +} + +int cdb_read(struct cdb *c,char *buf,unsigned int len,uint32 pos) +{ + if (c->map) { + if ((pos > c->size) || (c->size - pos < len)) goto FORMAT; + byte_copy(buf,len,c->map + pos); + } + else { + if (seek_set(c->fd,pos) == -1) return -1; + while (len > 0) { + int r; + do + r = read(c->fd,buf,len); + while ((r == -1) && (errno == error_intr)); + if (r == -1) return -1; + if (r == 0) goto FORMAT; + buf += r; + len -= r; + } + } + return 0; + + FORMAT: + errno = error_proto; + return -1; +} + +static int match(struct cdb *c,char *key,unsigned int len,uint32 pos) +{ + char buf[32]; + int n; + + while (len > 0) { + n = sizeof buf; + if (n > len) n = len; + if (cdb_read(c,buf,n,pos) == -1) return -1; + if (byte_diff(buf,n,key)) return 0; + pos += n; + key += n; + len -= n; + } + return 1; +} + +int cdb_findnext(struct cdb *c,char *key,unsigned int len) +{ + char buf[8]; + uint32 pos; + uint32 u; + + if (!c->loop) { + u = cdb_hash(key,len); + if (cdb_read(c,buf,8,(u << 3) & 2047) == -1) return -1; + uint32_unpack(buf + 4,&c->hslots); + if (!c->hslots) return 0; + uint32_unpack(buf,&c->hpos); + c->khash = u; + u >>= 8; + u %= c->hslots; + u <<= 3; + c->kpos = c->hpos + u; + } + + while (c->loop < c->hslots) { + if (cdb_read(c,buf,8,c->kpos) == -1) return -1; + uint32_unpack(buf + 4,&pos); + if (!pos) return 0; + c->loop += 1; + c->kpos += 8; + if (c->kpos == c->hpos + (c->hslots << 3)) c->kpos = c->hpos; + uint32_unpack(buf,&u); + if (u == c->khash) { + if (cdb_read(c,buf,8,pos) == -1) return -1; + uint32_unpack(buf,&u); + if (u == len) + switch(match(c,key,len,pos + 8)) { + case -1: + return -1; + case 1: + uint32_unpack(buf + 4,&c->dlen); + c->dpos = pos + 8 + len; + return 1; + } + } + } + + return 0; +} + +int cdb_find(struct cdb *c,char *key,unsigned int len) +{ + cdb_findstart(c); + return cdb_findnext(c,key,len); +} diff -uN /home/pkg/netqmail-1.05/qmail-1.03/cdb.h /home/pkg/netqmail-1.05/qmail-xuki-patch/cdb.h --- /home/pkg/netqmail-1.05/qmail-1.03/cdb.h 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/cdb.h 2008-01-31 18:09:48.310206200 +0800 @@ -1,12 +1,37 @@ +/* Public domain. */ + #ifndef CDB_H #define CDB_H #include "uint32.h" -extern uint32 cdb_hash(); -extern uint32 cdb_unpack(); +#define CDB_HASHSTART 5381 +extern uint32 cdb_hashadd(uint32,unsigned char); +extern uint32 cdb_hash(char *,unsigned int); + +struct cdb { + char *map; /* 0 if no map is available */ + int fd; + uint32 size; /* initialized if map is nonzero */ + uint32 loop; /* number of hash slots searched under this key */ + uint32 khash; /* initialized if loop is nonzero */ + uint32 kpos; /* initialized if loop is nonzero */ + uint32 hpos; /* initialized if loop is nonzero */ + uint32 hslots; /* initialized if loop is nonzero */ + uint32 dpos; /* initialized if cdb_findnext() returns 1 */ + uint32 dlen; /* initialized if cdb_findnext() returns 1 */ +} ; + +extern void cdb_free(struct cdb *); +extern void cdb_init(struct cdb *,int fd); + +extern int cdb_read(struct cdb *,char *,unsigned int,uint32); + +extern void cdb_findstart(struct cdb *); +extern int cdb_findnext(struct cdb *,char *,unsigned int); +extern int cdb_find(struct cdb *,char *,unsigned int); -extern int cdb_bread(); -extern int cdb_seek(); +#define cdb_datapos(c) ((c)->dpos) +#define cdb_datalen(c) ((c)->dlen) #endif diff -uN /home/pkg/netqmail-1.05/qmail-1.03/cdb_hash.c /home/pkg/netqmail-1.05/qmail-xuki-patch/cdb_hash.c --- /home/pkg/netqmail-1.05/qmail-1.03/cdb_hash.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/cdb_hash.c 2008-01-31 18:09:48.311206048 +0800 @@ -1,16 +1,21 @@ +/* Public domain. */ + #include "cdb.h" -uint32 cdb_hash(buf,len) -unsigned char *buf; -unsigned int len; +uint32 cdb_hashadd(uint32 h,unsigned char c) +{ + h += (h << 5); + return h ^ c; +} + +uint32 cdb_hash(char *buf,unsigned int len) { uint32 h; - h = 5381; + h = CDB_HASHSTART; while (len) { + h = cdb_hashadd(h,*buf++); --len; - h += (h << 5); - h ^= (uint32) *buf++; } return h; } diff -uN /home/pkg/netqmail-1.05/qmail-1.03/cdb_make.c /home/pkg/netqmail-1.05/qmail-xuki-patch/cdb_make.c --- /home/pkg/netqmail-1.05/qmail-1.03/cdb_make.c 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/cdb_make.c 2008-01-31 18:09:48.311206048 +0800 @@ -0,0 +1,153 @@ +/* Public domain. */ + +#include "readwrite.h" +#include "seek.h" +#include "error.h" +#include "alloc.h" +#include "cdb.h" +#include "cdb_make.h" + +int cdb_make_start(struct cdb_make *c,int fd) +{ + c->head = 0; + c->split = 0; + c->hash = 0; + c->numentries = 0; + c->fd = fd; + c->pos = sizeof c->final; + buffer_init(&c->b,write,fd,c->bspace,sizeof c->bspace); + return seek_set(fd,c->pos); +} + +static int posplus(struct cdb_make *c,uint32 len) +{ + uint32 newpos = c->pos + len; + if (newpos < len) { errno = error_nomem; return -1; } + c->pos = newpos; + return 0; +} + +int cdb_make_addend(struct cdb_make *c,unsigned int keylen,unsigned int datalen,uint32 h) +{ + struct cdb_hplist *head; + + head = c->head; + if (!head || (head->num >= CDB_HPLIST)) { + head = (struct cdb_hplist *) alloc(sizeof(struct cdb_hplist)); + if (!head) return -1; + head->num = 0; + head->next = c->head; + c->head = head; + } + head->hp[head->num].h = h; + head->hp[head->num].p = c->pos; + ++head->num; + ++c->numentries; + if (posplus(c,8) == -1) return -1; + if (posplus(c,keylen) == -1) return -1; + if (posplus(c,datalen) == -1) return -1; + return 0; +} + +int cdb_make_addbegin(struct cdb_make *c,unsigned int keylen,unsigned int datalen) +{ + char buf[8]; + + if (keylen > 0xffffffff) { errno = error_nomem; return -1; } + if (datalen > 0xffffffff) { errno = error_nomem; return -1; } + + uint32_pack(buf,keylen); + uint32_pack(buf + 4,datalen); + if (buffer_putalign(&c->b,buf,8) == -1) return -1; + return 0; +} + +int cdb_make_add(struct cdb_make *c,char *key,unsigned int keylen,char *data,unsigned int datalen) +{ + if (cdb_make_addbegin(c,keylen,datalen) == -1) return -1; + if (buffer_putalign(&c->b,key,keylen) == -1) return -1; + if (buffer_putalign(&c->b,data,datalen) == -1) return -1; + return cdb_make_addend(c,keylen,datalen,cdb_hash(key,keylen)); +} + +int cdb_make_finish(struct cdb_make *c) +{ + char buf[8]; + int i; + uint32 len; + uint32 u; + uint32 memsize; + uint32 count; + uint32 where; + struct cdb_hplist *x; + struct cdb_hp *hp; + + for (i = 0;i < 256;++i) + c->count[i] = 0; + + for (x = c->head;x;x = x->next) { + i = x->num; + while (i--) + ++c->count[255 & x->hp[i].h]; + } + + memsize = 1; + for (i = 0;i < 256;++i) { + u = c->count[i] * 2; + if (u > memsize) + memsize = u; + } + + memsize += c->numentries; /* no overflow possible up to now */ + u = (uint32) 0 - (uint32) 1; + u /= sizeof(struct cdb_hp); + if (memsize > u) { errno = error_nomem; return -1; } + + c->split = (struct cdb_hp *) alloc(memsize * sizeof(struct cdb_hp)); + if (!c->split) return -1; + + c->hash = c->split + c->numentries; + + u = 0; + for (i = 0;i < 256;++i) { + u += c->count[i]; /* bounded by numentries, so no overflow */ + c->start[i] = u; + } + + for (x = c->head;x;x = x->next) { + i = x->num; + while (i--) + c->split[--c->start[255 & x->hp[i].h]] = x->hp[i]; + } + + for (i = 0;i < 256;++i) { + count = c->count[i]; + + len = count + count; /* no overflow possible */ + uint32_pack(c->final + 8 * i,c->pos); + uint32_pack(c->final + 8 * i + 4,len); + + for (u = 0;u < len;++u) + c->hash[u].h = c->hash[u].p = 0; + + hp = c->split + c->start[i]; + for (u = 0;u < count;++u) { + where = (hp->h >> 8) % len; + while (c->hash[where].p) + if (++where == len) + where = 0; + c->hash[where] = *hp++; + } + + for (u = 0;u < len;++u) { + uint32_pack(buf,c->hash[u].h); + uint32_pack(buf + 4,c->hash[u].p); + if (buffer_putalign(&c->b,buf,8) == -1) return -1; + if (posplus(c,8) == -1) return -1; + } + } + + if (buffer_flush(&c->b) == -1) return -1; + if (seek_begin(c->fd) == -1) return -1; + return buffer_putflush(&c->b,c->final,sizeof c->final); +} diff -uN /home/pkg/netqmail-1.05/qmail-1.03/cdb_make.h /home/pkg/netqmail-1.05/qmail-xuki-patch/cdb_make.h --- /home/pkg/netqmail-1.05/qmail-1.03/cdb_make.h 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/cdb_make.h 2008-01-31 18:09:48.311206048 +0800 @@ -0,0 +1,39 @@ +/* Public domain. */ + +#ifndef CDB_MAKE_H +#define CDB_MAKE_H + +#include "buffer.h" +#include "uint32.h" + +#define CDB_HPLIST 1000 + +struct cdb_hp { uint32 h; uint32 p; } ; + +struct cdb_hplist { + struct cdb_hp hp[CDB_HPLIST]; + struct cdb_hplist *next; + int num; +} ; + +struct cdb_make { + char bspace[8192]; + char final[2048]; + uint32 count[256]; + uint32 start[256]; + struct cdb_hplist *head; + struct cdb_hp *split; /* includes space for hash */ + struct cdb_hp *hash; + uint32 numentries; + buffer b; + uint32 pos; + int fd; +} ; + +extern int cdb_make_start(struct cdb_make *,int); +extern int cdb_make_addbegin(struct cdb_make *,unsigned int,unsigned int); +extern int cdb_make_addend(struct cdb_make *,unsigned int,unsigned int,uint32); +extern int cdb_make_add(struct cdb_make *,char *,unsigned int,char *,unsigned int); +extern int cdb_make_finish(struct cdb_make *); + +#endif Binary files /home/pkg/netqmail-1.05/qmail-1.03/cdb_make.o and /home/pkg/netqmail-1.05/qmail-xuki-patch/cdb_make.o differ diff -uN /home/pkg/netqmail-1.05/qmail-1.03/conf-cc /home/pkg/netqmail-1.05/qmail-xuki-patch/conf-cc --- /home/pkg/netqmail-1.05/qmail-1.03/conf-cc 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/conf-cc 2008-01-31 18:09:48.311206048 +0800 @@ -1,3 +1,7 @@ +cc -O2 -include /usr/include/errno.h + +Recommend by DJB instead of cc -O2 + This will be used to compile .c files. diff -uN /home/pkg/netqmail-1.05/qmail-1.03/control.c /home/pkg/netqmail-1.05/qmail-xuki-patch/control.c --- /home/pkg/netqmail-1.05/qmail-1.03/control.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/control.c 2008-01-31 18:09:48.312205896 +0800 @@ -8,7 +8,7 @@ #include "alloc.h" #include "scan.h" -static char inbuf[64]; +static char inbuf[2048]; static stralloc line = {0}; static stralloc me = {0}; static int meok = 0; diff -uN /home/pkg/netqmail-1.05/qmail-1.03/date822fmt.c /home/pkg/netqmail-1.05/qmail-xuki-patch/date822fmt.c --- /home/pkg/netqmail-1.05/qmail-1.03/date822fmt.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/date822fmt.c 2008-01-31 18:10:17.004843952 +0800 @@ -1,3 +1,4 @@ +#include #include "datetime.h" #include "fmt.h" #include "date822fmt.h" @@ -12,18 +13,51 @@ { unsigned int i; unsigned int len; + time_t now; + datetime_sec utc; + datetime_sec local; + struct tm *tm; + struct datetime new_dt; + int minutes; + + utc = datetime_untai(dt); + now = (time_t)utc; + tm = localtime(&now); + new_dt.year = tm->tm_year; + new_dt.mon = tm->tm_mon; + new_dt.mday = tm->tm_mday; + new_dt.hour = tm->tm_hour; + new_dt.min = tm->tm_min; + new_dt.sec = tm->tm_sec; + local = datetime_untai(&new_dt); + len = 0; - i = fmt_uint(s,dt->mday); len += i; if (s) s += i; + i = fmt_uint(s,new_dt.mday); len += i; if (s) s += i; i = fmt_str(s," "); len += i; if (s) s += i; - i = fmt_str(s,montab[dt->mon]); len += i; if (s) s += i; + i = fmt_str(s,montab[new_dt.mon]); len += i; if (s) s += i; i = fmt_str(s," "); len += i; if (s) s += i; - i = fmt_uint(s,dt->year + 1900); len += i; if (s) s += i; + i = fmt_uint(s,new_dt.year + 1900); len += i; if (s) s += i; i = fmt_str(s," "); len += i; if (s) s += i; - i = fmt_uint0(s,dt->hour,2); len += i; if (s) s += i; + i = fmt_uint0(s,new_dt.hour,2); len += i; if (s) s += i; i = fmt_str(s,":"); len += i; if (s) s += i; - i = fmt_uint0(s,dt->min,2); len += i; if (s) s += i; + i = fmt_uint0(s,new_dt.min,2); len += i; if (s) s += i; i = fmt_str(s,":"); len += i; if (s) s += i; - i = fmt_uint0(s,dt->sec,2); len += i; if (s) s += i; - i = fmt_str(s," -0000\n"); len += i; if (s) s += i; + i = fmt_uint0(s,new_dt.sec,2); len += i; if (s) s += i; + + if (local < utc) { + minutes = (utc - local + 30) / 60; + i = fmt_str(s," -"); len += i; if (s) s += i; + i = fmt_uint0(s,minutes / 60,2); len += i; if (s) s += i; + i = fmt_uint0(s,minutes % 60,2); len += i; if (s) s += i; + } + else { + minutes = (local - utc + 30) / 60; + i = fmt_str(s," +"); len += i; if (s) s += i; + i = fmt_uint0(s,minutes / 60,2); len += i; if (s) s += i; + i = fmt_uint0(s,minutes % 60,2); len += i; if (s) s += i; + } + + i = fmt_str(s,"\n"); len += i; if (s) s += i; + return len; } diff -uN /home/pkg/netqmail-1.05/qmail-1.03/error.c /home/pkg/netqmail-1.05/qmail-xuki-patch/error.c --- /home/pkg/netqmail-1.05/qmail-1.03/error.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/error.c 2008-01-31 18:09:48.312205896 +0800 @@ -93,3 +93,10 @@ #else -13; #endif + +int error_proto = +#ifdef EPROTO +EPROTO; +#else +-15; +#endif diff -uN /home/pkg/netqmail-1.05/qmail-1.03/error.h /home/pkg/netqmail-1.05/qmail-xuki-patch/error.h --- /home/pkg/netqmail-1.05/qmail-1.03/error.h 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/error.h 2008-01-31 18:09:48.312205896 +0800 @@ -1,5 +1,6 @@ #ifndef ERROR_H #define ERROR_H +#include extern int errno; @@ -16,6 +17,7 @@ extern int error_pipe; extern int error_perm; extern int error_acces; +extern int error_proto; extern char *error_str(); extern int error_temp(); diff -uN /home/pkg/netqmail-1.05/qmail-1.03/hier.c /home/pkg/netqmail-1.05/qmail-xuki-patch/hier.c --- /home/pkg/netqmail-1.05/qmail-1.03/hier.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/hier.c 2008-01-31 18:09:48.312205896 +0800 @@ -4,6 +4,8 @@ #include "fmt.h" #include "fifo.h" +/* #define BIGTODO */ + char buf[100 + FMT_ULONG]; void dsplit(base,uid,mode) @@ -55,6 +57,10 @@ d(auto_qmail,"queue/bounce",auto_uids,auto_gidq,0700); dsplit("queue/mess",auto_uidq,0750); +#ifdef BIGTODO + dsplit("queue/todo",auto_uidq,0750); + dsplit("queue/intd",auto_uidq,0700); +#endif dsplit("queue/info",auto_uids,0700); dsplit("queue/local",auto_uids,0700); dsplit("queue/remote",auto_uids,0700); @@ -110,7 +116,11 @@ c(auto_qmail,"bin","qmail-send",auto_uido,auto_gidq,0711); c(auto_qmail,"bin","splogger",auto_uido,auto_gidq,0711); c(auto_qmail,"bin","qmail-newu",auto_uido,auto_gidq,0700); + c(auto_qmail,"bin","qmail-badloadertypes",auto_uido,auto_gidq,0700); + c(auto_qmail,"bin","qmail-badmimetypes",auto_uido,auto_gidq,0700); c(auto_qmail,"bin","qmail-newmrh",auto_uido,auto_gidq,0700); + c(auto_qmail,"bin","qmail-recipients",auto_uido,auto_gidq,0700); + c(auto_qmail,"bin","qmail-mfrules",auto_uido,auto_gidq,0700); c(auto_qmail,"bin","qmail-pw2u",auto_uido,auto_gidq,0711); c(auto_qmail,"bin","qmail-inject",auto_uido,auto_gidq,0755); c(auto_qmail,"bin","predate",auto_uido,auto_gidq,0755); @@ -221,8 +231,16 @@ c(auto_qmail,"man/cat8","qmail-inject.0",auto_uido,auto_gidq,0644); c(auto_qmail,"man/man8","qmail-showctl.8",auto_uido,auto_gidq,0644); c(auto_qmail,"man/cat8","qmail-showctl.0",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/man8","qmail-badloadertypes.8",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/cat8","qmail-badloadertypes.0",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/man8","qmail-badmimetypes.8",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/cat8","qmail-badmimetypes.0",auto_uido,auto_gidq,0644); c(auto_qmail,"man/man8","qmail-newmrh.8",auto_uido,auto_gidq,0644); c(auto_qmail,"man/cat8","qmail-newmrh.0",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/man8","qmail-recipients.8",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/cat8","qmail-recipients.0",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/man8","qmail-mfrules.8",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/cat8","qmail-mfrules.0",auto_uido,auto_gidq,0644); c(auto_qmail,"man/man8","qmail-newu.8",auto_uido,auto_gidq,0644); c(auto_qmail,"man/cat8","qmail-newu.0",auto_uido,auto_gidq,0644); c(auto_qmail,"man/man8","qmail-pw2u.8",auto_uido,auto_gidq,0644); diff -uN /home/pkg/netqmail-1.05/qmail-1.03/install-big.c /home/pkg/netqmail-1.05/qmail-xuki-patch/install-big.c --- /home/pkg/netqmail-1.05/qmail-1.03/install-big.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/install-big.c 2008-01-31 18:09:48.313205744 +0800 @@ -110,6 +110,10 @@ c(auto_qmail,"bin","qmail-send",auto_uido,auto_gidq,0711); c(auto_qmail,"bin","splogger",auto_uido,auto_gidq,0711); c(auto_qmail,"bin","qmail-newu",auto_uido,auto_gidq,0700); + c(auto_qmail,"bin","qmail-badloadertypes",auto_uido,auto_gidq,0700); + c(auto_qmail,"bin","qmail-badmimetypes",auto_uido,auto_gidq,0700); + c(auto_qmail,"bin","qmail-recipients",auto_uido,auto_gidq,0700); + c(auto_qmail,"bin","qmail-mfrules",auto_uido,auto_gidq,0700); c(auto_qmail,"bin","qmail-newmrh",auto_uido,auto_gidq,0700); c(auto_qmail,"bin","qmail-pw2u",auto_uido,auto_gidq,0711); c(auto_qmail,"bin","qmail-inject",auto_uido,auto_gidq,0755); @@ -221,6 +225,14 @@ c(auto_qmail,"man/cat8","qmail-inject.0",auto_uido,auto_gidq,0644); c(auto_qmail,"man/man8","qmail-showctl.8",auto_uido,auto_gidq,0644); c(auto_qmail,"man/cat8","qmail-showctl.0",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/man8","qmail-badloadertypes.8",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/cat8","qmail-badloadertypes.0",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/man8","qmail-badmimetypes.8",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/cat8","qmail-badmimetypes.0",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/man8","qmail-recipients.8",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/cat8","qmail-recipients.0",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/man8","qmail-mfrules.8",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/cat8","qmail-mfrules.0",auto_uido,auto_gidq,0644); c(auto_qmail,"man/man8","qmail-newmrh.8",auto_uido,auto_gidq,0644); c(auto_qmail,"man/cat8","qmail-newmrh.0",auto_uido,auto_gidq,0644); c(auto_qmail,"man/man8","qmail-newu.8",auto_uido,auto_gidq,0644); diff -uN /home/pkg/netqmail-1.05/qmail-1.03/ipme.c /home/pkg/netqmail-1.05/qmail-xuki-patch/ipme.c --- /home/pkg/netqmail-1.05/qmail-1.03/ipme.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/ipme.c 2008-01-31 18:09:48.313205744 +0800 @@ -14,6 +14,10 @@ #include "ipalloc.h" #include "stralloc.h" #include "ipme.h" +#include "substdio.h" +#include "readwrite.h" + +/* #define MOREIPME */ static int ipmeok = 0; ipalloc ipme = {0}; @@ -31,6 +35,14 @@ static stralloc buf = {0}; +#ifdef MOREIPME +#define ipme_init_retclean(ret) { \ + if (notipme.ix) alloc_free(notipme.ix); \ + if (moreipme.ix) alloc_free(moreipme.ix); \ + if (buf.s) alloc_free(buf.s); \ + return ret; } +#endif + int ipme_init() { struct ifconf ifc; @@ -40,17 +52,48 @@ int len; int s; struct ip_mx ix; + +#ifdef MOREIPME + ipalloc notipme = {0}; + ipalloc moreipme = {0}; + int i; if (ipmeok) return 1; + if (!ipalloc_readyplus(&ipme,0)) ipme_init_retclean(0); + if (!ipalloc_readyplus(¬ipme,0)) ipme_init_retclean(0); + if (!ipalloc_readyplus(&moreipme,0)) ipme_init_retclean(0); +#else + if (ipmeok) return 1; if (!ipalloc_readyplus(&ipme,0)) return 0; +#endif ipme.len = 0; ix.pref = 0; - + +#ifdef MOREIPME + if (!ipme_readipfile(¬ipme, "control/notipme")) ipme_init_retclean(0); +#endif + + /* 0.0.0.0 is a special address which always refers to + * "this host, this network", according to RFC 1122, Sec. 3.2.1.3a. + */ + byte_copy(&ix.ip,4,"\0\0\0\0"); + +#ifdef MOREIPME + if ((s = socket(AF_INET,SOCK_STREAM,0)) == -1) ipme_init_retclean(-1); + if (!ipme_append_unless(&ix,¬ipme)) ipme_init_retclean(0); +#else + if (!ipalloc_append(&ipme,&ix)) { return 0; } + if ((s = socket(AF_INET,SOCK_STREAM,0)) == -1) return -1; +#endif len = 256; for (;;) { - if (!stralloc_ready(&buf,len)) { close(s); return 0; } +#ifdef MOREIPME + if (!stralloc_ready(&buf,len)) { close(s); ipme_init_retclean(0); } +#else + if (!stralloc_ready(&buf,len)) { close(s); return 0; } +#endif buf.len = 0; ifc.ifc_buf = buf.s; ifc.ifc_len = len; @@ -59,7 +102,11 @@ buf.len = ifc.ifc_len; break; } +#ifdef MOREIPME + if (len > 200000) { close(s); ipme_init_retclean(-1); } +#else if (len > 200000) { close(s); return -1; } +#endif len += 100 + (len >> 2); } x = buf.s; @@ -74,7 +121,11 @@ byte_copy(&ix.ip,4,&sin->sin_addr); if (ioctl(s,SIOCGIFFLAGS,x) == 0) if (ifr->ifr_flags & IFF_UP) +#ifdef MOREIPME + if (!ipme_append_unless(&ix,¬ipme)) { close(s); ipme_init_retclean(0); } +#else if (!ipalloc_append(&ipme,&ix)) { close(s); return 0; } +#endif } #else len = sizeof(*ifr); @@ -84,12 +135,64 @@ if (ifr->ifr_addr.sa_family == AF_INET) { sin = (struct sockaddr_in *) &ifr->ifr_addr; byte_copy(&ix.ip,4,&sin->sin_addr); - if (!ipalloc_append(&ipme,&ix)) { close(s); return 0; } +#ifdef MOREIPME + if (!ipme_append_unless(&ix,¬ipme)) { close(s); ipme_init_retclean(0); } +#else + if (!ipalloc_append(&ipme,&ix)) { close(s); return 0; } +#endif } #endif x += len; } close(s); + +#ifdef MOREIPME + if (!ipme_readipfile(&moreipme, "control/moreipme")) ipme_init_retclean(0); + for(i = 0;i < moreipme.len;++i) + if (!ipme_append_unless(&moreipme.ix[i],¬ipme)) ipme_init_retclean(0); + + ipmeok = 1; + ipme_init_retclean(1); +} + + +int ipme_readipfile(ipa, fn) + ipalloc *ipa; + char *fn; +{ + int fd = -1; + char inbuf[1024]; + substdio ss; + stralloc l = {0}; + int match; + struct ip_mx ix; + int ret = 1; + + if ( (fd = open_read(fn)) != -1) { + substdio_fdbuf(&ss, read, fd, inbuf, sizeof(inbuf)); + while ( (getln(&ss,&l,&match,'\n') != -1) && (match || l.len) ) { + l.len--; + if (!stralloc_0(&l)) { ret = 0; break; } + if (!ip_scan(l.s, &ix.ip)) continue; + if (!ipalloc_append(ipa,&ix)) { ret = 0; break; } + } + if (l.s) alloc_free(l.s); + if ( (fd >= 0) && (close(fd) == -1) ) + ret = 0; + } + return ret; +} + +int ipme_append_unless(ix, notip) + struct ip_mx *ix; + struct ipalloc *notip; +{ + int i; + for (i = 0;i < notip->len;++i) + if (byte_equal(¬ip->ix[i].ip,4,&ix->ip)) return 1; + return ipalloc_append(&ipme, ix); +#else ipmeok = 1; return 1; +#endif } diff -uN /home/pkg/netqmail-1.05/qmail-1.03/ipmeprint.c /home/pkg/netqmail-1.05/qmail-xuki-patch/ipmeprint.c --- /home/pkg/netqmail-1.05/qmail-1.03/ipmeprint.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/ipmeprint.c 2008-01-31 18:09:48.313205744 +0800 @@ -3,12 +3,15 @@ #include "ip.h" #include "ipme.h" #include "exit.h" +#include "auto_qmail.h" char temp[IPFMT]; void main() { int j; + + chdir(auto_qmail); switch(ipme_init()) { case 0: substdio_putsflush(subfderr,"out of memory\n"); _exit(111); diff -uN /home/pkg/netqmail-1.05/qmail-1.03/Makefile /home/pkg/netqmail-1.05/qmail-xuki-patch/Makefile --- /home/pkg/netqmail-1.05/qmail-1.03/Makefile 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/Makefile 2008-01-31 18:09:48.315205440 +0800 @@ -136,6 +136,10 @@ compile auto_usera.c ./compile auto_usera.c +base64.o: \ +compile base64.c base64.h stralloc.h substdio.h str.h + ./compile base64.c + binm1: \ binm1.sh conf-qmail cat binm1.sh \ @@ -217,9 +221,9 @@ case.a: \ makelib case_diffb.o case_diffs.o case_lowerb.o case_lowers.o \ -case_starts.o +case_starts.o case_startb.o ./makelib case.a case_diffb.o case_diffs.o case_lowerb.o \ - case_lowers.o case_starts.o + case_lowers.o case_starts.o case_startb.o case_diffb.o: \ compile case_diffb.c case.h @@ -237,13 +241,21 @@ compile case_lowers.c case.h ./compile case_lowers.c +case_startb.o: \ +compile case_startb.c case.h + ./compile case_startb.c + case_starts.o: \ compile case_starts.c case.h ./compile case_starts.c cdb.a: \ -makelib cdb_hash.o cdb_unpack.o cdb_seek.o - ./makelib cdb.a cdb_hash.o cdb_unpack.o cdb_seek.o +makelib cdb.o cdb_hash.o cdb_unpack.o cdb_seek.o cdb_make.o + ./makelib cdb.a cdb.o cdb_hash.o cdb_unpack.o cdb_seek.o cdb_make.o + +cdb.o: \ +compile cdb.c readwrite.h error.h seek.h byte.h cdb.h uint32.h + ./compile cdb.c cdb_hash.o: \ compile cdb_hash.c cdb.h uint32.h @@ -275,10 +287,15 @@ ./compile cdbmake_pack.c cdbmss.o: \ -compile cdbmss.c readwrite.h seek.h alloc.h cdbmss.h cdbmake.h \ +compile cdbmss.c readwrite.h seek.h alloc.h cdbmss.h cdb.h cdbmake.h \ uint32.h substdio.h ./compile cdbmss.c +cdb_make.o: \ +compile cdb_make.c readwrite.h seek.h error.h alloc.h cdb.h uint32.h \ +cdb_make.h buffer.h uint32.h + ./compile cdb_make.c + check: \ it man ./instcheck @@ -783,18 +800,18 @@ ipme.o: \ compile ipme.c hassalen.h byte.h ip.h ipalloc.h ip.h gen_alloc.h \ -stralloc.h gen_alloc.h ipme.h ip.h ipalloc.h +stralloc.h gen_alloc.h ipme.h ip.h ipalloc.h readwrite.h ./compile ipme.c ipmeprint: \ -load ipmeprint.o ipme.o ip.o ipalloc.o stralloc.a alloc.a substdio.a \ +load ipmeprint.o ipme.o ip.o ipalloc.o auto_qmail.o open.a getln.a stralloc.a alloc.a substdio.a \ error.a str.a fs.a socket.lib - ./load ipmeprint ipme.o ip.o ipalloc.o stralloc.a alloc.a \ + ./load ipmeprint ipme.o ip.o auto_qmail.o ipalloc.o open.a getln.a stralloc.a alloc.a \ substdio.a error.a str.a fs.a `cat socket.lib` ipmeprint.o: \ compile ipmeprint.c subfd.h substdio.h substdio.h ip.h ipme.h ip.h \ -ipalloc.h ip.h gen_alloc.h exit.h +ipalloc.h ip.h gen_alloc.h exit.h auto_qmail.h ./compile ipmeprint.c it: \ @@ -803,6 +820,7 @@ predate datemail mailsubj qmail-upq qmail-showctl qmail-newu \ qmail-pw2u qmail-qread qmail-qstat qmail-tcpto qmail-tcpok \ qmail-pop3d qmail-popup qmail-qmqpc qmail-qmqpd qmail-qmtpd \ +qmail-badmimetypes qmail-badloadertypes qmail-recipients qmail-mfrules \ qmail-smtpd sendmail tcp-env qmail-newmrh config config-fast dnscname \ dnsptr dnsip dnsmxip dnsfq hostname ipmeprint qreceipt qsmhook qbiff \ forward preline condredirect bouncesaying except maildirmake \ @@ -928,6 +946,7 @@ qmail-local.0 qmail-lspawn.0 qmail-getpw.0 qmail-remote.0 \ qmail-rspawn.0 qmail-clean.0 qmail-send.0 qmail-start.0 splogger.0 \ qmail-queue.0 qmail-inject.0 mailsubj.0 qmail-showctl.0 qmail-newu.0 \ +qmail-badmimetypes.0 qmail-badloadertypes.0 qmail-recipients.0 qmail-mfrules.0 \ qmail-pw2u.0 qmail-qread.0 qmail-qstat.0 qmail-tcpto.0 qmail-tcpok.0 \ qmail-pop3d.0 qmail-popup.0 qmail-qmqpc.0 qmail-qmqpd.0 qmail-qmtpd.0 \ qmail-smtpd.0 tcp-env.0 qmail-newmrh.0 qreceipt.0 qbiff.0 forward.0 \ @@ -1216,6 +1235,56 @@ slurpclose.h auto_qmail.h auto_uids.h qlx.h ./compile qmail-lspawn.c +qmail-badmimetypes: \ +load qmail-badmimetypes.o cdbmss.o getln.a open.a cdbmake.a seek.a case.a \ +stralloc.a alloc.a strerr.a substdio.a error.a str.a auto_qmail.o + ./load qmail-badmimetypes cdbmss.o getln.a open.a cdbmake.a \ + seek.a case.a stralloc.a alloc.a strerr.a substdio.a \ + error.a str.a auto_qmail.o + +qmail-badmimetypes.0: \ +qmail-badmimetypes.8 + nroff -man qmail-badmimetypes.8 > qmail-badmimetypes.0 + +qmail-badmimetypes.8: \ +qmail-badmimetypes.9 conf-break conf-spawn + cat qmail-badmimetypes.9 \ + | sed s}QMAILHOME}"`head -1 conf-qmail`"}g \ + | sed s}BREAK}"`head -1 conf-break`"}g \ + | sed s}SPAWN}"`head -1 conf-spawn`"}g \ + > qmail-badmimetypes.8 + +qmail-badmimetypes.o: \ +compile qmail-badmimetypes.c strerr.h stralloc.h gen_alloc.h substdio.h \ +getln.h exit.h readwrite.h open.h auto_qmail.h cdbmss.h cdbmake.h \ +uint32.h substdio.h + ./compile qmail-badmimetypes.c + +qmail-badloadertypes: \ +load qmail-badloadertypes.o cdbmss.o getln.a open.a cdbmake.a seek.a case.a \ +stralloc.a alloc.a strerr.a substdio.a error.a str.a auto_qmail.o + ./load qmail-badloadertypes cdbmss.o getln.a open.a cdbmake.a \ + seek.a case.a stralloc.a alloc.a strerr.a substdio.a \ + error.a str.a auto_qmail.o + +qmail-badloadertypes.0: \ +qmail-badloadertypes.8 + nroff -man qmail-badloadertypes.8 > qmail-badloadertypes.0 + +qmail-badloadertypes.8: \ +qmail-badloadertypes.9 conf-break conf-spawn + cat qmail-badloadertypes.9 \ + | sed s}QMAILHOME}"`head -1 conf-qmail`"}g \ + | sed s}BREAK}"`head -1 conf-break`"}g \ + | sed s}SPAWN}"`head -1 conf-spawn`"}g \ + > qmail-badloadertypes.8 + +qmail-badloadertypes.o: \ +compile qmail-badloadertypes.c strerr.h stralloc.h gen_alloc.h substdio.h \ +getln.h exit.h readwrite.h open.h auto_qmail.h cdbmss.h cdbmake.h \ +uint32.h substdio.h + ./compile qmail-badloadertypes.c + qmail-newmrh: \ load qmail-newmrh.o cdbmss.o getln.a open.a cdbmake.a seek.a case.a \ stralloc.a alloc.a strerr.a substdio.a error.a str.a auto_qmail.o @@ -1241,6 +1310,56 @@ uint32.h substdio.h ./compile qmail-newmrh.c +qmail-recipients: \ +load qmail-recipients.o cdbmss.o getln.a open.a cdbmake.a seek.a case.a \ +stralloc.a alloc.a strerr.a substdio.a error.a str.a auto_qmail.o + ./load qmail-recipients cdbmss.o getln.a open.a cdbmake.a \ + seek.a case.a stralloc.a alloc.a strerr.a substdio.a \ + error.a str.a auto_qmail.o + +qmail-recipients.0: \ +qmail-recipients.8 + nroff -man qmail-recipients.8 > qmail-recipients.0 + +qmail-recipients.8: \ +qmail-recipients.9 conf-break conf-spawn + cat qmail-recipients.9 \ + | sed s}QMAILHOME}"`head -1 conf-qmail`"}g \ + | sed s}BREAK}"`head -1 conf-break`"}g \ + | sed s}SPAWN}"`head -1 conf-spawn`"}g \ + > qmail-recipients.8 + +qmail-recipients.o: \ +compile qmail-recipients.c strerr.h stralloc.h gen_alloc.h substdio.h \ +getln.h exit.h readwrite.h open.h auto_qmail.h cdbmss.h cdbmake.h \ +uint32.h substdio.h + ./compile qmail-recipients.c + +qmail-mfrules: \ +load qmail-mfrules.o cdbmss.o getln.a open.a cdbmake.a seek.a case.a \ +fs.a stralloc.a alloc.a strerr.a substdio.a error.a str.a auto_qmail.o + ./load qmail-mfrules cdbmss.o open.a cdbmake.a getln.a \ + fs.a seek.a case.a stralloc.a alloc.a strerr.a substdio.a \ + error.a str.a auto_qmail.o + +qmail-mfrules.0: \ +qmail-mfrules.8 + nroff -man qmail-mfrules.8 > qmail-mfrules.0 + +qmail-mfrules.8: \ +qmail-mfrules.9 conf-break conf-spawn + cat qmail-mfrules.9 \ + | sed s}QMAILHOME}"`head -1 conf-qmail`"}g \ + | sed s}BREAK}"`head -1 conf-break`"}g \ + | sed s}SPAWN}"`head -1 conf-spawn`"}g \ + > qmail-mfrules.8 + +qmail-mfrules.o: \ +compile qmail-mfrules.c strerr.h stralloc.h gen_alloc.h \ +readwrite.h open.h auto_qmail.h cdbmss.h cdbmake.h getln.h \ +substdio.h byte.h scan.h fmt.h error.h + ./compile qmail-mfrules.c + qmail-newu: \ load qmail-newu.o cdbmss.o getln.a open.a seek.a cdbmake.a case.a \ stralloc.a alloc.a substdio.a error.a str.a auto_qmail.o @@ -1288,9 +1407,11 @@ qmail-popup: \ load qmail-popup.o commands.o timeoutread.o timeoutwrite.o now.o \ +envread.o ucspitls.o env.a \ case.a fd.a sig.a wait.a stralloc.a alloc.a substdio.a error.a str.a \ fs.a socket.lib ./load qmail-popup commands.o timeoutread.o timeoutwrite.o \ + envread.o ucspitls.o env.a \ now.o case.a fd.a sig.a wait.a stralloc.a alloc.a \ substdio.a error.a str.a fs.a `cat socket.lib` @@ -1383,7 +1504,7 @@ qmail-qmtpd.o: \ compile qmail-qmtpd.c stralloc.h gen_alloc.h substdio.h qmail.h \ substdio.h now.h datetime.h str.h fmt.h env.h sig.h rcpthosts.h \ -auto_qmail.h readwrite.h control.h received.h +auto_qmail.h readwrite.h control.h received.h recipients.h ./compile qmail-qmtpd.c qmail-qread: \ @@ -1419,11 +1540,13 @@ nroff -man qmail-qstat.8 > qmail-qstat.0 qmail-queue: \ -load qmail-queue.o triggerpull.o fmtqfn.o now.o date822fmt.o \ -datetime.a seek.a ndelay.a open.a sig.a alloc.a substdio.a error.a \ +load qmail-queue.o triggerpull.o fmtqfn.o now.o date822fmt.o qregex.o \ +datetime.a seek.a case.a ndelay.a open.a sig.a getln.a stralloc.a alloc.a substdio.a error.a \ +env.a wait.a control.o constmap.o \ str.a fs.a auto_qmail.o auto_split.o auto_uids.o ./load qmail-queue triggerpull.o fmtqfn.o now.o \ - date822fmt.o datetime.a seek.a ndelay.a open.a sig.a \ + date822fmt.o datetime.a qregex.o control.o constmap.o case.a seek.a ndelay.a open.a sig.a \ + env.a wait.a getln.a stralloc.a \ alloc.a substdio.a error.a str.a fs.a auto_qmail.o \ auto_split.o auto_uids.o @@ -1433,6 +1556,7 @@ qmail-queue.o: \ compile qmail-queue.c readwrite.h sig.h exit.h open.h seek.h fmt.h \ +env.h fork.h wait.h \ alloc.h substdio.h datetime.h now.h datetime.h triggerpull.h extra.h \ auto_qmail.h auto_uids.h date822fmt.h fmtqfn.h ./compile qmail-queue.c @@ -1441,12 +1565,12 @@ load qmail-remote.o control.o constmap.o timeoutread.o timeoutwrite.o \ timeoutconn.o tcpto.o now.o dns.o ip.o ipalloc.o ipme.o quote.o \ ndelay.a case.a sig.a open.a lock.a seek.a getln.a stralloc.a alloc.a \ -substdio.a error.a str.a fs.a auto_qmail.o dns.lib socket.lib +substdio.a error.a str.a fs.a auto_qmail.o base64.o dns.lib socket.lib ./load qmail-remote control.o constmap.o timeoutread.o \ timeoutwrite.o timeoutconn.o tcpto.o now.o dns.o ip.o \ ipalloc.o ipme.o quote.o ndelay.a case.a sig.a open.a \ lock.a seek.a getln.a stralloc.a alloc.a substdio.a error.a \ - str.a fs.a auto_qmail.o `cat dns.lib` `cat socket.lib` + str.a fs.a auto_qmail.o base64.o `cat dns.lib` `cat socket.lib` qmail-remote.0: \ qmail-remote.8 @@ -1483,12 +1607,12 @@ trigger.o fmtqfn.o quote.o now.o readsubdir.o qmail.o date822fmt.o \ datetime.a case.a ndelay.a getln.a wait.a seek.a fd.a sig.a open.a \ lock.a stralloc.a alloc.a substdio.a error.a str.a fs.a auto_qmail.o \ -auto_split.o +auto_split.o env.a ./load qmail-send qsutil.o control.o constmap.o newfield.o \ prioq.o trigger.o fmtqfn.o quote.o now.o readsubdir.o \ qmail.o date822fmt.o datetime.a case.a ndelay.a getln.a \ wait.a seek.a fd.a sig.a open.a lock.a stralloc.a alloc.a \ - substdio.a error.a str.a fs.a auto_qmail.o auto_split.o + substdio.a error.a str.a fs.a auto_qmail.o auto_split.o env.a qmail-send.0: \ qmail-send.8 @@ -1534,15 +1658,17 @@ qmail-smtpd: \ load qmail-smtpd.o rcpthosts.o commands.o timeoutread.o \ timeoutwrite.o ip.o ipme.o ipalloc.o control.o constmap.o received.o \ -date822fmt.o now.o qmail.o cdb.a fd.a wait.a datetime.a getln.a \ -open.a sig.a case.a env.a stralloc.a alloc.a substdio.a error.a str.a \ -fs.a auto_qmail.o socket.lib - ./load qmail-smtpd rcpthosts.o commands.o timeoutread.o \ - timeoutwrite.o ip.o ipme.o ipalloc.o control.o constmap.o \ - received.o date822fmt.o now.o qmail.o cdb.a fd.a wait.a \ +recipients.o mfrules.o uint32_unpack.o ucspitls.o \ +date822fmt.o now.o qmail.o wildmat.o cdb.a fd.a wait.a datetime.a getln.a \ +open.a sig.a case.a env.a stralloc.a alloc.a substdio.a error.a str.a seek.a \ +fs.a auto_qmail.o base64.o socket.lib + ./load qmail-smtpd rcpthosts.o recipients.o commands.o timeoutread.o \ + mfrules.o uint32_unpack.o ucspitls.o \ + timeoutwrite.o ip.o ipme.o ipalloc.o control.o constmap.o \ + received.o date822fmt.o now.o qmail.o wildmat.o cdb.a seek.a fd.a wait.a \ datetime.a getln.a open.a sig.a case.a env.a stralloc.a \ - alloc.a substdio.a error.a str.a fs.a auto_qmail.o `cat \ - socket.lib` + alloc.a substdio.a error.a str.a fs.a auto_qmail.o base64.o `cat \ + socket.lib` dns.o `cat dns.lib` qmail-smtpd.0: \ qmail-smtpd.8 @@ -1553,7 +1679,8 @@ substdio.h alloc.h auto_qmail.h control.h received.h constmap.h \ error.h ipme.h ip.h ipalloc.h ip.h gen_alloc.h ip.h qmail.h \ substdio.h str.h fmt.h scan.h byte.h case.h env.h now.h datetime.h \ -exit.h rcpthosts.h timeoutread.h timeoutwrite.h commands.h +exit.h rcpthosts.h timeoutread.h timeoutwrite.h commands.h wait.h \ +fd.h base64.h recipients.h mfrules.h ./compile qmail-smtpd.c qmail-start: \ @@ -1681,6 +1808,20 @@ constmap.h stralloc.h gen_alloc.h rcpthosts.h ./compile rcpthosts.c +qregex.o: \ +compile qregex.c qregex.h + ./compile qregex.c + +recipients.o: \ +compile recipients.c cdb.h uint32.h byte.h open.h error.h control.h \ +constmap.h stralloc.h gen_alloc.h recipients.h + ./compile recipients.c + +mfrules.o: \ +compile mfrules.c stralloc.h gen_alloc.h open.h cdb.h uint32.h \ +case.h mfrules.h stralloc.h + ./compile mfrules.c + readsubdir.o: \ compile readsubdir.c readsubdir.h direntry.h fmt.h scan.h str.h \ auto_split.h @@ -1768,22 +1909,24 @@ qmail-command.8 qmail-control.9 qmail-getpw.9 qmail-header.5 \ qmail-inject.8 qmail-limits.9 qmail-local.8 qmail-log.5 \ qmail-lspawn.8 qmail-newmrh.9 qmail-newu.9 qmail-pop3d.8 \ +qmail-newbmt.9 qmail-recipients.9 qmail-mfrules.9 \ qmail-popup.8 qmail-pw2u.9 qmail-qmqpc.8 qmail-qmqpd.8 qmail-qmtpd.8 \ qmail-qread.8 qmail-qstat.8 qmail-queue.8 qmail-remote.8 \ qmail-rspawn.8 qmail-send.9 qmail-showctl.8 qmail-smtpd.8 \ qmail-start.9 qmail-tcpok.8 qmail-tcpto.8 qmail-users.9 qmail.7 \ qreceipt.1 splogger.8 tcp-env.1 config.sh config-fast.sh \ qmail-clean.c qmail-getpw.c qmail-inject.c qmail-local.c \ -qmail-lspawn.c qmail-newmrh.c qmail-newu.c qmail-pop3d.c \ +qmail-lspawn.c qmail-newbmt.c qmail-newmrh.c qmail-newu.c qmail-pop3d.c \ qmail-popup.c qmail-pw2u.c qmail-qmqpc.c qmail-qmqpd.c qmail-qmtpd.c \ qmail-qread.c qmail-qstat.sh qmail-queue.c qmail-remote.c \ qmail-rspawn.c qmail-send.c qmail-showctl.c qmail-smtpd.c \ +qmail-mfrules.c mfrules.c mfrules.h \ qmail-start.c qmail-tcpok.c qmail-tcpto.c spawn.c dnscname.c dnsfq.c \ dnsip.c dnsmxip.c dnsptr.c hostname.c ipmeprint.c tcp-env.c \ sendmail.c qreceipt.c qsmhook.c qbiff.c forward.c preline.c predate.c \ except.c bouncesaying.c condredirect.c maildirmake.c maildir2mbox.c \ maildirwatch.c splogger.c qail.sh elq.sh pinq.sh qmail-upq.sh \ -datemail.sh mailsubj.sh qlx.h rcpthosts.h rcpthosts.c commands.h \ +datemail.sh mailsubj.sh qlx.h rcpthosts.h rcpthosts.c recipients.c commands.h \ commands.c dnsdoe.h dnsdoe.c fmtqfn.h fmtqfn.c gfrom.h gfrom.c \ myctime.h myctime.c newfield.h newfield.c qsutil.h qsutil.c \ readsubdir.h readsubdir.c received.h received.c tcpto.h tcpto.c \ @@ -2121,6 +2264,10 @@ compile triggerpull.c ndelay.h open.h triggerpull.h ./compile triggerpull.c +uint32_unpack.o: \ +compile uint32_unpack.c uint32.h + ./compile uint32_unpack.c + uint32.h: \ tryulong32.c compile load uint32.h1 uint32.h2 ( ( ./compile tryulong32.c && ./load tryulong32 && \ @@ -2139,3 +2286,11 @@ wait_pid.o: \ compile wait_pid.c error.h haswaitp.h ./compile wait_pid.c + +wildmat.o: \ +compile wildmat.c + ./compile wildmat.c + +ucspitls.o: \ +compile ucspitls.c ucspitls.h + ./compile ucspitls.c diff -uN /home/pkg/netqmail-1.05/qmail-1.03/mfrules.c /home/pkg/netqmail-1.05/qmail-xuki-patch/mfrules.c --- /home/pkg/netqmail-1.05/qmail-1.03/mfrules.c 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/mfrules.c 2008-01-31 18:09:48.315205440 +0800 @@ -0,0 +1,131 @@ +#include "alloc.h" +#include "stralloc.h" +#include "open.h" +#include "cdb.h" +#include "case.h" +#include "mfrules.h" + +/* return -9: problems reading cdb */ +/* return -1: key matches; data not */ +/* return 0: no key */ +/* return 1: key matches without data */ +/* return 2: key and data match */ + +stralloc key = {0}; + +static struct cdb c; + +static int mffind(char *mf) +{ + char *x; + char *data; + unsigned int datalen; + int plus = 0; + int dlen; + int len; + int mflen; + int delta; + + switch(cdb_find(&c,key.s,key.len)) { + case -1: return -9; + case 0: return 0; + } + + datalen = cdb_datalen(&c); + data = alloc(datalen); + if (!data) return -9; + if (!datalen) return 1; + mflen = str_len(mf); + + if (cdb_read(&c,data,datalen,cdb_datapos(&c)) == -1) { + alloc_free(data); + return -9; + } + + x = data; dlen = datalen - 1; /* trailing separator */ + + while (dlen > 0) { + plus = byte_rchr(data,dlen,'+'); + x = data + plus + 1; + len = dlen - plus; + delta = (mflen > len) ? mflen - len : 0; + if (!byte_diff(x,len,mf + delta)) { alloc_free(data); return 2; } + dlen = plus - 1; + } + + alloc_free(data); + return -1; +} + +int mfsearch(char *ip,char *host,char *info,char *mf) +{ + int r; + + if (info) { + if (!stralloc_copys(&key,info)) return -9; + r = mffind(mf); + if (r < -1 || r > 0) return r; + + if (!stralloc_cats(&key,"@")) return -9; + if (!stralloc_cats(&key,ip)) return -9; + r = mffind(mf); + if (r < -1 || r > 0) return r; + + if (host) { + if (!stralloc_copys(&key,info)) return -9; + if (!stralloc_cats(&key,"@=")) return -9; + if (!stralloc_cats(&key,host)) return -9; + r = mffind(mf); + if (r < -1 || r > 0) return r; + } + } + + if (!stralloc_copys(&key,ip)) return -9; + r = mffind(mf); + if (r < -1 || r > 0) return r; + + if (host) { + if (!stralloc_copys(&key,"=")) return -9; + if (!stralloc_cats(&key,host)) return -9; + r = mffind(mf); + if (r < -1 || r > 0) return r; + } + + if (!stralloc_copys(&key,ip)) return -9; + while (key.len > 0) { + if (ip[key.len - 1] == '.') { + r = mffind(mf); + if (r < -1 || r > 0) return r; + } + --key.len; + } + + if (host) { + while (*host) { + if (*host == '.') { + if (!stralloc_copys(&key,"=")) return -9; + if (!stralloc_cats(&key,host)) return -9; + r = mffind(mf); + if (r < -1 || r > 0) return r; + } + ++host; + } + if (!stralloc_copys(&key,"=")) return -9; + r = mffind(mf); + if (r < -1 || r > 0) return r; + } + + key.len = 0; +/* return mffind(mf); */ + return -1; +} + +int mfrules(int fd,char *ip,char *host,char *info,char *mf) +{ + int r; + cdb_init(&c,fd); + case_lowers(mf); + r = mfsearch(ip,host,info,mf); + cdb_free(&c); + return r; +} diff -uN /home/pkg/netqmail-1.05/qmail-1.03/mfrules.h /home/pkg/netqmail-1.05/qmail-xuki-patch/mfrules.h --- /home/pkg/netqmail-1.05/qmail-1.03/mfrules.h 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/mfrules.h 2008-01-31 18:09:48.315205440 +0800 @@ -0,0 +1,9 @@ +#ifndef MFRULES_H +#define MFRULES_H + +#include "stralloc.h" + +extern stralloc key; +extern int mfrules(int,char *,char *,char *,char *); + +#endif diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail.7 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail.7 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail.7 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail.7 2008-01-31 18:09:48.316205288 +0800 @@ -64,3 +64,12 @@ for other .BR qmail -related software. + +.BR qmail +is modified with the SPAMCONTROL patch +2.4.18. +The SPAMCONTROL patch can be found at +.B http://www.fehcom.de/qmail.html +in addition with other +.BR qmail -related +software. diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-badloadertypes.0 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badloadertypes.0 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-badloadertypes.0 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badloadertypes.0 2008-01-31 18:09:48.316205288 +0800 @@ -0,0 +1,35 @@ +qmail-badloadertypes(8) qmail-badloadertypes(8) + + + +NNAAMMEE + qmail-badloadertypes - prepare badloadertypes for qmail-smtpd + +SSYYNNOOPPSSIISS + qqmmaaiill--bbaaddllooaaddeerrttyyppeess + +DDEESSCCRRIIPPTTIIOONN + qqmmaaiill--bbaaddllooaaddeerrttyyppeess reads the instructions in //vvaarr//qqmmaaiill//ccoonnttrrooll//bbaadd-- + llooaaddeerrttyyppeess and writes them into //vvaarr//qqmmaaiill//ccoonnttrrooll//bbaaddllooaaddeerrttyyppeess..ccddbb + in a binary format suited for quick access by qqmmaaiill--ssmmttppdd. + + If there is a problem with ccoonnttrrooll//bbaaddllooaaddeerrttyyppeess, qqmmaaiill--bbaaddllooaaddeerrttyyppeess + complains and leaves ccoonnttrrooll//bbaaddllooaaddeerrttyyppeess..ccddbb alone. + + qqmmaaiill--bbaaddllooaaddeerrttyyppeess ensures that ccoonnttrrooll//bbaaddllooaaddeerrttyyppeess..ccddbb is updated + atomically, so qqmmaaiill--ssmmttppdd never has to wait for qqmmaaiill--bbaaddllooaaddeerrttyyppeess + to finish. However, qqmmaaiill--bbaaddllooaaddeerrttyyppeess makes no attempt to protect + against two simultaneous updates of ccoonnttrrooll//bbaaddllooaaddeerrttyyppeess..ccddbb. For + convenience, qqmmaaiill--bbaaddllooaaddeerrttyyppeess allows comments (lines starting with + ’#’) and copies only the significant leading characters to ccoonnttrrooll//bbaadd-- + llooaaddeerrttyyppeess..ccddbb. + + The binary ccoonnttrrooll//bbaaddllooaaddeerrttyyppeess..ccddbb format is portable across + machines. + +SSEEEE AALLSSOO + qmail-smtpd(8) + + + + qmail-badloadertypes(8) diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-badloadertypes.8 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badloadertypes.8 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-badloadertypes.8 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badloadertypes.8 2008-01-31 18:09:48.316205288 +0800 @@ -0,0 +1,46 @@ +.TH qmail-badloadertypes 8 +.SH NAME +qmail-badloadertypes \- prepare badloadertypes for qmail-smtpd +.SH SYNOPSIS +.B qmail-badloadertypes +.SH DESCRIPTION +.B qmail-badloadertypes +reads the instructions in +.B /var/qmail/control/badloadertypes +and writes them into +.B /var/qmail/control/badloadertypes.cdb +in a binary format suited +for quick access by +.BR qmail-smtpd . + +If there is a problem with +.BR control/badloadertypes , +.B qmail-badloadertypes +complains and leaves +.B control/badloadertypes.cdb +alone. + +.B qmail-badloadertypes +ensures that +.B control/badloadertypes.cdb +is updated atomically, +so +.B qmail-smtpd +never has to wait for +.B qmail-badloadertypes +to finish. +However, +.B qmail-badloadertypes +makes no attempt to protect against two simultaneous updates of +.BR control/badloadertypes.cdb . +For convenience, +.B qmail-badloadertypes +allows comments (lines starting with '#') and +copies only the significant leading characters to +.BR control/badloadertypes.cdb . + +The binary +.B control/badloadertypes.cdb +format is portable across machines. +.SH "SEE ALSO" +qmail-smtpd(8) diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-badloadertypes.9 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badloadertypes.9 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-badloadertypes.9 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badloadertypes.9 2008-01-31 18:09:48.316205288 +0800 @@ -0,0 +1,46 @@ +.TH qmail-badloadertypes 8 +.SH NAME +qmail-badloadertypes \- prepare badloadertypes for qmail-smtpd +.SH SYNOPSIS +.B qmail-badloadertypes +.SH DESCRIPTION +.B qmail-badloadertypes +reads the instructions in +.B QMAILHOME/control/badloadertypes +and writes them into +.B QMAILHOME/control/badloadertypes.cdb +in a binary format suited +for quick access by +.BR qmail-smtpd . + +If there is a problem with +.BR control/badloadertypes , +.B qmail-badloadertypes +complains and leaves +.B control/badloadertypes.cdb +alone. + +.B qmail-badloadertypes +ensures that +.B control/badloadertypes.cdb +is updated atomically, +so +.B qmail-smtpd +never has to wait for +.B qmail-badloadertypes +to finish. +However, +.B qmail-badloadertypes +makes no attempt to protect against two simultaneous updates of +.BR control/badloadertypes.cdb . +For convenience, +.B qmail-badloadertypes +allows comments (lines starting with '#') and +copies only the significant leading characters to +.BR control/badloadertypes.cdb . + +The binary +.B control/badloadertypes.cdb +format is portable across machines. +.SH "SEE ALSO" +qmail-smtpd(8) diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-badloadertypes.c /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badloadertypes.c --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-badloadertypes.c 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badloadertypes.c 2008-01-31 18:09:48.317205136 +0800 @@ -0,0 +1,64 @@ +#include "strerr.h" +#include "stralloc.h" +#include "substdio.h" +#include "getln.h" +#include "exit.h" +#include "readwrite.h" +#include "open.h" +#include "auto_qmail.h" +#include "cdbmss.h" + +#define FATAL "qmail-badloadertypes: fatal: " +#define LOADER_LEN 5 + +void die_read() +{ + strerr_die2sys(111,FATAL,"unable to read control/badloadertypes: "); +} +void die_write() +{ + strerr_die2sys(111,FATAL,"unable to write to control/badloadertypes.tmp: "); +} + +char inbuf[1024]; +substdio ssin; + +int fd; +int fdtemp; + +struct cdbmss cdbmss; +stralloc line = {0}; +int match; + +void main() +{ + umask(033); + if (chdir(auto_qmail) == -1) + strerr_die4sys(111,FATAL,"unable to chdir to ",auto_qmail,": "); + + fd = open_read("control/badloadertypes"); + if (fd == -1) die_read(); + + substdio_fdbuf(&ssin,read,fd,inbuf,sizeof inbuf); + + fdtemp = open_trunc("control/badloadertypes.tmp"); + if (fdtemp == -1) die_write(); + + if (cdbmss_start(&cdbmss,fdtemp) == -1) die_write(); + + for (;;) { + if (getln(&ssin,&line,&match,'\n') != 0) die_read(); + if (line.s[0] != '#' && line.len > LOADER_LEN) + if (cdbmss_add(&cdbmss,line.s,LOADER_LEN,"",0) == -1) + die_write(); + if (!match) break; + } + + if (cdbmss_finish(&cdbmss) == -1) die_write(); + if (fsync(fdtemp) == -1) die_write(); + if (close(fdtemp) == -1) die_write(); /* NFS stupidity */ + if (rename("control/badloadertypes.tmp","control/badloadertypes.cdb") == -1) + strerr_die2sys(111,FATAL,"unable to move control/badloadertypes.tmp to control/badloadertypes.cdb"); + + _exit(0); +} diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-badmimetypes.0 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badmimetypes.0 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-badmimetypes.0 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badmimetypes.0 2008-01-31 18:09:48.317205136 +0800 @@ -0,0 +1,34 @@ +qmail-badmimetype(8) qmail-badmimetype(8) + + + +NNAAMMEE + qmail-badmimetypes - prepare badmimetypes for qmail-smtpd + +SSYYNNOOPPSSIISS + qqmmaaiill--bbaaddmmiimmeettyyppee + +DDEESSCCRRIIPPTTIIOONN + qqmmaaiill--bbaaddmmiimmeettyyppeess reads the instructions in //vvaarr//qqmmaaiill//ccoonnttrrooll//bbaadd-- + mmiimmeettyyppeess and writes them into //vvaarr//qqmmaaiill//ccoonnttrrooll//bbaaddmmiimmeettyyppeess..ccddbb in a + binary format suited for quick access by qqmmaaiill--ssmmttppdd. + + If there is a problem with ccoonnttrrooll//bbaaddmmiimmeettyyppeess, qqmmaaiill--bbaaddmmiimmeettyyppeess + complains and leaves ccoonnttrrooll//bbaaddmmiimmeettyyppeess..ccddbb alone. + + qqmmaaiill--bbaaddmmiimmeettyyppeess ensures that ccoonnttrrooll//bbaaddmmiimmeettyyppeess..ccddbb is updated + atomically, so qqmmaaiill--ssmmttppdd never has to wait for qqmmaaiill--bbaaddmmiimmeettyyppeess to + finish. However, qqmmaaiill--bbaaddmmiimmeettyyppeess makes no attempt to protect + against two simultaneous updates of ccoonnttrrooll//bbaaddmmiimmeettyyppeess..ccddbb. For con- + venience, qqmmaaiill--bbaaddmmiimmeettyyppeess allows comments (lines starting with ’#’) + and copies only the significant leading characters to ccoonnttrrooll//bbaaddmmiimmee-- + ttyyppeess..ccddbb. + + The binary ccoonnttrrooll//bbaaddmmiimmeettyyppeess..ccddbb format is portable across machines. + +SSEEEE AALLSSOO + qmail-smtpd(8) + + + + qmail-badmimetype(8) diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-badmimetypes.8 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badmimetypes.8 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-badmimetypes.8 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badmimetypes.8 2008-01-31 18:09:48.317205136 +0800 @@ -0,0 +1,46 @@ +.TH qmail-badmimetype 8 +.SH NAME +qmail-badmimetypes \- prepare badmimetypes for qmail-smtpd +.SH SYNOPSIS +.B qmail-badmimetype +.SH DESCRIPTION +.B qmail-badmimetypes +reads the instructions in +.B /var/qmail/control/badmimetypes +and writes them into +.B /var/qmail/control/badmimetypes.cdb +in a binary format suited +for quick access by +.BR qmail-smtpd . + +If there is a problem with +.BR control/badmimetypes , +.B qmail-badmimetypes +complains and leaves +.B control/badmimetypes.cdb +alone. + +.B qmail-badmimetypes +ensures that +.B control/badmimetypes.cdb +is updated atomically, +so +.B qmail-smtpd +never has to wait for +.B qmail-badmimetypes +to finish. +However, +.B qmail-badmimetypes +makes no attempt to protect against two simultaneous updates of +.BR control/badmimetypes.cdb . +For convenience, +.B qmail-badmimetypes +allows comments (lines starting with '#') and +copies only the significant leading characters to +.BR control/badmimetypes.cdb . + +The binary +.B control/badmimetypes.cdb +format is portable across machines. +.SH "SEE ALSO" +qmail-smtpd(8) diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-badmimetypes.9 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badmimetypes.9 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-badmimetypes.9 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badmimetypes.9 2008-01-31 18:09:48.317205136 +0800 @@ -0,0 +1,46 @@ +.TH qmail-badmimetype 8 +.SH NAME +qmail-badmimetypes \- prepare badmimetypes for qmail-smtpd +.SH SYNOPSIS +.B qmail-badmimetype +.SH DESCRIPTION +.B qmail-badmimetypes +reads the instructions in +.B QMAILHOME/control/badmimetypes +and writes them into +.B QMAILHOME/control/badmimetypes.cdb +in a binary format suited +for quick access by +.BR qmail-smtpd . + +If there is a problem with +.BR control/badmimetypes , +.B qmail-badmimetypes +complains and leaves +.B control/badmimetypes.cdb +alone. + +.B qmail-badmimetypes +ensures that +.B control/badmimetypes.cdb +is updated atomically, +so +.B qmail-smtpd +never has to wait for +.B qmail-badmimetypes +to finish. +However, +.B qmail-badmimetypes +makes no attempt to protect against two simultaneous updates of +.BR control/badmimetypes.cdb . +For convenience, +.B qmail-badmimetypes +allows comments (lines starting with '#') and +copies only the significant leading characters to +.BR control/badmimetypes.cdb . + +The binary +.B control/badmimetypes.cdb +format is portable across machines. +.SH "SEE ALSO" +qmail-smtpd(8) diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-badmimetypes.c /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badmimetypes.c --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-badmimetypes.c 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-badmimetypes.c 2008-01-31 18:09:48.318204984 +0800 @@ -0,0 +1,64 @@ +#include "strerr.h" +#include "stralloc.h" +#include "substdio.h" +#include "getln.h" +#include "exit.h" +#include "readwrite.h" +#include "open.h" +#include "auto_qmail.h" +#include "cdbmss.h" + +#define FATAL "qmail-badmimetypes: fatal: " +#define MIMETYPE_LEN 9 + +void die_read() +{ + strerr_die2sys(111,FATAL,"unable to read control/badmimetypes: "); +} +void die_write() +{ + strerr_die2sys(111,FATAL,"unable to write to control/badmimetypes.tmp: "); +} + +char inbuf[1024]; +substdio ssin; + +int fd; +int fdtemp; + +struct cdbmss cdbmss; +stralloc line = {0}; +int match; + +void main() +{ + umask(033); + if (chdir(auto_qmail) == -1) + strerr_die4sys(111,FATAL,"unable to chdir to ",auto_qmail,": "); + + fd = open_read("control/badmimetypes"); + if (fd == -1) die_read(); + + substdio_fdbuf(&ssin,read,fd,inbuf,sizeof inbuf); + + fdtemp = open_trunc("control/badmimetypes.tmp"); + if (fdtemp == -1) die_write(); + + if (cdbmss_start(&cdbmss,fdtemp) == -1) die_write(); + + for (;;) { + if (getln(&ssin,&line,&match,'\n') != 0) die_read(); + if (line.s[0] != '#' && line.len > MIMETYPE_LEN) + if (cdbmss_add(&cdbmss,line.s,MIMETYPE_LEN,"",0) == -1) + die_write(); + if (!match) break; + } + + if (cdbmss_finish(&cdbmss) == -1) die_write(); + if (fsync(fdtemp) == -1) die_write(); + if (close(fdtemp) == -1) die_write(); /* NFS stupidity */ + if (rename("control/badmimetypes.tmp","control/badmimetypes.cdb") == -1) + strerr_die2sys(111,FATAL,"unable to move control/badmimetypes.tmp to control/badmimetypes.cdb"); + + _exit(0); +} diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail.c /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail.c --- /home/pkg/netqmail-1.05/qmail-1.03/qmail.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail.c 2008-01-31 18:09:48.318204984 +0800 @@ -6,8 +6,17 @@ #include "fd.h" #include "qmail.h" #include "auto_qmail.h" +#include "env.h" -static char *binqqargs[2] = { "bin/qmail-queue", 0 } ; +static char *binqqargs[2] = { 0, 0 } ; + +static void setup_qqargs() +{ + if(!binqqargs[0]) + binqqargs[0] = env_get("QMAILQUEUE"); + if(!binqqargs[0]) + binqqargs[0] = "bin/qmail-queue"; +} int qmail_open(qq) struct qmail *qq; @@ -15,6 +24,8 @@ int pim[2]; int pie[2]; + setup_qqargs(); + if (pipe(pim) == -1) return -1; if (pipe(pie) == -1) { close(pim[0]); close(pim[1]); return -1; } diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-clean.c /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-clean.c --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-clean.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-clean.c 2008-01-31 18:09:48.318204984 +0800 @@ -17,6 +17,7 @@ #include "fmtqfn.h" #include "auto_qmail.h" +/* #define BIGTODO */ #define OSSIFIED 129600 /* see qmail-send.c */ stralloc line = {0}; @@ -73,22 +74,43 @@ if (line.len < 7) { respond("x"); continue; } if (line.len > 100) { respond("x"); continue; } if (line.s[line.len - 1]) { respond("x"); continue; } /* impossible */ +#ifdef BIGTODO + for (i = line.len - 2;i > 4;--i) + { + if (line.s[i] == '/') break; +#else for (i = 5;i < line.len - 1;++i) +#endif if ((unsigned char) (line.s[i] - '0') > 9) { respond("x"); continue; } +#ifdef BIGTODO + } + if (line.s[i] == '/') + if (!scan_ulong(line.s + i + 1,&id)) { respond("x"); continue; } +#else if (!scan_ulong(line.s + 5,&id)) { respond("x"); continue; } +#endif if (byte_equal(line.s,5,"foop/")) { #define U(prefix,flag) fmtqfn(fnbuf,prefix,id,flag); \ if (unlink(fnbuf) == -1) if (errno != error_noent) { respond("!"); continue; } +#ifdef BIGTODO + U("intd/",1) +#else U("intd/",0) +#endif U("mess/",1) respond("+"); } else if (byte_equal(line.s,4,"todo/")) { +#ifdef BIGTODO + U("intd/",1) + U("todo/",1) +#else U("intd/",0) U("todo/",0) +#endif respond("+"); } else diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-control.9 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-control.9 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-control.9 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-control.9 2008-01-31 18:09:48.318204984 +0800 @@ -18,9 +18,10 @@ This file is used as the default for other hostname-related control files. -Comments are allowed +Comments (\'# comment\') are allowed in .IR badmailfrom , +.IR badmimtypes , .IR locals , .IR percenthack , .IR qmqpservers , @@ -28,7 +29,7 @@ .IR smtproutes , and .IR virtualdomains . -Trailing spaces and tabs are allowed in any control file. +Trailing spaces and tabs are allowed in any control. The following table lists all control files other than @@ -40,14 +41,19 @@ .ta 5c 10c control default used by +.I authsenders \fR(none) \fRqmail-remote +.I badhelo \fR(none) \fRqmail-smtpd .I badmailfrom \fR(none) \fRqmail-smtpd +.I badmimetypes \fR$BADMIMETYPE \fRqmail-smtpd +.I badrcptto \fR(none) \fRqmail-smtpd .I bouncefrom \fRMAILER-DAEMON \fRqmail-send .I bouncehost \fIme \fRqmail-send +.I bouncemaxbytes \fI0 \fRqmail-send .I concurrencylocal \fR10 \fRqmail-send .I concurrencyremote \fR20 \fRqmail-send .I defaultdomain \fIme \fRqmail-inject .I defaulthost \fIme \fRqmail-inject -.I databytes \fR0 \fRqmail-smtpd +.I databytes \fR$DATABYTES \fRqmail-smtpd .I doublebouncehost \fIme \fRqmail-send .I doublebounceto \fRpostmaster \fRqmail-send .I envnoathost \fIme \fRqmail-send @@ -55,24 +61,44 @@ .I idhost \fIme \fRqmail-inject .I localiphost \fIme \fRqmail-smtpd .I locals \fIme \fRqmail-send +.I moreip \fR(none) \fRqmail-smtpd (c) .I morercpthosts \fR(none) \fRqmail-smtpd +.I mailfromrules \fR(none) \fRqmail-smtpd +.I notipme \fR(none) \fRqmail-smtpd .I percenthack \fR(none) \fRqmail-send .I plusdomain \fIme \fRqmail-inject .I qmqpservers \fR(none) \fRqmail-qmqpc .I queuelifetime \fR604800 \fRqmail-send +.I recipients \fR(none) \fRqmail-smtpd +.I relaymailfrom \fR(none) \fRqmail-smtpd (c) .I rcpthosts \fR(none) \fRqmail-smtpd .I smtpgreeting \fIme \fRqmail-smtpd .I smtproutes \fR(none) \fRqmail-remote +.I taps \fR(none) \fRqmail-queue +.I tarpitcount \fR$TARPITCOUNT=0 \fRqmail-smtpd +.I tarpitdelay \fR$TARPITDELAY=5 \fRqmail-smtpd .I timeoutconnect \fR60 \fRqmail-remote .I timeoutremote \fR1200 \fRqmail-remote .I timeoutsmtpd \fR1200 \fRqmail-smtpd .I virtualdomains \fR(none) \fRqmail-send .fi + .RE +.IR Defaultvalues +following a $ sign (ie. $RELAYCLIENT) depend on the +corresponding environment variable. + +.IR Compiler +options can be used to activate support for additional +control files marked with a (c). Use +.BR qmail-showctl +to display actual settings. + .SH "SEE ALSO" qmail-inject(8), qmail-qmqpc(8), +qmail-queue(8), qmail-remote(8), qmail-send(8), qmail-showctl(8), -qmail-smtpd(8) +qmail-smtpd(8). diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-local.c /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-local.c --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-local.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-local.c 2008-01-31 18:09:48.319204832 +0800 @@ -645,7 +645,8 @@ { cmds.s[j] = 0; k = j; - while ((k > i) && (cmds.s[k - 1] == ' ') || (cmds.s[k - 1] == '\t')) + /* Recommended patch contributed by Matthias Andree */ + while ((k > i) && ((cmds.s[k - 1] == ' ') || (cmds.s[k - 1] == '\t'))) cmds.s[--k] = 0; switch(cmds.s[i]) { diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-log.5 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-log.5 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-log.5 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-log.5 2008-01-31 18:09:48.319204832 +0800 @@ -108,6 +108,13 @@ is .IR q . .TP +.B double bounce: discarding ... +Message +.I m +was discarded due to an \'empty\' recipient in +. +.IR doublebounceto . +.TP .B triple bounce: discarding ... Message .I m @@ -232,6 +239,11 @@ is unable to queue a bounce message, usually because the machine is almost out of memory. It will try again later. +This can also be caused by incorrect settings of +.B $QMAILQUEUE +or errors in a program or script which +.B $QMAILQUEUE ++points to. .TP .B unable to stat ... .B qmail-send @@ -257,5 +269,172 @@ .B qmail-queue or .BR qmail-send . + +.SH "SPAMCONTROL INFORMATION" +.B qmail-smtpd +logs additional information in the extensible format +\fIAction::Type::Condition:\fB \fIInformation\fB. + +.I Action +is either +.IR Reject , +or +.IR Accept . +.I Type +is one from +.IR SMTP , +.IR SNDR , +.IR ORIG , +.IR RCTP , +or +.IR DATA . +.I SNDR +is the hostname of the sending MTA, +.I ORIG +is the return path \fF:\fB, +.I RCPT +is the forwarding path \fIT:\fB, +.I DATA +is the message. + +The following Condition and Information are currently provided: +.TP +.I Bad_Helo +the client's HELO/EHLO greeting string was found in +.IR badhelo +or rejected because of one of the following conditions indicated +in the information section: '!' (HELO/EHLO not provided/empty) +, '\.'/'*' (HELO/EHLO rejected due to a direct/wildmat match with entries in +.IR badhelo ). +.TP +.I Bad_Loader +the content of a base64 encoded MIME part matched an +entry in +.IR badloadertypes.cdb . +.TP +.I Bad_MIME +a base64 encoded MIME part matched an entry n +.IR badmimetypes.cdb . +.TP +.I Bad_Mailfrom +the provided matched an entry in +.I badmailfrom +additionally with the rejection conditions: '@' (address), '*' +(wildmat), '-' (badmailfromunknown), and '+' (spoofing). +.TP +.I Bad_Rcptto +the provided matched an entry in +.IR badrcptto . + +.TP +.I DNS_Helo +the client's HELO/EHLO greeting did not match it's +FQDN or no DNS A/MX RR was found as indicated with the +following symbols: '=' (HELO/EHLO does not match +.BR TCPREMOTEHOST ) +, 'A' (DNS A-Name lookup failed for HELO/EHLO) +, 'M' (DNS MX lookup failed for HELO/EHLO). +.TP +.I DNS_MF +no DNS MX RR was found for the . + +.TP +.I Failed_Rcptto +the did not match entry in the provdided +cdbs as per +.IR recipients . + +.TP +.I Invalid_Relay +the none-RELAYCLIENT provided a not +allowed as per +.I rcpthosts +or +.IR morercpthosts.cdb . +.TP +.I Invalid_Sender +the of a RELAYCLIENT did not match the +provided value of LOCALMFCHECK or did not match against +.I mailfromrules.cdb +or was not found in +.I rcpthosts +or +.IR morercpthosts.cdb . +.TP +.I Invalid_Size +the message size exceeded the maximum as provided by +DATEBYTES or +.IR databytes . + +.TP +.I Toomany_Rcptto +the number of Recipients ('RCPT TO:') exaggerated the +value provided as MAXRECPIENTS. + +.TP +.I Start_TLS +TLS session encryption started. +.TP +.I Missing_TLS +TLS was required for this connection but not achieved. + +.TP +.I Failed_Auth +in SMTP authentication, the user could not authenticated. +.TP +.IR Missing_Auth , +SMTP authentication was required (REQAUTH), but was not granted. +.TP +.IR Valid_Auth +SMTP authentication was granted. + +.TP +.I Recipients_Rcptto +the matched an entry in the cdbs available per +.IR reccients . +.TP +.I Recipients_Verp +the Forwarding-Path was recogized as VERP and matched an entry +in the cdbs available per +.IR recipients . +.TP +.I Recipients_Domain +the Forwarding-Path matched a wildcard domain entry in the cdbs +available per +.IR recipients . +.TP +.I Rcpthosts_Rcptto +the domain part of the matched an entry in +.I rcpthosts +or +.IR morercpthosts.cdb . + +.TP +.I P:protocol +the effective ESMTP protocol variant in use. +.TP +.I S:IP:FQDN +the clients IP and FQDN address available via +TCPREMOTEIP and TCPREMOTEHOST. +.TP +.I H:string +the clients HELO/EHLO greeting string. +.TP +.I F:Return-Path +the provided 'MAIL FROM:' address (if any). +.TP +.I T:Forwarding-Path +the given 'RCPT TO:' address. +.TP +.I 'authtype' ?= 'userid' +in case of SMTP authentication it's type and the userid. +.TP +.I 'cipher' != 'DN' +in case of TLS the actual cipher used and the client's +\'Subject\' Distinguished Name (DN) - if available +(otherwise \'unknown\'). + .SH "SEE ALSO" -qmail-send(8) +qmail-send(8), +qmail-smtpd(8), +qmail-control(9) Binary files /home/pkg/netqmail-1.05/qmail-1.03/qmail-mfrules and /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-mfrules differ diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-mfrules.0 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-mfrules.0 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-mfrules.0 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-mfrules.0 2008-01-31 18:40:42.387343632 +0800 @@ -0,0 +1,91 @@ +qmail-mfrules(8) qmail-mfrules(8) + + + +NNAAMMEE + qmail-mfrules - prepare mfrules for qmail-smtpd + +SSYYNNOOPPSSIISS + qqmmaaiill--mmffrruulleess + +DDEESSCCRRIIPPTTIIOONN + qqmmaaiill--mmffrruulleess reads the addresses provided in //vvaarr//qqmmaaiill//ccoonnttrrooll//mmaaiill-- + ffrroommrruulleess, converts them into lowercase, and writes them into + //vvaarr//qqmmaaiill//ccoonnttrrooll//mmaaiillffrroommrruulleess..ccddbb in a binary format suited for + quick access by qqmmaaiill--ssmmttppdd. + + If there is a problem with ccoonnttrrooll//mmaaiillffrroommrruulleess, qqmmaaiill--mmffrruulleess com- + plains and leaves ccoonnttrrooll//mmaaiillffrroommrruulleess..ccddbb alone. + + qqmmaaiill--mmffrruulleess ensures that ccoonnttrrooll//mmaaiillffrroommrruulleess..ccddbb is updated atomi- + cally, so qqmmaaiill--ssmmttppdd never has to wait for qqmmaaiill--mmffrruulleess to finish. + However, qqmmaaiill--mmffrruulleess makes no attempt to protect against two simulta- + neous updates of ccoonnttrrooll//mmaaiillffrroommrruulleess..ccddbb. + + The binary ccoonnttrrooll//mmaaiillffrroommrruulleess..ccddbb format is portable across + machines. + + +RRUULLEE FFOORRMMAATT + A rule is one line. A file containing rules may also contain comments: + lines beginning with # are ignored. All addresses are evaluated case- + insensitive. + + Each rule contains an address, a colon, and a list of strings separated + by commas to be used for ’Mail From: Address Verification’ (MAV). When + qqmmaaiill--ssmmttppdd(8) receives a connection from that address, it checks + whether the received envelope sender address correspondes with a MAV + string (from the right to the left). The MAV string for an address may + be NULL in order to allow any envelope sender address. NULLSENDER enve- + lope addresses are not subject of the MAV. + + +AADDDDRREESSSSEESS + qqmmaaiill--ssmmttppdd(8) looks for rules with various addresses in the following + order: + + 1 $TCPREMOTEINNFO, if $TCPREMOTEINFO is set (e.g. by SMTP Authen- + tication); + + 2. $TCPREMOTEINFO@$TCPREMOTEIP, if $TCPREMOTEINFO is set; + + 3. $TCPREMOTEINFO@=$TCPREMOTEHOST, if $TCPREMOTEINFO is set and + $TCPREMOTEHOST is set; + + 4. $TCPREMOTEIP; + + 5. =$TCPREMOTEHOST, if $TCPREMOTEHOST is set; + + 6. shorter and shorter prefixes of $TCPREMOTEIP ending with a dot; + + 7. shorter and shorter suffixes of $TCPREMOTEHOST starting with a + dot, preceded by =, if $TCPREMOTEHOST is set; and finally + + 8. =, if $TCPREMOTEHOST is set. + + qqmmaaiill--ssmmttppdd(1) employes the first matching rule for the MAV check. You + should use the --pp option to ttccppsseerrvveerr(1) if you rely on $TCPREMOTEHOST + here. + + For example, here are some rules: + + jsmith@virtualdomain.com:john.smith@virtualdomain.com + joe@18.23.0.32:joe@example.com + 18.23.0.32:@example.com + =.heaven.mil:god@heaven.mil,st.peter@heaven.mil,-angles@heaven.mil + 127.:localhost + + + +AADDDDRREESSSS RRAANNGGEESS + qqmmaaiill--ssmmttppdd treats 1.2.3.37-53:ins as an abbreviation for the rules + 1.2.3.37:ins, 1.2.3.38:ins, and so on up through 1.2.3.53:ins. Simi- + larly, 10.2-3.:ins is an abbreviation for 10.2.:ins and 10.3.:ins. + + +SSEEEE AALLSSOO + qmail-smtpd(8) + + + + qmail-mfrules(8) diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-mfrules.9 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-mfrules.9 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-mfrules.9 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-mfrules.9 2008-01-31 18:09:48.320204680 +0800 @@ -0,0 +1,99 @@ +.TH qmail-mfrules 8 +.SH NAME +qmail-mfrules \- prepare mfrules for qmail-smtpd +.SH SYNOPSIS +.B qmail-mfrules +.SH DESCRIPTION +.B qmail-mfrules +reads the addresses provided in +.BR QMAILHOME/control/mailfromrules , +converts them into lowercase, and writes them into +.B QMAILHOME/control/mailfromrules.cdb +in a binary format suited +for quick access by +.BR qmail-smtpd . + +If there is a problem with +.BR control/mailfromrules , +.B qmail-mfrules +complains and leaves +.B control/mailfromrules.cdb +alone. + +.B qmail-mfrules +ensures that +.B control/mailfromrules.cdb +is updated atomically, +so +.B qmail-smtpd +never has to wait for +.B qmail-mfrules +to finish. +However, +.B qmail-mfrules +makes no attempt to protect against two simultaneous updates of +.BR control/mailfromrules.cdb . + +The binary +.B control/mailfromrules.cdb +format is portable across machines. + +.SH "RULE FORMAT" +A rule is one line. A file containing rules may also contain comments: lines +beginning with # are ignored. All addresses are evaluated case-insensitive. + +Each rule contains an address, a colon, and a list of strings separated by +commas to be used for 'Mail From: Address Verification' (MAV). When +.BR qmail-smtpd (8) +receives a connection from that address, it checks whether the received +envelope sender address correspondes with a MAV string (from the right +to the left). +The MAV string for an address may be NULL in order to allow any envelope +sender address. NULLSENDER envelope addresses are not subject of the MAV. + +.SH ADDRESSES +.BR qmail-smtpd (8) +looks for rules with various addresses in the following order: +.IP 1 +$TCPREMOTEINNFO, if $TCPREMOTEINFO is set (e.g. by SMTP Authentication); +.IP 2. +$TCPREMOTEINFO@$TCPREMOTEIP, if $TCPREMOTEINFO is set; +.IP 3. +$TCPREMOTEINFO@=$TCPREMOTEHOST, if $TCPREMOTEINFO is set and $TCPREMOTEHOST is +set; +.IP 4. +$TCPREMOTEIP; +.IP 5. +=$TCPREMOTEHOST, if $TCPREMOTEHOST is set; +.IP 6. +shorter and shorter prefixes of $TCPREMOTEIP ending with a dot; +.IP 7. +shorter and shorter suffixes of $TCPREMOTEHOST starting with a dot, preceded +by =, if $TCPREMOTEHOST is set; and finally +.IP 8. +=, if $TCPREMOTEHOST is set. +.P +.BR qmail-smtpd (1) +employes the first matching rule for the MAV check. You should use the +.B -p +option to +.BR tcpserver (1) +if you rely on $TCPREMOTEHOST here. + +For example, here are some rules: + + jsmith@virtualdomain.com:john.smith@virtualdomain.com + joe@18.23.0.32:joe@example.com + 18.23.0.32:@example.com + =.heaven.mil:god@heaven.mil,st.peter@heaven.mil,-angles@heaven.mil + 127.:localhost + + +.SH ADDRESS RANGES +.B qmail-smtpd +treats 1.2.3.37-53:ins as an abbreviation for the rules 1.2.3.37:ins, +1.2.3.38:ins, and so on up through 1.2.3.53:ins. Similarly, 10.2-3.:ins is an +abbreviation for 10.2.:ins and 10.3.:ins. + +.SH "SEE ALSO" +qmail-smtpd(8) diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-mfrules.c /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-mfrules.c --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-mfrules.c 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-mfrules.c 2008-01-31 18:09:48.320204680 +0800 @@ -0,0 +1,175 @@ +#include "strerr.h" +#include "stralloc.h" +#include "substdio.h" +#include "getln.h" +#include "error.h" +#include "exit.h" +#include "readwrite.h" +#include "open.h" +#include "auto_qmail.h" +#include "cdbmss.h" +#include "fmt.h" +#include "scan.h" +#include "byte.h" + +#define FATAL "qmail-mfrules: fatal: " + +stralloc address = {0}; +stralloc data = {0}; +stralloc key = {0}; +stralloc line = {0}; + +char inbuf[1024]; +substdio ssin; + +int fd; +int fdtemp; +int match = 1; + +struct cdbmss cdbmss; + +void die_nomem(void) +{ + strerr_die2x(112,FATAL,"out of memory"); +} +void die_parse(void) +{ + if (!stralloc_0(&line)) die_nomem(); + strerr_die3x(100,FATAL,"unable to parse this line: ",line.s); +} +void die_read() +{ + strerr_die2sys(111,FATAL,"unable to read control/mailfromrules: "); +} +void die_write() +{ + strerr_die2sys(111,FATAL,"unable to write to control/mailfromrules.tmp: "); +} + +char strnum[FMT_ULONG]; +stralloc sanum = {0}; + +void getnum(char *buf,int len,unsigned long *u) +{ + if (!stralloc_copyb(&sanum,buf,len)) die_nomem(); + if (!stralloc_0(&sanum)) die_nomem(); + if (sanum.s[scan_ulong(sanum.s,u)]) die_parse(); +} + +void doaddressdata(void) +{ + int i; + int left; + int right; + unsigned long bot; + unsigned long top; + + if (byte_chr(address.s,address.len,'=') == address.len) + if (byte_chr(address.s,address.len,'@') == address.len) { + i = byte_chr(address.s,address.len,'-'); + if (i < address.len) { + left = byte_rchr(address.s,i,'.'); + if (left == i) left = 0; else ++left; + + ++i; + right = i + byte_chr(address.s + i,address.len - i,'.'); + + getnum(address.s + left,i - 1 - left,&bot); + getnum(address.s + i,right - i,&top); + if (top > 255) top = 255; + + while (bot <= top) { + if (!stralloc_copyb(&key,address.s,left)) die_nomem(); + if (!stralloc_catb(&key,strnum,fmt_ulong(strnum,bot))) die_nomem(); + if (!stralloc_catb(&key,address.s + right,address.len - right)) die_nomem(); + case_lowerb(key.s,key.len); + if (cdbmss_add(&cdbmss,key.s,key.len,data.s,data.len) == -1) die_write(); + ++bot; + } + + return; + } + } + + case_lowerb(address.s,address.len); + case_lowerb(data.s,data.len); + if (cdbmss_add(&cdbmss,address.s,address.len,data.s,data.len) == -1) die_write(); +} + +void main() +{ + int colon; + int dot; + int i; + int len; + char *x; + char ch; + + umask(033); + if (chdir(auto_qmail) == -1) + strerr_die4sys(111,FATAL,"unable to chdir to ",auto_qmail,": "); + + fd = open_read("control/mailfromrules"); + if (fd == -1) die_read(); + + substdio_fdbuf(&ssin,read,fd,inbuf,sizeof inbuf); + + fdtemp = open_trunc("control/mailfromrules.tmp"); + if (fdtemp == -1) die_write(); + + if (cdbmss_start(&cdbmss,fdtemp) == -1) die_write(); + + while (match) { + if (getln(&ssin,&line,&match,'\n') != 0) die_read(); + + x = line.s; len = line.len; + + if (!len) break; + if (x[0] == '#') continue; + if (x[0] == '\n') continue; + + while (len) { + ch = x[len - 1]; + if (ch != '\n') if (ch != ' ') if (ch != '\t') break; + --len; + } + line.len = len; /* for die_parse() */ + + colon = byte_chr(x,len,':'); + if (!colon) die_parse(); + if (colon) if (colon == len || colon < 2) die_parse(); + + dot = byte_chr(x,len,'.'); + if (!dot) die_parse(); + if (dot) if (dot == len) die_parse(); + + if (!stralloc_copyb(&address,x,colon)) die_nomem(); + if (!stralloc_copys(&data,"")) die_nomem(); + + x = line.s + colon + 1; len = line.len - colon - 1; + + while (len) { + if (len < 3) die_parse(); /* input checks */ + if ( *x == ',' || *x == ' ' || *x == '\t') die_parse(); + i = byte_chr(x,len,','); + if (i > 0 && i < len) { + if (!stralloc_catb(&data,"+",1)) die_nomem(); + if (!stralloc_catb(&data,x,i)) die_nomem(); + x += i + 1; len -= i + 1; } + else { + if (!stralloc_catb(&data,"+",1)) die_nomem(); + if (!stralloc_catb(&data,x,len)) die_nomem(); + len = 0; } + } + + doaddressdata(); + } + + if (cdbmss_finish(&cdbmss) == -1) die_write(); + if (fsync(fdtemp) == -1) die_write(); + if (close(fdtemp) == -1) die_write(); /* NFS stupidity */ + if (rename("control/mailfromrules.tmp","control/mailfromrules.cdb") == -1) + strerr_die2sys(111,FATAL,"unable to move control/mailfromrules.tmp to control/mailfromrules.cdb"); + + _exit(0); +} diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-popup.8 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-popup.8 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-popup.8 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-popup.8 2008-01-31 18:09:48.321204528 +0800 @@ -12,12 +12,12 @@ .IR subprogram . .B qmail-popup -is most commonly invoked from -.B inetd +typically from +.B tcpserver as .EX - qmail-popup CHANGEME checkpassword qmail-pop3d Maildir + tcpserver 0 pop3 qmail-popup CHANGEME checkpassword qmail-pop3d Maildir .EE with @@ -54,6 +54,18 @@ an active attacker can still take over the connection and wreak havoc. +However, +.B qmail-popup +can be adviced to use a TLS encrypted session by means of the environment variable UCSPITLS. +In this case, +.B qmail-popup +communicates with +.B sslserver +instead of the +.B tcpserver +program interface through a control socket, a reading and a writing pipe dynamically +defined during the session start to be used for transport layer encryption. + .B qmail-popup has a 20-minute idle timeout. diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-popup.c /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-popup.c --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-popup.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-popup.c 2008-01-31 18:09:48.321204528 +0800 @@ -13,6 +13,8 @@ #include "readwrite.h" #include "timeoutread.h" #include "timeoutwrite.h" +#include "env.h" +#include "ucspitls.h" void die() { _exit(1); } @@ -61,6 +63,7 @@ void die_fork() { err("unable to fork"); die(); } void die_childcrashed() { err("aack, child crashed"); } void die_badauth() { err("authorization failed"); } +void die_tls() { err("TLS startup failed"); die(); } void err_syntax() { err("syntax error"); } void err_wantuser() { err("USER first"); } @@ -77,7 +80,7 @@ char **childargs; substdio ssup; char upbuf[128]; - +int stls = 0; void doanddie(user,userlen,pass) char *user; @@ -155,12 +158,36 @@ *space++ = 0; doanddie(arg,space - arg,space); } +void pop3_capa(arg) char *arg; +{ + puts("+OK capability list follows\r\n"); + if (stls == 1) + puts("STLS\r\n"); + puts(".\r\n"); + flush(); +} +void pop3_stls(arg) char *arg; +{ + if (stls != 1) + return err("STLS not available"); + puts("+OK starting TLS negotiation\r\n"); + flush(); + + if (!ucspitls()) + die_tls(); + + stls = 2; + /* reset state */ + seenuser = 0; +} struct commands pop3commands[] = { { "user", pop3_user, 0 } , { "pass", pop3_pass, 0 } , { "apop", pop3_apop, 0 } , { "quit", pop3_quit, 0 } +, { "capa", pop3_capa, 0 } +, { "stls", pop3_stls, 0 } , { "noop", okay, 0 } , { 0, err_authoriz, 0 } } ; @@ -176,6 +203,8 @@ if (!hostname) die_usage(); childargs = argv + 2; if (!*childargs) die_usage(); + + if (env_get("UCSPITLS")) stls = 1; pop3_greet(); commands(&ssin,pop3commands); diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-queue.8 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-queue.8 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-queue.8 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-queue.8 2008-01-31 18:09:48.321204528 +0800 @@ -40,6 +40,18 @@ However, the recipients probably expect to see a proper header, as described in .BR qmail-header(5) . +.SH "CONTROL FILES" +.TP 5 +.I taps +Should contain regex syntax of email addresses to tap and +the associated email address to send the copy to. The two +fields should be separated by a colon. + +Programs included with qmail which invoke +.B qmail-queue +will invoke the contents of +.B QMAILQUEUE +instead, if that environment variable is set. .SH "FILESYSTEM RESTRICTIONS" .B qmail-queue imposes two constraints on the queue structure: @@ -93,8 +105,10 @@ .TP .B 55 Unable to read a configuration file. -(Not used by -.BR qmail-queue .) +The virus scanner called via the +.BR QHPSI +returned with return code other then +0 or QHPSIRC. .TP .B 56 Problem making a network connection from this host. @@ -145,6 +159,31 @@ .TP .B 91 Envelope format error. +.SH "QHPSI ARGUMENTS" +The Qmail High Performance Scanner interface QHPSI allows +.B qmail-queue +to read up to seven arguments taken from the environment to be used +as a call-interface for an external virus scanner: +.TP 5 +.B QHPSI +is set to the file name of the virus scanner, ie. QHPSI='/usr/local/bin/clamscan'. +The path can be omitted, if the virus scanner is in the default path. +.TP +.B QHPSIARG1...3 +Optional additional arguments can be included here, ie. QHPSIARG1="--verbose". +Useful to suppress output in case an email is +clean and to enable mailbox support for the virus scanner. +.TP +.B QHPSIRC +To specify the return code of the virus scanner in case of an infection; default is 1. +.TP +.B QHPSIMINSIZE +The minimal size of the message to invoke the virus scanner; default is 0. +A typical choice would be QHPSIMISIZE=10000 (~10k). +.TP +.B QHPSIMAXSIZE +The maximal size of the message to invoke the virus scanner; default is unrestricted. +A typical choice would be QHPPIMAXSIZE=1000000 (~1M). .SH "SEE ALSO" addresses(5), envelopes(5), diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-queue.c /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-queue.c --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-queue.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-queue.c 2008-01-31 18:14:05.351130040 +0800 @@ -16,6 +16,13 @@ #include "auto_uids.h" #include "date822fmt.h" #include "fmtqfn.h" +#include "stralloc.h" +#include "constmap.h" +#include "env.h" +#include "fork.h" +#include "wait.h" + +/* #define BIGTODO */ #define DEATH 86400 /* 24 hours; _must_ be below q-s's OSSIFIED (36 hours) */ #define ADDR 1003 @@ -24,6 +31,13 @@ struct substdio ssin; char outbuf[256]; struct substdio ssout; +int tapok = 0; +stralloc tap = {0}; +struct constmap maptap; +stralloc chkaddr = {0}; +int tapped; +stralloc tapaddr = {0}; +stralloc controlfile = {0}; datetime_sec starttime; struct datetime dt; @@ -55,6 +69,7 @@ } void die(e) int e; { _exit(e); } +void die_qhpsi() { cleanup(); die(71); } void die_write() { cleanup(); die(53); } void die_read() { cleanup(); die(54); } void sigalrm() { /* thou shalt not clean up here */ die(52); } @@ -70,9 +85,9 @@ unsigned int i; unsigned int len; len = 0; - i = fmt_str(s,"Received: (qmail "); len += i; if (s) s += i; + i = fmt_str(s,"Received: ( Xmail -- www.vvvk.net "); len += i; if (s) s += i; i = fmt_ulong(s,mypid); len += i; if (s) s += i; - i = fmt_str(s," invoked "); len += i; if (s) s += i; +/* i = fmt_str(s," invoked "); len += i; if (s) s += i; if (uid == auto_uida) { i = fmt_str(s,"by alias"); len += i; if (s) s += i; } else if (uid == auto_uidd) @@ -83,7 +98,7 @@ { i = fmt_str(s,"by uid "); len += i; if (s) s += i; i = fmt_ulong(s,uid); len += i; if (s) s += i; - } + }*/ i = fmt_str(s,"); "); len += i; if (s) s += i; i = date822fmt(s,&dt); len += i; if (s) s += i; return len; @@ -149,6 +164,59 @@ die(63); } +char *qhpsi; + +void qhpsiprog(arg) char *arg; +{ + int wstat; + int child; + char *qhpsiargs[6] = { 0, 0, 0, 0, 0, 0 }; + char *x; + unsigned long u; + int childrc; + int qhpsirc = 1; + unsigned int size; + unsigned int qhpsiminsize = 0; + unsigned int qhpsimaxsize = 0; + + struct stat st; + + if (stat(messfn,&st) == -1) die(63); + size = (unsigned int) st.st_size; + + x = env_get("QHPSIMINSIZE"); + if (x) { scan_ulong(x,&u); qhpsiminsize = (int) u; } + if (qhpsiminsize) if (size < qhpsiminsize) return; + x = env_get("QHPSIMAXSIZE"); + if (x) { scan_ulong(x,&u); qhpsimaxsize = (int) u; } + if (qhpsimaxsize) if (size > qhpsimaxsize) return; + + if (*arg) { + switch(child = fork()) { + case -1: + die_qhpsi(); + case 0: + qhpsiargs[0] = arg; + qhpsiargs[1] = messfn; + qhpsiargs[2] = env_get("QHPSIARG1"); + if(!qhpsiargs[2]) qhpsiargs[2] = 0; + qhpsiargs[3] = env_get("QHPSIARG2"); + if(!qhpsiargs[3]) qhpsiargs[3] = 0; + qhpsiargs[4] = env_get("QHPSIARG3"); + if(!qhpsiargs[4]) qhpsiargs[4] = 0; + x = env_get("QHPSIRC"); + if (x) { scan_ulong(x,&u); qhpsirc = (int) u; } + execvp(*qhpsiargs,qhpsiargs); + die_qhpsi(); + } + if (wait_pid(&wstat,child) == -1) die_qhpsi(); + if (wait_crashed(wstat)) die_qhpsi(); + childrc = wait_exitcode(wstat); + if (childrc == qhpsirc) { cleanup(); die(31); } + else if (childrc != 0) die_qhpsi(); + } +} + char tmp[FMT_ULONG]; void main() @@ -165,6 +233,7 @@ uid = getuid(); starttime = now(); datetime_tai(&dt,starttime); + qhpsi = env_get("QHPSI"); received_setup(); @@ -175,13 +244,25 @@ alarm(DEATH); + stralloc_copys( &controlfile, auto_qmail); + stralloc_cats( &controlfile, "/control/taps"); + stralloc_0( &controlfile); + tapok = control_readfile(&tap,controlfile.s,0); + if (tapok == -1) die(65); + if (!constmap_init(&maptap,tap.s,tap.len,0)) die(65); + pidopen(); if (fstat(messfd,&pidst) == -1) die(63); messnum = pidst.st_ino; messfn = fnnum("mess/",1); +#ifdef BIGTODO + todofn = fnnum("todo/",1); + intdfn = fnnum("intd/",1); +#else todofn = fnnum("todo/",0); intdfn = fnnum("intd/",0); +#endif if (link(pidfn,messfn) == -1) die(64); if (unlink(pidfn) == -1) die(63); @@ -219,31 +300,62 @@ if (substdio_get(&ssin,&ch,1) < 1) die_read(); if (ch != 'F') die(91); if (substdio_bput(&ssout,&ch,1) == -1) die_write(); + stralloc_0(&chkaddr); for (len = 0;len < ADDR;++len) { + if ( len == 1 ) stralloc_copyb(&chkaddr, &ch,1); + else if ( len > 1 ) stralloc_catb(&chkaddr, &ch,1); if (substdio_get(&ssin,&ch,1) < 1) die_read(); if (substdio_put(&ssout,&ch,1) == -1) die_write(); if (!ch) break; } if (len >= ADDR) die(11); + /* check the from address */ + stralloc_0(&chkaddr); + if (tapped == 0 && tapcheck()==1 ) { + tapped = 1; + if ( tapaddr.len > 0 ) { + if (substdio_bput(&ssout,"T",1) == -1) die_write(); + if (substdio_bput(&ssout,tapaddr.s,tapaddr.len) == -1) die_write(); + if (substdio_bput(&ssout,"",1) == -1) die_write(); + } + } + if (substdio_bput(&ssout,QUEUE_EXTRA,QUEUE_EXTRALEN) == -1) die_write(); for (;;) { if (substdio_get(&ssin,&ch,1) < 1) die_read(); if (!ch) break; + if (ch == 'Q') { qhpsi = 0; break; } if (ch != 'T') die(91); if (substdio_bput(&ssout,&ch,1) == -1) die_write(); for (len = 0;len < ADDR;++len) { + if ( len == 1 ) stralloc_copyb(&chkaddr, &ch,1); + else if ( len > 1 ) stralloc_catb(&chkaddr, &ch,1); if (substdio_get(&ssin,&ch,1) < 1) die_read(); if (substdio_bput(&ssout,&ch,1) == -1) die_write(); if (!ch) break; } + + /* check the to address */ + stralloc_0(&chkaddr); + if (tapped == 0 && tapcheck()==1 ) { + tapped = 1; + if ( tapaddr.len > 0 ) { + if (substdio_bput(&ssout,"T",1) == -1) die_write(); + if (substdio_bput(&ssout,tapaddr.s,tapaddr.len) == -1) die_write(); + if (substdio_bput(&ssout,"",1) == -1) die_write(); + } + } + if (len >= ADDR) die(11); } + if (qhpsi) qhpsiprog(qhpsi); + if (substdio_flush(&ssout) == -1) die_write(); if (fsync(intdfd) == -1) die_write(); @@ -252,3 +364,42 @@ triggerpull(); die(0); } + +int tapcheck() +{ + int i = 0; + int j = 0; + int x = 0; + int negate = 0; + stralloc curregex = {0}; + char tmpbuf[200]; + + while (j < tap.len) { + i = j; + while ((tap.s[i] != ':') && (i < tap.len)) i++; + if (tap.s[j] == '!') { + negate = 1; + j++; + } + stralloc_copys(&tapaddr, &tap.s[i+1]); + + stralloc_copyb(&curregex,tap.s + j,(i - j)); + stralloc_0(&curregex); + x = matchregex(chkaddr.s, curregex.s, tmpbuf); + + while ((tap.s[i] != '\0') && (i < tap.len)) i++; + + if ((negate) && (x == 0)) { + return 1; + } + if (!(negate) && (x > 0)) { + return 1; + } + j = i + 1; + negate = 0; + + + } + return 0; +} + diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-recipients.9 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-recipients.9 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-recipients.9 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-recipients.9 2008-01-31 18:09:48.322204376 +0800 @@ -0,0 +1,44 @@ +.TH qmail-recipients 8 +.SH NAME +qmail-recipients \- prepare recipients for qmail-smtpd +.SH SYNOPSIS +.B qmail-recipients +.SH DESCRIPTION +.B qmail-recipients +reads the addresses provided in +.BR QMAILHOME/users/recipients , +converts them into lowercase, and writes them into +.B QMAILHOME/users/recipients.cdb +in a binary format suited +for quick access by +.BR qmail-smtpd . + +If there is a problem with +.BR users/recipients , +.B qmail-recipients +complains and leaves +.B users/recipients.cdb +alone. + +.B qmail-recipients +ensures that +.B users/recipients.cdb +is updated atomically, +so +.B qmail-smtpd +never has to wait for +.B qmail-recipients +to finish. +However, +.B qmail-recipients +makes no attempt to protect against two simultaneous updates of +.BR users/recipients.cdb . + +The binary +.B users/recipients.cdb +is compatible with +.B setforward +generated \'fastforward\' cdbs and it's +format is portable across machines. +.SH "SEE ALSO" +qmail-smtpd(8) diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-recipients.c /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-recipients.c --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-recipients.c 1970-01-01 08:00:00.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-recipients.c 2008-01-31 18:09:48.322204376 +0800 @@ -0,0 +1,73 @@ +#include "strerr.h" +#include "stralloc.h" +#include "substdio.h" +#include "getln.h" +#include "exit.h" +#include "readwrite.h" +#include "open.h" +#include "auto_qmail.h" +#include "cdbmss.h" + +#define FATAL "qmail-recipients: fatal: " + +void die_read() +{ + strerr_die2sys(111,FATAL,"unable to read users/recipients: "); +} +void die_write() +{ + strerr_die2sys(111,FATAL,"unable to write to users/recipients.tmp: "); +} + +char inbuf[1024]; +substdio ssin; + +int fd; +int fdtemp; + +struct cdbmss cdbmss; +stralloc line = {0}; +stralloc key = {0}; +int match; + +void main() +{ + umask(033); + if (chdir(auto_qmail) == -1) + strerr_die4sys(111,FATAL,"unable to chdir to ",auto_qmail,": "); + + fd = open_read("users/recipients"); + if (fd == -1) die_read(); + + substdio_fdbuf(&ssin,read,fd,inbuf,sizeof inbuf); + + fdtemp = open_trunc("users/recipients.tmp"); + if (fdtemp == -1) die_write(); + + if (cdbmss_start(&cdbmss,fdtemp) == -1) die_write(); + + for (;;) { + stralloc_copys(&key,":"); + if (getln(&ssin,&line,&match,'\n') != 0) die_read(); + while (line.len) { + if (line.s[line.len - 1] == ' ') { --line.len; continue; } + if (line.s[line.len - 1] == '\n') { --line.len; continue; } + if (line.s[line.len - 1] == '\t') { --line.len; continue; } + if (line.s[0] != '#' && stralloc_cat(&key,&line)) { + case_lowerb(key.s,key.len); + if (cdbmss_add(&cdbmss,key.s,key.len,"",0) == -1) + die_write(); + } + break; + } + if (!match) break; + } + + if (cdbmss_finish(&cdbmss) == -1) die_write(); + if (fsync(fdtemp) == -1) die_write(); + if (close(fdtemp) == -1) die_write(); /* NFS stupidity */ + if (rename("users/recipients.tmp","users/recipients.cdb") == -1) + strerr_die2sys(111,FATAL,"unable to move users/recipients.tmp to users/recipients.cdb"); + + _exit(0); +} diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-remote.8 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-remote.8 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-remote.8 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-remote.8 2008-01-31 18:09:48.323204224 +0800 @@ -26,7 +26,7 @@ or to a mail exchanger for .I host listed in the Domain Name System, -via the Simple Mail Transfer Protocol (SMTP). +via the Simple Mail Transfer Protocol (SMTP/ESMTP). .I host can be either a fully-qualified domain name: @@ -39,6 +39,12 @@ .EX [128.32.183.163] .EE + +In case the primary mail exchanger for that Domain +will issue a 5xy reply message during the connection, +.B qmail-remote +will contact all responsible mail exchangers in turn +in order to deliver the message anyway. The envelope recipient addresses are listed as .I recip @@ -53,6 +59,7 @@ and does not follow the .B getopt standard. + .SH TRANSPARENCY End-of-file in SMTP is encoded as dot CR LF. A dot at the beginning of a line is encoded as dot dot. @@ -100,6 +107,48 @@ After this letter comes a human-readable description of what happened. +.B qmail-remote +may use SMTP Authenticaton to connect to remote hosts. +The following reports are provided: +.TP 5 +K +no supported AUTH method found, continuing without authentication. +.TP 5 +Z +Connected to +.I host +but authentication was rejected (AUTH PLAIN). +.TP 5 +Z +Connected to +.I host +but unable to base64encode (plain). +.TP 5 +Z +Connected to +.I host +but authentication was rejected (plain)." +.TP 5 +Z +Connected to +.I host +but authentication was rejected (AUTH LOGIN). +.TP 5 +Z +Connected to +.I host +but unable to base64encode user. +.TP 5 +Z +Connected to +.I host +but authentication was rejected (username). +.TP 5 +Z +Connected to +.I host +but unable to base64encode pass. +.PP The recipient reports will always be printed in the same order as .BR qmail-remote 's .I recip @@ -114,6 +163,51 @@ always exits zero. .SH "CONTROL FILES" .TP 5 +.I authsenders +Authenticated sender. +For each +.I sender +included in +.IR authsenders : +.I sender\fB:\fIrelay\fB:\fIport\fB|\fIuser\fB|\fIpassword +.B qmail-remote +will try SMTP Authentication +of type LOGIN or PLAIN +with the provided user name +.I user +and password +.I password +(the authentication information) +and eventually relay the +mail through +.I relay +on port +.IR port . +The use of +.I relay +and +.I port +follows the same rules as for +.IR smtproutes +Note: In case +.I sender +is empty, +.B qmail-remote +will try to deliver each outgoing mail +SMTP authenticated. If the authentication +information is missing, the mail is +delivered none-authenticated. +.I authsenders +can be constructed as follows: + +.EX + @example.com|generic|passwd + .subdomain.example.com|other|otherpw + mail@example.com|test|testpass + info@example.com:smtp.example.com:26|other|otherpw + :mailrelay.example.com|e=mc2|testpass +.EE +.TP 5 .I helohost Current host name, for use solely in saying hello to the remote SMTP server. diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-remote.c /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-remote.c --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-remote.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-remote.c 2008-01-31 18:09:48.324204072 +0800 @@ -28,6 +28,7 @@ #include "timeoutconn.h" #include "timeoutread.h" #include "timeoutwrite.h" +#include "base64.h" #define HUGESMTPTEXT 5000 @@ -44,6 +45,14 @@ stralloc host = {0}; stralloc sender = {0}; +stralloc authsenders = {0}; +struct constmap mapauthsenders; +stralloc user = {0}; +stralloc pass = {0}; +stralloc auth = {0}; +stralloc plain = {0}; +char *authsender; + saa reciplist = {0}; struct ip_address partner; @@ -86,6 +95,12 @@ it isn't in my control/locals file, so I don't treat it as local. (#5.4.6)\n"); zerodie(); } +void err_authprot() { + out("Kno supported AUTH method found, continuing without authentication.\n"); + zero(); + substdio_flush(subfdoutsmall); +} + void outhost() { char x[IPFMT]; @@ -192,23 +207,39 @@ void blast() { int r; + int i; + int o; char ch; + char in[4096]; + char out[4096*2+1]; + int sol; - for (;;) { - r = substdio_get(&ssin,&ch,1); + for (sol = 1;;) { + r = substdio_get(&ssin,in,sizeof in); if (r == 0) break; if (r == -1) temp_read(); - if (ch == '.') - substdio_put(&smtpto,".",1); - while (ch != '\n') { - substdio_put(&smtpto,&ch,1); - r = substdio_get(&ssin,&ch,1); - if (r == 0) perm_partialline(); - if (r == -1) temp_read(); + + for (i = o = 0; i < r; ) { + if (sol && in[i] == '.') { + out[o++] = '.'; + out[o++] = in[i++]; + } + sol = 0; + while (i < r) { + if (in[i] == '\n') { + sol = 1; + ++i; + out[o++] = '\r'; + out[o++] = '\n'; + break; + } + out[o++] = in[i++]; + } } - substdio_put(&smtpto,"\r\n",2); + substdio_put(&smtpto,out,o); } + if (!sol) perm_partialline(); flagcritical = 1; substdio_put(&smtpto,".\r\n",3); substdio_flush(&smtpto); @@ -216,24 +247,144 @@ stralloc recip = {0}; +void mailfrom() +{ + substdio_puts(&smtpto,"MAIL FROM:<"); + substdio_put(&smtpto,sender.s,sender.len); + substdio_puts(&smtpto,">\r\n"); + substdio_flush(&smtpto); +} + +stralloc xuser = {0}; + +int xtext(sa,s,len) +stralloc *sa; +char *s; +int len; +{ + int i; + + if(!stralloc_copys(sa,"")) temp_nomem(); + + for (i = 0; i < len; i++) { + if (s[i] == '+') { + if (!stralloc_cats(sa,"+3D")) temp_nomem(); + } else if (s[i] == '=') { + if (!stralloc_cats(sa,"+2B")) temp_nomem(); + } else if ((int) s[i] < 33 || (int) s[i] > 126) { + if (!stralloc_cats(sa,"+3F")) temp_nomem(); /* ok. not correct */ + } else if (!stralloc_catb(sa,s+i,1)) { + temp_nomem(); + } + } + + return sa->len; +} + +void mailfrom_plain() +{ + substdio_puts(&smtpto,"AUTH PLAIN\r\n"); + substdio_flush(&smtpto); + if (smtpcode() != 334) quit("ZConnected to "," but authentication was rejected (AUTH PLAIN)."); + + if(!stralloc_cat(&plain,&sender)) temp_nomem(); /* Mail From: */ + if(!stralloc_0(&plain)) temp_nomem(); + if(!stralloc_cat(&plain,&user)) temp_nomem(); /* user-id */ + if(!stralloc_0(&plain)) temp_nomem(); + if(!stralloc_cat(&plain,&pass)) temp_nomem(); /* password */ + if (b64encode(&plain,&auth)) quit("ZConnected to "," but unable to base64encode (plain)."); + substdio_put(&smtpto,auth.s,auth.len); + substdio_puts(&smtpto,"\r\n"); + substdio_flush(&smtpto); + if (smtpcode() != 235) quit("ZConnected to "," but authentication was rejected (plain)."); + + if (!xtext(&xuser,user.s,user.len)) temp_nomem(); + substdio_puts(&smtpto,"MAIL FROM:<"); + substdio_put(&smtpto,sender.s,sender.len); + substdio_puts(&smtpto,"> AUTH="); + substdio_put(&smtpto,xuser.s,xuser.len); + substdio_puts(&smtpto,"\r\n"); + substdio_flush(&smtpto); +} + +void mailfrom_login() +{ + substdio_puts(&smtpto,"AUTH LOGIN\r\n"); + substdio_flush(&smtpto); + if (smtpcode() != 334) quit("ZConnected to "," but authentication was rejected (AUTH LOGIN)."); + + if (!stralloc_copys(&auth,"")) temp_nomem(); + if (b64encode(&user,&auth)) quit("ZConnected to "," but unable to base64encode user."); + substdio_put(&smtpto,auth.s,auth.len); + substdio_puts(&smtpto,"\r\n"); + substdio_flush(&smtpto); + if (smtpcode() != 334) quit("ZConnected to "," but authentication was rejected (username)."); + + if (!stralloc_copys(&auth,"")) temp_nomem(); + if (b64encode(&pass,&auth)) quit("ZConnected to "," but unable to base64encode pass."); + substdio_put(&smtpto,auth.s,auth.len); + substdio_puts(&smtpto,"\r\n"); + substdio_flush(&smtpto); + if (smtpcode() != 235) quit("ZConnected to "," but authentication was rejected (password)"); + + if (!xtext(&xuser,user.s,user.len)) temp_nomem(); + substdio_puts(&smtpto,"MAIL FROM:<"); + substdio_put(&smtpto,sender.s,sender.len); + substdio_puts(&smtpto,"> AUTH="); + substdio_put(&smtpto,xuser.s,xuser.len); + substdio_puts(&smtpto,"\r\n"); + substdio_flush(&smtpto); +} + +void smtp_auth() +{ + int i = 0; + int j; + while ((i += str_chr(smtptext.s+i,'\n') + 1) && + (i+8 < smtptext.len) && + str_diffn(smtptext.s+i+4,"AUTH",4)); { + j = str_chr(smtptext.s+i+8,'L'); /* AUTH LOGIN */ + if (j > 0) + if (case_starts(smtptext.s+i+8+j,"LOGIN")) { mailfrom_login(); return; } + j = str_chr(smtptext.s+i+8,'P'); /* AUTH PLAIN */ + if (j > 0) + if (case_starts(smtptext.s+i+8+j,"PLAIN")) { mailfrom_plain(); return; } + err_authprot(); + mailfrom(); + } +} + void smtp() { unsigned long code; int flagbother; int i; - if (smtpcode() != 220) quit("ZConnected to "," but greeting failed"); + code = smtpcode(); + if (code >= 400) return; /* try next MX */ + if (code != 220) quit("ZConnected to "," but greeting failed"); - substdio_puts(&smtpto,"HELO "); + substdio_puts(&smtpto,"EHLO "); substdio_put(&smtpto,helohost.s,helohost.len); substdio_puts(&smtpto,"\r\n"); substdio_flush(&smtpto); - if (smtpcode() != 250) quit("ZConnected to "," but my name was rejected"); - - substdio_puts(&smtpto,"MAIL FROM:<"); - substdio_put(&smtpto,sender.s,sender.len); - substdio_puts(&smtpto,">\r\n"); - substdio_flush(&smtpto); + + if (smtpcode() != 250) { + substdio_puts(&smtpto,"HELO "); + substdio_put(&smtpto,helohost.s,helohost.len); + substdio_puts(&smtpto,"\r\n"); + substdio_flush(&smtpto); + code = smtpcode(); + authsender = 0; + if (code >= 500) quit("DConnected to "," but my name was rejected"); + if (code != 250) quit("ZConnected to "," but my name was rejected"); + } + + if (authsender) + smtp_auth(); + else + mailfrom(); + code = smtpcode(); if (code >= 500) quit("DConnected to "," but sender was rejected"); if (code >= 400) quit("ZConnected to "," but sender was rejected"); @@ -324,6 +475,15 @@ case 1: if (!constmap_init(&maproutes,routes.s,routes.len,1)) temp_nomem(); break; } + + switch(control_readfile(&authsenders,"control/authsenders",0)) { + case -1: + temp_control(); + case 0: + if (!constmap_init(&mapauthsenders,"",0,1)) temp_nomem(); break; + case 1: + if (!constmap_init(&mapauthsenders,authsenders.s,authsenders.len,1)) temp_nomem(); break; + } } void main(argc,argv) @@ -331,41 +491,74 @@ char **argv; { static ipalloc ip = {0}; - int i; + int i, j; unsigned long random; char **recips; unsigned long prefme; int flagallaliases; int flagalias; char *relayhost; - + sig_pipeignore(); if (argc < 4) perm_usage(); if (chdir(auto_qmail) == -1) temp_chdir(); getcontrols(); - if (!stralloc_copys(&host,argv[1])) temp_nomem(); - + + authsender = 0; relayhost = 0; - for (i = 0;i <= host.len;++i) - if ((i == 0) || (i == host.len) || (host.s[i] == '.')) - if (relayhost = constmap(&maproutes,host.s + i,host.len - i)) + + addrmangle(&sender,argv[2],&flagalias,0); + + for (i = 0;i <= sender.len;++i) + if ((i == 0) || (i == sender.len) || (sender.s[i] == '.') || (sender.s[i] == '@')) + if (authsender = constmap(&mapauthsenders,sender.s + i,sender.len - i)) break; - if (relayhost && !*relayhost) relayhost = 0; - - if (relayhost) { - i = str_chr(relayhost,':'); - if (relayhost[i]) { - scan_ulong(relayhost + i + 1,&port); - relayhost[i] = 0; + + if (authsender && !*authsender) authsender = 0; + + if (authsender) { + i = str_chr(authsender,'|'); + if (authsender[i]) { + j = str_chr(authsender + i + 1,'|'); + if (authsender[j]) { + authsender[i] = 0; + authsender[i + j + 1] = 0; + if (!stralloc_copys(&user,"")) temp_nomem(); + if (!stralloc_copys(&user,authsender + i + 1)) temp_nomem(); + if (!stralloc_copys(&pass,"")) temp_nomem(); + if (!stralloc_copys(&pass,authsender + i + j + 2)) temp_nomem(); + } + } + i = str_chr(authsender,':'); + if (authsender[i]) { + scan_ulong(authsender + i + 1,&port); + authsender[i] = 0; } - if (!stralloc_copys(&host,relayhost)) temp_nomem(); - } + if (!stralloc_copys(&relayhost,authsender)) temp_nomem(); + if (!stralloc_copys(&host,authsender)) temp_nomem(); + + } + else { /* default smtproutes */ + for (i = 0;i <= host.len;++i) + if ((i == 0) || (i == host.len) || (host.s[i] == '.')) + if (relayhost = constmap(&maproutes,host.s + i,host.len - i)) + break; + + if (relayhost && !*relayhost) relayhost = 0; + + if (relayhost) { + i = str_chr(relayhost,':'); + if (relayhost[i]) { + scan_ulong(relayhost + i + 1,&port); + relayhost[i] = 0; + } + if (!stralloc_copys(&host,relayhost)) temp_nomem(); + } + } - addrmangle(&sender,argv[2],&flagalias,0); - if (!saa_readyplus(&reciplist,0)) temp_nomem(); if (ipme_init() != 1) temp_oserr(); @@ -417,7 +610,7 @@ if (timeoutconn(smtpfd,&ip.ix[i].ip,(unsigned int) port,timeoutconnect) == 0) { tcpto_err(&ip.ix[i].ip,0); partner = ip.ix[i].ip; - smtp(); /* does not return */ + smtp(); /* read THOUGHTS; section 6 */ } tcpto_err(&ip.ix[i].ip,errno == error_timeout); close(smtpfd); diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-send.9 /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-send.9 --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-send.9 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-send.9 2008-01-31 18:09:48.324204072 +0800 @@ -51,9 +51,12 @@ .B qmail-send receives a HUP signal, it will reread -.I locals +.IR locals , +.IR virtualdomains , +as well as +.IR concurrencylocal and -.IR virtualdomains . +.IR concurrencyremote . .TP 5 .I bouncefrom Bounce username. @@ -77,6 +80,11 @@ .B From: \fIbouncefrom\fB@\fIbouncehost\fR, although its envelope sender is empty. .TP 5 +.I bouncemaxbytes +Maximum size (in bytes) of bounce messages. +Bounce messages exceeding this limit will be truncated. +Default is 0; which means no limit. +.TP 5 .I concurrencylocal Maximum number of simultaneous local delivery attempts. Default: 10. @@ -115,6 +123,11 @@ (If that bounces, .B qmail-send gives up.) +As a special case, if the first line of +.IR doublebounceto +contains a '@' or an empty line +.B qmail-send +will discard all double-bounces. .TP 5 .I envnoathost Presumed domain name for addresses without @ signs. diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-send.c /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-send.c --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-send.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-send.c 2008-01-31 18:39:53.757736456 +0800 @@ -32,6 +32,8 @@ #include "fmtqfn.h" #include "readsubdir.h" +/* #define BIGTODO */ + /* critical timing feature #1: if not triggered, do not busy-loop */ /* critical timing feature #2: if triggered, respond within fixed time */ /* important timing feature: when triggered, respond instantly */ @@ -43,6 +45,7 @@ #define OSSIFIED 129600 /* 36 hours; _must_ exceed q-q's DEATH (24 hours) */ int lifetime = 604800; +int bouncemaxbytes = 0; stralloc percenthack = {0}; struct constmap mappercenthack; @@ -96,7 +99,11 @@ } void fnmake_info(id) unsigned long id; { fn.len = fmtqfn(fn.s,"info/",id,1); } +#ifdef BIGTODO +void fnmake_todo(id) unsigned long id; { fn.len = fmtqfn(fn.s,"todo/",id,1); } +#else void fnmake_todo(id) unsigned long id; { fn.len = fmtqfn(fn.s,"todo/",id,0); } +#endif void fnmake_mess(id) unsigned long id; { fn.len = fmtqfn(fn.s,"mess/",id,1); } void fnmake_foop(id) unsigned long id; { fn.len = fmtqfn(fn.s,"foop/",id,0); } void fnmake_split(id) unsigned long id; { fn.len = fmtqfn(fn.s,"",id,1); } @@ -683,6 +690,8 @@ } if (str_equal(sender.s,"#@[]")) log3("triple bounce: discarding ",fn2.s,"\n"); + else if (!*sender.s && *doublebounceto.s == '@') + log3("double bounce: discarding ",fn2.s,"\n"); else { if (qmail_open(&qqt) == -1) @@ -705,7 +714,7 @@ qmail_puts(&qqt,"\n\ Subject: failure notice\n\ \n\ -Hi. This is the qmail-send program at "); +Hi. This is the xukiMail at "); qmail_put(&qqt,bouncehost.s,bouncehost.len); qmail_puts(&qqt,*sender.s ? ".\n\ I'm afraid I wasn't able to deliver your message to the following addresses.\n\ @@ -740,9 +749,25 @@ qmail_fail(&qqt); else { - substdio_fdbuf(&ssread,read,fd,inbuf,sizeof(inbuf)); - while ((r = substdio_get(&ssread,buf,sizeof(buf))) > 0) - qmail_put(&qqt,buf,r); + if (bouncemaxbytes) + { + int bytestogo = bouncemaxbytes; + int bytestoget = (bytestogo < sizeof buf) ? bytestogo : sizeof buf; + substdio_fdbuf(&ssread,read,fd,inbuf,sizeof(inbuf)); + while (bytestoget > 0 && (r = substdio_get(&ssread,buf,bytestoget)) > 0) { + qmail_put(&qqt,buf,r); + bytestogo -= bytestoget; + bytestoget = (bytestogo < sizeof buf) ? bytestogo : sizeof buf; + } + if (r > 0) + qmail_puts(&qqt,"\n\n--- Rest of message truncated.\n"); + } + else /* preserve default behavior */ + { + substdio_fdbuf(&ssread,read,fd,inbuf,sizeof(inbuf)); + while ((r = substdio_get(&ssread,buf,sizeof(buf))) > 0) + qmail_put(&qqt,buf,r); + } close(fd); if (r == -1) qmail_fail(&qqt); @@ -1216,7 +1241,12 @@ /* this file is too long ---------------------------------------------- TODO */ datetime_sec nexttodorun; +#ifdef BIGTODO +int flagtododir = 0; /* if 0, have to readsubdir_init again */ +readsubdir todosubdir; +#else DIR *tododir; /* if 0, have to opendir again */ +#endif stralloc todoline = {0}; char todobuf[SUBSTDIO_INSIZE]; char todobufinfo[512]; @@ -1224,7 +1254,11 @@ void todo_init() { +#ifdef BIGTODO + flagtododir = 0; +#else tododir = 0; +#endif nexttodorun = now(); trigger_set(); } @@ -1236,7 +1270,11 @@ { if (flagexitasap) return; trigger_selprep(nfds,rfds); +#ifdef BIGTODO + if (flagtododir) *wakeup = 0; +#else if (tododir) *wakeup = 0; +#endif if (*wakeup > nexttodorun) *wakeup = nexttodorun; } @@ -1253,8 +1291,12 @@ char ch; int match; unsigned long id; +#ifdef BIGTODO + int z; +#else unsigned int len; direntry *d; +#endif int c; unsigned long uid; unsigned long pid; @@ -1265,21 +1307,43 @@ if (flagexitasap) return; +#ifdef BIGTODO + if (!flagtododir) +#else if (!tododir) +#endif { if (!trigger_pulled(rfds)) - if (recent < nexttodorun) - return; + { + if (recent < nexttodorun) + return; + } trigger_set(); +#ifdef BIGTODO + readsubdir_init(&todosubdir, "todo", pausedir); + flagtododir = 1; +#else tododir = opendir("todo"); if (!tododir) { pausedir("todo"); return; } +#endif nexttodorun = recent + SLEEP_TODO; } +#ifdef BIGTODO + switch(readsubdir_next(&todosubdir, &id)) + { + case 1: + break; + case 0: + flagtododir = 0; + default: + return; + } +#else d = readdir(tododir); if (!d) { @@ -1291,6 +1355,7 @@ if (str_equal(d->d_name,"..")) return; len = scan_ulong(d->d_name,&id); if (!len || d->d_name[len]) return; +#endif fnmake_todo(id); @@ -1448,6 +1513,7 @@ if (control_rldef(&envnoathost,"control/envnoathost",1,"envnoathost") != 1) return 0; if (control_rldef(&bouncefrom,"control/bouncefrom",0,"MAILER-DAEMON") != 1) return 0; if (control_rldef(&bouncehost,"control/bouncehost",1,"bouncehost") != 1) return 0; + if (control_readint(&bouncemaxbytes,"control/bouncemaxbytes") == -1) return 0; if (control_rldef(&doublebouncehost,"control/doublebouncehost",1,"doublebouncehost") != 1) return 0; if (control_rldef(&doublebounceto,"control/doublebounceto",0,"postmaster") != 1) return 0; if (!stralloc_cats(&doublebounceto,"@")) return 0; @@ -1478,6 +1544,14 @@ if (control_readfile(&newlocals,"control/locals",1) != 1) { log1("alert: unable to reread control/locals\n"); return; } + if (control_readint(&concurrency[0],"control/concurrencylocal") == -1) + { log1("alert: unable to reread control/concurrencylocal\n",0); return; } + if (control_readint(&concurrency[1],"control/concurrencyremote") == -1) + { log1("alert: unable to reread control/concurrencyremote\n",0); return; } + if (control_readint(&lifetime,"control/queuelifetime") == -1) + { log1("alert: unable to reread control/queuelifetime\n",0); return; } + r = control_readfile(&newvdoms,"control/virtualdomains",0); + r = control_readfile(&newvdoms,"control/virtualdomains",0); r = control_readfile(&newvdoms,"control/virtualdomains",0); if (r == -1) { log1("alert: unable to reread control/virtualdomains\n"); return; } diff -uN /home/pkg/netqmail-1.05/qmail-1.03/qmail-showctl.c /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-showctl.c --- /home/pkg/netqmail-1.05/qmail-1.03/qmail-showctl.c 1998-06-15 18:53:16.000000000 +0800 +++ /home/pkg/netqmail-1.05/qmail-xuki-patch/qmail-showctl.c 2008-01-31 18:09:48.325203920 +0800 @@ -16,6 +16,9 @@ #include "auto_spawn.h" #include "auto_split.h" +/* #define RELAYMAILFROM */ +/* #define MOREIPME */ + stralloc me = {0}; int meok; @@ -214,9 +217,45 @@ _exit(111); } + do_lst("authsenders","No authenticated SMTP senders.","Authenicated SMTP senders: ",""); + do_lst("badhelo","Any HELO/EHLO greeting is allowed.",""," not accepted in HELO/EHLO."); do_lst("badmailfrom","Any MAIL FROM is allowed.",""," not accepted in MAIL FROM."); + do_lst("badloadertypes","Any loader types are accepted.",""," not accepted as loader type."); + /* XXX: check badloadertypes.cdb contents */ + substdio_puts(subfdout,"\nbadloadertypes.cdb: "); + if (stat("badloadertypes",&stmrh) == -1) + if (stat("badloadertypes.cdb",&stmrhcdb) == -1) + substdio_puts(subfdout,"(Default.) No effect.\n"); + else + substdio_puts(subfdout,"Oops! badloadertypes.cdb exists but badloadertypes doesn't.\n"); + else + if (stat("badloadertypes.cdb",&stmrhcdb) == -1) + substdio_puts(subfdout,"Oops! badloadertypes exists but badloadertypes.cdb doesn't.\n"); + else + if (stmrh.st_mtime > stmrhcdb.st_mtime) + substdio_puts(subfdout,"Oops! badloadertypes.cdb is older than badloadertypes.\n"); + else + substdio_puts(subfdout,"Modified recently enough; hopefully up to date.\n"); + do_lst("badmimetypes","Any MIME types are accepted.",""," not accepted as MIME type."); + /* XXX: check badmimetypes.cdb contents */ + substdio_puts(subfdout,"\nbadmimetypes.cdb: "); + if (stat("badmimetypes",&stmrh) == -1) + if (stat("badmimetypes.cdb",&stmrhcdb) == -1) + substdio_puts(subfdout,"(Default.) No effect.\n"); + else + substdio_puts(subfdout,"Oops! badmimetypes.cdb exists but badmimetypes doesn't.\n"); + else + if (stat("badmimetypes.cdb",&stmrhcdb) == -1) + substdio_puts(subfdout,"Oops! badmimetypes exists but badmimetypes.cdb doesn't.\n"); + else + if (stmrh.st_mtime > stmrhcdb.st_mtime) + substdio_puts(subfdout,"Oops! badmimetypes.cdb is older than badmimetypes.\n"); + else + substdio_puts(subfdout,"Modified recently enough; hopefully up to date.\n"); + do_lst("badrcptto","Any RCPT TO is allowed.",""," not accepted in RCPT TO."); do_str("bouncefrom",0,"MAILER-DAEMON","Bounce user name is "); do_str("bouncehost",1,"bouncehost","Bounce host name is "); + do_int("bouncemaxbytes","0","Bounce size limit is "," bytes"); do_int("concurrencylocal","10","Local concurrency is ",""); do_int("concurrencyremote","20","Remote concurrency is ",""); do_int("databytes","0","SMTP DATA limit is "," bytes"); @@ -230,6 +269,28 @@ do_str("localiphost",1,"localiphost","Local IP address becomes "); do_lst("locals","Messages for me are delivered locally.","Messages for "," are delivered locally."); do_str("me",0,"undefined! Uh-oh","My name is "); + + do_lst("mailfromrules","Any envelope sender are are accepted.",""," (MAV rule)."); + /* XXX: check mailfromrules.cdb contents */ + substdio_puts(subfdout,"\nmailfromrules.cdb: "); + if (stat("mailfromrules",&stmrh) == -1) + if (stat("mailfromrules.cdb",&stmrhcdb) == -1) + substdio_puts(subfdout,"(Default.) No effect.\n"); + else + substdio_puts(subfdout,"Oops! mailfromrules.cdb exists but mailfromrules doesn't.\n"); + else + if (stat("mailfromrules.cdb",&stmrhcdb) == -1) + substdio_puts(subfdout,"Oops! mailfromrules exists but mailfromrules.cdb doesn't.\n"); + else + if (stmrh.st_mtime > stmrhcdb.st_mtime) + substdio_puts(subfdout,"Oops! mailfromrules.cdb is older than mailfromrules.\n"); + else + substdio_puts(subfdout,"Modified recently enough; hopefully up to date.\n"); + +#ifdef MOREIPME + do_lst("moreipme","No additional IP addresses are me.","IP address "," is me."); + do_lst("notipme","All of my IP addresses are me.","IP address "," is not me."); +#endif do_lst("percenthack","The percent hack is not allowed.","The percent hack is allowed for user%host@","."); do_str("plusdomain",1,"plusdomain","Plus domain name is "); do_lst("qmqpservers","No QMQP servers.","QMQP server: ","."); @@ -254,22 +315,33 @@ substdio_puts(subfdout,"Oops! morercpthosts.cdb is older than morercpthosts.\n"); else substdio_puts(subfdout,"Modified recently enough; hopefully up to date.\n"); - + do_lst("recipients","SMTP clients may send messages to any recipient.","SMTP clients may send messages to local recipients listed in ","."); do_str("smtpgreeting",1,"smtpgreeting","SMTP greeting: 220 "); do_lst("smtproutes","No artificial SMTP routes.","SMTP route: ",""); do_int("timeoutconnect","60","SMTP client connection timeout is "," seconds"); do_int("timeoutremote","1200","SMTP client data timeout is "," seconds"); do_int("timeoutsmtpd","1200","SMTP server data timeout is "," seconds"); do_lst("virtualdomains","No virtual domains.","Virtual domain: ",""); +#ifdef RELAYMAIL