# This patch modify the follow code for qmail-1.03+spamcontrol-216_tgz.bin. # http://sourceforge.net/projects/indimail/files/netqmail-addons/qmail-dkim-1.0/dkim-netqmail-1.06.patch-1.7.gz # --- dkim-netqmail-1.06.patch-1.7 2011-05-16 11:42:51.000000000 +0900 +++ dkim-qmail-1.03.patch 2011-05-16 11:56:45.000000000 +0900 @@ -28,9 +28,422 @@ 192.203.178.:allow,DKVERIFY="DEGIJKfh",QMAILQUEUE="bin/qmail-dk" -diff -Naur netqmail-1.06.org/alloc.c netqmail-1.06/alloc.c ---- netqmail-1.06.org/alloc.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/alloc.c 2011-02-11 09:34:40.148272045 +0530 +diff -Naur qmail-1.03-orig/MakeArgs.c qmail-1.03/MakeArgs.c +--- qmail-1.03-orig/MakeArgs.c 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/MakeArgs.c 2011-05-04 09:39:32.000000000 +0900 +@@ -0,0 +1,144 @@ ++/* ++ * $Log: MakeArgs.c,v $ ++ * Revision 2.8 2007-12-21 14:35:42+05:30 Cprogrammer ++ * included env.h to prevent compiler warning ++ * ++ * Revision 2.7 2007-12-20 12:45:28+05:30 Cprogrammer ++ * expand environment variables with '$' sign ++ * ++ * Revision 2.6 2005-08-23 17:31:28+05:30 Cprogrammer ++ * removed sccsid variable ++ * ++ * Revision 2.5 2005-04-02 19:06:02+05:30 Cprogrammer ++ * djb version ++ * ++ * Revision 2.4 2005-03-30 22:52:47+05:30 Cprogrammer ++ * BUG - Incorrect free ++ * ++ * Revision 2.3 2004-07-12 22:47:58+05:30 Cprogrammer ++ * bug fix. Free all allocated members ++ * ++ * Revision 2.2 2002-12-21 18:21:09+05:30 Cprogrammer ++ * added functionality of escaping text via quotes ++ * ++ * Revision 2.1 2002-08-13 20:35:44+05:30 Cprogrammer ++ * addition spaces were not getting skipped ++ * ++ * Revision 1.2 2002-03-03 17:23:05+05:30 Cprogrammer ++ * replaced strcpy with scopy ++ * ++ * Revision 1.1 2001-12-13 01:46:09+05:30 Cprogrammer ++ * Initial revision ++ * ++ */ ++#include "alloc.h" ++#include "str.h" ++#include "stralloc.h" ++#include "env.h" ++#include ++ ++#define isEscape(ch) ((ch) == '"' || (ch) == '\'') ++ ++/* ++ * function to expand a string into command line ++ * arguments. To free memory allocated by this ++ * function the following should be done ++ * ++ * free(argv); ++ * ++ */ ++char ** ++MakeArgs(char *cmmd) ++{ ++ char *ptr, *marker; ++ char **argv; ++ int argc, idx; ++ static stralloc sptr = { 0 }; ++ ++ for (ptr = cmmd;*ptr && isspace((int) *ptr);ptr++); ++ idx = str_len(ptr); ++ if (!stralloc_copys(&sptr, ptr)) ++ return((char **) 0); ++ if (!stralloc_0(&sptr)) ++ return((char **) 0); ++ /*- ++ * Get the number of arguments by counting ++ * white spaces. Allow escape via the double ++ * quotes character at the first word ++ */ ++ for (argc = 0, ptr = sptr.s;*ptr;) ++ { ++ for (;*ptr && isspace((int) *ptr);ptr++); ++ if (!*ptr) ++ break; ++ argc++; ++ marker = ptr; ++ /*- Move till you hit the next white space */ ++ for (;*ptr && !isspace((int) *ptr);ptr++) ++ { ++ /*- ++ * 1. If escape char is encounted skip till you ++ * hit the terminating escape char ++ * 2. If terminating escape char is missing, come ++ * back to the start escape char ++ */ ++ if (ptr == marker && isEscape(*ptr)) ++ { ++ for (ptr++;*ptr && !isEscape(*ptr);ptr++); ++ if (!*ptr) ++ ptr = marker; ++ } ++ } /*- for(;*ptr && !isspace((int) *ptr);ptr++) */ ++ } /*- for (argc = 0, ptr = sptr.s;*ptr;) */ ++ /* ++ * Allocate memory to store the arguments ++ * Do not bother extra bytes occupied by ++ * white space characters. ++ */ ++ if (!(argv = (char **) alloc((argc + 1) * sizeof(char *)))) ++ return ((char **) 0); ++ for (idx = 0, ptr = sptr.s;*ptr;) ++ { ++ for (;*ptr && isspace((int) *ptr);ptr++) ++ *ptr = 0; ++ if (!*ptr) ++ break; ++ if (*ptr == '$') ++ argv[idx++] = env_get(ptr + 1); ++ else ++ argv[idx++] = ptr; ++ marker = ptr; ++ for (;*ptr && !isspace((int) *ptr);ptr++) ++ { ++ if (ptr == marker && isEscape(*ptr)) ++ { ++ for (ptr++;*ptr && !isEscape(*ptr);ptr++); ++ if (!*ptr) ++ ptr = marker; ++ else /*- Remove the quotes */ ++ { ++ argv[idx - 1] += 1; ++ *ptr = 0; ++ } ++ } ++ } ++ } /*- for (idx = 0, ptr = sptr.s;*ptr;) */ ++ argv[idx++] = (char *) 0; ++ return (argv); ++} ++ ++void ++FreeMakeArgs(char **argv) ++{ ++ alloc_free(argv); ++ return; ++} ++ ++void ++getversion_MakeArgs__c() ++{ ++ static char *x = "$Id: MakeArgs.c,v 2.8 2007-12-21 14:35:42+05:30 Cprogrammer Stab mbhangui $"; ++ x++; ++ x--; ++ return; ++} +diff -Naur qmail-1.03-orig/Makefile qmail-1.03/Makefile +--- qmail-1.03-orig/Makefile 2011-05-04 09:38:51.000000000 +0900 ++++ qmail-1.03/Makefile 2011-05-04 09:39:32.000000000 +0900 +@@ -815,6 +815,7 @@ + dnsptr dnsip dnsmxip dnsfq hostname ipmeprint qreceipt qsmhook qbiff \ + forward preline condredirect bouncesaying except maildirmake \ + maildir2mbox maildirwatch qail elq pinq idedit install-big install \ ++qmail-dk qmail-dkim dkimtest spawn-filter dk-filter \ + instcheck home home+df proc proc+df binm1 binm1+df binm2 binm2+df \ + binm3 binm3+df + +@@ -943,7 +944,7 @@ + maildir2mbox.0 maildirwatch.0 qmail.0 qmail-limits.0 qmail-log.0 \ + qmail-control.0 qmail-header.0 qmail-users.0 dot-qmail.0 \ + qmail-command.0 tcp-environ.0 maildir.0 mbox.0 addresses.0 \ +-envelopes.0 forgeries.0 ++envelopes.0 forgeries.0 qmail-dk.0 qmail-dkim.0 dk-filter.0 spawn-filter.0 + + mbox.0: \ + mbox.5 +@@ -1115,6 +1116,49 @@ + | sed s}SPAWN}"`head -1 conf-spawn`"}g \ + > qmail-control.5 + ++qmail-dk: \ ++load qmail-dk.o triggerpull.o fmtqfn.o now.o date822fmt.o \ ++subgetopt.o MakeArgs.o datetime.a seek.a ndelay.a open.a sig.a alloc.a substdio.a error.a \ ++str.a case.a fs.a auto_qmail.o auto_split.o auto_uids.o fd.a wait.a \ ++../libdomainkeys.a env.a getln.a control.o stralloc.a dns.lib ++ ./load qmail-dk triggerpull.o fmtqfn.o now.o \ ++ date822fmt.o datetime.a seek.a ndelay.a open.a sig.a \ ++ subgetopt.o MakeArgs.o substdio.a error.a fs.a auto_qmail.o \ ++ auto_split.o auto_uids.o \ ++ fd.a wait.a ../libdomainkeys.a -lcrypto env.a control.o open.a getln.a \ ++ stralloc.a alloc.a substdio.a str.a case.a `cat dns.lib` ++ ++qmail-dk.0: \ ++qmail-dk.8 ++ nroff -man qmail-dk.8 > qmail-dk.0 ++ ++qmail-dk.o: \ ++compile qmail-dk.c readwrite.h sig.h exit.h open.h seek.h fmt.h \ ++qmail.h alloc.h substdio.h datetime.h now.h datetime.h triggerpull.h extra.h \ ++env.h wait.h fd.h fork.h str.h \ ++auto_qmail.h auto_uids.h date822fmt.h fmtqfn.h ++ ./compile qmail-dk.c ++ ++qmail-dkim: \ ++load qmail-dkim.o triggerpull.o fmtqfn.o now.o date822fmt.o \ ++subgetopt.o MakeArgs.o dkimdns.o datetime.a seek.a ndelay.a \ ++open.a sig.a alloc.a substdio.a error.a \ ++str.a case.a fs.a auto_qmail.o auto_split.o auto_uids.o fd.a wait.a \ ++../libdomainkeys.a env.a getln.a control.o stralloc.a dns.lib libdkim.a ++ g++ -o qmail-dkim qmail-dkim.o triggerpull.o fmtqfn.o now.o \ ++ subgetopt.o MakeArgs.o date822fmt.o dkimdns.o datetime.a seek.a ndelay.a \ ++ open.a sig.a substdio.a error.a fs.a auto_qmail.o \ ++ auto_split.o auto_uids.o fd.a wait.a \ ++ ../libdomainkeys.a -lcrypto env.a control.o open.a getln.a \ ++ stralloc.a alloc.a substdio.a str.a case.a libdkim.a `cat dns.lib` ++ ++qmail-dkim.o: \ ++compile qmail-dkim.c readwrite.h sig.h exit.h open.h seek.h fmt.h \ ++qmail.h alloc.h substdio.h datetime.h now.h datetime.h triggerpull.h extra.h \ ++sgetopt.h env.h wait.h fd.h fork.h str.h dkim.h \ ++auto_qmail.h auto_uids.h date822fmt.h fmtqfn.h ++ ./compile qmail-dkim.c ++ + qmail-getpw: \ + load qmail-getpw.o case.a substdio.a error.a str.a fs.a auto_break.o \ + auto_usera.o +@@ -1133,6 +1177,20 @@ + | sed s}SPAWN}"`head -1 conf-spawn`"}g \ + > qmail-getpw.8 + ++qmail-dkim.0: qmail-dkim.8 ++ nroff -man qmail-dkim.8 > qmail-dkim.0 ++qmail-dkim.8: qmail-dkim.9 ++ cat qmail-dkim.9 \ ++ | sed s}QMAILHOME}"`head -1 conf-qmail`"}g \ ++ > qmail-dkim.8 ++ ++dk-filter.0: dk-filter.8 ++ nroff -man dk-filter.8 > dk-filter.0 ++dk-filter.8: dk-filter.9 ++ cat dk-filter.9 \ ++ | sed s}QMAILHOME}"`head -1 conf-qmail`"}g \ ++ > dk-filter.8 ++ + qmail-getpw.o: \ + compile qmail-getpw.c readwrite.h substdio.h subfd.h substdio.h \ + error.h exit.h byte.h str.h case.h fmt.h auto_usera.h auto_break.h \ +@@ -1208,11 +1266,11 @@ + qmail-lspawn: \ + load qmail-lspawn.o spawn.o prot.o slurpclose.o coe.o sig.a wait.a \ + case.a cdb.a fd.a open.a stralloc.a alloc.a substdio.a error.a str.a \ +-fs.a auto_qmail.o auto_uids.o auto_spawn.o ++fs.a auto_qmail.o auto_uids.o auto_spawn.o envread.o str_diffn.o + ./load qmail-lspawn spawn.o prot.o slurpclose.o coe.o \ + sig.a wait.a case.a cdb.a fd.a open.a stralloc.a alloc.a \ + substdio.a error.a str.a fs.a auto_qmail.o auto_uids.o \ +- auto_spawn.o ++ auto_spawn.o envread.o str_diffn.o + + qmail-lspawn.0: \ + qmail-lspawn.8 +@@ -1221,7 +1279,7 @@ + qmail-lspawn.o: \ + compile qmail-lspawn.c fd.h wait.h prot.h substdio.h stralloc.h \ + gen_alloc.h scan.h exit.h fork.h error.h cdb.h uint32.h case.h \ +-slurpclose.h auto_qmail.h auto_uids.h qlx.h ++slurpclose.h auto_qmail.h auto_uids.h qlx.h env.h + ./compile qmail-lspawn.c + + qmail-newbmt: \ +@@ -1496,11 +1554,11 @@ + qmail-rspawn: \ + load qmail-rspawn.o spawn.o tcpto_clean.o now.o coe.o sig.a open.a \ + seek.a lock.a wait.a fd.a stralloc.a alloc.a substdio.a error.a str.a \ +-auto_qmail.o auto_uids.o auto_spawn.o ++auto_qmail.o auto_uids.o auto_spawn.o envread.o str_diffn.o + ./load qmail-rspawn spawn.o tcpto_clean.o now.o coe.o \ + sig.a open.a seek.a lock.a wait.a fd.a stralloc.a alloc.a \ + substdio.a error.a str.a auto_qmail.o auto_uids.o \ +- auto_spawn.o ++ auto_spawn.o envread.o str_diffn.o + + qmail-rspawn.0: \ + qmail-rspawn.8 +@@ -1508,7 +1566,7 @@ + + qmail-rspawn.o: \ + compile qmail-rspawn.c fd.h wait.h substdio.h exit.h fork.h error.h \ +-tcpto.h ++tcpto.h env.h + ./compile qmail-rspawn.c + + qmail-send: \ +@@ -1516,12 +1574,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 +@@ -1946,11 +2004,11 @@ + ./compile splogger.c + + str.a: \ +-makelib str_len.o str_diff.o str_diffn.o str_cpy.o str_chr.o \ ++makelib str_len.o str_diff.o str_diffn.o str_cpy.o str_cpyb.o str_chr.o \ + str_rchr.o str_start.o byte_chr.o byte_rchr.o byte_diff.o byte_copy.o \ + byte_cr.o byte_zero.o + ./makelib str.a str_len.o str_diff.o str_diffn.o str_cpy.o \ +- str_chr.o str_rchr.o str_start.o byte_chr.o byte_rchr.o \ ++ str_cpyb.o str_chr.o str_rchr.o str_start.o byte_chr.o byte_rchr.o \ + byte_diff.o byte_copy.o byte_cr.o byte_zero.o + + str_chr.o: \ +@@ -1961,6 +2019,10 @@ + compile str_cpy.c str.h + ./compile str_cpy.c + ++str_cpyb.o: \ ++compile str_cpyb.c str.h ++ ./compile str_cpyb.c ++ + str_diff.o: \ + compile str_diff.c str.h + ./compile str_diff.c +@@ -2176,3 +2238,59 @@ + + wildmat.o: \ + ./compile wildmat.c ++ ++MakeArgs.o: compile MakeArgs.c alloc.h str.h alloc.h stralloc.h ++ ./compile MakeArgs.c ++ ++spawn-filter: \ ++load spawn-filter.o auto_qmail.o \ ++fmt_ulong.o scan_ulong.o control.o open_read.o wildmat.o qregex.o MakeArgs.o \ ++case_lowerb.o constmap.o byte_chr.o byte_cr.o case_diffb.o \ ++error.a env.a stralloc.a wait.a strerr.a str.a getln.a substdio.a alloc.a ++ ./load spawn-filter \ ++ fmt_ulong.o scan_ulong.o control.o open_read.o wildmat.o qregex.o MakeArgs.o \ ++ case_lowerb.o constmap.o byte_chr.o byte_cr.o case_diffb.o auto_qmail.o \ ++ error.a env.a stralloc.a wait.a strerr.a str.a getln.a substdio.a alloc.a ++ ++spawn-filter.o: \ ++compile spawn-filter.c fmt.h str.h strerr.h env.h substdio.h stralloc.h error.h \ ++wait.h qregex.h ++ ./compile spawn-filter.c ++ ++qregex.o: \ ++compile qregex.c case.h stralloc.h constmap.h substdio.h byte.h env.h ++ ./compile qregex.c ++ ++wildmat.o: \ ++compile wildmat.c ++ ./compile wildmat.c ++ ++spawn-filter.0: \ ++spawn-filter.8 ++ nroff -man spawn-filter.8 > spawn-filter.0 ++ ++spawn-filter.8: \ ++spawn-filter.9 ++ cat spawn-filter.9 \ ++ | sed s}QMAILHOME}"`head -1 conf-qmail`"}g \ ++ > spawn-filter.8 ++ ++dk-filter: \ ++warn-auto.sh dk-filter.sh conf-qmail ++ cat warn-auto.sh dk-filter.sh \ ++ | sed s}QMAILHOME}"`head -1 conf-qmail`"}g \ ++ > dk-filter ++ ++DKIMHDRS = dkim.h dkimdns.h dkimbase.h dkimsign.h dkimverify.h ++DKIMSRCS = dkimfuncs.cpp dkimbase.cpp dkimsign.cpp dkimverify.cpp ++DKIMOBJS = $(DKIMSRCS:.cpp=.o) ++dkimtest : libdkim.a dkimtest.o dkimdns.o ++ g++ -g -o dkimtest $(LFLAGS) -L. dkimtest.o dkimdns.o libdkim.a `cat dns.lib` -lcrypto ++ ++dkimtest.o: dkimtest.c $(DKIMHDRS) ++ g++ -I. -c dkimtest.c ++libdkim.a: $(DKIMOBJS) makelib ++ rm -f libdkim.a ++ ./makelib libdkim.a $(DKIMOBJS) ++.cpp.o: ++ g++ -I. -g $(CFLAGS) $(INCL) -c $< +diff -Naur qmail-1.03-orig/TARGETS qmail-1.03/TARGETS +--- qmail-1.03-orig/TARGETS 2011-05-04 09:38:51.000000000 +0900 ++++ qmail-1.03/TARGETS 2011-05-04 09:39:32.000000000 +0900 +@@ -394,3 +394,24 @@ + man + setup + check ++qmail-dk ++qmail-dkim ++qmail-dkim.o ++qmail-dk.o ++libdkim.a ++dkimbase.o ++dkimdns.o ++dkim.o ++dkimsign.o ++dkimverify.o ++dkimtest ++dkimtest.o ++qmail-dkim.8 ++qmail-dkim.0 ++str_cpyb.o ++dkimfuncs.o ++MakeArgs.o ++spawn-filter spawn-filter.o qregex.o wildmat.o ++spawn-filter.8 ++qmail-dk.0 spawn-filter.0 ++dk-filter echo.o echo dk-filter.0 dk-filter.8 +diff -Naur qmail-1.03-orig/alloc.c qmail-1.03/alloc.c +--- qmail-1.03-orig/alloc.c 1998-06-15 19:53:16.000000000 +0900 ++++ qmail-1.03/alloc.c 2011-05-04 09:39:32.000000000 +0900 @@ -1,6 +1,6 @@ #include "alloc.h" #include "error.h" @@ -39,106 +452,9 @@ extern void free(); #define ALIGNMENT 16 /* XXX: assuming that this alignment is enough */ -diff -Naur netqmail-1.06.org/auto-int8.c netqmail-1.06/auto-int8.c ---- netqmail-1.06.org/auto-int8.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/auto-int8.c 2011-02-11 09:36:44.751405769 +0530 -@@ -7,7 +7,7 @@ - char buf1[256]; - substdio ss1 = SUBSTDIO_FDBUF(write,1,buf1,sizeof(buf1)); - --void puts(s) -+void my_puts(s) - char *s; - { - if (substdio_puts(&ss1,s) == -1) _exit(111); -@@ -30,11 +30,11 @@ - scan_8long(value,&num); - strnum[fmt_ulong(strnum,num)] = 0; - -- puts("int "); -- puts(name); -- puts(" = "); -- puts(strnum); -- puts(";\n"); -+ my_puts("int "); -+ my_puts(name); -+ my_puts(" = "); -+ my_puts(strnum); -+ my_puts(";\n"); - if (substdio_flush(&ss1) == -1) _exit(111); - _exit(0); - } -diff -Naur netqmail-1.06.org/auto-int.c netqmail-1.06/auto-int.c ---- netqmail-1.06.org/auto-int.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/auto-int.c 2011-02-11 09:36:52.107882310 +0530 -@@ -7,7 +7,7 @@ - char buf1[256]; - substdio ss1 = SUBSTDIO_FDBUF(write,1,buf1,sizeof(buf1)); - --void puts(s) -+void my_puts(s) - char *s; - { - if (substdio_puts(&ss1,s) == -1) _exit(111); -@@ -30,11 +30,11 @@ - scan_ulong(value,&num); - strnum[fmt_ulong(strnum,num)] = 0; - -- puts("int "); -- puts(name); -- puts(" = "); -- puts(strnum); -- puts(";\n"); -+ my_puts("int "); -+ my_puts(name); -+ my_puts(" = "); -+ my_puts(strnum); -+ my_puts(";\n"); - if (substdio_flush(&ss1) == -1) _exit(111); - _exit(0); - } -diff -Naur netqmail-1.06.org/auto-str.c netqmail-1.06/auto-str.c ---- netqmail-1.06.org/auto-str.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/auto-str.c 2011-02-11 09:35:49.108365112 +0530 -@@ -5,7 +5,7 @@ - char buf1[256]; - substdio ss1 = SUBSTDIO_FDBUF(write,1,buf1,sizeof(buf1)); - --void puts(s) -+void my_puts(s) - char *s; - { - if (substdio_puts(&ss1,s) == -1) _exit(111); -@@ -25,20 +25,20 @@ - value = argv[2]; - if (!value) _exit(100); - -- puts("char "); -- puts(name); -- puts("[] = \"\\\n"); -+ my_puts("char "); -+ my_puts(name); -+ my_puts("[] = \"\\\n"); - - while (ch = *value++) { -- puts("\\"); -+ my_puts("\\"); - octal[3] = 0; - octal[2] = '0' + (ch & 7); ch >>= 3; - octal[1] = '0' + (ch & 7); ch >>= 3; - octal[0] = '0' + (ch & 7); -- puts(octal); -+ my_puts(octal); - } - -- puts("\\\n\";\n"); -+ my_puts("\\\n\";\n"); - if (substdio_flush(&ss1) == -1) _exit(111); - _exit(0); - } -diff -Naur netqmail-1.06.org/control.c netqmail-1.06/control.c ---- netqmail-1.06.org/control.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/control.c 2011-02-11 09:32:40.675705570 +0530 +diff -Naur qmail-1.03-orig/control.c qmail-1.03/control.c +--- qmail-1.03-orig/control.c 2011-05-04 09:38:51.000000000 +0900 ++++ qmail-1.03/control.c 2011-05-04 09:39:32.000000000 +0900 @@ -85,6 +85,28 @@ return 1; } @@ -168,9 +484,9 @@ int control_readfile(sa,fn,flagme) stralloc *sa; char *fn; -diff -Naur netqmail-1.06.org/control.h netqmail-1.06/control.h ---- netqmail-1.06.org/control.h 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/control.h 2011-02-11 09:32:40.675705570 +0530 +diff -Naur qmail-1.03-orig/control.h qmail-1.03/control.h +--- qmail-1.03-orig/control.h 1998-06-15 19:53:16.000000000 +0900 ++++ qmail-1.03/control.h 2011-05-04 09:39:32.000000000 +0900 @@ -3,6 +3,7 @@ extern int control_init(); @@ -179,9 +495,9 @@ extern int control_rldef(); extern int control_readint(); extern int control_readfile(); -diff -Naur netqmail-1.06.org/dk-filter.9 netqmail-1.06/dk-filter.9 ---- netqmail-1.06.org/dk-filter.9 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/dk-filter.9 2011-02-11 09:32:40.675705570 +0530 +diff -Naur qmail-1.03-orig/dk-filter.9 qmail-1.03/dk-filter.9 +--- qmail-1.03-orig/dk-filter.9 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/dk-filter.9 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,107 @@ +.TH dk-filter 8 +.SH NAME @@ -290,9 +606,9 @@ +Problems with +.B dk-filter +should be forwarded to "Manvendra Bhangui" -diff -Naur netqmail-1.06.org/dk-filter.sh netqmail-1.06/dk-filter.sh ---- netqmail-1.06.org/dk-filter.sh 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/dk-filter.sh 2011-02-11 09:32:40.676705501 +0530 +diff -Naur qmail-1.03-orig/dk-filter.sh qmail-1.03/dk-filter.sh +--- qmail-1.03-orig/dk-filter.sh 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/dk-filter.sh 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,280 @@ +# +# $Log: dk-filter.sh,v $ @@ -504,79 +820,262 @@ + shift + ;; + -+ -c) -+ dkopts="$dkopts -c $2" -+ shift -+ ;; ++ -c) ++ dkopts="$dkopts -c $2" ++ shift ++ ;; ++ ++ -s) ++ sopt=1 ++ dkopts="$dkopts -s $2" ++ shift ++ ;; ++ esac ++ shift # next flag ++ done ++ if [ $sopt -eq 0 ] ; then ++ dkopts="$dkopts -s $dkkeyfn" ++ fi ++ exec 0 HeaderList; +}; +#endif /*- DKIMBASE_H */ -diff -Naur netqmail-1.06.org/dkimdns.cpp netqmail-1.06/dkimdns.cpp ---- netqmail-1.06.org/dkimdns.cpp 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/dkimdns.cpp 2011-02-11 09:32:40.677705432 +0530 +diff -Naur qmail-1.03-orig/dkimdns.cpp qmail-1.03/dkimdns.cpp +--- qmail-1.03-orig/dkimdns.cpp 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/dkimdns.cpp 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,127 @@ +/* + * $Log: dns.cpp,v $ @@ -1118,9 +1617,9 @@ + + x++; +} -diff -Naur netqmail-1.06.org/dkimdns.h netqmail-1.06/dkimdns.h ---- netqmail-1.06.org/dkimdns.h 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/dkimdns.h 2011-02-11 09:32:40.677705432 +0530 +diff -Naur qmail-1.03-orig/dkimdns.h qmail-1.03/dkimdns.h +--- qmail-1.03-orig/dkimdns.h 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/dkimdns.h 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,47 @@ +/* + * $Log: dns.h,v $ @@ -1169,9 +1668,9 @@ +// Pass in the FQDN to get the TXT record +int DNSGetTXT(const char *szFQDN, char *Buffer, int nBufLen); +char *dns_text(char *szFQDN); -diff -Naur netqmail-1.06.org/dkimfuncs.cpp netqmail-1.06/dkimfuncs.cpp ---- netqmail-1.06.org/dkimfuncs.cpp 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/dkimfuncs.cpp 2011-02-11 09:32:40.677705432 +0530 +diff -Naur qmail-1.03-orig/dkimfuncs.cpp qmail-1.03/dkimfuncs.cpp +--- qmail-1.03-orig/dkimfuncs.cpp 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/dkimfuncs.cpp 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,224 @@ +/* + * $Log: dkimfuncs.cpp,v $ @@ -1349,240 +1848,57 @@ +DKIMVerifyGetDomain(DKIMContext *pVerifyContext) +{ + CDKIMVerify *pVerify = (CDKIMVerify *) ValidateContext(pVerifyContext, false); -+ if (pVerify) -+ return pVerify->GetDomain(); -+ return ((char *) 0); -+} -+ -+char *DKIM_CALL -+DKIMVersion() -+{ -+ return (char *) "1.1"; -+} -+ -+static char *DKIMErrorStrings[-1 - DKIM_MAX_ERROR] = { -+ (char *) "DKIM_FAIL", -+ (char *) "DKIM_BAD_SYNTAX", -+ (char *) "DKIM_SIGNATURE_BAD", -+ (char *) "DKIM_SIGNATURE_BAD_BUT_TESTING", -+ (char *) "DKIM_SIGNATURE_EXPIRED", -+ (char *) "DKIM_SELECTOR_INVALID", -+ (char *) "DKIM_SELECTOR_GRANULARITY_MISMATCH", -+ (char *) "DKIM_SELECTOR_KEY_REVOKED", -+ (char *) "DKIM_SELECTOR_DOMAIN_NAME_TOO_LONG", -+ (char *) "DKIM_SELECTOR_DNS_TEMP_FAILURE", -+ (char *) "DKIM_SELECTOR_DNS_PERM_FAILURE", -+ (char *) "DKIM_SELECTOR_PUBLIC_KEY_INVALID", -+ (char *) "DKIM_NO_SIGNATURES", -+ (char *) "DKIM_NO_VALID_SIGNATURES", -+ (char *) "DKIM_BODY_HASH_MISMATCH", -+ (char *) "DKIM_SELECTOR_ALGORITHM_MISMATCH", -+ (char *) "DKIM_STAT_INCOMPAT" -+}; -+ -+char *DKIM_CALL -+DKIMGetErrorString(int ErrorCode) -+{ -+ if (ErrorCode >= 0 || ErrorCode <= DKIM_MAX_ERROR) -+ return (char *) "Unknown"; -+ -+ else -+ return DKIMErrorStrings[-1 - ErrorCode]; -+} -+ -+void -+getversion_dkimfuncs_cpp() -+{ -+ static char *x = (char *) "$Id: dkimfuncs.cpp,v 1.2 2009-03-26 15:11:12+05:30 Cprogrammer Exp mbhangui $"; -+ -+ x++; -+} -diff -Naur netqmail-1.06.org/dkim.h netqmail-1.06/dkim.h ---- netqmail-1.06.org/dkim.h 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/dkim.h 2011-02-11 09:32:40.678705363 +0530 -@@ -0,0 +1,179 @@ -+/* -+ * $Log: dkim.h,v $ -+ * Revision 1.5 2009-03-27 20:19:05+05:30 Cprogrammer -+ * major changes made for incorporating ADSP -+ * -+ * Revision 1.4 2009-03-26 19:28:15+05:30 Cprogrammer -+ * removed DKIM_3PS_PARTIAL_SUCCESS -+ * -+ * Revision 1.3 2009-03-26 15:11:33+05:30 Cprogrammer -+ * added ADSP -+ * -+ * Revision 1.2 2009-03-25 08:37:58+05:30 Cprogrammer -+ * changed definitions of constants to avoid clash between error and success -+ * -+ * Revision 1.1 2009-03-21 08:50:19+05:30 Cprogrammer -+ * Initial revision -+ * -+ * -+ * Copyright 2005 Alt-N Technologies, Ltd. -+ * -+ * Licensed under the Apache License, Version 2.0 (the "License"); -+ * you may not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * This code incorporates intellectual property owned by Yahoo! and licensed -+ * pursuant to the Yahoo! DomainKeys Patent License Agreement. -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ * -+ */ -+ -+#define DKIM_CALL -+#define MAKELONG(a,b) ((long)(((unsigned)(a) & 0xffff) | (((unsigned)(b) & 0xffff) << 16))) -+ -+#ifdef __cplusplus -+extern "C" { -+#endif -+ -+// DKIM Body hash versions -+#define DKIM_BODYHASH_ALLMAN_1 1 -+#define DKIM_BODYHASH_IETF_1 2 -+#define DKIM_BODYHASH_BOTH DKIM_BODYHASH_ALLMAN_1 | DKIM_BODYHASH_IETF_1 -+ -+// DKIM hash algorithms -+#define DKIM_HASH_SHA1 1 -+#define DKIM_HASH_SHA256 2 -+#define DKIM_HASH_SHA1_AND_256 DKIM_HASH_SHA1 | DKIM_HASH_SHA256 -+ -+// DKIM canonicalization methods -+#define DKIM_CANON_SIMPLE 1 -+#define DKIM_CANON_NOWSP 2 -+#define DKIM_CANON_RELAXED 3 -+ -+#define DKIM_SIGN_SIMPLE MAKELONG(DKIM_CANON_SIMPLE,DKIM_CANON_SIMPLE) -+#define DKIM_SIGN_SIMPLE_RELAXED MAKELONG(DKIM_CANON_RELAXED,DKIM_CANON_SIMPLE) -+#define DKIM_SIGN_RELAXED MAKELONG(DKIM_CANON_RELAXED,DKIM_CANON_RELAXED) -+#define DKIM_SIGN_RELAXED_SIMPLE MAKELONG(DKIM_CANON_SIMPLE,DKIM_CANON_RELAXED) -+ -+// DKIM Error codes -+#define DKIM_OUT_OF_MEMORY 6 // memory allocation failed -+#define DKIM_INVALID_CONTEXT 7 // DKIMContext structure invalid for this operation -+#define DKIM_NO_SENDER 8 // Could not find From: or Sender: header in message -+#define DKIM_BAD_PRIVATE_KEY 9 // Could not parse private key -+#define DKIM_BUFFER_TOO_SMALL 10 // Buffer passed in is not large enough -+ -+// DKIM_SUCCESS // verify result: all signatures verified -+// signature result: signature verified -+#define DKIM_SUCCESS 0 // operation successful -+#define DKIM_FINISHED_BODY 1 // process result: no more message body is needed -+#define DKIM_PARTIAL_SUCCESS 2 // verify result: at least one but not all signatures verified -+#define DKIM_NEUTRAL 3 // verify result: no signatures verified but message is not suspicous -+#define DKIM_SUCCESS_BUT_EXTRA 4 // signature result: signature verified but it did not include all of the body -+#define DKIM_3PS_SIGNATURE 5 // 3rd-party signature -+ -+// DKIM Verification Error codes -+#define DKIM_FAIL -1 // verify error: message is suspicious -+#define DKIM_BAD_SYNTAX -2 // signature error: DKIM-Signature could not parse or has bad tags/values -+#define DKIM_SIGNATURE_BAD -3 // signature error: RSA verify failed -+#define DKIM_SIGNATURE_BAD_BUT_TESTING -4 // signature error: RSA verify failed but testing -+#define DKIM_SIGNATURE_EXPIRED -5 // signature error: x= is old -+#define DKIM_SELECTOR_INVALID -6 // signature error: selector doesn't parse or contains invalid values -+#define DKIM_SELECTOR_GRANULARITY_MISMATCH -7 // signature error: selector g= doesn't match i= -+#define DKIM_SELECTOR_KEY_REVOKED -8 // signature error: selector p= empty -+#define DKIM_SELECTOR_DOMAIN_NAME_TOO_LONG -9 // signature error: selector domain name too long to request -+#define DKIM_SELECTOR_DNS_TEMP_FAILURE -10 // signature error: temporary dns failure requesting selector -+#define DKIM_SELECTOR_DNS_PERM_FAILURE -11 // signature error: permanent dns failure requesting selector -+#define DKIM_SELECTOR_PUBLIC_KEY_INVALID -12 // signature error: selector p= value invalid or wrong format -+#define DKIM_NO_SIGNATURES -13 // process error, no sigs -+#define DKIM_NO_VALID_SIGNATURES -14 // process error, no valid sigs -+#define DKIM_BODY_HASH_MISMATCH -15 // sigature verify error: message body does not hash to bh value -+#define DKIM_SELECTOR_ALGORITHM_MISMATCH -16 // signature error: selector h= doesn't match signature a= -+#define DKIM_STAT_INCOMPAT -17 // signature error: incompatible v= -+#define DKIM_MAX_ERROR -18 // set this to 1 greater than the highest error code (but negative) -+ -+#define DKIM_SSP_UNKNOWN 1 /*- some messages may be signed */ -+#define DKIM_SSP_ALL 2 /*- all messages are signed, 3rd party allowed */ -+#define DKIM_SSP_STRICT 3 /*- all messages are signed, no 3rd party allowed */ -+#define DKIM_SSP_SCOPE 4 /*- the domain should be considered invalid */ -+#define DKIM_SSP_TEMPFAIL 5 /*- Temporary Error */ -+ -+#define DKIM_ADSP_UNKNOWN 1 /*- some messages may be signed */ -+#define DKIM_ADSP_ALL 2 /*- All message are signed with author signature */ -+#define DKIM_ADSP_DISCARDABLE 3 /*- messages which fail verification are Discardable */ -+#define DKIM_ADSP_SCOPE 4 /*- domain is out of scope */ -+#define DKIM_ADSP_TEMPFAIL 5 /*- Temporary Error */ -+ -+ -+// This function is called once for each header in the message -+// return 1 to include this header in the signature and 0 to exclude. -+typedef int (DKIM_CALL * DKIMHEADERCALLBACK) (const char *szHeader); -+ -+// This function is called to retrieve a TXT record from DNS -+typedef int (DKIM_CALL * DKIMDNSCALLBACK) (const char *szFQDN, char *szBuffer, int nBufLen); ++ if (pVerify) ++ return pVerify->GetDomain(); ++ return ((char *) 0); ++} + -+typedef struct DKIMContext_t { -+ unsigned int reserved1; -+ unsigned int reserved2; -+ void *reserved3; -+} DKIMContext; ++char *DKIM_CALL ++DKIMVersion() ++{ ++ return (char *) "1.1"; ++} + -+typedef struct DKIMSignOptions_t { -+ int nCanon; // canonization -+ int nIncludeBodyLengthTag; // 0 = don't include l= tag, 1 = include l= tag -+ int nIncludeTimeStamp; // 0 = don't include t= tag, 1 = include t= tag -+ int nIncludeQueryMethod; // 0 = don't include q= tag, 1 = include q= tag -+ char szSelector[80]; // selector - required -+ char szDomain[256]; // domain - optional - if empty, domain is computed from sender -+ char szIdentity[256]; // for i= tag, if empty tag will not be included in sig -+ unsigned long expireTime; // for x= tag, if 0 tag will not be included in sig -+ DKIMHEADERCALLBACK pfnHeaderCallback; // header callback -+ char szRequiredHeaders[256]; // colon-separated list of headers that must be signed -+ int nHash; // use one of the DKIM_HASH_xx constants here -+ // even if not present in the message -+ int nIncludeCopiedHeaders; // 0 = don't include z= tag, 1 = include z= tag -+ int nIncludeBodyHash; // use one of the DKIM_BODYHASH_xx constants here -+} DKIMSignOptions; ++static char *DKIMErrorStrings[-1 - DKIM_MAX_ERROR] = { ++ (char *) "DKIM_FAIL", ++ (char *) "DKIM_BAD_SYNTAX", ++ (char *) "DKIM_SIGNATURE_BAD", ++ (char *) "DKIM_SIGNATURE_BAD_BUT_TESTING", ++ (char *) "DKIM_SIGNATURE_EXPIRED", ++ (char *) "DKIM_SELECTOR_INVALID", ++ (char *) "DKIM_SELECTOR_GRANULARITY_MISMATCH", ++ (char *) "DKIM_SELECTOR_KEY_REVOKED", ++ (char *) "DKIM_SELECTOR_DOMAIN_NAME_TOO_LONG", ++ (char *) "DKIM_SELECTOR_DNS_TEMP_FAILURE", ++ (char *) "DKIM_SELECTOR_DNS_PERM_FAILURE", ++ (char *) "DKIM_SELECTOR_PUBLIC_KEY_INVALID", ++ (char *) "DKIM_NO_SIGNATURES", ++ (char *) "DKIM_NO_VALID_SIGNATURES", ++ (char *) "DKIM_BODY_HASH_MISMATCH", ++ (char *) "DKIM_SELECTOR_ALGORITHM_MISMATCH", ++ (char *) "DKIM_STAT_INCOMPAT" ++}; + -+typedef struct DKIMVerifyOptions_t { -+ DKIMDNSCALLBACK pfnSelectorCallback; // selector record callback -+ DKIMDNSCALLBACK pfnPracticesCallback; // SSP record callback -+ int nHonorBodyLengthTag; // 0 = ignore l= tag, 1 = use l= tag to limit the amount of body verified -+ int nCheckPractices; // 0 = use default (unknown) practices, 1 = request and use sender's signing practices -+ int nSubjectRequired; // 0 = subject is required to be signed, 1 = not required -+ int nSaveCanonicalizedData; // 0 = canonicalized data is not saved, 1 = canonicalized data is saved -+ int nAccept3ps; // 0 = don't check 3rd party signature(s), 1 = check 3rd party signature(s) -+} DKIMVerifyOptions; ++char *DKIM_CALL ++DKIMGetErrorString(int ErrorCode) ++{ ++ if (ErrorCode >= 0 || ErrorCode <= DKIM_MAX_ERROR) ++ return (char *) "Unknown"; + -+typedef struct DKIMVerifyDetails_t { -+ char *szSignature; -+ char *DNS; -+ char *szCanonicalizedData; -+ int nResult; -+} DKIMVerifyDetails; ++ else ++ return DKIMErrorStrings[-1 - ErrorCode]; ++} + -+int DKIM_CALL DKIMSignInit(DKIMContext *pSignContext, DKIMSignOptions * pOptions); -+int DKIM_CALL DKIMSignProcess(DKIMContext *pSignContext, char *szBuffer, int nBufLength); -+int DKIM_CALL DKIMSignGetSig(DKIMContext *pSignContext, char *szPrivKey, char *szSignature, int nSigLength); -+int DKIM_CALL DKIMSignGetSig2(DKIMContext *pSignContext, char *szPrivKey, char **pszSignature); -+void DKIM_CALL DKIMSignFree(DKIMContext *pSignContext); -+char *DKIM_CALL DKIMSignGetDomain(DKIMContext *pSignContext); ++void ++getversion_dkimfuncs_cpp() ++{ ++ static char *x = (char *) "$Id: dkimfuncs.cpp,v 1.2 2009-03-26 15:11:12+05:30 Cprogrammer Exp mbhangui $"; + -+int DKIM_CALL DKIMVerifyInit(DKIMContext *pVerifyContext, DKIMVerifyOptions * pOptions); -+int DKIM_CALL DKIMVerifyProcess(DKIMContext *pVerifyContext, char *szBuffer, int nBufLength); -+int DKIM_CALL DKIMVerifyResults(DKIMContext *pVerifyContext , int *sCount, int *sSize); -+int DKIM_CALL DKIMVerifyGetDetails(DKIMContext *pVerifyContext, int *nSigCount, DKIMVerifyDetails **pDetails, char *szPractices); -+char *DKIM_CALL DKIMVerifyGetDomain(DKIMContext *pVerifyContext); -+void DKIM_CALL DKIMVerifyFree(DKIMContext *pVerifyContext); -+char *DKIM_CALL DKIMVersion(); -+char *DKIM_CALL DKIMGetErrorString(int ErrorCode); -+#include "macros.h" -+#ifdef __cplusplus ++ x++; +} -+#endif -diff -Naur netqmail-1.06.org/dkimsign.cpp netqmail-1.06/dkimsign.cpp ---- netqmail-1.06.org/dkimsign.cpp 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/dkimsign.cpp 2011-02-11 09:32:40.679705294 +0530 +diff -Naur qmail-1.03-orig/dkimsign.cpp qmail-1.03/dkimsign.cpp +--- qmail-1.03-orig/dkimsign.cpp 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/dkimsign.cpp 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,907 @@ +/* + * $Log: dkimsign.cpp,v $ @@ -2491,9 +2807,9 @@ + + x++; +} -diff -Naur netqmail-1.06.org/dkimsign.h netqmail-1.06/dkimsign.h ---- netqmail-1.06.org/dkimsign.h 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/dkimsign.h 2011-02-11 09:32:40.679705294 +0530 +diff -Naur qmail-1.03-orig/dkimsign.h qmail-1.03/dkimsign.h +--- qmail-1.03-orig/dkimsign.h 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/dkimsign.h 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,93 @@ +/* + * $Log: dkimsign.h,v $ @@ -2588,9 +2904,9 @@ +}; + +#endif // DKIMSIGN_H -diff -Naur netqmail-1.06.org/dkimtest.c netqmail-1.06/dkimtest.c ---- netqmail-1.06.org/dkimtest.c 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/dkimtest.c 2011-02-11 09:32:40.680705225 +0530 +diff -Naur qmail-1.03-orig/dkimtest.c qmail-1.03/dkimtest.c +--- qmail-1.03-orig/dkimtest.c 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/dkimtest.c 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,850 @@ +/* + * $Log: dkim.c,v $ @@ -3442,9 +3758,9 @@ + + x++; +} -diff -Naur netqmail-1.06.org/dkimverify.cpp netqmail-1.06/dkimverify.cpp ---- netqmail-1.06.org/dkimverify.cpp 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/dkimverify.cpp 2011-02-11 09:32:40.682705087 +0530 +diff -Naur qmail-1.03-orig/dkimverify.cpp qmail-1.03/dkimverify.cpp +--- qmail-1.03-orig/dkimverify.cpp 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/dkimverify.cpp 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,1154 @@ +/* + * $Log: dkimverify.cpp,v $ @@ -4600,9 +4916,9 @@ + + x++; +} -diff -Naur netqmail-1.06.org/dkimverify.h netqmail-1.06/dkimverify.h ---- netqmail-1.06.org/dkimverify.h 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/dkimverify.h 2011-02-11 09:32:40.682705087 +0530 +diff -Naur qmail-1.03-orig/dkimverify.h qmail-1.03/dkimverify.h +--- qmail-1.03-orig/dkimverify.h 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/dkimverify.h 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,118 @@ +/* + * $Log: dkimverify.h,v $ @@ -4722,9 +5038,9 @@ +}; + +#endif /*- DKIMVERIFY_H */ -diff -Naur netqmail-1.06.org/dktrace.h netqmail-1.06/dktrace.h ---- netqmail-1.06.org/dktrace.h 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/dktrace.h 2011-02-11 09:32:40.682705087 +0530 +diff -Naur qmail-1.03-orig/dktrace.h qmail-1.03/dktrace.h +--- qmail-1.03-orig/dktrace.h 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/dktrace.h 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,26 @@ +/* $Id: dktrace.h,v 1.3 2005/06/27 18:47:57 ted46045 Exp $ */ + @@ -4752,9 +5068,9 @@ +extern int dkt_hdrtotrace(char *ptr, DK_TRACE *store); + +#endif -diff -Naur netqmail-1.06.org/domainkeys.h netqmail-1.06/domainkeys.h ---- netqmail-1.06.org/domainkeys.h 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/domainkeys.h 2011-02-11 09:32:40.683705018 +0530 +diff -Naur qmail-1.03-orig/domainkeys.h qmail-1.03/domainkeys.h +--- qmail-1.03-orig/domainkeys.h 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/domainkeys.h 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,377 @@ +/* This file is automatically created from the corresponding .c file */ +/* Do not change this file; change the .c file instead. */ @@ -5020,654 +5336,196 @@ +; + + -+/* Returns a pointer to the selector name used or NULL if there isn't one -+ * Added by rjp -+ */ -+const char *dk_selector(DK *dk) -+; -+ -+ -+/* Returns a pointer to the domain name used or NULL if there isn't one -+ */ -+const char *dk_domain(DK *dk) -+; -+ -+ -+/* -+ * Returns a pointer to a string which begins with "N", "S", or "F", -+ * corresponding to None, Sender: and From:, respectively. -+ * This single character is followed by a null-terminated RFC 2822 address. -+ * The first character is "N" if no valid address has been seen yet, -+ * "S" if the address came from the Sender: field, and "F" if the -+ * address came from the From: field. -+ */ -+char *dk_address(DK *dk) -+; -+ -+ -+/* -+ * Returns a pointer to a null-terminated string containing the granularity -+ * value found in the selector DNS record, if any, but only after dk_end -+ * has been called. Otherwise returns NULL. -+ */ -+char *dk_granularity(DK *dk) -+; -+ -+ -+/* -+ * Called at end-of-message (before response to DATA-dot, if synchronous with SMTP session). -+ * If verifying, returns signature validity. -+ * This does not calculate the signature. Call dk_getsig() for that. -+ * Flags are returned indirectly through dkf. -+ * If you pass in NULL for dkf, the flags will not be fetched. -+ * If there is a DK-Sig line, the d= entry will be used to fetch the flags. -+ * Otherwise the Sender: domain will be used to fetch the flags. -+ * Otherwise the From: domain will be used to fetch the flags. -+ * -+ * NOTE: If for some reason dk_end() returns an error (!DK_STAT_OK) dk_policy() should be called -+ * to get the domain signing policy (o=) and handle accordingly. -+ * dkf (selector flags) wont be set if dk_end() returns -+ * DK_STAT_NOSIG -+ * DK_STAT_NOKEY -+ * DK_STAT_SYNTAX -+ * DK_STAT_NORESOURCE -+ * DK_STAT_BADKEY -+ * DK_STAT_CANTVERIFY -+ */ -+DK_STAT dk_end(DK *dk, DK_FLAGS *dkf) -+; -+ -+ -+/* -+ * DEPRECATED in favor of calling dk_end and dk_policy() directly. -+ * If you pass in NULL for dkf, the policy flags will not be fetched. -+ * If the message verified okay, the policy flags will not be fetched. -+ */ -+DK_STAT dk_eom(DK *dk, DK_FLAGS *dkf) -+; -+ -+ -+/* -+ * -+ * privatekey is the private key used to create the signature; It should contain -+ * the entire contents of a PEM-format private key file, thusly it will begin with -+ * -----BEGIN RSA PRIVATE KEY-----. It should be null-terminated. -+ */ -+size_t dk_siglen(void *privatekey) -+; -+ -+ -+/* -+ * Sets buf to a null-terminated string. -+ * If the message is being signed, signature is stored in the buffer. -+ * If the message is being verified, returns DK_STAT_INTERNAL. -+ * privatekey is the private key used to create the signature; It should contain -+ * the entire contents of a PEM-format private key file, thus it will begin with -+ * -----BEGIN RSA PRIVATE KEY-----. It should be null-terminated. -+ * If you pass in NULL for buf, you'll get back DK_STAT_NORESOURCE. -+ * If len is not big enough, you'll get back DK_STAT_NORESOURCE. -+ */ -+DK_STAT dk_getsig(DK *dk, void *privatekey, unsigned char buf[], size_t len) -+; -+ -+ -+/* -+ * Free all resources associated with this message. -+ * dk is no longer usable. -+ * if doClearErrState != 0, the OpenSSL ErrorState is freed. -+ * Set clearErrState=0 if you use other openssl functions and -+ * want to call openssl's ERR_remove_state(0) by yourself -+ * ERR_remove_state(0) is declared in -+ */ -+DK_STAT dk_free(DK *dk, int doClearErrState) -+; -+ -+ -+/* -+ * return a pointer to a string which describes st. -+ * The string is structured. All the characters up to the first colon -+ * contain the name of the DK_STAT constant. From there to the end of -+ * string is a human-readable description of the error. -+ */ -+const char *DK_STAT_to_string(DK_STAT st) -+; -+ -+ -diff -Naur netqmail-1.06.org/hier.c netqmail-1.06/hier.c ---- netqmail-1.06.org/hier.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/hier.c 2011-02-11 09:32:40.683705018 +0530 -@@ -104,10 +104,15 @@ - c(auto_qmail,"bin","qmail-start",auto_uido,auto_gidq,0700); - c(auto_qmail,"bin","qmail-getpw",auto_uido,auto_gidq,0711); - c(auto_qmail,"bin","qmail-local",auto_uido,auto_gidq,0711); -+ c(auto_qmail,"bin","spawn-filter",auto_uido,auto_gidq,0711); -+ c(auto_qmail,"bin","dk-filter",auto_uido,auto_gidq,0555); - c(auto_qmail,"bin","qmail-remote",auto_uido,auto_gidq,0711); - c(auto_qmail,"bin","qmail-rspawn",auto_uido,auto_gidq,0711); - c(auto_qmail,"bin","qmail-clean",auto_uido,auto_gidq,0711); - c(auto_qmail,"bin","qmail-send",auto_uido,auto_gidq,0711); -+ c(auto_qmail,"bin","qmail-dk",auto_uidq,auto_gidq,0711); -+ c(auto_qmail,"bin","qmail-dkim",auto_uidq,auto_gidq,0711); -+ c(auto_qmail,"bin","dkimtest",auto_uidq,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-newmrh",auto_uido,auto_gidq,0700); -@@ -198,6 +203,14 @@ - c(auto_qmail,"man/cat1","tcp-env.0",auto_uido,auto_gidq,0644); - - c(auto_qmail,"man/man8","qmail-local.8",auto_uido,auto_gidq,0644); -+ c(auto_qmail,"man/man8","qmail-dk.8",auto_uido,auto_gidq,0644); -+ c(auto_qmail,"man/cat8","qmail-dk.0",auto_uido,auto_gidq,0644); -+ c(auto_qmail,"man/man8","qmail-dkim.8",auto_uido,auto_gidq,0644); -+ c(auto_qmail,"man/cat8","qmail-dkim.0",auto_uido,auto_gidq,0644); -+ c(auto_qmail,"man/man8","dk-filter.8",auto_uido,auto_gidq,0644); -+ c(auto_qmail,"man/cat8","dk-filter.0",auto_uido,auto_gidq,0644); -+ c(auto_qmail,"man/man8","spawn-filter.8",auto_uido,auto_gidq,0644); -+ c(auto_qmail,"man/cat8","spawn-filter.0",auto_uido,auto_gidq,0644); - c(auto_qmail,"man/cat8","qmail-local.0",auto_uido,auto_gidq,0644); - c(auto_qmail,"man/man8","qmail-lspawn.8",auto_uido,auto_gidq,0644); - c(auto_qmail,"man/cat8","qmail-lspawn.0",auto_uido,auto_gidq,0644); -diff -Naur netqmail-1.06.org/ip.h netqmail-1.06/ip.h ---- netqmail-1.06.org/ip.h 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/ip.h 2011-02-11 09:32:40.684704949 +0530 -@@ -2,6 +2,7 @@ - #define IP_H - - struct ip_address { unsigned char d[4]; } ; -+typedef struct ip_address ip_addr; - - extern unsigned int ip_fmt(); - #define IPFMT 19 -diff -Naur netqmail-1.06.org/macros.h netqmail-1.06/macros.h ---- netqmail-1.06.org/macros.h 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/macros.h 2011-02-11 09:32:40.684704949 +0530 -@@ -0,0 +1,25 @@ -+/* -+ * $Log: macros.h,v $ -+ * Revision 1.1 2009-03-21 08:50:25+05:30 Cprogrammer -+ * Initial revision -+ * -+ * -+ * macros.h: Useful macros -+ * -+ * Author: -+ * Dick Porter (dick@ximian.com) -+ * -+ * (C) 2002 Ximian, Inc. ++/* Returns a pointer to the selector name used or NULL if there isn't one ++ * Added by rjp + */ ++const char *dk_selector(DK *dk) ++; + -+#ifndef _WAPI_MACROS_H_ -+#define _WAPI_MACROS_H_ + -+#include ++/* Returns a pointer to the domain name used or NULL if there isn't one ++ */ ++const char *dk_domain(DK *dk) ++; + -+#define MAKEWORD(low, high) ((__uint16_t)(((__uint8_t)(low)) | \ -+ ((__uint16_t)((__uint8_t)(high))) << 8)) -+#define LOBYTE(i16) ((__uint8_t)((i16) & 0xFF)) -+#define HIBYTE(i16) ((__uint8_t)(((__uint16_t)(i16) >> 8) & 0xFF)) + -+#endif /* _WAPI_MACROS_H_ */ -diff -Naur netqmail-1.06.org/MakeArgs.c netqmail-1.06/MakeArgs.c ---- netqmail-1.06.org/MakeArgs.c 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/MakeArgs.c 2011-02-11 09:32:40.684704949 +0530 -@@ -0,0 +1,144 @@ +/* -+ * $Log: MakeArgs.c,v $ -+ * Revision 2.8 2007-12-21 14:35:42+05:30 Cprogrammer -+ * included env.h to prevent compiler warning -+ * -+ * Revision 2.7 2007-12-20 12:45:28+05:30 Cprogrammer -+ * expand environment variables with '$' sign -+ * -+ * Revision 2.6 2005-08-23 17:31:28+05:30 Cprogrammer -+ * removed sccsid variable -+ * -+ * Revision 2.5 2005-04-02 19:06:02+05:30 Cprogrammer -+ * djb version -+ * -+ * Revision 2.4 2005-03-30 22:52:47+05:30 Cprogrammer -+ * BUG - Incorrect free -+ * -+ * Revision 2.3 2004-07-12 22:47:58+05:30 Cprogrammer -+ * bug fix. Free all allocated members -+ * -+ * Revision 2.2 2002-12-21 18:21:09+05:30 Cprogrammer -+ * added functionality of escaping text via quotes -+ * -+ * Revision 2.1 2002-08-13 20:35:44+05:30 Cprogrammer -+ * addition spaces were not getting skipped -+ * -+ * Revision 1.2 2002-03-03 17:23:05+05:30 Cprogrammer -+ * replaced strcpy with scopy -+ * -+ * Revision 1.1 2001-12-13 01:46:09+05:30 Cprogrammer -+ * Initial revision -+ * ++ * Returns a pointer to a string which begins with "N", "S", or "F", ++ * corresponding to None, Sender: and From:, respectively. ++ * This single character is followed by a null-terminated RFC 2822 address. ++ * The first character is "N" if no valid address has been seen yet, ++ * "S" if the address came from the Sender: field, and "F" if the ++ * address came from the From: field. + */ -+#include "alloc.h" -+#include "str.h" -+#include "stralloc.h" -+#include "env.h" -+#include ++char *dk_address(DK *dk) ++; + -+#define isEscape(ch) ((ch) == '"' || (ch) == '\'') + +/* -+ * function to expand a string into command line -+ * arguments. To free memory allocated by this -+ * function the following should be done -+ * -+ * free(argv); -+ * ++ * Returns a pointer to a null-terminated string containing the granularity ++ * value found in the selector DNS record, if any, but only after dk_end ++ * has been called. Otherwise returns NULL. + */ -+char ** -+MakeArgs(char *cmmd) -+{ -+ char *ptr, *marker; -+ char **argv; -+ int argc, idx; -+ static stralloc sptr = { 0 }; -+ -+ for (ptr = cmmd;*ptr && isspace((int) *ptr);ptr++); -+ idx = str_len(ptr); -+ if (!stralloc_copys(&sptr, ptr)) -+ return((char **) 0); -+ if (!stralloc_0(&sptr)) -+ return((char **) 0); -+ /*- -+ * Get the number of arguments by counting -+ * white spaces. Allow escape via the double -+ * quotes character at the first word -+ */ -+ for (argc = 0, ptr = sptr.s;*ptr;) -+ { -+ for (;*ptr && isspace((int) *ptr);ptr++); -+ if (!*ptr) -+ break; -+ argc++; -+ marker = ptr; -+ /*- Move till you hit the next white space */ -+ for (;*ptr && !isspace((int) *ptr);ptr++) -+ { -+ /*- -+ * 1. If escape char is encounted skip till you -+ * hit the terminating escape char -+ * 2. If terminating escape char is missing, come -+ * back to the start escape char -+ */ -+ if (ptr == marker && isEscape(*ptr)) -+ { -+ for (ptr++;*ptr && !isEscape(*ptr);ptr++); -+ if (!*ptr) -+ ptr = marker; -+ } -+ } /*- for(;*ptr && !isspace((int) *ptr);ptr++) */ -+ } /*- for (argc = 0, ptr = sptr.s;*ptr;) */ -+ /* -+ * Allocate memory to store the arguments -+ * Do not bother extra bytes occupied by -+ * white space characters. -+ */ -+ if (!(argv = (char **) alloc((argc + 1) * sizeof(char *)))) -+ return ((char **) 0); -+ for (idx = 0, ptr = sptr.s;*ptr;) -+ { -+ for (;*ptr && isspace((int) *ptr);ptr++) -+ *ptr = 0; -+ if (!*ptr) -+ break; -+ if (*ptr == '$') -+ argv[idx++] = env_get(ptr + 1); -+ else -+ argv[idx++] = ptr; -+ marker = ptr; -+ for (;*ptr && !isspace((int) *ptr);ptr++) -+ { -+ if (ptr == marker && isEscape(*ptr)) -+ { -+ for (ptr++;*ptr && !isEscape(*ptr);ptr++); -+ if (!*ptr) -+ ptr = marker; -+ else /*- Remove the quotes */ -+ { -+ argv[idx - 1] += 1; -+ *ptr = 0; -+ } -+ } -+ } -+ } /*- for (idx = 0, ptr = sptr.s;*ptr;) */ -+ argv[idx++] = (char *) 0; -+ return (argv); -+} -+ -+void -+FreeMakeArgs(char **argv) -+{ -+ alloc_free(argv); -+ return; -+} -+ -+void -+getversion_MakeArgs__c() -+{ -+ static char *x = "$Id: MakeArgs.c,v 2.8 2007-12-21 14:35:42+05:30 Cprogrammer Stab mbhangui $"; -+ x++; -+ x--; -+ return; -+} -diff -Naur netqmail-1.06.org/Makefile netqmail-1.06/Makefile ---- netqmail-1.06.org/Makefile 2007-12-01 01:52:54.000000000 +0530 -+++ netqmail-1.06/Makefile 2011-02-11 09:39:20.255340711 +0530 -@@ -807,6 +807,7 @@ - dnsptr dnsip dnsmxip dnsfq hostname ipmeprint qreceipt qsmhook qbiff \ - forward preline condredirect bouncesaying except maildirmake \ - maildir2mbox maildirwatch qail elq pinq idedit install-big install \ -+qmail-dk qmail-dkim dkimtest spawn-filter dk-filter \ - instcheck home home+df proc proc+df binm1 binm1+df binm2 binm2+df \ - binm3 binm3+df - -@@ -935,7 +936,7 @@ - maildir2mbox.0 maildirwatch.0 qmail.0 qmail-limits.0 qmail-log.0 \ - qmail-control.0 qmail-header.0 qmail-users.0 dot-qmail.0 \ - qmail-command.0 tcp-environ.0 maildir.0 mbox.0 addresses.0 \ --envelopes.0 forgeries.0 -+envelopes.0 forgeries.0 qmail-dk.0 qmail-dkim.0 dk-filter.0 spawn-filter.0 - - mbox.0: \ - mbox.5 -@@ -1107,6 +1108,49 @@ - | sed s}SPAWN}"`head -1 conf-spawn`"}g \ - > qmail-control.5 - -+qmail-dk: \ -+load qmail-dk.o triggerpull.o fmtqfn.o now.o date822fmt.o \ -+subgetopt.o MakeArgs.o datetime.a seek.a ndelay.a open.a sig.a alloc.a substdio.a error.a \ -+str.a case.a fs.a auto_qmail.o auto_split.o auto_uids.o fd.a wait.a \ -+../libdomainkeys.a env.a getln.a control.o stralloc.a dns.lib -+ ./load qmail-dk triggerpull.o fmtqfn.o now.o \ -+ date822fmt.o datetime.a seek.a ndelay.a open.a sig.a \ -+ subgetopt.o MakeArgs.o substdio.a error.a fs.a auto_qmail.o \ -+ auto_split.o auto_uids.o \ -+ fd.a wait.a ../libdomainkeys.a -lcrypto env.a control.o open.a getln.a \ -+ stralloc.a alloc.a substdio.a str.a case.a `cat dns.lib` -+ -+qmail-dk.0: \ -+qmail-dk.8 -+ nroff -man qmail-dk.8 > qmail-dk.0 -+ -+qmail-dk.o: \ -+compile qmail-dk.c readwrite.h sig.h exit.h open.h seek.h fmt.h \ -+qmail.h alloc.h substdio.h datetime.h now.h datetime.h triggerpull.h extra.h \ -+env.h wait.h fd.h fork.h str.h \ -+auto_qmail.h auto_uids.h date822fmt.h fmtqfn.h -+ ./compile qmail-dk.c -+ -+qmail-dkim: \ -+load qmail-dkim.o triggerpull.o fmtqfn.o now.o date822fmt.o \ -+subgetopt.o MakeArgs.o dkimdns.o datetime.a seek.a ndelay.a \ -+open.a sig.a alloc.a substdio.a error.a \ -+str.a case.a fs.a auto_qmail.o auto_split.o auto_uids.o fd.a wait.a \ -+../libdomainkeys.a env.a getln.a control.o stralloc.a dns.lib libdkim.a -+ g++ -o qmail-dkim qmail-dkim.o triggerpull.o fmtqfn.o now.o \ -+ subgetopt.o MakeArgs.o date822fmt.o dkimdns.o datetime.a seek.a ndelay.a \ -+ open.a sig.a substdio.a error.a fs.a auto_qmail.o \ -+ auto_split.o auto_uids.o fd.a wait.a \ -+ ../libdomainkeys.a -lcrypto env.a control.o open.a getln.a \ -+ stralloc.a alloc.a substdio.a str.a case.a libdkim.a `cat dns.lib` ++char *dk_granularity(DK *dk) ++; + -+qmail-dkim.o: \ -+compile qmail-dkim.c readwrite.h sig.h exit.h open.h seek.h fmt.h \ -+qmail.h alloc.h substdio.h datetime.h now.h datetime.h triggerpull.h extra.h \ -+sgetopt.h env.h wait.h fd.h fork.h str.h dkim.h \ -+auto_qmail.h auto_uids.h date822fmt.h fmtqfn.h -+ ./compile qmail-dkim.c + - qmail-getpw: \ - load qmail-getpw.o case.a substdio.a error.a str.a fs.a auto_break.o \ - auto_usera.o -@@ -1125,6 +1169,20 @@ - | sed s}SPAWN}"`head -1 conf-spawn`"}g \ - > qmail-getpw.8 - -+qmail-dkim.0: qmail-dkim.8 -+ nroff -man qmail-dkim.8 > qmail-dkim.0 -+qmail-dkim.8: qmail-dkim.9 -+ cat qmail-dkim.9 \ -+ | sed s}QMAILHOME}"`head -1 conf-qmail`"}g \ -+ > qmail-dkim.8 ++/* ++ * Called at end-of-message (before response to DATA-dot, if synchronous with SMTP session). ++ * If verifying, returns signature validity. ++ * This does not calculate the signature. Call dk_getsig() for that. ++ * Flags are returned indirectly through dkf. ++ * If you pass in NULL for dkf, the flags will not be fetched. ++ * If there is a DK-Sig line, the d= entry will be used to fetch the flags. ++ * Otherwise the Sender: domain will be used to fetch the flags. ++ * Otherwise the From: domain will be used to fetch the flags. ++ * ++ * NOTE: If for some reason dk_end() returns an error (!DK_STAT_OK) dk_policy() should be called ++ * to get the domain signing policy (o=) and handle accordingly. ++ * dkf (selector flags) wont be set if dk_end() returns ++ * DK_STAT_NOSIG ++ * DK_STAT_NOKEY ++ * DK_STAT_SYNTAX ++ * DK_STAT_NORESOURCE ++ * DK_STAT_BADKEY ++ * DK_STAT_CANTVERIFY ++ */ ++DK_STAT dk_end(DK *dk, DK_FLAGS *dkf) ++; + -+dk-filter.0: dk-filter.8 -+ nroff -man dk-filter.8 > dk-filter.0 -+dk-filter.8: dk-filter.9 -+ cat dk-filter.9 \ -+ | sed s}QMAILHOME}"`head -1 conf-qmail`"}g \ -+ > dk-filter.8 + - qmail-getpw.o: \ - compile qmail-getpw.c readwrite.h substdio.h subfd.h substdio.h \ - error.h exit.h byte.h str.h case.h fmt.h auto_usera.h auto_break.h \ -@@ -1200,11 +1258,11 @@ - qmail-lspawn: \ - load qmail-lspawn.o spawn.o prot.o slurpclose.o coe.o sig.a wait.a \ - case.a cdb.a fd.a open.a stralloc.a alloc.a substdio.a error.a str.a \ --fs.a auto_qmail.o auto_uids.o auto_spawn.o -+fs.a auto_qmail.o auto_uids.o auto_spawn.o envread.o str_diffn.o - ./load qmail-lspawn spawn.o prot.o slurpclose.o coe.o \ - sig.a wait.a case.a cdb.a fd.a open.a stralloc.a alloc.a \ - substdio.a error.a str.a fs.a auto_qmail.o auto_uids.o \ -- auto_spawn.o -+ auto_spawn.o envread.o str_diffn.o - - qmail-lspawn.0: \ - qmail-lspawn.8 -@@ -1213,7 +1271,7 @@ - qmail-lspawn.o: \ - compile qmail-lspawn.c fd.h wait.h prot.h substdio.h stralloc.h \ - gen_alloc.h scan.h exit.h fork.h error.h cdb.h uint32.h case.h \ --slurpclose.h auto_qmail.h auto_uids.h qlx.h -+slurpclose.h auto_qmail.h auto_uids.h qlx.h env.h - ./compile qmail-lspawn.c - - qmail-newmrh: \ -@@ -1463,11 +1521,11 @@ - qmail-rspawn: \ - load qmail-rspawn.o spawn.o tcpto_clean.o now.o coe.o sig.a open.a \ - seek.a lock.a wait.a fd.a stralloc.a alloc.a substdio.a error.a str.a \ --auto_qmail.o auto_uids.o auto_spawn.o -+auto_qmail.o auto_uids.o auto_spawn.o envread.o str_diffn.o - ./load qmail-rspawn spawn.o tcpto_clean.o now.o coe.o \ - sig.a open.a seek.a lock.a wait.a fd.a stralloc.a alloc.a \ - substdio.a error.a str.a auto_qmail.o auto_uids.o \ -- auto_spawn.o -+ auto_spawn.o envread.o str_diffn.o - - qmail-rspawn.0: \ - qmail-rspawn.8 -@@ -1475,7 +1533,7 @@ - - qmail-rspawn.o: \ - compile qmail-rspawn.c fd.h wait.h substdio.h exit.h fork.h error.h \ --tcpto.h -+tcpto.h env.h - ./compile qmail-rspawn.c - - qmail-send: \ -@@ -1541,8 +1599,7 @@ - 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 `cat \ -- socket.lib` -+ alloc.a substdio.a error.a str.a fs.a auto_qmail.o `cat socket.lib` - - qmail-smtpd.0: \ - qmail-smtpd.8 -@@ -1912,11 +1969,11 @@ - ./compile splogger.c - - str.a: \ --makelib str_len.o str_diff.o str_diffn.o str_cpy.o str_chr.o \ -+makelib str_len.o str_diff.o str_diffn.o str_cpy.o str_cpyb.o str_chr.o \ - str_rchr.o str_start.o byte_chr.o byte_rchr.o byte_diff.o byte_copy.o \ - byte_cr.o byte_zero.o - ./makelib str.a str_len.o str_diff.o str_diffn.o str_cpy.o \ -- str_chr.o str_rchr.o str_start.o byte_chr.o byte_rchr.o \ -+ str_cpyb.o str_chr.o str_rchr.o str_start.o byte_chr.o byte_rchr.o \ - byte_diff.o byte_copy.o byte_cr.o byte_zero.o - - str_chr.o: \ -@@ -1927,6 +1984,10 @@ - compile str_cpy.c str.h - ./compile str_cpy.c - -+str_cpyb.o: \ -+compile str_cpyb.c str.h -+ ./compile str_cpyb.c ++/* ++ * DEPRECATED in favor of calling dk_end and dk_policy() directly. ++ * If you pass in NULL for dkf, the policy flags will not be fetched. ++ * If the message verified okay, the policy flags will not be fetched. ++ */ ++DK_STAT dk_eom(DK *dk, DK_FLAGS *dkf) ++; + - str_diff.o: \ - compile str_diff.c str.h - ./compile str_diff.c -@@ -2139,3 +2200,58 @@ - wait_pid.o: \ - compile wait_pid.c error.h haswaitp.h - ./compile wait_pid.c -+MakeArgs.o: compile MakeArgs.c alloc.h str.h alloc.h stralloc.h -+ ./compile MakeArgs.c + -+spawn-filter: \ -+load spawn-filter.o auto_qmail.o \ -+fmt_ulong.o scan_ulong.o control.o open_read.o wildmat.o qregex.o MakeArgs.o \ -+case_lowerb.o constmap.o byte_chr.o byte_cr.o case_diffb.o \ -+error.a env.a stralloc.a wait.a strerr.a str.a getln.a substdio.a alloc.a -+ ./load spawn-filter \ -+ fmt_ulong.o scan_ulong.o control.o open_read.o wildmat.o qregex.o MakeArgs.o \ -+ case_lowerb.o constmap.o byte_chr.o byte_cr.o case_diffb.o auto_qmail.o \ -+ error.a env.a stralloc.a wait.a strerr.a str.a getln.a substdio.a alloc.a ++/* ++ * ++ * privatekey is the private key used to create the signature; It should contain ++ * the entire contents of a PEM-format private key file, thusly it will begin with ++ * -----BEGIN RSA PRIVATE KEY-----. It should be null-terminated. ++ */ ++size_t dk_siglen(void *privatekey) ++; + -+spawn-filter.o: \ -+compile spawn-filter.c fmt.h str.h strerr.h env.h substdio.h stralloc.h error.h \ -+wait.h qregex.h -+ ./compile spawn-filter.c + -+qregex.o: \ -+compile qregex.c case.h stralloc.h constmap.h substdio.h byte.h env.h -+ ./compile qregex.c ++/* ++ * Sets buf to a null-terminated string. ++ * If the message is being signed, signature is stored in the buffer. ++ * If the message is being verified, returns DK_STAT_INTERNAL. ++ * privatekey is the private key used to create the signature; It should contain ++ * the entire contents of a PEM-format private key file, thus it will begin with ++ * -----BEGIN RSA PRIVATE KEY-----. It should be null-terminated. ++ * If you pass in NULL for buf, you'll get back DK_STAT_NORESOURCE. ++ * If len is not big enough, you'll get back DK_STAT_NORESOURCE. ++ */ ++DK_STAT dk_getsig(DK *dk, void *privatekey, unsigned char buf[], size_t len) ++; + -+wildmat.o: \ -+compile wildmat.c -+ ./compile wildmat.c + -+spawn-filter.0: \ -+spawn-filter.8 -+ nroff -man spawn-filter.8 > spawn-filter.0 ++/* ++ * Free all resources associated with this message. ++ * dk is no longer usable. ++ * if doClearErrState != 0, the OpenSSL ErrorState is freed. ++ * Set clearErrState=0 if you use other openssl functions and ++ * want to call openssl's ERR_remove_state(0) by yourself ++ * ERR_remove_state(0) is declared in ++ */ ++DK_STAT dk_free(DK *dk, int doClearErrState) ++; + -+spawn-filter.8: \ -+spawn-filter.9 -+ cat spawn-filter.9 \ -+ | sed s}QMAILHOME}"`head -1 conf-qmail`"}g \ -+ > spawn-filter.8 + -+dk-filter: \ -+warn-auto.sh dk-filter.sh conf-qmail -+ cat warn-auto.sh dk-filter.sh \ -+ | sed s}QMAILHOME}"`head -1 conf-qmail`"}g \ -+ > dk-filter ++/* ++ * return a pointer to a string which describes st. ++ * The string is structured. All the characters up to the first colon ++ * contain the name of the DK_STAT constant. From there to the end of ++ * string is a human-readable description of the error. ++ */ ++const char *DK_STAT_to_string(DK_STAT st) ++; + -+DKIMHDRS = dkim.h dkimdns.h dkimbase.h dkimsign.h dkimverify.h -+DKIMSRCS = dkimfuncs.cpp dkimbase.cpp dkimsign.cpp dkimverify.cpp -+DKIMOBJS = $(DKIMSRCS:.cpp=.o) -+dkimtest : libdkim.a dkimtest.o dkimdns.o -+ g++ -g -o dkimtest $(LFLAGS) -L. dkimtest.o dkimdns.o libdkim.a `cat dns.lib` -lcrypto -+ -+dkimtest.o: dkimtest.c $(DKIMHDRS) -+ g++ -I. -c dkimtest.c -+libdkim.a: $(DKIMOBJS) makelib -+ rm -f libdkim.a -+ ./makelib libdkim.a $(DKIMOBJS) -+.cpp.o: -+ g++ -I. -g $(CFLAGS) $(INCL) -c $< -diff -Naur netqmail-1.06.org/qmail.c netqmail-1.06/qmail.c ---- netqmail-1.06.org/qmail.c 2007-12-01 01:52:54.000000000 +0530 -+++ netqmail-1.06/qmail.c 2011-02-11 09:32:40.687704742 +0530 -@@ -23,22 +23,27 @@ - { - int pim[2]; - int pie[2]; -+ int pic[2]; - - setup_qqargs(); - - if (pipe(pim) == -1) return -1; - if (pipe(pie) == -1) { close(pim[0]); close(pim[1]); return -1; } -+ if (pipe(pic) == -1) { close(pim[0]); close(pim[1]); close(pie[0]); close(pie[1]); return -1; } - - switch(qq->pid = vfork()) { - case -1: - close(pim[0]); close(pim[1]); - close(pie[0]); close(pie[1]); -+ close(pic[0]); close(pic[1]); - return -1; - case 0: - close(pim[1]); - close(pie[1]); -+ close(pic[0]); /*- we want to receive data */ - if (fd_move(0,pim[0]) == -1) _exit(120); - if (fd_move(1,pie[0]) == -1) _exit(120); -+ if (fd_move(CUSTOM_ERR_FD,pic[1]) == -1) _exit(120); - if (chdir(auto_qmail) == -1) _exit(61); - execv(*binqqargs,binqqargs); - _exit(120); -@@ -46,6 +51,7 @@ - - qq->fdm = pim[1]; close(pim[0]); - qq->fde = pie[1]; close(pie[0]); -+ qq->fdc = pic[0]; close(pic[1]); - substdio_fdbuf(&qq->ss,write,qq->fdm,qq->buf,sizeof(qq->buf)); - qq->flagerr = 0; - return 0; -@@ -93,10 +99,21 @@ - { - int wstat; - int exitcode; -+ int len = 0; -+ char ch; -+ static char errstr[256]; - - qmail_put(qq,"",1); - if (!qq->flagerr) if (substdio_flush(&qq->ss) == -1) qq->flagerr = 1; - close(qq->fde); -+ substdio_fdbuf(&qq->ss, read, qq->fdc, qq->buf, sizeof(qq->buf)); -+ while (substdio_bget(&qq->ss, &ch, 1) && len < 255) -+ { -+ errstr[len] = ch; len++; -+ } -+ if (len > 0) -+ errstr[len] = 0; /* add str-term */ -+ close(qq->fdc); ++ +diff -Naur qmail-1.03-orig/hier.c qmail-1.03/hier.c +--- qmail-1.03-orig/hier.c 2011-05-04 09:38:54.000000000 +0900 ++++ qmail-1.03/hier.c 2011-05-04 09:39:32.000000000 +0900 +@@ -106,10 +106,15 @@ + c(auto_qmail,"bin","qmail-start",auto_uido,auto_gidq,0700); + c(auto_qmail,"bin","qmail-getpw",auto_uido,auto_gidq,0711); + c(auto_qmail,"bin","qmail-local",auto_uido,auto_gidq,0711); ++ c(auto_qmail,"bin","spawn-filter",auto_uido,auto_gidq,0711); ++ c(auto_qmail,"bin","dk-filter",auto_uido,auto_gidq,0555); + c(auto_qmail,"bin","qmail-remote",auto_uido,auto_gidq,0711); + c(auto_qmail,"bin","qmail-rspawn",auto_uido,auto_gidq,0711); + c(auto_qmail,"bin","qmail-clean",auto_uido,auto_gidq,0711); + c(auto_qmail,"bin","qmail-send",auto_uido,auto_gidq,0711); ++ c(auto_qmail,"bin","qmail-dk",auto_uidq,auto_gidq,0711); ++ c(auto_qmail,"bin","qmail-dkim",auto_uidq,auto_gidq,0711); ++ c(auto_qmail,"bin","dkimtest",auto_uidq,auto_gidq,0711); + c(auto_qmail,"bin","splogger",auto_uido,auto_gidq,0711); + c(auto_qmail,"bin","qmail-newu",auto_uido,auto_gidq,0700); + #ifdef BADMIMETYPE +@@ -203,6 +208,14 @@ + c(auto_qmail,"man/cat1","tcp-env.0",auto_uido,auto_gidq,0644); - if (wait_pid(&wstat,qq->pid) != qq->pid) - return "Zqq waitpid surprise (#4.3.0)"; -@@ -108,6 +125,7 @@ - case 115: /* compatibility */ - case 11: return "Denvelope address too long for qq (#5.1.3)"; - case 31: return "Dmail server permanently rejected message (#5.3.0)"; -+ case 32: return "DPrivate key file does not exist (#5.3.5)"; - case 51: return "Zqq out of memory (#4.3.0)"; - case 52: return "Zqq timeout (#4.3.0)"; - case 53: return "Zqq write error or disk full (#4.3.0)"; -@@ -127,6 +145,9 @@ - case 74: return "Zcommunication with mail server failed (#4.4.2)"; - case 91: /* fall through */ - case 81: return "Zqq internal bug (#4.3.0)"; -+ case 88: /*- custom error */ -+ if (len > 2) -+ return errstr; - case 120: return "Zunable to exec qq (#4.3.0)"; - default: - if ((exitcode >= 11) && (exitcode <= 40)) -diff -Naur netqmail-1.06.org/qmail-dk.8 netqmail-1.06/qmail-dk.8 ---- netqmail-1.06.org/qmail-dk.8 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/qmail-dk.8 2011-02-11 09:32:40.687704742 +0530 + c(auto_qmail,"man/man8","qmail-local.8",auto_uido,auto_gidq,0644); ++ c(auto_qmail,"man/man8","qmail-dk.8",auto_uido,auto_gidq,0644); ++ c(auto_qmail,"man/cat8","qmail-dk.0",auto_uido,auto_gidq,0644); ++ c(auto_qmail,"man/man8","qmail-dkim.8",auto_uido,auto_gidq,0644); ++ c(auto_qmail,"man/cat8","qmail-dkim.0",auto_uido,auto_gidq,0644); ++ c(auto_qmail,"man/man8","dk-filter.8",auto_uido,auto_gidq,0644); ++ c(auto_qmail,"man/cat8","dk-filter.0",auto_uido,auto_gidq,0644); ++ c(auto_qmail,"man/man8","spawn-filter.8",auto_uido,auto_gidq,0644); ++ c(auto_qmail,"man/cat8","spawn-filter.0",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/cat8","qmail-local.0",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/man8","qmail-lspawn.8",auto_uido,auto_gidq,0644); + c(auto_qmail,"man/cat8","qmail-lspawn.0",auto_uido,auto_gidq,0644); +diff -Naur qmail-1.03-orig/ip.h qmail-1.03/ip.h +--- qmail-1.03-orig/ip.h 1998-06-15 19:53:16.000000000 +0900 ++++ qmail-1.03/ip.h 2011-05-04 09:39:32.000000000 +0900 +@@ -2,6 +2,7 @@ + #define IP_H + + struct ip_address { unsigned char d[4]; } ; ++typedef struct ip_address ip_addr; + + extern unsigned int ip_fmt(); + #define IPFMT 19 +diff -Naur qmail-1.03-orig/macros.h qmail-1.03/macros.h +--- qmail-1.03-orig/macros.h 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/macros.h 2011-05-04 09:39:32.000000000 +0900 +@@ -0,0 +1,25 @@ ++/* ++ * $Log: macros.h,v $ ++ * Revision 1.1 2009-03-21 08:50:25+05:30 Cprogrammer ++ * Initial revision ++ * ++ * ++ * macros.h: Useful macros ++ * ++ * Author: ++ * Dick Porter (dick@ximian.com) ++ * ++ * (C) 2002 Ximian, Inc. ++ */ ++ ++#ifndef _WAPI_MACROS_H_ ++#define _WAPI_MACROS_H_ ++ ++#include ++ ++#define MAKEWORD(low, high) ((__uint16_t)(((__uint8_t)(low)) | \ ++ ((__uint16_t)((__uint8_t)(high))) << 8)) ++#define LOBYTE(i16) ((__uint8_t)((i16) & 0xFF)) ++#define HIBYTE(i16) ((__uint8_t)(((__uint16_t)(i16) >> 8) & 0xFF)) ++ ++#endif /* _WAPI_MACROS_H_ */ +diff -Naur qmail-1.03-orig/qmail-dk.8 qmail-1.03/qmail-dk.8 +--- qmail-1.03-orig/qmail-dk.8 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/qmail-dk.8 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,141 @@ +.TH qmail-dk 8 +.SH NAME @@ -5810,9 +5668,9 @@ +qmail-smtpd(8), +domain-keys(5) + -diff -Naur netqmail-1.06.org/qmail-dk.c netqmail-1.06/qmail-dk.c ---- netqmail-1.06.org/qmail-dk.c 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/qmail-dk.c 2011-02-11 09:32:40.688704673 +0530 +diff -Naur qmail-1.03-orig/qmail-dk.c qmail-1.03/qmail-dk.c +--- qmail-1.03-orig/qmail-dk.c 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/qmail-dk.c 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,775 @@ +/* + * $Log: qmail-dk.c,v $ @@ -6589,9 +6447,9 @@ + + x++; +} -diff -Naur netqmail-1.06.org/qmail-dkim.9 netqmail-1.06/qmail-dkim.9 ---- netqmail-1.06.org/qmail-dkim.9 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/qmail-dkim.9 2011-02-11 09:32:40.689704605 +0530 +diff -Naur qmail-1.03-orig/qmail-dkim.9 qmail-1.03/qmail-dkim.9 +--- qmail-1.03-orig/qmail-dkim.9 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/qmail-dkim.9 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,307 @@ +.TH qmail-dk 8 +.SH NAME @@ -6900,9 +6758,9 @@ +Problems with +.B qmail-dkim +should be forwarded to "Manvendra Bhangui" -diff -Naur netqmail-1.06.org/qmail-dkim.c netqmail-1.06/qmail-dkim.c ---- netqmail-1.06.org/qmail-dkim.c 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/qmail-dkim.c 2011-02-11 09:32:40.691704468 +0530 +diff -Naur qmail-1.03-orig/qmail-dkim.c qmail-1.03/qmail-dkim.c +--- qmail-1.03-orig/qmail-dkim.c 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/qmail-dkim.c 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,1363 @@ +/* + * $Log: qmail-dkim.c,v $ @@ -8267,107 +8125,9 @@ + + x++; +} -diff -Naur netqmail-1.06.org/qmail.h netqmail-1.06/qmail.h ---- netqmail-1.06.org/qmail.h 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/qmail.h 2011-02-11 09:32:40.691704468 +0530 -@@ -3,11 +3,13 @@ - - #include "substdio.h" - -+#define CUSTOM_ERR_FD 2 - struct qmail { - int flagerr; - unsigned long pid; - int fdm; - int fde; -+ int fdc; - substdio ss; - char buf[1024]; - } ; -diff -Naur netqmail-1.06.org/qmail-inject.c netqmail-1.06/qmail-inject.c ---- netqmail-1.06.org/qmail-inject.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/qmail-inject.c 2011-02-11 09:37:17.862049744 +0530 -@@ -55,7 +55,7 @@ - - void put(s,len) char *s; int len; - { if (flagqueue) qmail_put(&qqt,s,len); else substdio_put(subfdout,s,len); } --void puts(s) char *s; { put(s,str_len(s)); } -+void my_puts(s) char *s; { put(s,str_len(s)); } - - void perm() { _exit(100); } - void temp() { _exit(111); } -@@ -549,16 +549,16 @@ - - if (i == tocclist.len) return; - -- puts("Mail-Followup-To: "); -+ my_puts("Mail-Followup-To: "); - i = tocclist.len; - while (i--) { - if (!stralloc_copy(&sa,&tocclist.sa[i])) die_nomem(); - if (!stralloc_0(&sa)) die_nomem(); - if (!quote2(&sa2,sa.s)) die_nomem(); - put(sa2.s,sa2.len); -- if (i) puts(",\n "); -+ if (i) my_puts(",\n "); - } -- puts("\n"); -+ my_puts("\n"); - } - - void finishheader() -@@ -580,9 +580,9 @@ - if (!stralloc_0(&sa)) die_nomem(); - if (!quote2(&sa2,sa.s)) die_nomem(); - -- puts("Return-Path: <"); -+ my_puts("Return-Path: <"); - put(sa2.s,sa2.len); -- puts(">\n"); -+ my_puts(">\n"); - } - - /* could check at this point whether there are any recipients */ -@@ -594,23 +594,23 @@ - if (!htypeseen[H_R_DATE]) - { - if (!newfield_datemake(starttime)) die_nomem(); -- puts("Resent-"); -+ my_puts("Resent-"); - put(newfield_date.s,newfield_date.len); - } - if (!htypeseen[H_R_MESSAGEID]) - { - if (!newfield_msgidmake(control_idhost.s,control_idhost.len,starttime)) die_nomem(); -- puts("Resent-"); -+ my_puts("Resent-"); - put(newfield_msgid.s,newfield_msgid.len); - } - if (!htypeseen[H_R_FROM]) - { - defaultfrommake(); -- puts("Resent-"); -+ my_puts("Resent-"); - put(defaultfrom.s,defaultfrom.len); - } - if (!htypeseen[H_R_TO] && !htypeseen[H_R_CC]) -- puts("Resent-Cc: recipient list not shown: ;\n"); -+ my_puts("Resent-Cc: recipient list not shown: ;\n"); - } - else - { -@@ -630,7 +630,7 @@ - put(defaultfrom.s,defaultfrom.len); - } - if (!htypeseen[H_TO] && !htypeseen[H_CC]) -- puts("Cc: recipient list not shown: ;\n"); -+ my_puts("Cc: recipient list not shown: ;\n"); - finishmft(); - } - -diff -Naur netqmail-1.06.org/qmail-lspawn.c netqmail-1.06/qmail-lspawn.c ---- netqmail-1.06.org/qmail-lspawn.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/qmail-lspawn.c 2011-02-11 09:38:24.079337977 +0530 +diff -Naur qmail-1.03-orig/qmail-lspawn.c qmail-1.03/qmail-lspawn.c +--- qmail-1.03-orig/qmail-lspawn.c 1998-06-15 19:53:16.000000000 +0900 ++++ qmail-1.03/qmail-lspawn.c 2011-05-04 09:39:32.000000000 +0900 @@ -1,4 +1,5 @@ #include "fd.h" +#include "env.h" @@ -8394,167 +8154,25 @@ if (error_temp(errno)) _exit(QLX_EXECSOFT); _exit(QLX_EXECHARD); } -diff -Naur netqmail-1.06.org/qmail-pop3d.c netqmail-1.06/qmail-pop3d.c ---- netqmail-1.06.org/qmail-pop3d.c 2007-12-01 01:52:54.000000000 +0530 -+++ netqmail-1.06/qmail-pop3d.c 2011-02-11 09:37:33.746919438 +0530 -@@ -45,7 +45,7 @@ - { - substdio_put(&ssout,buf,len); - } --void puts(s) char *s; -+void my_puts(s) char *s; - { - substdio_puts(&ssout,s); - } -@@ -55,9 +55,9 @@ - } - void err(s) char *s; - { -- puts("-ERR "); -- puts(s); -- puts("\r\n"); -+ my_puts("-ERR "); -+ my_puts(s); -+ my_puts("\r\n"); - flush(); - } - -@@ -73,7 +73,7 @@ - void err_nosuch() { err("unable to open that message"); } - void err_nounlink() { err("unable to unlink all deleted messages"); } - --void okay(arg) char *arg; { puts("+OK \r\n"); flush(); } -+void okay(arg) char *arg; { my_puts("+OK \r\n"); flush(); } - - void printfn(fn) char *fn; - { -@@ -153,11 +153,11 @@ - - total = 0; - for (i = 0;i < numm;++i) if (!m[i].flagdeleted) total += m[i].size; -- puts("+OK "); -+ my_puts("+OK "); - put(strnum,fmt_uint(strnum,numm)); -- puts(" "); -+ my_puts(" "); - put(strnum,fmt_ulong(strnum,total)); -- puts("\r\n"); -+ my_puts("\r\n"); - flush(); - } - -@@ -171,9 +171,9 @@ - - void pop3_last(arg) char *arg; - { -- puts("+OK "); -+ my_puts("+OK "); - put(strnum,fmt_uint(strnum,last)); -- puts("\r\n"); -+ my_puts("\r\n"); - flush(); - } - -@@ -222,10 +222,10 @@ - int flaguidl; - { - put(strnum,fmt_uint(strnum,i + 1)); -- puts(" "); -+ my_puts(" "); - if (flaguidl) printfn(m[i].fn); - else put(strnum,fmt_ulong(strnum,m[i].size)); -- puts("\r\n"); -+ my_puts("\r\n"); - } - - void dolisting(arg,flaguidl) char *arg; int flaguidl; -@@ -234,7 +234,7 @@ - if (*arg) { - i = msgno(arg); - if (i == -1) return; -- puts("+OK "); -+ my_puts("+OK "); - list(i,flaguidl); - } - else { -@@ -242,7 +242,7 @@ - for (i = 0;i < numm;++i) - if (!m[i].flagdeleted) - list(i,flaguidl); -- puts(".\r\n"); -+ my_puts(".\r\n"); - } - flush(); - } -diff -Naur netqmail-1.06.org/qmail-popup.c netqmail-1.06/qmail-popup.c ---- netqmail-1.06.org/qmail-popup.c 2007-12-01 01:52:54.000000000 +0530 -+++ netqmail-1.06/qmail-popup.c 2011-02-11 09:37:48.999834101 +0530 -@@ -38,7 +38,7 @@ - char ssinbuf[128]; - substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof ssinbuf); - --void puts(s) char *s; -+void my_puts(s) char *s; - { - substdio_puts(&ssout,s); - } -@@ -48,9 +48,9 @@ - } - void err(s) char *s; - { -- puts("-ERR "); -- puts(s); -- puts("\r\n"); -+ my_puts("-ERR "); -+ my_puts(s); -+ my_puts("\r\n"); - flush(); - } - -@@ -66,7 +66,7 @@ - void err_wantuser() { err("USER first"); } - void err_authoriz(arg) char *arg; { err("authorization first"); } - --void okay(arg) char *arg; { puts("+OK \r\n"); flush(); } -+void okay(arg) char *arg; { my_puts("+OK \r\n"); flush(); } - void pop3_quit(arg) char *arg; { okay(0); die(); } - - -@@ -127,10 +127,10 @@ - s += fmt_ulong(s,(unsigned long) now()); - *s++ = '@'; - *s++ = 0; -- puts("+OK <"); -- puts(unique); -- puts(hostname); -- puts(">\r\n"); -+ my_puts("+OK <"); -+ my_puts(unique); -+ my_puts(hostname); -+ my_puts(">\r\n"); - flush(); - } - void pop3_user(arg) char *arg; -diff -Naur netqmail-1.06.org/qmail-pw2u.c netqmail-1.06/qmail-pw2u.c ---- netqmail-1.06.org/qmail-pw2u.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/qmail-pw2u.c 2011-02-11 09:34:08.818501348 +0530 +diff -Naur qmail-1.03-orig/qmail-pw2u.c qmail-1.03/qmail-pw2u.c +--- qmail-1.03-orig/qmail-pw2u.c 1998-06-15 19:53:16.000000000 +0900 ++++ qmail-1.03/qmail-pw2u.c 2011-05-04 09:39:32.000000000 +0900 @@ -1,3 +1,4 @@ +#include #include #include #include "substdio.h" -diff -Naur netqmail-1.06.org/qmail-qmtpd.c netqmail-1.06/qmail-qmtpd.c ---- netqmail-1.06.org/qmail-qmtpd.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/qmail-qmtpd.c 2011-02-11 09:34:15.547022576 +0530 -@@ -1,3 +1,5 @@ -+#include +diff -Naur qmail-1.03-orig/qmail-qmtpd.c qmail-1.03/qmail-qmtpd.c +--- qmail-1.03-orig/qmail-qmtpd.c 1998-06-15 19:53:16.000000000 +0900 ++++ qmail-1.03/qmail-qmtpd.c 2011-05-04 09:39:32.000000000 +0900 +@@ -1,3 +1,4 @@ +#include #include "stralloc.h" #include "substdio.h" #include "qmail.h" -diff -Naur netqmail-1.06.org/qmail-rspawn.c netqmail-1.06/qmail-rspawn.c ---- netqmail-1.06.org/qmail-rspawn.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/qmail-rspawn.c 2011-02-11 09:39:09.844081539 +0530 +diff -Naur qmail-1.03-orig/qmail-rspawn.c qmail-1.03/qmail-rspawn.c +--- qmail-1.03-orig/qmail-rspawn.c 1998-06-15 19:53:16.000000000 +0900 ++++ qmail-1.03/qmail-rspawn.c 2011-05-04 09:39:32.000000000 +0900 @@ -1,3 +1,4 @@ +#include "env.h" #include "fd.h" @@ -8581,61 +8199,10 @@ if (error_temp(errno)) _exit(111); _exit(100); } -diff -Naur netqmail-1.06.org/qmail-send.c netqmail-1.06/qmail-send.c ---- netqmail-1.06.org/qmail-send.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/qmail-send.c 2011-02-11 09:40:43.308430975 +0530 -@@ -754,7 +754,7 @@ - { log1("warning: trouble injecting bounce message, will try later\n"); return 0; } - - strnum2[fmt_ulong(strnum2,id)] = 0; -- log2("bounce msg ",strnum2); -+ my_log2("bounce msg ",strnum2); - strnum2[fmt_ulong(strnum2,qp)] = 0; - log3(" qp ",strnum2,"\n"); - } -@@ -794,8 +794,8 @@ - for (c = 0;c < CHANNELS;++c) { - strnum2[fmt_ulong(strnum2,(unsigned long) concurrencyused[c])] = 0; - strnum3[fmt_ulong(strnum3,(unsigned long) concurrency[c])] = 0; -- log2(chanstatusmsg[c],strnum2); -- log2("/",strnum3); -+ my_log2(chanstatusmsg[c],strnum2); -+ my_log2("/",strnum3); - } - if (flagexitasap) log1(" exitasap"); - log1("\n"); -@@ -859,7 +859,7 @@ - - strnum2[fmt_ulong(strnum2,d[c][i].delid)] = 0; - strnum3[fmt_ulong(strnum3,jo[j].id)] = 0; -- log2("starting delivery ",strnum2); -+ my_log2("starting delivery ",strnum2); - log3(": msg ",strnum3,tochan[c]); - logsafe(recip); - log1("\n"); -@@ -1352,14 +1352,14 @@ - fnmake_info(id); - log3("warning: trouble writing to ",fn.s,"\n"); goto fail; - } -- log2("info msg ",strnum3); -+ my_log2("info msg ",strnum3); - strnum2[fmt_ulong(strnum2,(unsigned long) st.st_size)] = 0; -- log2(": bytes ",strnum2); -+ my_log2(": bytes ",strnum2); - log1(" from <"); logsafe(todoline.s + 1); - strnum2[fmt_ulong(strnum2,pid)] = 0; -- log2("> qp ",strnum2); -+ my_log2("> qp ",strnum2); - strnum2[fmt_ulong(strnum2,uid)] = 0; -- log2(" uid ",strnum2); -+ my_log2(" uid ",strnum2); - log1("\n"); - break; - case 'T': -diff -Naur netqmail-1.06.org/qmail-showctl.c netqmail-1.06/qmail-showctl.c ---- netqmail-1.06.org/qmail-showctl.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/qmail-showctl.c 2011-02-11 09:32:40.693704330 +0530 -@@ -112,7 +112,7 @@ +diff -Naur qmail-1.03-orig/qmail-showctl.c qmail-1.03/qmail-showctl.c +--- qmail-1.03-orig/qmail-showctl.c 2011-05-04 09:38:53.000000000 +0900 ++++ qmail-1.03/qmail-showctl.c 2011-05-04 09:39:32.000000000 +0900 +@@ -119,7 +119,7 @@ substdio_puts(subfdout,"\n"); substdio_puts(subfdout,fn); substdio_puts(subfdout,": "); @@ -8644,36 +8211,123 @@ case 0: substdio_puts(subfdout,"(Default.) "); substdio_puts(subfdout,def); -diff -Naur netqmail-1.06.org/qmail-smtpd.c netqmail-1.06/qmail-smtpd.c ---- netqmail-1.06.org/qmail-smtpd.c 2007-12-01 01:52:54.000000000 +0530 -+++ netqmail-1.06/qmail-smtpd.c 2011-02-11 09:32:40.694704261 +0530 -@@ -25,6 +25,7 @@ - #include "commands.h" - - #define MAXHOPS 100 -+static char strnum[FMT_ULONG]; - unsigned int databytes = 0; - int timeout = 1200; - -@@ -218,6 +219,7 @@ - - - int seenmail = 0; -+int rcptcount = 0; - int flagbarf; /* defined if seenmail */ - stralloc mailfrom = {0}; - stralloc rcptto = {0}; -@@ -261,6 +263,7 @@ - if (!stralloc_cats(&rcptto,"T")) die_nomem(); - if (!stralloc_cats(&rcptto,addr.s)) die_nomem(); - if (!stralloc_0(&rcptto)) die_nomem(); -+ rcptcount++; - out("250 ok\r\n"); - } +diff -Naur qmail-1.03-orig/qmail.c qmail-1.03/qmail.c +--- qmail-1.03-orig/qmail.c 1998-06-15 19:53:16.000000000 +0900 ++++ qmail-1.03/qmail.c 2011-05-04 09:39:32.000000000 +0900 +@@ -6,28 +6,44 @@ + #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; + { + int pim[2]; + int pie[2]; ++ int pic[2]; ++ ++ setup_qqargs(); + + if (pipe(pim) == -1) return -1; + if (pipe(pie) == -1) { close(pim[0]); close(pim[1]); return -1; } ++ if (pipe(pic) == -1) { close(pim[0]); close(pim[1]); close(pie[0]); close(pie[1]); return -1; } + + switch(qq->pid = vfork()) { + case -1: + close(pim[0]); close(pim[1]); + close(pie[0]); close(pie[1]); ++ close(pic[0]); close(pic[1]); + return -1; + case 0: + close(pim[1]); + close(pie[1]); ++ close(pic[0]); /*- we want to receive data */ + if (fd_move(0,pim[0]) == -1) _exit(120); + if (fd_move(1,pie[0]) == -1) _exit(120); ++ if (fd_move(CUSTOM_ERR_FD,pic[1]) == -1) _exit(120); + if (chdir(auto_qmail) == -1) _exit(61); + execv(*binqqargs,binqqargs); + _exit(120); +@@ -35,6 +51,7 @@ + + qq->fdm = pim[1]; close(pim[0]); + qq->fde = pie[1]; close(pie[0]); ++ qq->fdc = pic[0]; close(pic[1]); + substdio_fdbuf(&qq->ss,write,qq->fdm,qq->buf,sizeof(qq->buf)); + qq->flagerr = 0; + return 0; +@@ -82,10 +99,21 @@ + { + int wstat; + int exitcode; ++ int len = 0; ++ char ch; ++ static char errstr[256]; + + qmail_put(qq,"",1); + if (!qq->flagerr) if (substdio_flush(&qq->ss) == -1) qq->flagerr = 1; + close(qq->fde); ++ substdio_fdbuf(&qq->ss, read, qq->fdc, qq->buf, sizeof(qq->buf)); ++ while (substdio_bget(&qq->ss, &ch, 1) && len < 255) ++ { ++ errstr[len] = ch; len++; ++ } ++ if (len > 0) ++ errstr[len] = 0; /* add str-term */ ++ close(qq->fdc); + + if (wait_pid(&wstat,qq->pid) != qq->pid) + return "Zqq waitpid surprise (#4.3.0)"; +@@ -97,6 +125,7 @@ + case 115: /* compatibility */ + case 11: return "Denvelope address too long for qq (#5.1.3)"; + case 31: return "Dmail server permanently rejected message (#5.3.0)"; ++ case 32: return "DPrivate key file does not exist (#5.3.5)"; + case 51: return "Zqq out of memory (#4.3.0)"; + case 52: return "Zqq timeout (#4.3.0)"; + case 53: return "Zqq write error or disk full (#4.3.0)"; +@@ -116,6 +145,9 @@ + case 74: return "Zcommunication with mail server failed (#4.4.2)"; + case 91: /* fall through */ + case 81: return "Zqq internal bug (#4.3.0)"; ++ case 88: /*- custom error */ ++ if (len > 2) ++ return errstr; + case 120: return "Zunable to exec qq (#4.3.0)"; + default: + if ((exitcode >= 11) && (exitcode <= 40)) +diff -Naur qmail-1.03-orig/qmail.h qmail-1.03/qmail.h +--- qmail-1.03-orig/qmail.h 1998-06-15 19:53:16.000000000 +0900 ++++ qmail-1.03/qmail.h 2011-05-04 09:39:32.000000000 +0900 +@@ -3,11 +3,13 @@ + + #include "substdio.h" -diff -Naur netqmail-1.06.org/qregex.c netqmail-1.06/qregex.c ---- netqmail-1.06.org/qregex.c 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/qregex.c 2011-02-11 09:32:40.694704261 +0530 ++#define CUSTOM_ERR_FD 2 + struct qmail { + int flagerr; + unsigned long pid; + int fdm; + int fde; ++ int fdc; + substdio ss; + char buf[1024]; + } ; +diff -Naur qmail-1.03-orig/qregex.c qmail-1.03/qregex.c +--- qmail-1.03-orig/qregex.c 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/qregex.c 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,239 @@ +/* + * $Log: qregex.c,v $ @@ -8914,9 +8568,9 @@ + x++; +#endif +} -diff -Naur netqmail-1.06.org/qregex.h netqmail-1.06/qregex.h ---- netqmail-1.06.org/qregex.h 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/qregex.h 2011-02-11 09:32:40.695704192 +0530 +diff -Naur qmail-1.03-orig/qregex.h qmail-1.03/qregex.h +--- qmail-1.03-orig/qregex.h 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/qregex.h 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,24 @@ +/* + * $Log: qregex.h,v $ @@ -8942,33 +8596,9 @@ +int matchregex(char *, char *); +void setdotChar(char); +#endif -diff -Naur netqmail-1.06.org/qsutil.c netqmail-1.06/qsutil.c ---- netqmail-1.06.org/qsutil.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/qsutil.c 2011-02-11 09:41:06.062811861 +0530 -@@ -12,7 +12,7 @@ - substdio_putflush(&sserr,sa->s,sa->len); } - void log1(s1) char *s1; { - substdio_putsflush(&sserr,s1); } --void log2(s1,s2) char *s1; char *s2; { -+void my_log2(s1,s2) char *s1; char *s2; { - substdio_putsflush(&sserr,s1); - substdio_putsflush(&sserr,s2); } - void log3(s1,s2,s3) char *s1; char *s2; char *s3; { -diff -Naur netqmail-1.06.org/qsutil.h netqmail-1.06/qsutil.h ---- netqmail-1.06.org/qsutil.h 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/qsutil.h 2011-02-11 09:40:52.589770550 +0530 -@@ -2,7 +2,7 @@ - #define QSUTIL_H - - extern void log1(); --extern void log2(); -+extern void my_log2(); - extern void log3(); - extern void logsa(); - extern void nomem(); -diff -Naur netqmail-1.06.org/scan_ulong.c netqmail-1.06/scan_ulong.c ---- netqmail-1.06.org/scan_ulong.c 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/scan_ulong.c 2011-02-11 09:32:40.695704192 +0530 +diff -Naur qmail-1.03-orig/scan_ulong.c qmail-1.03/scan_ulong.c +--- qmail-1.03-orig/scan_ulong.c 1998-06-15 19:53:16.000000000 +0900 ++++ qmail-1.03/scan_ulong.c 2011-05-04 09:39:32.000000000 +0900 @@ -9,3 +9,43 @@ { result = result * 10 + c; ++pos; } *u = result; return pos; @@ -9013,9 +8643,9 @@ + *i = result * sign; + return pos; +} -diff -Naur netqmail-1.06.org/softwarelicense1-1.html netqmail-1.06/softwarelicense1-1.html ---- netqmail-1.06.org/softwarelicense1-1.html 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/softwarelicense1-1.html 2011-02-11 09:32:40.696704123 +0530 +diff -Naur qmail-1.03-orig/softwarelicense1-1.html qmail-1.03/softwarelicense1-1.html +--- qmail-1.03-orig/softwarelicense1-1.html 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/softwarelicense1-1.html 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,59 @@ + + @@ -9076,9 +8706,9 @@ + + + -diff -Naur netqmail-1.06.org/spawn-filter.9 netqmail-1.06/spawn-filter.9 ---- netqmail-1.06.org/spawn-filter.9 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/spawn-filter.9 2011-02-11 09:32:40.696704123 +0530 +diff -Naur qmail-1.03-orig/spawn-filter.9 qmail-1.03/spawn-filter.9 +--- qmail-1.03-orig/spawn-filter.9 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/spawn-filter.9 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,103 @@ +.TH spawn-filter 8 +.SH NAME @@ -9183,9 +8813,9 @@ +Problems with +.B spawn-filter +should be forwarded to "Manvendra Bhangui" -diff -Naur netqmail-1.06.org/spawn-filter.c netqmail-1.06/spawn-filter.c ---- netqmail-1.06.org/spawn-filter.c 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/spawn-filter.c 2011-02-11 09:32:40.697704054 +0530 +diff -Naur qmail-1.03-orig/spawn-filter.c qmail-1.03/spawn-filter.c +--- qmail-1.03-orig/spawn-filter.c 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/spawn-filter.c 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,546 @@ +/* + * netqmail-version without spam filter @@ -9733,9 +9363,9 @@ + + x++; +} -diff -Naur netqmail-1.06.org/str_cpyb.c netqmail-1.06/str_cpyb.c ---- netqmail-1.06.org/str_cpyb.c 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/str_cpyb.c 2011-02-11 09:32:40.697704054 +0530 +diff -Naur qmail-1.03-orig/str_cpyb.c qmail-1.03/str_cpyb.c +--- qmail-1.03-orig/str_cpyb.c 1970-01-01 09:00:00.000000000 +0900 ++++ qmail-1.03/str_cpyb.c 2011-05-04 09:39:32.000000000 +0900 @@ -0,0 +1,53 @@ +/* + * $Log: str_cpyb.c,v $ @@ -9790,38 +9420,51 @@ + + x++; +} -diff -Naur netqmail-1.06.org/TARGETS netqmail-1.06/TARGETS ---- netqmail-1.06.org/TARGETS 1998-06-15 16:23:16.000000000 +0530 -+++ netqmail-1.06/TARGETS 2011-02-11 09:32:40.699703916 +0530 -@@ -385,3 +385,24 @@ - man - setup - check -+qmail-dk -+qmail-dkim -+qmail-dkim.o -+qmail-dk.o -+libdkim.a -+dkimbase.o -+dkimdns.o -+dkim.o -+dkimsign.o -+dkimverify.o -+dkimtest -+dkimtest.o -+qmail-dkim.8 -+qmail-dkim.0 -+str_cpyb.o -+dkimfuncs.o -+MakeArgs.o -+spawn-filter spawn-filter.o qregex.o wildmat.o -+spawn-filter.8 -+qmail-dk.0 spawn-filter.0 -+dk-filter echo.o echo dk-filter.0 dk-filter.8 -diff -Naur netqmail-1.06.org/wildmat.c netqmail-1.06/wildmat.c ---- netqmail-1.06.org/wildmat.c 1970-01-01 05:30:00.000000000 +0530 -+++ netqmail-1.06/wildmat.c 2011-02-11 09:32:40.699703916 +0530 -@@ -0,0 +1,173 @@ +diff -Naur qmail-1.03-orig/wildmat.c qmail-1.03/wildmat.c +--- qmail-1.03-orig/wildmat.c 2003-10-16 14:57:05.000000000 +0900 ++++ qmail-1.03/wildmat.c 2011-05-04 09:39:32.000000000 +0900 +@@ -1,118 +1,117 @@ +-/*** wildmat.c.orig Wed Dec 3 11:46:31 1997 */ +-/* $Revision: 1.1 $ +-** +-** Do shell-style pattern matching for ?, \, [], and * characters. +-** Might not be robust in face of malformed patterns; e.g., "foo[a-" +-** could cause a segmentation violation. It is 8bit clean. +-** +-** Written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986. +-** Rich $alz is now . +-** April, 1991: Replaced mutually-recursive calls with in-line code +-** for the star character. +-** +-** Special thanks to Lars Mathiesen for the ABORT code. +-** This can greatly speed up failing wildcard patterns. For example: +-** pattern: -*-*-*-*-*-*-12-*-*-*-m-*-*-* +-** text 1: -adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1 +-** text 2: -adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1 +-** Text 1 matches with 51 calls, while text 2 fails with 54 calls. Without +-** the ABORT code, it takes 22310 calls to fail. Ugh. The following +-** explanation is from Lars: +-** The precondition that must be fulfilled is that DoMatch will consume +-** at least one character in text. This is true if *p is neither '*' nor +-** '\0'.) The last return has ABORT instead of FALSE to avoid quadratic +-** behaviour in cases like pattern "*a*b*c*d" with text "abcxxxxx". With +-** FALSE, each star-loop has to run to the end of the text; with ABORT +-** only the last one does. +-** +-** Once the control of one instance of DoMatch enters the star-loop, that +-** instance will return either TRUE or ABORT, and any calling instance +-** will therefore return immediately after (without calling recursively +-** again). In effect, only one star-loop is ever active. It would be +-** possible to modify the code to maintain this context explicitly, +-** eliminating all recursive calls at the cost of some complication and +-** loss of clarity (and the ABORT stuff seems to be unclear enough by +-** itself). I think it would be unwise to try to get this into a +-** released version unless you have a good test data base to try it out +-** on. +-*/ +- +-#define TRUE 1 +-#define FALSE 0 +/*-** wildmat.c.orig Wed Dec 3 11:46:31 1997 + * $Revision: 1.6 $ + * Do shell-style pattern matching for ?, \, [], and * characters. @@ -9861,23 +9504,78 @@ + */ +#define TRUE 1 +#define FALSE 0 -+#define ABORT -1 -+ -+ + #define ABORT -1 + + +- /* What character marks an inverted character class? */ +/*- What character marks an inverted character class? */ -+#define NEGATE_CLASS '^' + #define NEGATE_CLASS '^' +- /* Is "*" a common pattern? */ +/*- Is "*" a common pattern? */ -+#define OPTIMIZE_JUST_STAR + #define OPTIMIZE_JUST_STAR +- /* Do tar(1) matching rules, which ignore a trailing slash? */ +/*- Do tar(1) matching rules, which ignore a trailing slash? */ -+#undef MATCH_TAR_PATTERN -+ -+ + #undef MATCH_TAR_PATTERN + + +-/* +-** Match text and p, return TRUE, FALSE, or ABORT. +-*/ +/*- Match text and p, return TRUE, FALSE, or ABORT. */ -+static int -+DoMatch(text, p) + static int + DoMatch(text, p) +- register char *text; +- register char *p; + register char *text; + register char *p; -+{ + { +- register int last; +- register int matched; +- register int reverse; +- +- for ( ; *p; text++, p++) { +- if (*text == '\0' && *p != '*') +- return ABORT; +- switch (*p) { +- case '\\': +- /* Literal match with following character. */ +- p++; +- /* FALLTHROUGH */ +- default: +- if (*text != *p) +- return FALSE; +- continue; +- case '?': +- /* Match anything. */ +- continue; +- case '*': +- while (*++p == '*') +- /* Consecutive stars act just like one. */ +- continue; +- if (*p == '\0') +- /* Trailing star matches everything. */ +- return TRUE; +- while (*text) +- if ((matched = DoMatch(text++, p)) != FALSE) +- return matched; +- return ABORT; +- case '[': +- reverse = p[1] == NEGATE_CLASS ? TRUE : FALSE; +- if (reverse) +- /* Inverted character class. */ +- p++; +- matched = FALSE; +- if (p[1] == ']' || p[1] == '-') +- if (*++p == *text) +- matched = TRUE; +- for (last = *p; *++p && *p != ']'; last = *p) +- /* This next line requires a good C compiler. */ +- if (*p == '-' && p[1] != ']' +- ? *text <= *++p && *text >= last : *text == *p) +- matched = TRUE; +- if (matched == reverse) +- return FALSE; +- continue; + register int last; + register int matched; + register int reverse; @@ -9929,16 +9627,45 @@ + return FALSE; + continue; + } -+ } -+ -+#ifdef MATCH_TAR_PATTERN + } +- } + + #ifdef MATCH_TAR_PATTERN +- if (*text == '/') +- return TRUE; +-#endif /* MATCH_TAR_ATTERN */ +- return *text == '\0'; + if (*text == '/') + return TRUE; +#endif /*- MATCH_TAR_ATTERN */ + return *text == '\0'; -+} -+ -+ + } + + +@@ -121,51 +120,69 @@ + */ + int + wildmat(text, p) +- char *text; +- char *p; ++ char *text; ++ char *p; + { +-#ifdef OPTIMIZE_JUST_STAR ++#ifdef OPTIMIZE_JUST_STAR + if (p[0] == '*' && p[1] == '\0') +- return TRUE; +-#endif /* OPTIMIZE_JUST_STAR */ ++ return TRUE; ++#endif /* OPTIMIZE_JUST_STAR */ + return DoMatch(text, p) == TRUE; + } + +-#if defined(TEST) +-include +- +-/* Yes, we use gets not fgets. Sue me. */ +-extern char *gets(); +/*- User-level routine. Returns TRUE or FALSE. */ +int +wildmat_internal(text, p) @@ -9951,17 +9678,37 @@ +#endif /*- OPTIMIZE_JUST_STAR */ + return DoMatch(text, p) == TRUE; +} -+ + +#if defined(TEST) +include < stdio.h > +/*- Yes, we use gets not fgets. Sue me. */ -+ -+int -+main() -+{ + + int + main() + { +- char p[80]; +- char text[80]; + char p[80]; + char text[80]; -+ + +- printf("Wildmat tester. Enter pattern, then strings to test.\n"); +- printf("A blank line gets prompts for a new pattern; a blank pattern\n"); +- printf("exits the program.\n"); +- +- for ( ; ; ) { +- printf("\nEnter pattern: "); +- (void)fflush(stdout); +- if (gets(p) == NULL || p[0] == '\0') +- break; +- for ( ; ; ) { +- printf("Enter text: "); +- (void)fflush(stdout); +- if (gets(text) == NULL) +- exit(0); +- if (text[0] == '\0') +- /* Blank line; go back and get a new pattern. */ +- break; +- printf(" %s\n", wildmat(text, p) ? "YES" : "NO"); + printf("Wildmat tester. Enter pattern, then strings to test.\n"); + printf("A blank line gets prompts for a new pattern; a blank pattern\n"); + printf("exits the program.\n"); @@ -9982,16 +9729,20 @@ + break; + printf(" %s\n", wildmat_internal(text, p) ? "YES" : "NO"); + } -+ } + } +- } + exit(0); + /*- NOTREACHED */ +} +#endif /*- defined(TEST) */ -+ + +- exit(0); +- /* NOTREACHED */ +void +getversion_wildmat_internal_c() +{ + static char *x = "$Id: wildmat.c,v 1.6 2008-08-03 18:26:33+05:30 Cprogrammer Stab mbhangui $"; + x++; + x--; -+} + } +-#endif /* defined(TEST) */