-
Notifications
You must be signed in to change notification settings - Fork 1
/
rhsbl.patch
100 lines (88 loc) · 2.42 KB
/
rhsbl.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
I wrote a patch to enable rhsbl into rblsmtpd
There are 2 new options for rblsmtpd -A && -R
That should work as expected (with domain based lists as
dsn.rfc-ignorant.org)
Maybe it can be usefull for others people ?
Bye
Jean-Eudes ONFRAY
Mediation Telecom
--- rblsmtpd.c.orig Tue Dec 30 15:06:02 2003
+++ rblsmtpd.c Tue Dec 30 16:32:21 2003
@@ -22,11 +22,12 @@
}
void usage(void)
{
- strerr_die1x(100,"rblsmtpd: usage: rblsmtpd [ -b ] [ -R ] [ -t timeout ] [ -r base ] [ -a base ] smtpd [ arg ... ]");
+ strerr_die1x(100,"rblsmtpd: usage: rblsmtpd [ -b ] [ -c ] [ -t timeout ] [ -r base ] [ -a base ] [ -R base ] [ -A base ] smtpd [ arg ... ]");
}
char *ip_env;
static stralloc ip_reverse;
+char *host_env;
void ip_init(void)
{
@@ -36,6 +37,9 @@
ip_env = env_get("TCPREMOTEIP");
if (!ip_env) ip_env = "";
+ host_env = env_get("TCPREMOTEHOST");
+ if (!host_env) host_env = "";
+
if (!stralloc_copys(&ip_reverse,"")) nomem();
i = str_len(ip_env);
@@ -93,6 +97,43 @@
decision = 1;
}
+void rhsbl(char *base)
+{
+ if (decision) return;
+ if (!stralloc_copys(&tmp,host_env)) nomem();
+ if (!stralloc_cats(&tmp,".")) nomem();
+ if (!stralloc_cats(&tmp,base)) nomem();
+ if (dns_txt(&text,&tmp) == -1) {
+ flagmustnotbounce = 1;
+ if (flagfailclosed) {
+ if (!stralloc_copys(&text,"temporary RBL lookup error")) nomem();
+ decision = 2;
+ }
+ return;
+ }
+ if (text.len)
+ if (flagrblbounce)
+ decision = 3;
+ else
+ decision = 2;
+}
+
+void antirhsbl(char *base)
+{
+ if (decision) return;
+ if (!stralloc_copys(&tmp,host_env)) nomem();
+ if (!stralloc_cats(&tmp,".")) nomem();
+ if (!stralloc_cats(&tmp,base)) nomem();
+ if (dns_ip4(&text,&tmp) == -1) {
+ flagmustnotbounce = 1;
+ if (!flagfailclosed)
+ decision = 1;
+ return;
+ }
+ if (text.len)
+ decision = 1;
+}
+
char strnum[FMT_ULONG];
static stralloc message;
@@ -175,7 +216,7 @@
}
}
- while ((opt = getopt(argc,argv,"bBcCt:r:a:")) != opteof)
+ while ((opt = getopt(argc,argv,"bBcCt:r:a:R:A:")) != opteof)
switch(opt) {
case 'b': flagrblbounce = 1; break;
case 'B': flagrblbounce = 0; break;
@@ -184,6 +225,8 @@
case 't': scan_ulong(optarg,&timeout); break;
case 'r': rbl(optarg); flagwantdefaultrbl = 0; break;
case 'a': antirbl(optarg); break;
+ case 'R': rhsbl(optarg); break;
+ case 'A': antirhsbl(optarg); break;
default: usage();
}