Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 107846 | Differences between
and this patch

Collapse All | Expand All

(-)./Makefile (-6 / +11 lines)
Lines 1423-1435 Link Here
1423
	nroff -man qmail-qstat.8 > qmail-qstat.0
1423
	nroff -man qmail-qstat.8 > qmail-qstat.0
1424
1424
1425
qmail-queue: \
1425
qmail-queue: \
1426
load qmail-queue.o triggerpull.o fmtqfn.o now.o date822fmt.o \
1426
load qmail-queue.o triggerpull.o fmtqfn.o now.o date822fmt.o qregex.o \
1427
datetime.a seek.a ndelay.a open.a sig.a alloc.a substdio.a error.a \
1427
datetime.a seek.a case.a ndelay.a open.a sig.a getln.a stralloc.a alloc.a \
1428
str.a fs.a auto_qmail.o auto_split.o auto_uids.o
1428
substdio.a error.a control.o constmap.o str.a fs.a auto_qmail.o \
1429
auto_split.o auto_uids.o 
1429
	./load qmail-queue triggerpull.o fmtqfn.o now.o \
1430
	./load qmail-queue triggerpull.o fmtqfn.o now.o \
1430
	date822fmt.o datetime.a seek.a ndelay.a open.a sig.a \
1431
	date822fmt.o qregex.o control.o constmap.o datetime.a case.a seek.a \
1431
	alloc.a substdio.a error.a str.a fs.a auto_qmail.o \
1432
	ndelay.a open.a sig.a getln.a stralloc.a alloc.a substdio.a error.a \
1432
	auto_split.o auto_uids.o 
1433
	str.a fs.a auto_qmail.o auto_split.o auto_uids.o
1433
1434
1434
qmail-queue.0: \
1435
qmail-queue.0: \
1435
qmail-queue.8
1436
qmail-queue.8
Lines 1692-1697 Link Here
1692
constmap.h stralloc.h gen_alloc.h rcpthosts.h
1693
constmap.h stralloc.h gen_alloc.h rcpthosts.h
1693
	./compile rcpthosts.c
1694
	./compile rcpthosts.c
1694
1695
1696
qregex.o: \
1697
compile qregex.c qregex.h
1698
	./compile qregex.c
1699
1695
readsubdir.o: \
1700
readsubdir.o: \
1696
compile readsubdir.c readsubdir.h direntry.h fmt.h scan.h str.h \
1701
compile readsubdir.c readsubdir.h direntry.h fmt.h scan.h str.h \
1697
auto_split.h
1702
auto_split.h
(-)./README.tap (+29 lines)
Line 0 Link Here
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
29
(-)./TARGETS (+1 lines)
Lines 389-392 Link Here
389
man
389
man
390
setup
390
setup
391
check
391
check
392
qregex.o
392
update_tmprsadh
393
update_tmprsadh
(-)./qmail-control.9 (+2 lines)
Lines 69-74 Link Here
69
.I servercert.pem	\fR(none)	\fRqmail-smtpd
69
.I servercert.pem	\fR(none)	\fRqmail-smtpd
70
.I smtpgreeting	\fIme	\fRqmail-smtpd
70
.I smtpgreeting	\fIme	\fRqmail-smtpd
71
.I smtproutes	\fR(none)	\fRqmail-remote
71
.I smtproutes	\fR(none)	\fRqmail-remote
72
.I taps	\fR(none)	\fRqmail-queue
72
.I timeoutconnect	\fR60	\fRqmail-remote
73
.I timeoutconnect	\fR60	\fRqmail-remote
73
.I timeoutremote	\fR1200	\fRqmail-remote
74
.I timeoutremote	\fR1200	\fRqmail-remote
74
.I timeoutsmtpd	\fR1200	\fRqmail-smtpd
75
.I timeoutsmtpd	\fR1200	\fRqmail-smtpd
Lines 82-87 Link Here
82
.SH "SEE ALSO"
83
.SH "SEE ALSO"
83
qmail-inject(8),
84
qmail-inject(8),
84
qmail-qmqpc(8),
85
qmail-qmqpc(8),
86
qmail-queue(8),
85
qmail-remote(8),
87
qmail-remote(8),
86
qmail-send(8),
88
qmail-send(8),
87
qmail-showctl(8),
89
qmail-showctl(8),
(-)./qmail-queue.8 (+6 lines)
Lines 40-45 Link Here
40
However, the recipients probably expect to see a proper header,
40
However, the recipients probably expect to see a proper header,
41
as described in
41
as described in
42
.BR qmail-header(5) .
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
44
Programs included with qmail which invoke
50
Programs included with qmail which invoke
45
.B qmail-queue
51
.B qmail-queue
(-)./qmail-queue.c (+82 lines)
Lines 16-21 Link Here
16
#include "auto_uids.h"
16
#include "auto_uids.h"
17
#include "date822fmt.h"
17
#include "date822fmt.h"
18
#include "fmtqfn.h"
18
#include "fmtqfn.h"
19
#include "stralloc.h"
20
#include "constmap.h"
19
21
20
#define DEATH 86400 /* 24 hours; _must_ be below q-s's OSSIFIED (36 hours) */
22
#define DEATH 86400 /* 24 hours; _must_ be below q-s's OSSIFIED (36 hours) */
21
#define ADDR 1003
23
#define ADDR 1003
Lines 25-30 Link Here
25
char outbuf[256];
27
char outbuf[256];
26
struct substdio ssout;
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
datetime_sec starttime;
38
datetime_sec starttime;
29
struct datetime dt;
39
struct datetime dt;
30
unsigned long mypid;
40
unsigned long mypid;
Lines 175-180 Link Here
175
185
176
 alarm(DEATH);
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
 pidopen();
