source:
npl/mailserver/netqmail2/qmail-tap.diff
@
7c410f9
Last change on this file since 7c410f9 was c5c522c, checked in by , 8 years ago | |
---|---|
|
|
File size: 9.8 KB |
-
qmail-1.03
diff -Nur qmail-1.03/error.h qmail-1.03.tap/error.h
old new 1 1 #ifndef ERROR_H 2 2 #define ERROR_H 3 #include <errno.h> 3 4 4 5 extern int errno; 5 6 -
qmail-1.03
diff -Nur qmail-1.03/Makefile qmail-1.03.tap/Makefile
old new 1419 1419 nroff -man qmail-qstat.8 > qmail-qstat.0 1420 1420 1421 1421 qmail-queue: \ 1422 load qmail-queue.o triggerpull.o fmtqfn.o now.o date822fmt.o \ 1423 datetime.a seek.a ndelay.a open.a sig.a alloc.a substdio.a error.a \ 1424 str.a fs.a auto_qmail.o auto_split.o auto_uids.o 1422 load qmail-queue.o triggerpull.o fmtqfn.o now.o date822fmt.o qregex.o \ 1423 datetime.a seek.a case.a ndelay.a open.a sig.a getln.a stralloc.a alloc.a \ 1424 substdio.a error.a control.o constmap.o str.a fs.a auto_qmail.o \ 1425 auto_split.o auto_uids.o 1425 1426 ./load qmail-queue triggerpull.o fmtqfn.o now.o \ 1426 date822fmt.o datetime.a seek.a ndelay.a open.a sig.a \1427 alloc.a substdio.a error.a str.a fs.a auto_qmail.o\1428 auto_split.o auto_uids.o1427 date822fmt.o qregex.o control.o constmap.o datetime.a case.a seek.a \ 1428 ndelay.a open.a sig.a getln.a stralloc.a alloc.a substdio.a error.a \ 1429 str.a fs.a auto_qmail.o auto_split.o auto_uids.o 1429 1430 1430 1431 qmail-queue.0: \ 1431 1432 qmail-queue.8 … … 1681 1682 constmap.h stralloc.h gen_alloc.h rcpthosts.h 1682 1683 ./compile rcpthosts.c 1683 1684 1685 qregex.o: \ 1686 compile qregex.c qregex.h 1687 ./compile qregex.c 1688 1684 1689 readsubdir.o: \ 1685 1690 compile readsubdir.c readsubdir.h direntry.h fmt.h scan.h str.h \ 1686 1691 auto_split.h -
qmail-control.9
diff -Nur qmail-1.03/qmail-control.9 qmail-1.03.tap/qmail-control.9
old new 63 63 .I rcpthosts \fR(none) \fRqmail-smtpd 64 64 .I smtpgreeting \fIme \fRqmail-smtpd 65 65 .I smtproutes \fR(none) \fRqmail-remote 66 .I taps \fR(none) \fRqmail-queue 66 67 .I timeoutconnect \fR60 \fRqmail-remote 67 68 .I timeoutremote \fR1200 \fRqmail-remote 68 69 .I timeoutsmtpd \fR1200 \fRqmail-smtpd … … 72 73 .SH "SEE ALSO" 73 74 qmail-inject(8), 74 75 qmail-qmqpc(8), 76 qmail-queue(8), 75 77 qmail-remote(8), 76 78 qmail-send(8), 77 79 qmail-showctl(8), -
qmail-queue.8
diff -Nur qmail-1.03/qmail-queue.8 qmail-1.03.tap/qmail-queue.8
old new 40 40 However, the recipients probably expect to see a proper header, 41 41 as described in 42 42 .BR qmail-header(5) . 43 .SH "CONTROL FILES" 44 .TP 5 45 .I taps 46 Should contain regex syntax of email addresses to tap and 47 the associated email address to send the copy to. The two 48 fields should be separated by a colon. 43 49 .SH "FILESYSTEM RESTRICTIONS" 44 50 .B qmail-queue 45 51 imposes two constraints on the queue structure: -
qmail-queue.c
diff -Nur qmail-1.03/qmail-queue.c qmail-1.03.tap/qmail-queue.c
old new 16 16 #include "auto_uids.h" 17 17 #include "date822fmt.h" 18 18 #include "fmtqfn.h" 19 #include "stralloc.h" 20 #include "constmap.h" 19 21 20 22 #define DEATH 86400 /* 24 hours; _must_ be below q-s's OSSIFIED (36 hours) */ 21 23 #define ADDR 1003 … … 25 27 char outbuf[256]; 26 28 struct substdio ssout; 27 29 30 int tapok = 0; 31 stralloc tap = {0}; 32 struct constmap maptap; 33 stralloc chkaddr = {0}; 34 int tapped; 35 stralloc tapaddr = {0}; 36 stralloc controlfile = {0}; 37 28 38 datetime_sec starttime; 29 39 struct datetime dt; 30 40 unsigned long mypid; … … 175 185 176 186 alarm(DEATH); 177 187 188 stralloc_copys( &controlfile, auto_qmail); 189 stralloc_cats( &controlfile, "/control/taps"); 190 stralloc_0( &controlfile); 191 tapok = control_readfile(&tap,controlfile.s,0); 192 if (tapok == -1) die(65); 193 if (!constmap_init(&maptap,tap.s,tap.len,0)) die(65); 194 178 195 pidopen(); 179 196 if (fstat(messfd,&pidst) == -1) die(63); 180 197 … … 219 236 if (substdio_get(&ssin,&ch,1) < 1) die_read(); 220 237 if (ch != 'F') die(91); 221 238 if (substdio_bput(&ssout,&ch,1) == -1) die_write(); 239 stralloc_0(&chkaddr); 222 240 for (len = 0;len < ADDR;++len) 223 241 { 242 if ( len == 1 ) stralloc_copyb(&chkaddr, &ch,1); 243 else if ( len > 1 ) stralloc_catb(&chkaddr, &ch,1); 224 244 if (substdio_get(&ssin,&ch,1) < 1) die_read(); 225 245 if (substdio_put(&ssout,&ch,1) == -1) die_write(); 226 246 if (!ch) break; 227 247 } 228 248 if (len >= ADDR) die(11); 229 249 250 /* check the from address */ 251 stralloc_0(&chkaddr); 252 if (tapped == 0 && tapcheck()==1 ) { 253 tapped = 1; 254 if ( tapaddr.len > 0 ) { 255 if (substdio_bput(&ssout,"T",1) == -1) die_write(); 256 if (substdio_bput(&ssout,tapaddr.s,tapaddr.len) == -1) die_write(); 257 if (substdio_bput(&ssout,"",1) == -1) die_write(); 258 } 259 } 260 230 261 if (substdio_bput(&ssout,QUEUE_EXTRA,QUEUE_EXTRALEN) == -1) die_write(); 231 262 232 263 for (;;) … … 237 268 if (substdio_bput(&ssout,&ch,1) == -1) die_write(); 238 269 for (len = 0;len < ADDR;++len) 239 270 { 271 if ( len == 1 ) stralloc_copyb(&chkaddr, &ch,1); 272 else if ( len > 1 ) stralloc_catb(&chkaddr, &ch,1); 240 273 if (substdio_get(&ssin,&ch,1) < 1) die_read(); 241 274 if (substdio_bput(&ssout,&ch,1) == -1) die_write(); 242 275 if (!ch) break; 243 276 } 277 278 /* check the to address */ 279 stralloc_0(&chkaddr); 280 if (tapped == 0 && tapcheck()==1 ) { 281 tapped = 1; 282 if ( tapaddr.len > 0 ) { 283 if (substdio_bput(&ssout,"T",1) == -1) die_write(); 284 if (substdio_bput(&ssout,tapaddr.s,tapaddr.len) == -1) die_write(); 285 if (substdio_bput(&ssout,"",1) == -1) die_write(); 286 } 287 } 288 244 289 if (len >= ADDR) die(11); 245 290 } 246 291 … … 252 297 triggerpull(); 253 298 die(0); 254 299 } 300 301 int tapcheck() 302 { 303 int i = 0; 304 int j = 0; 305 int x = 0; 306 int negate = 0; 307 stralloc curregex = {0}; 308 char tmpbuf[200]; 309 310 while (j < tap.len) { 311 i = j; 312 while ((tap.s[i] != ':') && (i < tap.len)) i++; 313 if (tap.s[j] == '!') { 314 negate = 1; 315 j++; 316 } 317 stralloc_copys(&tapaddr, &tap.s[i+1]); 318 319 stralloc_copyb(&curregex,tap.s + j,(i - j)); 320 stralloc_0(&curregex); 321 x = matchregex(chkaddr.s, curregex.s, tmpbuf); 322 323 while ((tap.s[i] != '\0') && (i < tap.len)) i++; 324 325 if ((negate) && (x == 0)) { 326 return 1; 327 } 328 if (!(negate) && (x > 0)) { 329 return 1; 330 } 331 j = i + 1; 332 negate = 0; 333 334 335 } 336 return 0; 337 } 338 -
qmail-1.03
diff -Nur qmail-1.03/qregex.c qmail-1.03.tap/qregex.c
old new 1 /* 2 * qregex (v2) 3 * $Id: qregex.c,v 2.1 2001/12/28 07:05:21 evan Exp $ 4 * 5 * Author : Evan Borgstrom (evan at unixpimps dot org) 6 * Created : 2001/12/14 23:08:16 7 * Modified: $Date: 2001/12/28 07:05:21 $ 8 * Revision: $Revision: 2.1 $ 9 * 10 * Do POSIX regex matching on addresses for anti-relay / spam control. 11 * It logs to the maillog 12 * See the qregex-readme file included with this tarball. 13 * If you didn't get this file in a tarball please see the following URL: 14 * http://www.unixpimps.org/software/qregex 15 * 16 * qregex.c is released under a BSD style copyright. 17 * See http://www.unixpimps.org/software/qregex/copyright.html 18 * 19 * Note: this revision follows the coding guidelines set forth by the rest of 20 * the qmail code and that described at the following URL. 21 * http://cr.yp.to/qmail/guarantee.html 22 * 23 */ 24 25 #include <sys/types.h> 26 #include <regex.h> 27 #include "qregex.h" 28 29 #define REGCOMP(X,Y) regcomp(&X, Y, REG_EXTENDED|REG_ICASE) 30 #define REGEXEC(X,Y) regexec(&X, Y, (size_t)0, (regmatch_t *)0, (int)0) 31 32 int matchregex(char *text, char *regex) { 33 regex_t qreg; 34 int retval = 0; 35 36 37 /* build the regex */ 38 if ((retval = REGCOMP(qreg, regex)) != 0) { 39 regfree(&qreg); 40 return(-retval); 41 } 42 43 /* execute the regex */ 44 if ((retval = REGEXEC(qreg, text)) != 0) { 45 /* did we just not match anything? */ 46 if (retval == REG_NOMATCH) { 47 regfree(&qreg); 48 return(0); 49 } 50 regfree(&qreg); 51 return(-retval); 52 } 53 54 /* signal the match */ 55 regfree(&qreg); 56 return(1); 57 } -
qmail-1.03
diff -Nur qmail-1.03/qregex.h qmail-1.03.tap/qregex.h
old new 1 /* simple header file for the matchregex prototype */ 2 #ifndef _QREGEX_H_ 3 #define _QREGEX_H_ 4 int matchregex(char *text, char *regex); 5 #endif -
README.tap
diff -Nur qmail-1.03/README.tap qmail-1.03.tap/README.tap
old new 1 qmail provides the ability to make a copy of each email that flows through the system. 2 This is done using the QUEUE_EXTRA code. See qmail FAQ #8.2 3 4 The qmail tap patch adds additional functionality: 5 1) Specify which email addresses to tap using a regex style control file. With the 6 regex function, you can specify full domains or individual email addresses. 7 8 2) Specify which email address to send the emails to. 9 10 3) Qmail does not need to be restated to when the taps control file is changed. 11 12 The regex match is applied to both the to and from email addresses. So email 13 sent to or from the addresses will be copied. Matching is case insensitive. 14 If there are multiple matches, the first match is used. 15 16 The queue tap patch adds a new control file: 17 18 /var/qmail/control/taps 19 Contains a regex style list of addresses to tap and the email 20 address of where you want the copy sent to. 21 22 Examples: 23 a) To tap a whole domain add a line like: 24 .*@domain.com:joe@example.com 25 26 27 b) To tap an individual email address add a line like: 28 user@domain.com:other@example.com -
qmail-1.03
diff -Nur qmail-1.03/TARGETS qmail-1.03.tap/TARGETS
old new 385 385 man 386 386 setup 387 387 check 388 qregex.o
Note: See TracBrowser
for help on using the repository browser.