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

(-)qmail-1.03/error.h (+1 lines)
Lines 1-5 Link Here
1
#ifndef ERROR_H
1
#ifndef ERROR_H
2
#define ERROR_H
2
#define ERROR_H
3
#include <errno.h>
3
4
4
#include <errno.h>
5
#include <errno.h>
5
6
(-)qmail-1.03/Makefile (-6 / +11 lines)
Lines 1500-1512 Link Here
1500
	nroff -man qmail-qstat.8 > qmail-qstat.0
1500
	nroff -man qmail-qstat.8 > qmail-qstat.0
1501
1501
1502
qmail-queue: \
1502
qmail-queue: \
1503
load qmail-queue.o triggerpull.o fmtqfn.o now.o date822fmt.o \
1503
load qmail-queue.o triggerpull.o fmtqfn.o now.o date822fmt.o qregex.o \
1504
datetime.a seek.a ndelay.a open.a sig.a alloc.a substdio.a error.a \
1504
datetime.a seek.a case.a ndelay.a open.a sig.a getln.a stralloc.a alloc.a \
1505
str.a fs.a auto_qmail.o auto_split.o auto_uids.o
1505
substdio.a error.a control.o constmap.o str.a fs.a auto_qmail.o \
1506
auto_split.o auto_uids.o 
1506
	./load qmail-queue triggerpull.o fmtqfn.o now.o \
1507
	./load qmail-queue triggerpull.o fmtqfn.o now.o \
1507
	date822fmt.o datetime.a seek.a ndelay.a open.a sig.a \
1508
	date822fmt.o qregex.o control.o constmap.o datetime.a case.a seek.a \
1508
	alloc.a substdio.a error.a str.a fs.a auto_qmail.o \
1509
	ndelay.a open.a sig.a getln.a stralloc.a alloc.a substdio.a error.a \
1509
	auto_split.o auto_uids.o 
1510
	str.a fs.a auto_qmail.o auto_split.o auto_uids.o
1510
1511
1511
qmail-queue.0: \
1512
qmail-queue.0: \
1512
qmail-queue.8
1513
qmail-queue.8
Lines 1769-1774 Link Here
1769
compile qregex.c qregex.h
1770
compile qregex.c qregex.h
1770
	./compile qregex.c
1771
	./compile qregex.c
1771
1772
1773
qregex.o: \
1774
compile qregex.c qregex.h
1775
	./compile qregex.c
1776
1772
readsubdir.o: \
1777
readsubdir.o: \
1773
compile readsubdir.c readsubdir.h direntry.h fmt.h scan.h str.h \
1778
compile readsubdir.c readsubdir.h direntry.h fmt.h scan.h str.h \
1774
auto_split.h
1779
auto_split.h
(-)qmail-1.03/qmail-control.9 (+2 lines)
Lines 79-84 Link Here
79
.I servercert.pem	\fR(none)	\fRqmail-smtpd
79
.I servercert.pem	\fR(none)	\fRqmail-smtpd
80
.I smtpgreeting	\fIme	\fRqmail-smtpd
80
.I smtpgreeting	\fIme	\fRqmail-smtpd
81
.I smtproutes	\fR(none)	\fRqmail-remote
81
.I smtproutes	\fR(none)	\fRqmail-remote
82
.I taps	\fR(none)	\fRqmail-queue
82
.I timeoutconnect	\fR60	\fRqmail-remote
83
.I timeoutconnect	\fR60	\fRqmail-remote
83
.I timeoutremote	\fR1200	\fRqmail-remote
84
.I timeoutremote	\fR1200	\fRqmail-remote
84
.I timeoutsmtpd	\fR1200	\fRqmail-smtpd
85
.I timeoutsmtpd	\fR1200	\fRqmail-smtpd
Lines 92-97 Link Here
92
.SH "SEE ALSO"
93
.SH "SEE ALSO"
93
qmail-inject(8),
94
qmail-inject(8),
94
qmail-qmqpc(8),
95
qmail-qmqpc(8),
96
qmail-queue(8),
95
qmail-remote(8),
97
qmail-remote(8),
96
qmail-send(8),
98
qmail-send(8),
97
qmail-showctl(8),
99
qmail-showctl(8),
(-)qmail-1.03/qmail-queue.8 (+6 lines)
Lines 46-51 Link Here
46
will invoke the contents of
46
will invoke the contents of
47
.B $QMAILQUEUE
47
.B $QMAILQUEUE
48
instead, if that environment variable is set.
48
instead, if that environment variable is set.
49
.SH "CONTROL FILES"
50
.TP 5
51
.I taps
52
Should contain regex syntax of email addresses to tap and
53
the associated email address to send the copy to. The two
54
fields should be separated by a colon.
49
.SH "FILESYSTEM RESTRICTIONS"
55
.SH "FILESYSTEM RESTRICTIONS"
50
.B qmail-queue
56
.B qmail-queue
51
imposes two constraints on the queue structure:
57
imposes two constraints on the queue structure:
(-)qmail-1.03/qmail-queue.c (+84 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
     }
288
244
   if (len >= ADDR) die(11);
289
   if (len >= ADDR) die(11);
245
  }
290
  }
246
291
Lines 252-254 Link Here
252
 triggerpull();
297
 triggerpull();
253
 die(0);
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/README.tap (+28 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

Return to bug 107846