Mercurial > dnsbl
annotate src/context.cpp @ 320:e27c24c1974a
more smtp verify logging
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Sat, 17 Dec 2016 09:46:40 -0800 |
parents | e2dc882839f6 |
children | e172dc10fe24 |
rev | line source |
---|---|
94 | 1 /* |
2 | |
270
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
3 Copyright (c) 2013 Carl Byington - 510 Software Group, released under |
152 | 4 the GPL version 3 or any later version at your choice available at |
5 http://www.gnu.org/licenses/gpl-3.0.txt | |
94 | 6 |
7 */ | |
8 | |
9 #include "includes.h" | |
10 | |
160 | 11 #include <arpa/inet.h> |
94 | 12 #include <net/if.h> |
160 | 13 #include <netdb.h> |
94 | 14 #include <netinet/in.h> |
15 #include <netinet/tcp.h> | |
160 | 16 #include <sys/ioctl.h> |
94 | 17 #include <sys/socket.h> |
160 | 18 #include <sys/stat.h> |
94 | 19 #include <sys/un.h> |
160 | 20 #include <unistd.h> |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
21 #include <climits> |
94 | 22 |
270
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
23 const char *token_asterisk; |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
24 const char *token_autowhite; |
270
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
25 const char *token_bang; |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
26 const char *token_black; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
27 const char *token_content; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
28 const char *token_context; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
29 const char *token_dccbulk; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
30 const char *token_dccfrom; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
31 const char *token_dccgrey; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
32 const char *token_dccto; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
33 const char *token_default; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
34 const char *token_dnsbl; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
35 const char *token_dnsbll; |
249 | 36 const char *token_dnswl; |
37 const char *token_dnswll; | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
38 const char *token_envfrom; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
39 const char *token_envto; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
40 const char *token_filter; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
41 const char *token_generic; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
42 const char *token_host_limit; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
43 const char *token_html_limit; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
44 const char *token_html_tags; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
45 const char *token_ignore; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
46 const char *token_include; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
47 const char *token_inherit; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
48 const char *token_lbrace; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
49 const char *token_mailhost; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
50 const char *token_many; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
51 const char *token_no; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
52 const char *token_off; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
53 const char *token_ok; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
54 const char *token_ok2; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
55 const char *token_on; |
270
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
56 const char *token_period; |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
57 const char *token_rate; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
58 const char *token_rbrace; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
59 const char *token_require; |
268
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
60 const char *token_requirerdns; |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
61 const char *token_semi; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
62 const char *token_soft; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
63 const char *token_spamassassin; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
64 const char *token_substitute; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
65 const char *token_tld; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
66 const char *token_unknown; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
67 const char *token_uribl; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
68 const char *token_verify; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
69 const char *token_white; |
233
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
70 const char *token_white_regex; |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
71 const char *token_yes; |
94 | 72 |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
73 const char *token_myhostname; |
96
1edd4e8d3a60
fix missing include, not all systems define HOST_NAME_MAX
carl
parents:
94
diff
changeset
|
74 #ifndef HOST_NAME_MAX |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
75 #define HOST_NAME_MAX 255 |
96
1edd4e8d3a60
fix missing include, not all systems define HOST_NAME_MAX
carl
parents:
94
diff
changeset
|
76 #endif |
94 | 77 char myhostname[HOST_NAME_MAX+1]; |
78 | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
79 pthread_mutex_t verifier_mutex; // protect the verifier map |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
80 verify_map verifiers; |
153 | 81 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
82 pthread_mutex_t whitelister_mutex; // protect the whitelisters map |
153 | 83 whitelister_map whitelisters; |
84 | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
85 string_set all_strings; // owns all the strings, only modified by the config loader thread |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
86 const int maxlen = 1000; // used for snprintf buffers |
178 | 87 const int maxsmtp_age = 60;// smtp verify sockets older than this are ancient |
153 | 88 const int maxauto_age = 600;// auto whitelister delay before flushing to file |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
89 extern int NULL_SOCKET; |
129
c5cd1261394d
ignore smtp connection attempts for 10 minutes when getting connection errors on verify hosts
carl
parents:
119
diff
changeset
|
90 const time_t ERROR_SMTP_SOCKET_TIME = 600; // number of seconds between attempts to open a socket to an smtp server |
94 | 91 |
92 | |
93 int SMTP::writer() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
94 #ifdef VERIFY_DEBUG |
316
f7c5cfb76e86
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
314
diff
changeset
|
95 log("writer(%d) sees buffer with '%s'", buffer); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
96 #endif |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
97 int rs = 0; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
98 if (!error) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
99 int len = strlen(buffer); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
100 while (rs < len) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
101 int ws = write(fd, buffer+rs, len-rs); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
102 if (ws > 0) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
103 rs += ws; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
104 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
105 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
106 // peer closed the socket! |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
107 rs = 0; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
108 error = true; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
109 break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
110 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
111 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
112 } |
316
f7c5cfb76e86
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
314
diff
changeset
|
113 #ifdef VERIFY_DEBUG |
f7c5cfb76e86
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
314
diff
changeset
|
114 log("writer(%d) sees error %d", (int)error); |
f7c5cfb76e86
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
314
diff
changeset
|
115 #endif |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
116 return rs; |
94 | 117 } |
118 | |
119 | |
120 int SMTP::reader() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
121 // read some bytes terminated by lf or end of buffer. |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
122 // we may have a multi line response or part thereof in the buffer. |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
123 #ifdef VERIFY_DEBUG |
314
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
124 log("reader(%d) sees error %d", (int)error); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
125 #endif |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
126 if (error) return 0; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
127 int len = maxlen-1; // room for null terminator |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
128 while (pending < len) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
129 int ws = read(fd, buffer+pending, len-pending); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
130 if (ws > 0) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
131 pending += ws; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
132 if (buffer[pending-1] == '\n') break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
133 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
134 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
135 // peer closed the socket! |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
136 pending = 0; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
137 error = true; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
138 break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
139 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
140 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
141 buffer[pending] = '\0'; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
142 #ifdef VERIFY_DEBUG |
316
f7c5cfb76e86
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
314
diff
changeset
|
143 log("reader(%d) sees buffer with '%s'", buffer); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
144 #endif |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
145 return pending; |
94 | 146 } |
147 | |
148 | |
149 int SMTP::read_line() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
150 char *lf = strchr(buffer, '\n'); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
151 if (!lf) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
152 reader(); // get a lf |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
153 lf = strchr(buffer, '\n'); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
154 if (!lf) lf = buffer + pending - 1; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
155 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
156 return (lf-buffer)+1; // number of bytes in this line |
94 | 157 } |
158 | |
159 | |
97 | 160 void SMTP::flush_line(int r) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
161 if (pending > r) memmove(buffer, buffer+r, pending-r); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
162 pending -= r; |
94 | 163 } |
164 | |
165 | |
166 int SMTP::read_response() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
167 pending = 0; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
168 buffer[pending] = '\0'; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
169 while (true) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
170 int r = read_line(); |
316
f7c5cfb76e86
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
314
diff
changeset
|
171 log("verify::read_response(%d) sees line with '%s'", buffer); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
172 if (r == 0) return 0; // failed to read any bytes |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
173 if ((r > 4) && (buffer[3] == '-')) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
174 flush_line(r); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
175 continue; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
176 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
177 return atoi(buffer); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
178 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
179 return 0; |
94 | 180 } |
181 | |
182 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
183 int SMTP::cmd(const char *c) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
184 if (c) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
185 init(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
186 append(c); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
187 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
188 append("\r\n"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
189 writer(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
190 return read_response(); |
94 | 191 } |
192 | |
193 | |
194 int SMTP::helo() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
195 if (read_response() != 220) return 0; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
196 init(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
197 append("HELO "); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
198 append(token_myhostname); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
199 return cmd(NULL); |
94 | 200 } |
201 | |
202 | |
203 int SMTP::rset() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
204 efrom[0] = '\0'; |
316
f7c5cfb76e86
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
314
diff
changeset
|
205 return cmd("RSET"); |
94 | 206 } |
207 | |
208 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
209 int SMTP::from(const char *f) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
210 // the mail from address was originally passed in from sendmail enclosed in |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
211 // <>. to_lower_string() removed the <> and converted the rest to lowercase, |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
212 // except in the case of an empty return path, which was left as the two |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
213 // character string <>. |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
214 if (strncmp(efrom, f, maxlen)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
215 strncpy(efrom, f, maxlen); |
311
f5547e7b3a09
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
310
diff
changeset
|
216 efrom[maxlen-1] = '\0'; // ensure null termination |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
217 init(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
218 append("MAIL FROM:<"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
219 if (*f != '<') append(f); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
220 append(">"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
221 return cmd(NULL); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
222 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
223 return 250; // pretend it worked |
94 | 224 } |
225 | |
226 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
227 int SMTP::rcpt(const char *t) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
228 init(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
229 append("RCPT TO:<"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
230 append(t); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
231 append(">"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
232 return cmd(NULL); |
94 | 233 } |
234 | |
235 | |
236 int SMTP::quit() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
237 return cmd("QUIT"); |
94 | 238 } |
239 | |
240 | |
241 void SMTP::closefd() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
242 shutdown(fd, SHUT_RDWR); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
243 close(fd); |
94 | 244 } |
245 | |
246 | |
311
f5547e7b3a09
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
310
diff
changeset
|
247 void SMTP::log(const char *m, int v) { |
f5547e7b3a09
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
310
diff
changeset
|
248 char buf[maxlen]; |
314
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
249 snprintf(buf, maxlen, m, get_fd(), v); |
311
f5547e7b3a09
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
310
diff
changeset
|
250 my_syslog(queueid, buf); |
f5547e7b3a09
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
310
diff
changeset
|
251 } |
94 | 252 |
253 | |
311
f5547e7b3a09
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
310
diff
changeset
|
254 void SMTP::log(const char *m, const char *v) { |
f5547e7b3a09
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
310
diff
changeset
|
255 char buf[maxlen]; |
314
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
256 snprintf(buf, maxlen, m, get_fd(), v); |
311
f5547e7b3a09
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
310
diff
changeset
|
257 my_syslog(queueid, buf); |
f5547e7b3a09
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
310
diff
changeset
|
258 } |
94 | 259 |
260 | |
153 | 261 //////////////////////////////////////////////// |
262 // smtp verifier so backup mx machines can see the valid users | |
263 // | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
264 VERIFY::VERIFY(const char *h) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
265 host = h; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
266 last_err = 0; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
267 pthread_mutex_init(&mutex, 0); |
94 | 268 } |
269 | |
270 | |
320
e27c24c1974a
more smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
318
diff
changeset
|
271 void VERIFY::log(const char *m, const char *q, const char *v) { |
e27c24c1974a
more smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
318
diff
changeset
|
272 char buf[maxlen]; |
e27c24c1974a
more smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
318
diff
changeset
|
273 snprintf(buf, maxlen, m, v, host); |
e27c24c1974a
more smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
318
diff
changeset
|
274 my_syslog(q, buf); |
e27c24c1974a
more smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
318
diff
changeset
|
275 } |
e27c24c1974a
more smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
318
diff
changeset
|
276 |
e27c24c1974a
more smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
318
diff
changeset
|
277 |
94 | 278 void VERIFY::closer() { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
279 bool ok = true; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
280 while (ok) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
281 SMTP *conn = NULL; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
282 pthread_mutex_lock(&mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
283 if (connections.empty()) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
284 ok = false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
285 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
286 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
287 conn = connections.front(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
288 time_t now = time(NULL); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
289 if ((now - conn->get_stamp()) > maxsmtp_age) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
290 // this connection is ancient, remove it |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
291 connections.pop_front(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
292 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
293 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
294 ok = false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
295 conn = NULL; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
296 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
297 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
298 pthread_mutex_unlock(&mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
299 // avoid doing this work inside the mutex lock |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
300 if (conn) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
301 #ifdef VERIFY_DEBUG |
314
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
302 conn->log("closer(%d) closes ancient socket %s", ""); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
303 #endif |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
304 delete conn; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
305 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
306 } |
94 | 307 } |
308 | |
309 | |
311
f5547e7b3a09
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
310
diff
changeset
|
310 SMTP* VERIFY::get_connection(const char *queueid) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
311 SMTP *conn = NULL; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
312 pthread_mutex_lock(&mutex); |
314
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
313 while (!connections.empty()) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
314 conn = connections.front(); |
314
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
315 time_t now = time(NULL); |
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
316 if ((now - conn->get_stamp()) > maxsmtp_age) { |
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
317 // this connection is ancient, remove it |
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
318 conn->log("verify::get_connection(%d) closes ancient socket %s", ""); |
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
319 connections.pop_front(); |
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
320 delete conn; |
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
321 conn = NULL; |
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
322 } |
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
323 else { |
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
324 conn->set_id(queueid); |
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
325 connections.pop_front(); |
318
e2dc882839f6
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
316
diff
changeset
|
326 conn->log("verify::get_connection(%d) from cache %s", ""); |
314
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
327 break; |
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
328 } |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
329 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
330 pthread_mutex_unlock(&mutex); |
316
f7c5cfb76e86
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
314
diff
changeset
|
331 if (conn) { |
f7c5cfb76e86
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
314
diff
changeset
|
332 int rc = conn->rset(); |
f7c5cfb76e86
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
314
diff
changeset
|
333 conn->log("verify::getconnection(%d) rset sees %d", rc); |
f7c5cfb76e86
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
314
diff
changeset
|
334 if (rc == 250) return conn; |
318
e2dc882839f6
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
316
diff
changeset
|
335 delete conn; |
e2dc882839f6
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
316
diff
changeset
|
336 // old connection from cache was unusable, fall thru and make a new one |
316
f7c5cfb76e86
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
314
diff
changeset
|
337 } |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
338 int sock = NULL_SOCKET; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
339 if ((time(NULL) - last_err) > ERROR_SMTP_SOCKET_TIME) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
340 // nothing recent, maybe this time it will work |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
341 hostent *h = gethostbyname(host); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
342 if (h) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
343 sockaddr_in server; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
344 server.sin_family = h->h_addrtype; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
345 server.sin_port = htons(25); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
346 memcpy(&server.sin_addr, h->h_addr_list[0], h->h_length); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
347 sock = socket(PF_INET, SOCK_STREAM, 0); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
348 if (sock != NULL_SOCKET) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
349 bool rc = (connect(sock, (sockaddr *)&server, sizeof(server)) == 0); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
350 if (!rc) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
351 shutdown(sock, SHUT_RDWR); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
352 close(sock); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
353 sock = NULL_SOCKET; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
354 last_err = time(NULL); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
355 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
356 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
357 else last_err = time(NULL); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
358 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
359 else last_err = time(NULL); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
360 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
361 if (sock != NULL_SOCKET) { |
314
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
362 struct timeval tv; |
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
363 tv.tv_sec = 15; |
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
364 tv.tv_usec = 0; |
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
365 setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval)); |
316
f7c5cfb76e86
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
314
diff
changeset
|
366 setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(struct timeval)); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
367 conn = new SMTP(sock); |
311
f5547e7b3a09
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
310
diff
changeset
|
368 conn->set_id(queueid); |
318
e2dc882839f6
better smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
316
diff
changeset
|
369 conn->log("get_connection(%d) new socket %s", ""); |
311
f5547e7b3a09
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
310
diff
changeset
|
370 int rc = conn->helo(); |
314
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
371 conn->log("verify::get_connection(%d) helo sees %d", rc); |
311
f5547e7b3a09
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
310
diff
changeset
|
372 if (rc == 250) return conn; |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
373 delete conn; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
374 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
375 return NULL; |
94 | 376 } |
377 | |
378 | |
379 void VERIFY::put_connection(SMTP *conn) { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
380 if (conn->err()) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
381 #ifdef VERIFY_DEBUG |
314
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
382 conn->log("put_socket(%d) with error %s", ""); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
383 #endif |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
384 delete conn; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
385 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
386 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
387 #ifdef VERIFY_DEBUG |
314
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
388 conn->log("put_socket(%d) no error %s", ""); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
389 #endif |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
390 conn->now(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
391 pthread_mutex_lock(&mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
392 connections.push_back(conn); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
393 pthread_mutex_unlock(&mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
394 } |
94 | 395 } |
396 | |
397 | |
310
802e2b779ed1
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
278
diff
changeset
|
398 bool VERIFY::ok(const char *queueid, const char *from, const char *to) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
399 if (host == token_myhostname) return true; |
311
f5547e7b3a09
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
310
diff
changeset
|
400 SMTP *conn = get_connection(queueid); |
320
e27c24c1974a
more smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
318
diff
changeset
|
401 if (!conn) { |
e27c24c1974a
more smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
318
diff
changeset
|
402 log("unable to verify %s with %s due to socket errors", queueid, to); |
e27c24c1974a
more smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
318
diff
changeset
|
403 return true; // cannot verify right now, we have socket errors |
e27c24c1974a
more smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
318
diff
changeset
|
404 } |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
405 int rc; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
406 rc = conn->from(from); |
314
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
407 conn->log("verify::ok(%d) from sees %d", rc); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
408 if (rc != 250) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
409 put_connection(conn); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
410 return (rc >= 500) ? false : true; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
411 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
412 rc = conn->rcpt(to); |
314
ef5a6099cbe7
enable smtp verify logging
Carl Byington <carl@five-ten-sg.com>
parents:
311
diff
changeset
|
413 conn->log("verify::ok(%d) rcpt sees %d", rc); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
414 put_connection(conn); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
415 return (rc >= 500) ? false : true; |
94 | 416 } |
417 | |
418 | |
153 | 419 //////////////////////////////////////////////// |
420 // setup a new smtp verify host | |
421 // | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
422 VERIFYP add_verify_host(const char *host); |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
423 VERIFYP add_verify_host(const char *host) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
424 VERIFYP rc = NULL; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
425 pthread_mutex_lock(&verifier_mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
426 verify_map::iterator i = verifiers.find(host); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
427 if (i == verifiers.end()) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
428 rc = new VERIFY(host); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
429 verifiers[host] = rc; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
430 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
431 else rc = (*i).second; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
432 pthread_mutex_unlock(&verifier_mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
433 return rc; |
153 | 434 } |
435 | |
436 | |
437 //////////////////////////////////////////////// | |
438 // thread to check for verify hosts with old sockets that we can close | |
439 // | |
440 void* verify_closer(void *arg) { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
441 while (true) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
442 sleep(maxsmtp_age); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
443 pthread_mutex_lock(&verifier_mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
444 for (verify_map::iterator i=verifiers.begin(); i!=verifiers.end(); i++) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
445 VERIFYP v = (*i).second; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
446 v->closer(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
447 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
448 pthread_mutex_unlock(&verifier_mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
449 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
450 return NULL; |
153 | 451 } |
452 | |
453 | |
454 //////////////////////////////////////////////// | |
455 // automatic whitelister | |
456 // | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
457 WHITELISTER::WHITELISTER(const char *f, int d) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
458 fn = f; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
459 days = d; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
460 pthread_mutex_init(&mutex, 0); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
461 need = false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
462 loaded = time(NULL); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
463 merge(); |
160 | 464 } |
465 | |
466 | |
467 void WHITELISTER::merge() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
468 time_t now = time(NULL); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
469 ifstream ifs; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
470 ifs.open(fn); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
471 if (!ifs.fail()) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
472 const int maxlen = 1000; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
473 char buf[maxlen]; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
474 while (ifs.getline(buf, maxlen)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
475 char *p = strchr(buf, ' '); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
476 if (p) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
477 *p = '\0'; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
478 char *who = strdup(buf); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
479 time_t when = atoi(p+1); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
480 if ((when == 0) || (when > now)) when = now; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
481 autowhite_sent::iterator i = rcpts.find(who); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
482 if (i == rcpts.end()) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
483 rcpts[who] = when; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
484 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
485 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
486 time_t wh = (*i).second; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
487 if ((when == 1) || (when > wh)) (*i).second = when; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
488 free(who); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
489 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
490 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
491 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
492 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
493 ifs.close(); |
153 | 494 } |
495 | |
496 | |
497 void WHITELISTER::writer() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
498 pthread_mutex_lock(&mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
499 time_t limit = time(NULL) - days*86400; |
160 | 500 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
501 // check for manually modified autowhitelist file |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
502 struct stat st; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
503 if (stat(fn, &st)) need = true; // file has disappeared |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
504 else if (st.st_mtime > loaded) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
505 // file has been manually updated, merge new entries |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
506 merge(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
507 need = true; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
508 } |
160 | 509 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
510 // purge old entries |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
511 for (autowhite_sent::iterator i=rcpts.begin(); i!=rcpts.end();) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
512 time_t when = (*i).second; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
513 if (when < limit) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
514 const char *who = (*i).first; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
515 free((void*)who); |
195 | 516 rcpts.erase(i++); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
517 need = true; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
518 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
519 else i++; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
520 } |
160 | 521 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
522 if (need) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
523 // dump the file |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
524 ofstream ofs; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
525 ofs.open(fn); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
526 if (!ofs.fail()) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
527 for (autowhite_sent::iterator i=rcpts.begin(); i!=rcpts.end(); i++) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
528 const char *who = (*i).first; |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
529 int when = (*i).second; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
530 if (!strchr(who, ' ')) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
531 ofs << who << " " << when << endl; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
532 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
533 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
534 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
535 ofs.close(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
536 need = false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
537 loaded = time(NULL); // update load time |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
538 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
539 pthread_mutex_unlock(&mutex); |
153 | 540 } |
541 | |
542 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
543 void WHITELISTER::sent(const char *to) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
544 // we take ownership of the string |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
545 pthread_mutex_lock(&mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
546 need = true; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
547 autowhite_sent::iterator i = rcpts.find(to); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
548 if (i == rcpts.end()) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
549 rcpts[to] = time(NULL); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
550 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
551 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
552 (*i).second = time(NULL); |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
553 free((void*)to); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
554 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
555 pthread_mutex_unlock(&mutex); |
153 | 556 } |
557 | |
558 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
559 bool WHITELISTER::is_white(const char *from) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
560 pthread_mutex_lock(&mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
561 autowhite_sent::iterator i = rcpts.find(from); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
562 bool rc = (i != rcpts.end()); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
563 pthread_mutex_unlock(&mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
564 return rc; |
153 | 565 } |
566 | |
567 | |
568 //////////////////////////////////////////////// | |
569 // setup a new auto whitelister file | |
570 // | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
571 WHITELISTERP add_whitelister_file(const char *fn, int days); |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
572 WHITELISTERP add_whitelister_file(const char *fn, int days) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
573 WHITELISTERP rc = NULL; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
574 pthread_mutex_lock(&whitelister_mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
575 whitelister_map::iterator i = whitelisters.find(fn); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
576 if (i == whitelisters.end()) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
577 rc = new WHITELISTER(fn, days); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
578 whitelisters[fn] = rc; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
579 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
580 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
581 rc = (*i).second; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
582 rc->set_days(days); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
583 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
584 pthread_mutex_unlock(&whitelister_mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
585 return rc; |
153 | 586 } |
587 | |
588 | |
589 //////////////////////////////////////////////// | |
590 // thread to check for whitelister hosts with old sockets that we can close | |
591 // | |
592 void* whitelister_writer(void *arg) { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
593 while (true) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
594 sleep(maxauto_age); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
595 pthread_mutex_lock(&whitelister_mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
596 for (whitelister_map::iterator i=whitelisters.begin(); i!=whitelisters.end(); i++) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
597 WHITELISTERP v = (*i).second; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
598 v->writer(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
599 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
600 pthread_mutex_unlock(&whitelister_mutex); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
601 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
602 return NULL; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
603 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
604 |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
605 |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
606 DELAYWHITE::DELAYWHITE(const char *loto_, WHITELISTERP w_, CONTEXTP con_) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
607 loto = loto_; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
608 w = w_; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
609 con = con_; |
153 | 610 } |
611 | |
612 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
613 DNSBL::DNSBL(const char *n, const char *s, const char *m) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
614 name = n; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
615 suffix = s; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
616 message = m; |
94 | 617 } |
618 | |
619 | |
620 bool DNSBL::operator==(const DNSBL &rhs) { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
621 return (strcmp(name, rhs.name) == 0) && |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
622 (strcmp(suffix, rhs.suffix) == 0) && |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
623 (strcmp(message, rhs.message) == 0); |
94 | 624 } |
625 | |
626 | |
249 | 627 DNSWL::DNSWL(const char *n, const char *s, const int l) { |
628 name = n; | |
629 suffix = s; | |
630 level = l; | |
631 } | |
632 | |
633 | |
634 bool DNSWL::operator==(const DNSWL &rhs) { | |
635 return (strcmp(name, rhs.name) == 0) && | |
636 (strcmp(suffix, rhs.suffix) == 0) && | |
637 (level == rhs.level); | |
638 } | |
639 | |
640 | |
94 | 641 CONFIG::CONFIG() { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
642 reference_count = 0; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
643 generation = 0; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
644 load_time = 0; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
645 default_context = NULL; |
94 | 646 } |
647 | |
648 | |
649 CONFIG::~CONFIG() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
650 if (debug_syslog) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
651 char buf[maxlen]; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
652 snprintf(buf, sizeof(buf), "freeing memory for old configuration generation %d", generation); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
653 my_syslog(buf); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
654 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
655 for (context_list::iterator i=contexts.begin(); i!=contexts.end(); i++) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
656 CONTEXT *c = *i; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
657 delete c; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
658 } |
94 | 659 } |
660 | |
661 | |
662 void CONFIG::add_context(CONTEXTP con) { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
663 contexts.push_back(con); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
664 if (!default_context && !con->get_parent()) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
665 // first global context |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
666 default_context = con; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
667 } |
94 | 668 } |
669 | |
670 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
671 void CONFIG::add_to(const char *to, CONTEXTP con) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
672 context_map::iterator i = env_to.find(to); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
673 if (i != env_to.end()) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
674 CONTEXTP c = (*i).second; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
675 if ((c != con) && (c != con->get_parent())) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
676 if (debug_syslog) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
677 char oldname[maxlen]; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
678 char newname[maxlen]; |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
679 const char *oldn = c->get_full_name(oldname, maxlen); |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
680 const char *newn = con->get_full_name(newname, maxlen); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
681 char buf[maxlen*3]; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
682 snprintf(buf, maxlen*3, "both %s and %s claim envelope to %s, the second one wins", oldn, newn, to); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
683 my_syslog(buf); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
684 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
685 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
686 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
687 env_to[to] = con; |
94 | 688 } |
689 | |
690 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
691 CONTEXTP CONFIG::find_context(const char *to) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
692 context_map::iterator i = env_to.find(to); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
693 if (i != env_to.end()) return (*i).second; // found user@domain key |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
694 const char *x = strchr(to, '@'); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
695 if (x) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
696 x++; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
697 i = env_to.find(x); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
698 if (i != env_to.end()) return (*i).second; // found domain key |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
699 size_t len = x - to; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
700 char user[len+1]; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
701 memcpy(user, to, len); |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
702 user[len] = '\0'; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
703 i = env_to.find(user); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
704 if (i != env_to.end()) return (*i).second; // found user@ key |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
705 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
706 return default_context; |
94 | 707 } |
708 | |
709 | |
710 void CONFIG::dump() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
711 bool spamass = false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
712 if (default_context) default_context->dump(true, spamass); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
713 for (context_list::iterator i=contexts.begin(); i!=contexts.end(); i++) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
714 CONTEXTP c = *i; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
715 CONTEXTP p = c->get_parent(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
716 if (!p && (c != default_context)) c->dump(false, spamass); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
717 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
718 char buf[maxlen]; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
719 for (context_map::iterator i=env_to.begin(); i!=env_to.end(); i++) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
720 const char *to = (*i).first; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
721 CONTEXTP con = (*i).second; |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
722 printf("// envelope to %s \t-> context %s \n", to, con->get_full_name(buf,maxlen)); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
723 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
724 if (spamass && (spamc == spamc_empty)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
725 printf("// *** warning - spamassassin filtering requested, but spamc not found by autoconf.\n"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
726 } |
94 | 727 } |
728 | |
729 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
730 CONTEXT::CONTEXT(CONTEXTP parent_, const char *name_) { |
278
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
731 parent = parent_; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
732 name = name_; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
733 verify_host = NULL; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
734 verifier = NULL; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
735 generic_regx = NULL; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
736 generic_message = NULL; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
737 white_regx = NULL; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
738 autowhite_file = NULL; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
739 whitelister = NULL; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
740 env_from_default = (parent) ? token_inherit : token_unknown; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
741 content_filtering = (parent) ? parent->content_filtering : false; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
742 content_suffix = NULL; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
743 content_message = NULL; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
744 uribl_suffix = NULL; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
745 uribl_message = NULL; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
746 host_limit = (parent) ? parent->host_limit : 0; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
747 host_limit_message = NULL; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
748 host_random = (parent) ? parent->host_random : false; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
749 tag_limit = (parent) ? parent->tag_limit : 0; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
750 tag_limit_message = NULL; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
751 spamassassin_limit = (parent) ? parent->spamassassin_limit : 0; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
752 require_match = (parent) ? parent->require_match : false; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
753 require_rdns = (parent) ? parent->require_rdns : false; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
754 dcc_greylist = (parent) ? parent->dcc_greylist : false; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
755 dcc_bulk_threshold = (parent) ? parent->dcc_bulk_threshold : 0; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
756 dnsbl_list_parsed = false; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
757 dnswl_list_parsed = false; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
758 default_rate_limit = 36000; // 10 per second |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
759 default_address_limit = 10; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
760 daily_rate_multiple = 3; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
761 daily_address_multiple = 3; |
94 | 762 } |
763 | |
764 | |
765 CONTEXT::~CONTEXT() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
766 for (dnsblp_map::iterator i=dnsbl_names.begin(); i!=dnsbl_names.end(); i++) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
767 DNSBLP d = (*i).second; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
768 // delete the underlying DNSBL objects. |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
769 delete d; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
770 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
771 if (generic_regx) regfree(&generic_pattern); |
233
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
772 if (white_regx) regfree(&white_pattern); |
94 | 773 } |
774 | |
775 | |
776 bool CONTEXT::is_parent(CONTEXTP p) { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
777 if (p == parent) return true; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
778 if (!parent) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
779 return parent->is_parent(p); |
94 | 780 } |
781 | |
782 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
783 const char *CONTEXT::get_full_name(char *buffer, int size) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
784 if (!parent) return name; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
785 char buf[maxlen]; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
786 snprintf(buffer, size, "%s.%s", parent->get_full_name(buf, maxlen), name); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
787 return buffer; |
94 | 788 } |
789 | |
790 | |
233
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
791 bool CONTEXT::set_white(const char *regx) |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
792 { |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
793 int rc = 0; |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
794 if (white_regx) regfree(&white_pattern); |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
795 white_regx = regx; |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
796 if (white_regx) { |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
797 rc = regcomp(&white_pattern, regx, REG_NOSUB | REG_ICASE | REG_EXTENDED); |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
798 } |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
799 return rc; // true iff bad pattern |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
800 } |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
801 |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
802 |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
803 bool CONTEXT::white_match(const char *from) |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
804 { |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
805 return (from && |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
806 white_regx && |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
807 (0 == regexec(&white_pattern, from, 0, NULL, 0))); |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
808 } |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
809 |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
810 |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
811 bool CONTEXT::set_generic(const char *regx, const char *msg) |
168 | 812 { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
813 int rc = 0; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
814 if (generic_regx) regfree(&generic_pattern); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
815 generic_regx = regx; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
816 generic_message = msg; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
817 if (generic_regx) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
818 rc = regcomp(&generic_pattern, regx, REG_NOSUB | REG_ICASE | REG_EXTENDED); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
819 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
820 return rc; // true iff bad pattern |
168 | 821 } |
822 | |
823 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
824 const char *CONTEXT::generic_match(const char *client) |
168 | 825 { |
195 | 826 if (!client) return NULL; // allow missing _ macro, which will disable generic checking |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
827 if (parent && !generic_regx) return parent->generic_match(client); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
828 if (!generic_regx) return NULL; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
829 if (0 == regexec(&generic_pattern, client, 0, NULL, 0)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
830 return generic_message; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
831 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
832 return NULL; |
168 | 833 } |
834 | |
835 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
836 bool CONTEXT::cover_env_to(const char *to) { |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
837 const char *x = strchr(to, '@'); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
838 if (x) x++; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
839 else x = to; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
840 if (*x == '\0') return true; // always allow covering addresses with no domain name, eg abuse@ |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
841 if (!parent && env_to.empty()) return true; // empty env_to at global level covers everything |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
842 string_set::iterator i = env_to.find(x); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
843 if (i != env_to.end()) return true; // we cover the entire domain |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
844 if (x != to) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
845 i = env_to.find(to); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
846 if (i != env_to.end()) return true; // we cover the specific email address |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
847 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
848 return false; |
94 | 849 } |
850 | |
851 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
852 VERIFYP CONTEXT::find_verify(const char *to) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
853 if (verifier && (verify_host != token_myhostname) && cover_env_to(to)) |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
854 return verifier; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
855 else if (parent) |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
856 return parent->find_verify(to); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
857 else |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
858 return NULL; |
153 | 859 } |
94 | 860 |
153 | 861 |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
862 WHITELISTERP CONTEXT::find_autowhite(const char *from, const char *to) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
863 if (whitelister && cover_env_to(to) && !cover_env_to(from)) |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
864 return whitelister; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
865 else if (parent) |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
866 return parent->find_autowhite(from, to); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
867 else |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
868 return NULL; |
94 | 869 } |
870 | |
871 | |
278
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
872 int CONTEXT::find_rate_limit(const char *user) { |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
873 if (rcpt_per_hour.empty()) return default_rate_limit; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
874 rates::iterator i = rcpt_per_hour.find(user); // look for authen id, or sender user@email limiting |
259
be939802c64e
add recipient rate limits by email from address or domain
Carl Byington <carl@five-ten-sg.com>
parents:
255
diff
changeset
|
875 if (i != rcpt_per_hour.end()) return (*i).second; // found authen id, or user@email limiting |
be939802c64e
add recipient rate limits by email from address or domain
Carl Byington <carl@five-ten-sg.com>
parents:
255
diff
changeset
|
876 const char *f = strchr(user, '@'); |
278
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
877 if (!f) return default_rate_limit; |
259
be939802c64e
add recipient rate limits by email from address or domain
Carl Byington <carl@five-ten-sg.com>
parents:
255
diff
changeset
|
878 i = rcpt_per_hour.find(f); // look for @domain limiting |
be939802c64e
add recipient rate limits by email from address or domain
Carl Byington <carl@five-ten-sg.com>
parents:
255
diff
changeset
|
879 if (i != rcpt_per_hour.end()) return (*i).second; // found @domain limiting |
278
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
880 return default_rate_limit; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
881 } |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
882 |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
883 |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
884 int CONTEXT::find_address_limit(const char *user) { |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
885 if (addresses_per_hour.empty()) return default_address_limit; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
886 rates::iterator i = addresses_per_hour.find(user); // look for authen id, or sender user@email limiting |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
887 if (i != addresses_per_hour.end()) return (*i).second; // found authen id, or user@email limiting |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
888 const char *f = strchr(user, '@'); |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
889 if (!f) return default_address_limit; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
890 i = addresses_per_hour.find(f); // look for @domain limiting |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
891 if (i != addresses_per_hour.end()) return (*i).second; // found @domain limiting |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
892 return default_address_limit; |
259
be939802c64e
add recipient rate limits by email from address or domain
Carl Byington <carl@five-ten-sg.com>
parents:
255
diff
changeset
|
893 } |
be939802c64e
add recipient rate limits by email from address or domain
Carl Byington <carl@five-ten-sg.com>
parents:
255
diff
changeset
|
894 |
be939802c64e
add recipient rate limits by email from address or domain
Carl Byington <carl@five-ten-sg.com>
parents:
255
diff
changeset
|
895 |
be939802c64e
add recipient rate limits by email from address or domain
Carl Byington <carl@five-ten-sg.com>
parents:
255
diff
changeset
|
896 bool CONTEXT::is_unauthenticated_limited(const char *user) { |
278
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
897 rates::iterator i = rcpt_per_hour.find(user); // look for sender user@email limiting |
259
be939802c64e
add recipient rate limits by email from address or domain
Carl Byington <carl@five-ten-sg.com>
parents:
255
diff
changeset
|
898 if (i != rcpt_per_hour.end()) return true; // found user@email limiting |
be939802c64e
add recipient rate limits by email from address or domain
Carl Byington <carl@five-ten-sg.com>
parents:
255
diff
changeset
|
899 const char *f = strchr(user, '@'); |
266
582cfb9c4031
fix unauthenticated rate limit bug for empty mail from
Carl Byington <carl@five-ten-sg.com>
parents:
263
diff
changeset
|
900 if (!f) return false; |
259
be939802c64e
add recipient rate limits by email from address or domain
Carl Byington <carl@five-ten-sg.com>
parents:
255
diff
changeset
|
901 i = rcpt_per_hour.find(f); // look for sender @domain limiting |
be939802c64e
add recipient rate limits by email from address or domain
Carl Byington <carl@five-ten-sg.com>
parents:
255
diff
changeset
|
902 return (i != rcpt_per_hour.end()); // found @domain limiting |
136 | 903 } |
904 | |
905 | |
233
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
906 const char *CONTEXT::find_from(const char *from, bool update_white, const char *queueid) { |
211
4db1457cd11a
Extend auto-whitelisting when receiving mail even if the auto whitelist is specified in a parent context.
Carl Byington <carl@five-ten-sg.com>
parents:
203
diff
changeset
|
907 WHITELISTERP w = whitelister; |
4db1457cd11a
Extend auto-whitelisting when receiving mail even if the auto whitelist is specified in a parent context.
Carl Byington <carl@five-ten-sg.com>
parents:
203
diff
changeset
|
908 CONTEXTP p = parent; |
4db1457cd11a
Extend auto-whitelisting when receiving mail even if the auto whitelist is specified in a parent context.
Carl Byington <carl@five-ten-sg.com>
parents:
203
diff
changeset
|
909 while (!w && p) { |
4db1457cd11a
Extend auto-whitelisting when receiving mail even if the auto whitelist is specified in a parent context.
Carl Byington <carl@five-ten-sg.com>
parents:
203
diff
changeset
|
910 w = p->whitelister; |
4db1457cd11a
Extend auto-whitelisting when receiving mail even if the auto whitelist is specified in a parent context.
Carl Byington <carl@five-ten-sg.com>
parents:
203
diff
changeset
|
911 p = p->parent; |
4db1457cd11a
Extend auto-whitelisting when receiving mail even if the auto whitelist is specified in a parent context.
Carl Byington <carl@five-ten-sg.com>
parents:
203
diff
changeset
|
912 } |
4db1457cd11a
Extend auto-whitelisting when receiving mail even if the auto whitelist is specified in a parent context.
Carl Byington <carl@five-ten-sg.com>
parents:
203
diff
changeset
|
913 if (w && w->is_white(from)) { |
233
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
914 if (update_white && queueid) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
915 // update senders timestamp to extend the whitelisting period |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
916 if (debug_syslog > 1) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
917 char buf[maxlen]; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
918 char msg[maxlen]; |
233
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
919 snprintf(msg, sizeof(msg), "%s: extend whitelist reply from <%s> in context %s", queueid, from, get_full_name(buf,maxlen)); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
920 my_syslog(msg); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
921 } |
211
4db1457cd11a
Extend auto-whitelisting when receiving mail even if the auto whitelist is specified in a parent context.
Carl Byington <carl@five-ten-sg.com>
parents:
203
diff
changeset
|
922 w->sent(strdup(from)); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
923 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
924 return token_white; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
925 } |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
926 const char *rc = env_from_default; |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
927 string_map::iterator i = env_from.find(from); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
928 if (i != env_from.end()) rc = (*i).second; // found user@domain key |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
929 else { |
244
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
930 const char *x = strchr(from, '@'); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
931 if (x) { |
244
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
932 char buf[200]; |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
933 x++; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
934 i = env_from.find(x); |
244
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
935 size_t n = x - from; // length of user name plus @ |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
936 if (i != env_from.end()) rc = (*i).second; // found domain key |
244
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
937 else if (n < sizeof(buf)) { |
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
938 // we only test reasonably short user names, since we need |
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
939 // to copy them to a buffer to avoid a dup/free cycle on every |
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
940 // test here. |
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
941 strncpy(buf, from, n); |
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
942 buf[n] = '\0'; |
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
943 i = env_from.find(buf); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
944 if (i != env_from.end()) rc = (*i).second; // found user@ key |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
945 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
946 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
947 } |
233
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
948 if ((rc == token_inherit) || (rc == token_unknown)) { |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
949 bool ok = white_match(from); |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
950 if (ok) rc = token_white; |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
951 } |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
952 if ((rc == token_inherit) && parent) return parent->find_from(from); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
953 return (rc == token_inherit) ? token_unknown : rc; |
94 | 954 } |
955 | |
956 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
957 CONTEXTP CONTEXT::find_context(const char *from) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
958 context_map::iterator i = env_from_context.find(from); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
959 if (i != env_from_context.end()) return (*i).second; // found user@domain key |
244
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
960 const char *x = strchr(from, '@'); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
961 if (x) { |
244
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
962 char buf[200]; |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
963 x++; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
964 i = env_from_context.find(x); |
244
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
965 size_t n = x - from; // length of user name plus @ |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
966 if (i != env_from_context.end()) return (*i).second; // found domain key |
244
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
967 else if (n < sizeof(buf)) { |
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
968 // we only test reasonably short user names, since we need |
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
969 // to copy them to a buffer to avoid a dup/free cycle on every |
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
970 // test here. |
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
971 strncpy(buf, from, n); |
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
972 buf[n] = '\0'; |
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
973 i = env_from_context.find(buf); |
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
974 if (i != env_from_context.end()) return (*i).second; // found user@ key |
ef97c7cd4a6e
const correctness fixes from new gcc, libresolv.a moved to glibc-static on newer distributions
Carl Byington <carl@five-ten-sg.com>
parents:
233
diff
changeset
|
975 } |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
976 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
977 return this; |
94 | 978 } |
979 | |
980 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
981 CONTEXTP CONTEXT::find_from_context_name(const char *name) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
982 context_map::iterator i = children.find(name); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
983 if (i != children.end()) return (*i).second; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
984 return NULL; |
94 | 985 } |
986 | |
987 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
988 DNSBLP CONTEXT::find_dnsbl(const char *name) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
989 dnsblp_map::iterator i = dnsbl_names.find(name); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
990 if (i != dnsbl_names.end()) return (*i).second; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
991 if (parent) return parent->find_dnsbl(name); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
992 return NULL; |
94 | 993 } |
994 | |
995 | |
249 | 996 DNSWLP CONTEXT::find_dnswl(const char *name) { |
997 dnswlp_map::iterator i = dnswl_names.find(name); | |
998 if (i != dnswl_names.end()) return (*i).second; | |
999 if (parent) return parent->find_dnswl(name); | |
1000 return NULL; | |
1001 } | |
1002 | |
1003 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1004 const char* CONTEXT::get_content_suffix() { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1005 if (!content_suffix && parent) return parent->get_content_suffix(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1006 return content_suffix; |
94 | 1007 } |
1008 | |
1009 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1010 const char* CONTEXT::get_uribl_suffix() { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1011 if (!uribl_suffix && parent) return parent->get_uribl_suffix(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1012 return uribl_suffix; |
119 | 1013 } |
1014 | |
1015 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1016 const char* CONTEXT::get_content_message() { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1017 if (!content_message && parent) return parent->get_content_message(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1018 return content_message; |
94 | 1019 } |
1020 | |
1021 | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1022 const char* CONTEXT::get_uribl_message() { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1023 if (!uribl_message && parent) return parent->get_uribl_message(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1024 return uribl_message; |
119 | 1025 } |
1026 | |
1027 | |
94 | 1028 string_set& CONTEXT::get_content_host_ignore() { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1029 if (content_host_ignore.empty() && parent) return parent->get_content_host_ignore(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1030 return content_host_ignore; |
94 | 1031 } |
1032 | |
1033 | |
1034 string_set& CONTEXT::get_content_tlds() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1035 if (content_tlds.empty() && parent) return parent->get_content_tlds(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1036 return content_tlds; |
94 | 1037 } |
1038 | |
1039 | |
270
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1040 string_set& CONTEXT::get_content_tldwilds() { |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1041 if (content_tldwilds.empty() && parent) return parent->get_content_tldwilds(); |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1042 return content_tldwilds; |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1043 } |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1044 |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1045 |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1046 string_set& CONTEXT::get_content_tldnots() { |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1047 if (content_tldnots.empty() && parent) return parent->get_content_tldnots(); |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1048 return content_tldnots; |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1049 } |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1050 |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1051 |
94 | 1052 string_set& CONTEXT::get_html_tags() { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1053 if (html_tags.empty() && parent) return parent->get_html_tags(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1054 return html_tags; |
94 | 1055 } |
1056 | |
1057 | |
1058 dnsblp_list& CONTEXT::get_dnsbl_list() { | |
255
d6d5c50b9278
Allow dnswl_list and dnsbl_list to be empty, to override lists specified in the ancestor contexts. Add daily recipient limits as a multiple of the hourly limits.
Carl Byington <carl@five-ten-sg.com>
parents:
249
diff
changeset
|
1059 if (!dnsbl_list_parsed && parent) return parent->get_dnsbl_list(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1060 return dnsbl_list; |
94 | 1061 } |
1062 | |
1063 | |
249 | 1064 dnswlp_list& CONTEXT::get_dnswl_list() { |
255
d6d5c50b9278
Allow dnswl_list and dnsbl_list to be empty, to override lists specified in the ancestor contexts. Add daily recipient limits as a multiple of the hourly limits.
Carl Byington <carl@five-ten-sg.com>
parents:
249
diff
changeset
|
1065 if (!dnswl_list_parsed && parent) return parent->get_dnswl_list(); |
249 | 1066 return dnswl_list; |
1067 } | |
1068 | |
1069 | |
178 | 1070 bool CONTEXT::acceptable_content(recorder &memory, int score, int bulk, string& msg) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1071 if (spamassassin_limit && (score > spamassassin_limit)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1072 char buf[maxlen]; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1073 snprintf(buf, sizeof(buf), "Mail rejected - spam assassin score %d", score); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1074 msg = string(buf); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1075 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1076 } |
203
92a5c866bdfa
Verify from/to pairs even if they might be explicitly whitelisted.
Carl Byington <carl@five-ten-sg.com>
parents:
195
diff
changeset
|
1077 if (dcc_bulk_threshold && (bulk >= dcc_bulk_threshold)) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1078 char buf[maxlen]; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1079 snprintf(buf, sizeof(buf), "Mail rejected - dcc score %d", bulk); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1080 msg = string(buf); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1081 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1082 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1083 if (memory.excessive_bad_tags(tag_limit)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1084 msg = string(tag_limit_message); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1085 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1086 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1087 if (!host_random && memory.excessive_hosts(host_limit)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1088 msg = string(host_limit_message); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1089 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1090 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1091 return true; |
94 | 1092 } |
1093 | |
1094 | |
167
9b129ed78d7d
actually use spamassassin result, allow build without spam assassin, only call it if some recipient needs it.
carl
parents:
164
diff
changeset
|
1095 void CONTEXT::dump(bool isdefault, bool &spamass, int level) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1096 char indent[maxlen]; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1097 int i = min(maxlen-1, level*4); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1098 memset(indent, ' ', i); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1099 indent[i] = '\0'; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1100 char buf[maxlen]; |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1101 const char *fullname = get_full_name(buf,maxlen); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1102 printf("%s context %s { \t// %s\n", indent, name, fullname); |
94 | 1103 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1104 for (dnsblp_map::iterator i=dnsbl_names.begin(); i!=dnsbl_names.end(); i++) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1105 const char *n = (*i).first; |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1106 DNSBL &d = *(*i).second; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1107 printf("%s dnsbl %s %s \"%s\"; \n", indent, n, d.suffix, d.message); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1108 } |
94 | 1109 |
249 | 1110 for (dnswlp_map::iterator i=dnswl_names.begin(); i!=dnswl_names.end(); i++) { |
1111 const char *n = (*i).first; | |
1112 DNSWL &d = *(*i).second; | |
1113 printf("%s dnswl %s %s %d; \n", indent, n, d.suffix, d.level); | |
1114 } | |
1115 | |
1116 { | |
255
d6d5c50b9278
Allow dnswl_list and dnsbl_list to be empty, to override lists specified in the ancestor contexts. Add daily recipient limits as a multiple of the hourly limits.
Carl Byington <carl@five-ten-sg.com>
parents:
249
diff
changeset
|
1117 dnsblp_list dl = get_dnsbl_list(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1118 printf("%s dnsbl_list", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1119 for (dnsblp_list::iterator i=dl.begin(); i!=dl.end(); i++) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1120 DNSBL &d = *(*i); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1121 printf(" %s", d.name); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1122 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1123 printf("; \n"); |
268
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1124 printf("%s require_rdns %s; \n", indent, (require_rdns) ? "yes" : "no"); |
255
d6d5c50b9278
Allow dnswl_list and dnsbl_list to be empty, to override lists specified in the ancestor contexts. Add daily recipient limits as a multiple of the hourly limits.
Carl Byington <carl@five-ten-sg.com>
parents:
249
diff
changeset
|
1125 } |
249 | 1126 |
1127 { | |
255
d6d5c50b9278
Allow dnswl_list and dnsbl_list to be empty, to override lists specified in the ancestor contexts. Add daily recipient limits as a multiple of the hourly limits.
Carl Byington <carl@five-ten-sg.com>
parents:
249
diff
changeset
|
1128 dnswlp_list dl = get_dnswl_list(); |
249 | 1129 printf("%s dnswl_list", indent); |
1130 for (dnswlp_list::iterator i=dl.begin(); i!=dl.end(); i++) { | |
1131 DNSWL &d = *(*i); | |
1132 printf(" %s", d.name); | |
1133 } | |
1134 printf("; \n"); | |
255
d6d5c50b9278
Allow dnswl_list and dnsbl_list to be empty, to override lists specified in the ancestor contexts. Add daily recipient limits as a multiple of the hourly limits.
Carl Byington <carl@five-ten-sg.com>
parents:
249
diff
changeset
|
1135 } |
94 | 1136 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1137 if (content_filtering) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1138 printf("%s content on { \n", indent); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1139 if (content_suffix) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1140 printf("%s filter %s \"%s\"; \n", indent, content_suffix, content_message); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1141 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1142 if (uribl_suffix) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1143 printf("%s uribl %s \"%s\"; \n", indent, uribl_suffix, uribl_message); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1144 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1145 if (!content_host_ignore.empty()) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1146 printf("%s ignore { \n", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1147 for (string_set::iterator i=content_host_ignore.begin(); i!=content_host_ignore.end(); i++) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1148 printf("%s %s; \n", indent, *i); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1149 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1150 printf("%s }; \n", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1151 } |
270
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1152 if (!content_tlds.empty() || !content_tldwilds.empty() || !content_tldnots.empty()) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1153 printf("%s tld { \n", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1154 printf("%s ", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1155 for (string_set::iterator i=content_tlds.begin(); i!=content_tlds.end(); i++) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1156 printf("%s; ", *i); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1157 } |
270
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1158 for (string_set::iterator i=content_tldwilds.begin(); i!=content_tldwilds.end(); i++) { |
274
bdcf203e3f7b
fix -c printing config
Carl Byington <carl@five-ten-sg.com>
parents:
272
diff
changeset
|
1159 printf("*.%s; ", *i); |
270
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1160 } |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1161 for (string_set::iterator i=content_tldnots.begin(); i!=content_tldnots.end(); i++) { |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1162 printf("!%s; ", *i); |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1163 } |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1164 printf("\n%s }; \n", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1165 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1166 if (!html_tags.empty()) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1167 printf("%s html_tags { \n", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1168 printf("%s ", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1169 for (string_set::iterator i=html_tags.begin(); i!=html_tags.end(); i++) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1170 printf("%s; ", *i); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1171 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1172 printf("\n%s }; \n", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1173 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1174 if (host_limit_message) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1175 printf("%s host_limit on %d \"%s\"; \n", indent, host_limit, host_limit_message); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1176 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1177 else if (host_random) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1178 printf("%s host_limit soft %d; \n", indent, host_limit); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1179 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1180 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1181 printf("%s host_limit off; \n", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1182 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1183 if (tag_limit_message) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1184 printf("%s html_limit on %d \"%s\"; \n", indent, tag_limit, tag_limit_message); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1185 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1186 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1187 printf("%s html_limit off; \n", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1188 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1189 printf("%s spamassassin %d; \n", indent, spamassassin_limit); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1190 printf("%s require_match %s; \n", indent, (require_match) ? "yes" : "no"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1191 printf("%s dcc_greylist %s; \n", indent, (dcc_greylist) ? "yes" : "no"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1192 if (dcc_bulk_threshold == 0) printf("%s dcc_bulk_threshold off; \n", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1193 else if (dcc_bulk_threshold >= dccbulk) printf("%s dcc_bulk_threshold many; \n", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1194 else printf("%s dcc_bulk_threshold %d; \n", indent, dcc_bulk_threshold); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1195 printf("%s }; \n", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1196 spamass |= (spamassassin_limit != 0); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1197 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1198 else { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1199 printf("%s content off {}; \n", indent); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1200 } |
94 | 1201 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1202 printf("%s env_to { \t// %s\n", indent, fullname); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1203 for (string_set::iterator i=env_to.begin(); i!=env_to.end(); i++) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1204 printf("%s %s; \n", indent, *i); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1205 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1206 printf("%s }; \n", indent); |
94 | 1207 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1208 if (verify_host) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1209 printf("%s verify %s; \n", indent, verify_host); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1210 } |
94 | 1211 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1212 if (generic_regx) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1213 printf("%s generic \"%s\" \n", indent, generic_regx); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1214 printf("%s \"%s\"; \n", indent, generic_message); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1215 } |
168 | 1216 |
233
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1217 if (white_regx) { |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1218 printf("%s white_regex \"%s\"; \n", indent, white_regx); |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1219 } |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1220 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1221 if (autowhite_file && whitelister) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1222 printf("%s autowhite %d %s; \n", indent, whitelister->get_days(), autowhite_file); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1223 } |
153 | 1224 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1225 for (context_map::iterator i=children.begin(); i!=children.end(); i++) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1226 CONTEXTP c = (*i).second; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1227 c->dump(false, spamass, level+1); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1228 } |
94 | 1229 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1230 printf("%s env_from %s { \t// %s\n", indent, env_from_default, fullname); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1231 if (!env_from.empty()) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1232 printf("%s // white/black/unknown \n", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1233 for (string_map::iterator i=env_from.begin(); i!=env_from.end(); i++) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1234 const char *f = (*i).first; |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1235 const char *t = (*i).second; |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1236 printf("%s %s \t%s; \n", indent, f, t); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1237 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1238 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1239 if (!env_from_context.empty()) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1240 printf("%s // child contexts \n", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1241 for (context_map::iterator j=env_from_context.begin(); j!=env_from_context.end(); j++) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1242 const char *f = (*j).first; |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1243 CONTEXTP t = (*j).second; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1244 printf("%s %s \t%s; \n", indent, f, t->name); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1245 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1246 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1247 printf("%s }; \n", indent); |
94 | 1248 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1249 if (isdefault) { |
278
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
1250 printf("%s rate_limit %d %d %d %d { \n", indent, default_rate_limit, daily_rate_multiple, default_address_limit, daily_address_multiple); |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
1251 for (rates::iterator j=rcpt_per_hour.begin(); j!=rcpt_per_hour.end(); j++) { |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
1252 const char *u = (*j).first; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
1253 int l = (*j).second; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
1254 rates::iterator k = addresses_per_hour.find(u); |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
1255 int a = (k==addresses_per_hour.end()) ? default_address_limit : (*k).second; |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
1256 printf("%s \"%s\" \t%d %d; \n", indent, u, l, a); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1257 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1258 printf("%s }; \n", indent); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1259 } |
136 | 1260 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1261 printf("%s }; \n", indent); |
94 | 1262 } |
1263 | |
1264 | |
1265 //////////////////////////////////////////////// | |
1266 // helper to discard the strings held by a string_set | |
1267 // | |
1268 void discard(string_set &s) { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1269 for (string_set::iterator i=s.begin(); i!=s.end(); i++) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1270 free((void*)*i); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1271 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1272 s.clear(); |
94 | 1273 } |
1274 | |
1275 | |
1276 //////////////////////////////////////////////// | |
1277 // helper to register a string in a string set | |
1278 // | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1279 const char* register_string(string_set &s, const char *name) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1280 string_set::iterator i = s.find(name); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1281 if (i != s.end()) return *i; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1282 char *x = strdup(name); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1283 s.insert(x); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1284 return x; |
94 | 1285 } |
1286 | |
1287 | |
1288 //////////////////////////////////////////////// | |
1289 // register a global string | |
1290 // | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1291 const char* register_string(const char *name) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1292 return register_string(all_strings, name); |
94 | 1293 } |
1294 | |
1295 | |
1296 //////////////////////////////////////////////// | |
164 | 1297 // clear all global strings, helper for valgrind checking |
1298 // | |
1299 void clear_strings() { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1300 discard(all_strings); |
164 | 1301 } |
1302 | |
1303 | |
1304 //////////////////////////////////////////////// | |
94 | 1305 // |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1306 bool tsa(TOKEN &tok, const char *token); |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1307 bool tsa(TOKEN &tok, const char *token) { |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1308 const char *have = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1309 if (have == token) return true; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1310 tok.token_error(token, have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1311 return false; |
94 | 1312 } |
1313 | |
1314 | |
1315 //////////////////////////////////////////////// | |
1316 // | |
1317 bool parse_dnsbl(TOKEN &tok, CONFIG &dc, CONTEXT &me); | |
1318 bool parse_dnsbl(TOKEN &tok, CONFIG &dc, CONTEXT &me) { | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1319 const char *name = tok.next(); |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1320 const char *suf = tok.next(); |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1321 const char *msg = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1322 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1323 DNSBLP dnsnew = new DNSBL(name, suf, msg); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1324 DNSBLP dnsold = me.find_dnsbl(name); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1325 if (dnsold && (*dnsold == *dnsnew)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1326 // duplicate redefinition, ignore it |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1327 delete dnsnew; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1328 return true; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1329 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1330 me.add_dnsbl(name, dnsnew); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1331 return true; |
94 | 1332 } |
1333 | |
1334 | |
1335 //////////////////////////////////////////////// | |
1336 // | |
249 | 1337 bool parse_dnswl(TOKEN &tok, CONFIG &dc, CONTEXT &me); |
1338 bool parse_dnswl(TOKEN &tok, CONFIG &dc, CONTEXT &me) { | |
1339 const char *name = tok.next(); | |
1340 const char *suf = tok.next(); | |
1341 const int lev = tok.nextint(); | |
1342 if (!tsa(tok, token_semi)) return false; | |
1343 DNSWLP dnsnew = new DNSWL(name, suf, lev); | |
1344 DNSWLP dnsold = me.find_dnswl(name); | |
1345 if (dnsold && (*dnsold == *dnsnew)) { | |
1346 // duplicate redefinition, ignore it | |
1347 delete dnsnew; | |
1348 return true; | |
1349 } | |
1350 me.add_dnswl(name, dnsnew); | |
1351 return true; | |
1352 } | |
1353 | |
1354 | |
1355 //////////////////////////////////////////////// | |
1356 // | |
94 | 1357 bool parse_dnsbll(TOKEN &tok, CONFIG &dc, CONTEXT &me); |
1358 bool parse_dnsbll(TOKEN &tok, CONFIG &dc, CONTEXT &me) { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1359 while (true) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1360 const char *have = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1361 if (!have) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1362 if (have == token_semi) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1363 DNSBLP dns = me.find_dnsbl(have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1364 if (dns) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1365 me.add_dnsbl(dns); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1366 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1367 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1368 tok.token_error("dnsbl name", have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1369 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1370 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1371 } |
255
d6d5c50b9278
Allow dnswl_list and dnsbl_list to be empty, to override lists specified in the ancestor contexts. Add daily recipient limits as a multiple of the hourly limits.
Carl Byington <carl@five-ten-sg.com>
parents:
249
diff
changeset
|
1372 me.set_dnsbll_parsed(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1373 return true; |
94 | 1374 } |
1375 | |
1376 | |
1377 //////////////////////////////////////////////// | |
1378 // | |
249 | 1379 bool parse_dnswll(TOKEN &tok, CONFIG &dc, CONTEXT &me); |
1380 bool parse_dnswll(TOKEN &tok, CONFIG &dc, CONTEXT &me) { | |
1381 while (true) { | |
1382 const char *have = tok.next(); | |
1383 if (!have) break; | |
1384 if (have == token_semi) break; | |
1385 DNSWLP dns = me.find_dnswl(have); | |
1386 if (dns) { | |
1387 me.add_dnswl(dns); | |
1388 } | |
1389 else { | |
1390 tok.token_error("dnswl name", have); | |
1391 return false; | |
1392 } | |
1393 } | |
255
d6d5c50b9278
Allow dnswl_list and dnsbl_list to be empty, to override lists specified in the ancestor contexts. Add daily recipient limits as a multiple of the hourly limits.
Carl Byington <carl@five-ten-sg.com>
parents:
249
diff
changeset
|
1394 me.set_dnswll_parsed(); |
249 | 1395 return true; |
1396 } | |
1397 | |
1398 | |
1399 //////////////////////////////////////////////// | |
1400 // | |
268
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1401 bool parse_requirerdns(TOKEN &tok, CONFIG &dc, CONTEXT &me); |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1402 bool parse_requirerdns(TOKEN &tok, CONFIG &dc, CONTEXT &me) { |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1403 const char *have = tok.next(); |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1404 if (have == token_yes) me.set_requirerdns(true); |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1405 else if (have == token_no) me.set_requirerdns(false); |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1406 else { |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1407 tok.token_error("yes/no", have); |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1408 return false; |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1409 } |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1410 if (!tsa(tok, token_semi)) return false; |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1411 return true; |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1412 } |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1413 |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1414 |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1415 //////////////////////////////////////////////// |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1416 // |
94 | 1417 bool parse_content(TOKEN &tok, CONFIG &dc, CONTEXT &me); |
1418 bool parse_content(TOKEN &tok, CONFIG &dc, CONTEXT &me) { | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1419 const char *setting = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1420 if (setting == token_on) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1421 me.set_content_filtering(true); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1422 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1423 else if (setting == token_off) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1424 me.set_content_filtering(false); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1425 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1426 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1427 tok.token_error("on/off", setting); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1428 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1429 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1430 if (!tsa(tok, token_lbrace)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1431 while (true) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1432 const char *have = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1433 if (!have) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1434 if (have == token_filter) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1435 const char *suffix = tok.next(); |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1436 const char *messag = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1437 me.set_content_suffix(suffix); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1438 me.set_content_message(messag); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1439 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1440 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1441 else if (have == token_uribl) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1442 const char *suffix = tok.next(); |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1443 const char *messag = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1444 me.set_uribl_suffix(suffix); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1445 me.set_uribl_message(messag); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1446 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1447 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1448 else if (have == token_ignore) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1449 if (!tsa(tok, token_lbrace)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1450 while (true) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1451 if (!have) break; |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1452 const char *have = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1453 if (have == token_rbrace) break; // done |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1454 me.add_ignore(have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1455 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1456 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1457 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1458 else if (have == token_tld) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1459 if (!tsa(tok, token_lbrace)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1460 while (true) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1461 const char *have = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1462 if (!have) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1463 if (have == token_rbrace) break; // done |
270
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1464 if (have == token_bang) { |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1465 have = tok.next(); |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1466 if (!have) break; |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1467 if (have == token_rbrace) break; // done |
272
a99b6c1f5f67
Code cleanup, increase minimum hostname length for uribl checking
Carl Byington <carl@five-ten-sg.com>
parents:
270
diff
changeset
|
1468 me.add_tldnot(have); |
270
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1469 } |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1470 else if (have == token_asterisk) { |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1471 have = tok.next(); |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1472 if (!have) break; |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1473 if (have == token_rbrace) break; // done |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1474 if (have == token_period) { |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1475 have = tok.next(); |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1476 if (!have) break; |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1477 if (have == token_rbrace) break; // done |
272
a99b6c1f5f67
Code cleanup, increase minimum hostname length for uribl checking
Carl Byington <carl@five-ten-sg.com>
parents:
270
diff
changeset
|
1478 me.add_tldwild(have); |
270
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1479 } |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1480 } |
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1481 else me.add_tld(have); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1482 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1483 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1484 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1485 else if (have == token_html_tags) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1486 if (!tsa(tok, token_lbrace)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1487 while (true) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1488 const char *have = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1489 if (!have) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1490 if (have == token_rbrace) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1491 break; // done |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1492 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1493 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1494 me.add_tag(have); // base version |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1495 char buf[200]; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1496 snprintf(buf, sizeof(buf), "/%s", have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1497 me.add_tag(register_string(buf)); // leading / |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1498 snprintf(buf, sizeof(buf), "%s/", have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1499 me.add_tag(register_string(buf)); // trailing / |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1500 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1501 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1502 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1503 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1504 else if (have == token_html_limit) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1505 have = tok.next(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1506 if (have == token_on) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1507 me.set_tag_limit(tok.nextint()); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1508 me.set_tag_message(tok.next()); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1509 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1510 else if (have == token_off) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1511 me.set_tag_limit(0); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1512 me.set_tag_message(NULL); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1513 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1514 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1515 tok.token_error("on/off", have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1516 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1517 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1518 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1519 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1520 else if (have == token_host_limit) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1521 have = tok.next(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1522 if (have == token_on) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1523 me.set_host_limit(tok.nextint()); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1524 me.set_host_message(tok.next()); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1525 me.set_host_random(false); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1526 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1527 else if (have == token_off) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1528 me.set_host_limit(0); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1529 me.set_host_message(NULL); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1530 me.set_host_random(false); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1531 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1532 else if (have == token_soft) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1533 me.set_host_limit(tok.nextint()); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1534 me.set_host_message(NULL); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1535 me.set_host_random(true); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1536 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1537 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1538 tok.token_error("on/off/soft", have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1539 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1540 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1541 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1542 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1543 else if (have == token_spamassassin) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1544 me.set_spamassassin_limit(tok.nextint()); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1545 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1546 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1547 else if (have == token_require) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1548 have = tok.next(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1549 if (have == token_yes) me.set_require(true); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1550 else if (have == token_no) me.set_require(false); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1551 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1552 tok.token_error("yes/no", have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1553 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1554 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1555 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1556 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1557 else if (have == token_dccgrey) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1558 have = tok.next(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1559 if (have == token_yes) me.set_grey(true); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1560 else if (have == token_no) me.set_grey(false); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1561 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1562 tok.token_error("yes/no", have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1563 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1564 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1565 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1566 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1567 else if (have == token_dccbulk) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1568 have = tok.next(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1569 if (have == token_off) me.set_bulk(0); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1570 else if (have == token_many) me.set_bulk(dccbulk); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1571 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1572 char *e; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1573 long i = strtol(have, &e, 10); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1574 if (*e != '\0') { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1575 tok.token_error("integer", have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1576 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1577 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1578 me.set_bulk((int)i); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1579 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1580 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1581 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1582 else if (have == token_rbrace) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1583 break; // done |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1584 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1585 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1586 tok.token_error("content keyword", have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1587 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1588 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1589 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1590 return tsa(tok, token_semi); |
94 | 1591 } |
1592 | |
1593 | |
1594 //////////////////////////////////////////////// | |
1595 // | |
1596 bool parse_envto(TOKEN &tok, CONFIG &dc, CONTEXT &me); | |
1597 bool parse_envto(TOKEN &tok, CONFIG &dc, CONTEXT &me) { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1598 if (!tsa(tok, token_lbrace)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1599 while (true) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1600 const char *have = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1601 if (!have) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1602 if (have == token_rbrace) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1603 if (have == token_semi) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1604 // optional separators |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1605 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1606 else if (have == token_dccto) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1607 const char *flavor = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1608 if (!tsa(tok, token_lbrace)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1609 bool keeping = false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1610 while (true) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1611 const char *have = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1612 if (!have) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1613 if (have == token_rbrace) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1614 if (have == flavor) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1615 keeping = true; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1616 continue; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1617 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1618 else if ((have == token_ok) || (have == token_ok2) || (have == token_many)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1619 keeping = false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1620 continue; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1621 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1622 if (have == token_envto) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1623 have = tok.next(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1624 if (keeping) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1625 if (me.allow_env_to(have)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1626 me.add_to(have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1627 dc.add_to(have, &me); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1628 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1629 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1630 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1631 //else if (have == token_substitute) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1632 // if (tok.next() == token_mailhost) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1633 // have = tok.next(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1634 // if (keeping) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1635 // if (me.allow_env_to(have)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1636 // me.add_to(have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1637 // dc.add_to(have, &me); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1638 // } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1639 // } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1640 // } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1641 //} |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1642 tok.skipeol(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1643 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1644 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1645 else if (me.allow_env_to(have)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1646 me.add_to(have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1647 dc.add_to(have, &me); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1648 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1649 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1650 tok.token_error("user@ or user@domain.tld or domain.tld where domain.tld allowed by parent context", have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1651 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1652 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1653 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1654 return tsa(tok, token_semi); |
94 | 1655 } |
1656 | |
1657 | |
1658 //////////////////////////////////////////////// | |
1659 // | |
1660 bool parse_verify(TOKEN &tok, CONFIG &dc, CONTEXT &me); | |
1661 bool parse_verify(TOKEN &tok, CONFIG &dc, CONTEXT &me) { | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1662 const char *host = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1663 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1664 me.set_verify(host); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1665 me.set_verifier(add_verify_host(host)); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1666 return true; |
153 | 1667 } |
1668 | |
1669 | |
1670 //////////////////////////////////////////////// | |
1671 // | |
168 | 1672 bool parse_generic(TOKEN &tok, CONFIG &dc, CONTEXT &me); |
1673 bool parse_generic(TOKEN &tok, CONFIG &dc, CONTEXT &me) { | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1674 const char *regx = tok.next(); |
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1675 const char *msg = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1676 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1677 if (me.set_generic(regx, msg)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1678 tok.token_error("invalid regular expression %s", regx, regx); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1679 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1680 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1681 return true; |
168 | 1682 } |
1683 | |
1684 | |
1685 //////////////////////////////////////////////// | |
1686 // | |
233
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1687 bool parse_white(TOKEN &tok, CONFIG &dc, CONTEXT &me); |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1688 bool parse_white(TOKEN &tok, CONFIG &dc, CONTEXT &me) { |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1689 const char *regx = tok.next(); |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1690 if (!tsa(tok, token_semi)) return false; |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1691 if (me.set_white(regx)) { |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1692 tok.token_error("invalid regular expression %s", regx, regx); |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1693 return false; |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1694 } |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1695 return true; |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1696 } |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1697 |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1698 |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1699 //////////////////////////////////////////////// |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1700 // |
153 | 1701 bool parse_autowhite(TOKEN &tok, CONFIG &dc, CONTEXT &me); |
1702 bool parse_autowhite(TOKEN &tok, CONFIG &dc, CONTEXT &me) { | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1703 int days = tok.nextint(); |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1704 const char *fn = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1705 if (!tsa(tok, token_semi)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1706 me.set_autowhite(fn); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1707 me.set_whitelister(add_whitelister_file(fn, days)); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1708 return true; |
94 | 1709 } |
1710 | |
1711 | |
1712 //////////////////////////////////////////////// | |
1713 // | |
1714 bool parse_envfrom(TOKEN &tok, CONFIG &dc, CONTEXT &me); | |
1715 bool parse_envfrom(TOKEN &tok, CONFIG &dc, CONTEXT &me) { | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1716 const char *st = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1717 if ((st == token_black) || (st == token_white) || (st == token_unknown) || (st == token_inherit)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1718 me.set_from_default(st); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1719 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1720 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1721 tok.push(st); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1722 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1723 if (!tsa(tok, token_lbrace)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1724 while (true) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1725 const char *have = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1726 if (!have) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1727 if (have == token_rbrace) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1728 if (have == token_semi) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1729 // optional separators |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1730 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1731 else if (have == token_dccfrom) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1732 if (!tsa(tok, token_lbrace)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1733 bool keeping = false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1734 bool many = false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1735 while (true) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1736 const char *have = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1737 if (!have) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1738 if (have == token_rbrace) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1739 if (have == token_ok) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1740 keeping = true; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1741 many = false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1742 continue; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1743 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1744 else if (have == token_many) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1745 keeping = true; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1746 many = true; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1747 continue; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1748 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1749 else if (have == token_ok2) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1750 keeping = false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1751 continue; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1752 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1753 if (have == token_envfrom) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1754 have = tok.next(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1755 if (keeping) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1756 me.add_from(have, (many) ? token_black : token_white); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1757 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1758 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1759 else if (have == token_substitute) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1760 if (tok.next() == token_mailhost) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1761 have = tok.next(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1762 me.add_from(have, (many) ? token_black : token_white); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1763 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1764 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1765 tok.skipeol(); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1766 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1767 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1768 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1769 // may be a valid email address or domain name |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1770 const char *st = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1771 if ((st == token_white) || (st == token_black) || (st == token_unknown) || (st == token_inherit)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1772 me.add_from(have, st); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1773 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1774 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1775 CONTEXTP con = me.find_from_context_name(st); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1776 if (con) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1777 me.add_from_context(have, con); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1778 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1779 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1780 tok.token_error("white/black/unknown/inherit or child context name", st); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1781 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1782 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1783 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1784 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1785 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1786 return tsa(tok, token_semi); |
94 | 1787 } |
1788 | |
1789 | |
1790 //////////////////////////////////////////////// | |
1791 // | |
136 | 1792 bool parse_rate(TOKEN &tok, CONFIG &dc, CONTEXT &me); |
1793 bool parse_rate(TOKEN &tok, CONFIG &dc, CONTEXT &me) { | |
278
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
1794 me.set_default_rate_limit(tok.nextint()); |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
1795 me.set_daily_rate_multiple(tok.nextint()); |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
1796 me.set_default_address_limit(tok.nextint()); |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
1797 me.set_daily_address_multiple(tok.nextint()); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1798 if (!tsa(tok, token_lbrace)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1799 while (true) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1800 const char *have = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1801 if (!have) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1802 if (have == token_rbrace) break; |
278
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
1803 me.add_rate_limit(have, tok.nextint()); |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
1804 me.add_address_limit(have, tok.nextint()); |
368572c57013
add limits on unique ip addresses per hour per authenticated user
Carl Byington <carl@five-ten-sg.com>
parents:
274
diff
changeset
|
1805 if (!tsa(tok, token_semi)) return false; |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1806 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1807 return tsa(tok, token_semi); |
136 | 1808 } |
1809 | |
1810 | |
1811 //////////////////////////////////////////////// | |
1812 // | |
94 | 1813 bool parse_context(TOKEN &tok, CONFIG &dc, CONTEXTP parent); |
1814 bool parse_context(TOKEN &tok, CONFIG &dc, CONTEXTP parent) { | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1815 const char *name = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1816 if (!tsa(tok, token_lbrace)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1817 CONTEXTP con = new CONTEXT(parent, name); |
94 | 1818 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1819 while (true) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1820 const char *have = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1821 if (!have) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1822 if (have == token_rbrace) break; // done |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1823 if (have == token_dnsbl) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1824 if (!parse_dnsbl(tok, dc, *con)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1825 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1826 else if (have == token_dnsbll) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1827 if (!parse_dnsbll(tok, dc, *con)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1828 } |
249 | 1829 else if (have == token_dnswl) { |
1830 if (!parse_dnswl(tok, dc, *con)) return false; | |
1831 } | |
1832 else if (have == token_dnswll) { | |
1833 if (!parse_dnswll(tok, dc, *con)) return false; | |
1834 } | |
268
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1835 else if (have == token_requirerdns) { |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1836 if (!parse_requirerdns(tok, dc, *con)) return false; |
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1837 } |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1838 else if (have == token_content) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1839 if (!parse_content(tok, dc, *con)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1840 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1841 else if (have == token_envto) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1842 if (!parse_envto(tok, dc, *con)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1843 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1844 else if (have == token_verify) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1845 if (!parse_verify(tok, dc, *con)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1846 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1847 else if (have == token_generic) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1848 if (!parse_generic(tok, dc, *con)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1849 } |
233
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1850 else if (have == token_white_regex) { |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1851 if (!parse_white(tok, dc, *con)) return false; |
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1852 } |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1853 else if (have == token_autowhite) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1854 if (!parse_autowhite(tok, dc, *con)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1855 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1856 else if (have == token_envfrom) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1857 if (!parse_envfrom(tok, dc, *con)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1858 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1859 else if (have == token_rate) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1860 if (parent || dc.default_context) tok.token_error("rate limit ignored in non default context"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1861 if (!parse_rate(tok, dc, *con)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1862 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1863 else if (have == token_context) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1864 if (!parse_context(tok, dc, con)) return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1865 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1866 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1867 tok.token_error("context keyword", have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1868 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1869 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1870 } |
94 | 1871 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1872 if (!tsa(tok, token_semi)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1873 delete con; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1874 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1875 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1876 dc.add_context(con); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1877 if (parent) parent->add_context(con); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1878 return true; |
94 | 1879 } |
1880 | |
1881 | |
1882 //////////////////////////////////////////////// | |
1883 // parse a config file | |
1884 // | |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1885 bool load_conf(CONFIG &dc, const char *fn) { |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1886 int count = 0; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1887 TOKEN tok(fn, &dc.config_files); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1888 while (true) { |
214
82886d4dd71f
Fixes to compile on Fedora 9 and for const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
211
diff
changeset
|
1889 const char *have = tok.next(); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1890 if (!have) break; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1891 if (have == token_context) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1892 if (!parse_context(tok, dc, NULL)) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1893 tok.token_error("load_conf() failed to parse context"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1894 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1895 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1896 else count++; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1897 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1898 else { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1899 tok.token_error(token_context, have); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1900 return false; |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1901 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1902 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1903 tok.token_error("load_conf() found %d contexts in %s", count, fn); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1904 return (dc.default_context) ? true : false; |
94 | 1905 } |
1906 | |
1907 | |
1908 //////////////////////////////////////////////// | |
1909 // init the tokens | |
1910 // | |
1911 void token_init() { | |
270
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1912 token_asterisk = register_string("*"); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1913 token_autowhite = register_string("autowhite"); |
270
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1914 token_bang = register_string("!"); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1915 token_black = register_string("black"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1916 token_content = register_string("content"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1917 token_context = register_string("context"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1918 token_dccbulk = register_string("dcc_bulk_threshold"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1919 token_dccfrom = register_string("dcc_from"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1920 token_dccgrey = register_string("dcc_greylist"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1921 token_dccto = register_string("dcc_to"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1922 token_default = register_string("default"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1923 token_dnsbl = register_string("dnsbl"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1924 token_dnsbll = register_string("dnsbl_list"); |
249 | 1925 token_dnswl = register_string("dnswl"); |
1926 token_dnswll = register_string("dnswl_list"); | |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1927 token_envfrom = register_string("env_from"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1928 token_envto = register_string("env_to"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1929 token_filter = register_string("filter"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1930 token_generic = register_string("generic"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1931 token_host_limit = register_string("host_limit"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1932 token_html_limit = register_string("html_limit"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1933 token_html_tags = register_string("html_tags"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1934 token_ignore = register_string("ignore"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1935 token_include = register_string("include"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1936 token_inherit = register_string("inherit"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1937 token_lbrace = register_string("{"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1938 token_mailhost = register_string("mail_host"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1939 token_many = register_string("many"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1940 token_no = register_string("no"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1941 token_off = register_string("off"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1942 token_ok = register_string("ok"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1943 token_ok2 = register_string("ok2"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1944 token_on = register_string("on"); |
270
f92f24950bd3
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
268
diff
changeset
|
1945 token_period = register_string("."); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1946 token_rate = register_string("rate_limit"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1947 token_rbrace = register_string("}"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1948 token_require = register_string("require_match"); |
268
f941563c2a95
Add require_rdns checking
Carl Byington <carl@five-ten-sg.com>
parents:
266
diff
changeset
|
1949 token_requirerdns = register_string("require_rdns"); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1950 token_semi = register_string(";"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1951 token_soft = register_string("soft"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1952 token_spamassassin = register_string("spamassassin"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1953 token_substitute = register_string("substitute"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1954 token_tld = register_string("tld"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1955 token_unknown = register_string("unknown"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1956 token_uribl = register_string("uribl"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1957 token_verify = register_string("verify"); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1958 token_white = register_string("white"); |
233
5c3e9bf45bb5
Add whitelisting by regex expression filtering.
Carl Byington <carl@five-ten-sg.com>
parents:
214
diff
changeset
|
1959 token_white_regex = register_string("white_regex"); |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1960 token_yes = register_string("yes"); |
94 | 1961 |
192
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1962 if (gethostname(myhostname, HOST_NAME_MAX+1) != 0) { |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1963 strncpy(myhostname, "localhost", HOST_NAME_MAX+1); |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1964 } |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1965 myhostname[HOST_NAME_MAX] = '\0'; // ensure null termination |
8f4a9a37d4d9
delay autowhitelisting to avoid out of office reply bots
carl
parents:
180
diff
changeset
|
1966 token_myhostname = register_string(myhostname); |
94 | 1967 } |