195
 pidopen();
179
 if (fstat(messfd,&pidst) == -1) die(63);
196
 if (fstat(messfd,&pidst) == -1) die(63);
180
197
Lines 219-232 Link Here
219
 if (substdio_get(&ssin,&ch,1) < 1) die_read();
236
 if (substdio_get(&ssin,&ch,1) < 1) die_read();
220
 if (ch != 'F') die(91);
237
 if (ch != 'F') die(91);
221
 if (substdio_bput(&ssout,&ch,1) == -1) die_write();
238
 if (substdio_bput(&ssout,&ch,1) == -1) die_write();
239
 stralloc_0(&chkaddr);
222
 for (len = 0;len < ADDR;++len)
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
   if (substdio_get(&ssin,&ch,1) < 1) die_read();
244
   if (substdio_get(&ssin,&ch,1) < 1) die_read();
225
   if (substdio_put(&ssout,&ch,1) == -1) die_write();
245
   if (substdio_put(&ssout,&ch,1) == -1) die_write();
226
   if (!ch) break;
246
   if (!ch) break;
227
  }
247
  }
228
 if (len >= ADDR) die(11);
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
 if (substdio_bput(&ssout,QUEUE_EXTRA,QUEUE_EXTRALEN) == -1) die_write();
261
 if (substdio_bput(&ssout,QUEUE_EXTRA,QUEUE_EXTRALEN) == -1) die_write();
231
262
232
 for (;;)
263
 for (;;)
Lines 237-246 Link Here
237
   if (substdio_bput(&ssout,&ch,1) == -1) die_write();
268
   if (substdio_bput(&ssout,&ch,1) == -1) die_write();
238
   for (len = 0;len < ADDR;++len)
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
     if (substdio_get(&ssin,&ch,1) < 1) die_read();
273
     if (substdio_get(&ssin,&ch,1) < 1) die_read();
241
     if (substdio_bput(&ssout,&ch,1) == -1) die_write();
274
     if (substdio_bput(&ssout,&ch,1) == -1) die_write();
242
     if (!ch) break;
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
     }
244
   if (len >= ADDR) die(11);
288
   if (len >= ADDR) die(11);
245
  }
289
  }
246
290
Lines 252-254 Link Here
252
 triggerpull();
296
 triggerpull();
253
 die(0);
297
 die(0);
254
}
298
}
299
300
int tapcheck()
301
{
302
  int i = 0;
303
  int j = 0;
304
  int x = 0;
305
  int negate = 0;
306
  stralloc curregex = {0};
307
  char tmpbuf[200];
308
309
  while (j < tap.len) {
310
    i = j;
311
    while ((tap.s[i] != ':') && (i < tap.len)) i++;
312
    if (tap.s[j] == '!') {
313
      negate = 1;
314
      j++;
315
    }
316
    stralloc_copys(&tapaddr, &tap.s[i+1]);
317
318
    stralloc_copyb(&curregex,tap.s + j,(i - j));
319
    stralloc_0(&curregex);
320
    x = matchregex(chkaddr.s, curregex.s, tmpbuf);
321
322
    while ((tap.s[i] != '\0') && (i < tap.len)) i++;
323
  
324
    if ((negate) && (x == 0)) {
325
      return 1;
326
    }
327
    if (!(negate) && (x > 0)) {
328
      return 1;
329
    }
330
    j = i + 1;
331
    negate = 0;
332
333
334
  }
335
  return 0;
336
}
(-)./qregex.c (+58 lines)
Line 0 Link Here
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
}
58
(-)./qregex.h (+5 lines)
Line 0 Link Here
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

Return to bug 107846