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