|
1 stika.net antispam |
|
2 |
|
3 diff -r 72430e923db2 qmail-smtpd.c |
|
4 --- a/qmail-smtpd.c Thu Nov 01 16:46:06 2007 +0100 |
|
5 +++ b/qmail-smtpd.c Thu Nov 01 16:54:59 2007 +0100 |
|
6 @@ -31,6 +31,7 @@ |
|
7 #define BMCHECK_BMT 2 |
|
8 #define BMCHECK_BMTNR 3 |
|
9 #define BMCHECK_BHELO 4 |
|
10 +#define BMCHECK_GMF 5 // 20041202 tz - goodmailfrom functionality |
|
11 |
|
12 |
|
13 #define MAXHOPS 100 |
|
14 @@ -108,6 +109,9 @@ int bmfok = 0; |
|
15 int bmfok = 0; |
|
16 stralloc bmf = {0}; |
|
17 |
|
18 +int gmfok = 0; |
|
19 +stralloc gmf = {0}; |
|
20 + |
|
21 int bmfnrok = 0; |
|
22 stralloc bmfnr = {0}; |
|
23 |
|
24 @@ -140,6 +144,9 @@ void setup() |
|
25 |
|
26 bmfok = control_readfile(&bmf,"control/badmailfrom",0); |
|
27 if (bmfok == -1) die_control(); |
|
28 + |
|
29 + gmfok = control_readfile(&gmf,"control/goodmailfrom",0); |
|
30 + if (gmfok == -1) die_control(); |
|
31 |
|
32 bmfnrok = control_readfile(&bmfnr,"control/badmailfromnorelay",0); |
|
33 if (bmfnrok == -1) die_control(); |
|
34 @@ -247,6 +254,8 @@ int bmcheck(which) int which; |
|
35 |
|
36 if (which == BMCHECK_BMF) { |
|
37 if (!stralloc_copy(&bmb,&bmf)) die_nomem(); |
|
38 + } else if (which == BMCHECK_GMF) { // 20041202 tz - goodmailfrom |
|
39 + if (!stralloc_copy(&bmb,&gmf)) die_nomem(); |
|
40 } else if (which == BMCHECK_BMFNR) { |
|
41 if (!stralloc_copy(&bmb,&bmfnr)) die_nomem(); |
|
42 } else if (which == BMCHECK_BMT) { |
|
43 @@ -304,6 +313,7 @@ int flagbarfbhelo; |
|
44 int flagbarfbhelo; |
|
45 stralloc mailfrom = {0}; |
|
46 stralloc rcptto = {0}; |
|
47 +int senderallowed = 0; /* 20021121 tz - our anti-spam */ |
|
48 |
|
49 void smtp_helo(arg) char *arg; |
|
50 { |
|
51 @@ -327,6 +337,7 @@ void smtp_mail(arg) char *arg; |
|
52 if (!addrparse(arg)) { err_syntax(); return; } |
|
53 flagbarfbmf = 0; /* bmcheck is skipped for empty envelope senders */ |
|
54 if ((bmfok) && (addr.len != 1)) flagbarfbmf = bmcheck(BMCHECK_BMF); |
|
55 + if (flagbarfbmf && gmfok) flagbarfbmf = !bmcheck(BMCHECK_GMF); // 20041202 tz - goodmailfrom |
|
56 if ((!flagbarfbmf) && (bmfnrok) && (addr.len != 1) && (!relayclient)) { |
|
57 flagbarfbmf = bmcheck(BMCHECK_BMFNR); |
|
58 } |
|
59 @@ -334,6 +345,7 @@ void smtp_mail(arg) char *arg; |
|
60 if (!stralloc_copys(&rcptto,"")) die_nomem(); |
|
61 if (!stralloc_copys(&mailfrom,addr.s)) die_nomem(); |
|
62 if (!stralloc_0(&mailfrom)) die_nomem(); |
|
63 + senderallowed = addrallowed(); /* 20021121 tz - our anti-spam */ |
|
64 out("250 ok\r\n"); |
|
65 } |
|
66 void smtp_rcpt(arg) char *arg; { |
|
67 @@ -377,6 +389,7 @@ void smtp_rcpt(arg) char *arg; { |
|
68 } |
|
69 else |
|
70 if (!addrallowed()) { err_nogateway(); return; } |
|
71 + if (!(addrallowed() || senderallowed)) { err_nogateway(); return; } /* 20021121 tz - our anti-spam */ |
|
72 if (!stralloc_cats(&rcptto,"T")) die_nomem(); |
|
73 if (!stralloc_cats(&rcptto,addr.s)) die_nomem(); |
|
74 if (!stralloc_0(&rcptto)) die_nomem(); |