annotate src/context.cpp @ 93:591edabaf196

new tlds, add verify example in sample conf file
author carl
date Wed, 21 Sep 2005 12:24:44 -0700
parents 505e77188317
children e107ade3b1c0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
88
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1 /*
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
2
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
3 Copyright (c) 2004 Carl Byington - 510 Software Group, released under
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
4 the GPL version 2 or any later version at your choice available at
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
5 http://www.fsf.org/licenses/gpl.txt
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
6
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
7 */
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
8
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
9 #include "includes.h"
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
10
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
11 // needed for socket io
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
12 #include <sys/ioctl.h>
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
13 #include <net/if.h>
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
14 #include <arpa/inet.h>
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
15 #include <netinet/in.h>
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
16 #include <netinet/tcp.h>
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
17 #include <netdb.h>
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
18 #include <sys/socket.h>
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
19 #include <sys/un.h>
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
20
88
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
21 static char* context_version="$Id$";
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
22
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
23 char *token_black;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
24 char *token_content;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
25 char *token_context;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
26 char *token_dccfrom;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
27 char *token_dccto;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
28 char *token_default;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
29 char *token_dnsbl;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
30 char *token_dnsbll;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
31 char *token_envfrom;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
32 char *token_envto;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
33 char *token_filter;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
34 char *token_host_limit;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
35 char *token_html_limit;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
36 char *token_html_tags;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
37 char *token_ignore;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
38 char *token_include;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
39 char *token_inherit;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
40 char *token_lbrace;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
41 char *token_mailhost;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
42 char *token_many;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
43 char *token_off;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
44 char *token_ok2;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
45 char *token_ok;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
46 char *token_on;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
47 char *token_rbrace;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
48 char *token_semi;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
49 char *token_soft;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
50 char *token_substitute;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
51 char *token_tld;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
52 char *token_unknown;
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
53 char *token_verify;
88
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
54 char *token_white;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
55
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
56 char *token_myhostname;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
57 char myhostname[HOST_NAME_MAX+1];
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
58
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
59 verify_map verifiers;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
60 string_set all_strings; // owns all the strings, only modified by the config loader thread
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
61 const int maxlen = 1000; // used for snprintf buffers
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
62 const int maxage = 120; // smtp verify sockets older than this are ancient
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
63 extern int NULL_SOCKET;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
64 extern time_t ERROR_SOCKET_TIME; // number of seconds between attempts to open a socket an smtp host for address verification
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
65
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
66
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
67 int SMTP::writer() {
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
68 #ifdef VERIFY_DEBUG
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
69 log("writer() sees buffer with %s", buffer);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
70 log("writer() sees error %d", (int)error);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
71 #endif
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
72 int rs = 0;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
73 if (!error) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
74 int len = strlen(buffer);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
75 while (rs < len) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
76 int ws = write(fd, buffer+rs, len-rs);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
77 if (ws > 0) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
78 rs += ws;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
79 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
80 else {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
81 // peer closed the socket!
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
82 rs = 0;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
83 error = true;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
84 break;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
85 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
86 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
87 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
88 return rs;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
89 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
91
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
92 int SMTP::reader() {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
93 // read some bytes terminated by lf or end of buffer.
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
94 // we may have a multi line response or part thereof in the buffer.
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
95 #ifdef VERIFY_DEBUG
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
96 log("reader() sees error %d", (int)error);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
97 #endif
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
98 if (error) return 0;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
99 int len = maxlen-1; // room for null terminator
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
100 while (pending < len) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
101 int ws = read(fd, buffer+pending, len-pending);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
102 if (ws > 0) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
103 pending += ws;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
104 if (buffer[pending-1] == '\n') break;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
105 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
106 else {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
107 // peer closed the socket!
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
108 pending = 0;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
109 error = true;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
110 break;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
111 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
112 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
113 buffer[pending] = '\0';
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
114 #ifdef VERIFY_DEBUG
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
115 log("reader() sees buffer with %s", buffer);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
116 #endif
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
117 return pending;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
118 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
119
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
120
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
121 int SMTP::read_line() {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
122 char *lf = strchr(buffer, '\n');
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
123 if (!lf) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
124 reader(); // get a lf
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
125 lf = strchr(buffer, '\n');
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
126 if (!lf) lf = buffer + pending - 1;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
127 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
128 return (lf-buffer)+1; // number of bytes in this line
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
129 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
130
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
131
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
132 int SMTP::flush_line(int r) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
133 if (pending > r) memmove(buffer, buffer+r, pending-r);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
134 pending -= r;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
135 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
136
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
137
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
138 int SMTP::read_response() {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
139 pending = 0;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
140 buffer[pending] = '\0';
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
141 while (true) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
142 int r = read_line();
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
143 #ifdef VERIFY_DEBUG
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
144 log("read_response() sees line with %s", buffer);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
145 log("read_response() sees line length %d", r);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
146 #endif
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
147 if (r == 0) return 0; // failed to read any bytes
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
148 if ((r > 4) && (buffer[3] == '-')) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
149 flush_line(r);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
150 continue;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
151 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
152 return atoi(buffer);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
153 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
154 return 0;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
155 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
156
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
157
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
158 int SMTP::cmd(char *c) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
159 if (c) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
160 init();
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
161 append(c);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
162 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
163 append("\r\n");
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
164 writer();
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
165 return read_response();
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
166 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
167
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
168
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
169 int SMTP::helo() {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
170 if (read_response() != 220) return 0;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
171 init();
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
172 append("HELO ");
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
173 append(token_myhostname);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
174 return cmd(NULL);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
175 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
176
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
177
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
178 int SMTP::rset() {
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
179 int rc = cmd("RSET");
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
180 efrom[0] = '\0';
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
181 return rc;
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
182 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
183
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
184
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
185 int SMTP::from(char *f) {
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
186 if (strncmp(efrom, f, maxlen)) {
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
187 rset();
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
188 strncpy(efrom, f, maxlen);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
189 init();
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
190 append("MAIL FROM:<");
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
191 append(f);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
192 append(">");
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
193 return cmd(NULL);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
194 }
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
195 return 250; // pretend it worked
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
196 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
197
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
198
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
199 int SMTP::rcpt(char *t) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
200 init();
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
201 append("RCPT TO:<");
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
202 append(t);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
203 append(">");
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
204 return cmd(NULL);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
205 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
206
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
207
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
208 int SMTP::quit() {
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
209 return cmd("QUIT");
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
210 }
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
211
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
212
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
213 void SMTP::closefd() {
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
214 shutdown(fd, SHUT_RDWR);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
215 close(fd);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
216 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
217
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
218
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
219 #ifdef VERIFY_DEBUG
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
220 void SMTP::log(char *m, int v) {
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
221 char buf[maxlen];
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
222 snprintf(buf, maxlen, m, v);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
223 my_syslog(buf);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
224 }
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
225
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
226
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
227 void SMTP::log(char *m, char *v) {
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
228 char buf[maxlen];
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
229 snprintf(buf, maxlen, m, v);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
230 my_syslog(buf);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
231 }
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
232 #endif
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
233
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
234
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
235 VERIFY::VERIFY(char *h) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
236 host = h;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
237 last_err = 0;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
238 pthread_mutex_init(&mutex, 0);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
239 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
240
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
241
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
242 void VERIFY::closer() {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
243 bool ok = true;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
244 while (ok) {
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
245 SMTP *conn = NULL;
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
246 pthread_mutex_lock(&mutex);
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
247 if (connections.empty()) {
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
248 ok = false;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
249 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
250 else {
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
251 conn = connections.front();
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
252 time_t now = time(NULL);
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
253 if ((now - conn->get_stamp()) > maxage) {
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
254 // this connection is ancient, remove it
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
255 connections.pop_front();
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
256 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
257 else {
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
258 ok = false;
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
259 conn = NULL;
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
260 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
261 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
262 pthread_mutex_unlock(&mutex);
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
263 // avoid doing this work inside the mutex lock
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
264 if (conn) {
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
265 #ifdef VERIFY_DEBUG
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
266 conn->log("closer() closes ancient %d", conn->get_fd());
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
267 #endif
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
268 delete conn;
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
269 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
270 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
271 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
272
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
273
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
274 SMTP* VERIFY::get_connection() {
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
275 SMTP *conn = NULL;
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
276 pthread_mutex_lock(&mutex);
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
277 if (!connections.empty()) {
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
278 conn = connections.front();
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
279 connections.pop_front();
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
280 #ifdef VERIFY_DEBUG
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
281 conn->log("get_connection() %d from cache", conn->get_fd());
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
282 #endif
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
283 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
284 pthread_mutex_unlock(&mutex);
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
285 if (conn) return conn;
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
286 time_t now = time(NULL);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
287 int sock = NULL_SOCKET;
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
288 if ((now - last_err) > ERROR_SOCKET_TIME) {
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
289 // nothing recent, maybe this time it will work
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
290 hostent *h = gethostbyname(host);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
291 if (h) {
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
292 sockaddr_in server;
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
293 server.sin_family = h->h_addrtype;
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
294 server.sin_port = htons(25);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
295 memcpy(&server.sin_addr, h->h_addr_list[0], h->h_length);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
296 sock = socket(PF_INET, SOCK_STREAM, 0);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
297 if (sock != NULL_SOCKET) {
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
298 bool rc = (connect(sock, (sockaddr *)&server, sizeof(server)) == 0);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
299 if (!rc) {
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
300 shutdown(sock, SHUT_RDWR);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
301 close(sock);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
302 sock = NULL_SOCKET;
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
303 last_err = now;
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
304 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
305 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
306 else last_err = now;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
307 }
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
308 else last_err = now;
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
309 }
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
310 if (sock != NULL_SOCKET) {
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
311 conn = new SMTP(sock);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
312 #ifdef VERIFY_DEBUG
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
313 conn->log("get_connection() %d new socket", conn->get_fd());
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
314 #endif
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
315 if (conn->helo() == 250) return conn;
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
316 delete conn;
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
317 }
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
318 return NULL;
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
319 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
320
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
321
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
322 void VERIFY::put_connection(SMTP *conn) {
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
323 if (conn->err()) {
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
324 #ifdef VERIFY_DEBUG
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
325 conn->log("put_socket() %d with error, close it", conn->get_fd());
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
326 #endif
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
327 delete conn;
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
328 last_err = time(NULL);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
329 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
330 else {
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
331 #ifdef VERIFY_DEBUG
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
332 conn->log("put_socket() %d", conn->get_fd());
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
333 #endif
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
334 conn->now();
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
335 pthread_mutex_lock(&mutex);
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
336 connections.push_back(conn);
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
337 pthread_mutex_unlock(&mutex);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
338 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
339 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
340
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
341
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
342 bool VERIFY::ok(char *from, char *to) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
343 if (host == token_myhostname) return true;
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
344 SMTP *conn = get_connection();
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
345 if (!conn) return true; // cannot verify right now, we have socket errors
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
346 int rc;
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
347 rc = conn->from(from);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
348 #ifdef VERIFY_DEBUG
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
349 conn->log("verify::ok() from sees %d", rc);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
350 #endif
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
351 if (rc != 250) {
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
352 conn->rset();
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
353 put_connection(conn);
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
354 return (rc >= 500) ? false : true;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
355 }
92
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
356 rc = conn->rcpt(to);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
357 #ifdef VERIFY_DEBUG
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
358 conn->log("verify::ok() rcpt sees %d", rc);
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
359 #endif
505e77188317 optimize verification step, cleanup documentation
carl
parents: 91
diff changeset
360 put_connection(conn);
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
361 return (rc >= 500) ? false : true;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
362 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
363
88
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
364
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
365 DNSBL::DNSBL(char *n, char *s, char *m) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
366 name = n;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
367 suffix = s;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
368 message = m;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
369 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
370
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
371
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
372 bool DNSBL::operator==(const DNSBL &rhs) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
373 return (strcmp(name, rhs.name) == 0) &&
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
374 (strcmp(suffix, rhs.suffix) == 0) &&
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
375 (strcmp(message, rhs.message) == 0);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
376 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
377
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
378
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
379 CONFIG::CONFIG() {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
380 reference_count = 0;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
381 generation = 0;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
382 load_time = 0;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
383 default_context = NULL;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
384 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
385
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
386
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
387 CONFIG::~CONFIG() {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
388 for (context_list::iterator i=contexts.begin(); i!=contexts.end(); i++) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
389 CONTEXT *c = *i;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
390 delete c;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
391 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
392 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
393
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
394
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
395 void CONFIG::add_context(CONTEXTP con) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
396 contexts.push_back(con);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
397 if (!default_context && !con->get_parent()) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
398 // first global context
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
399 default_context = con;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
400 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
401 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
402
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
403
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
404 void CONFIG::add_to(char *to, CONTEXTP con) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
405 context_map::iterator i = env_to.find(to);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
406 if (i != env_to.end()) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
407 CONTEXTP c = (*i).second;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
408 int s = strlen(to);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
409 bool at = s && (to[s-1] == '@');
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
410 if (at && con->is_parent(c->get_parent())) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
411 if (debug_syslog) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
412 char oldname[maxlen];
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
413 char newname[maxlen];
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
414 char *oldn = c->get_full_name(oldname, maxlen);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
415 char *newn = con->get_full_name(newname, maxlen);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
416 char buf[maxlen*3];
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
417 snprintf(buf, maxlen*3, "both %s and %s claim envelope to %s, the first one wins", oldn, newn, to);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
418 my_syslog(buf);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
419 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
420 return; // don't take over user@ entries from your ancestors children
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
421 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
422 if ((c != con) && (c != con->get_parent())) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
423 if (debug_syslog) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
424 char oldname[maxlen];
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
425 char newname[maxlen];
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
426 char *oldn = c->get_full_name(oldname, maxlen);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
427 char *newn = con->get_full_name(newname, maxlen);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
428 char buf[maxlen*3];
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
429 snprintf(buf, maxlen*3, "both %s and %s claim envelope to %s, the second one wins", oldn, newn, to);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
430 my_syslog(buf);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
431 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
432 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
433 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
434 env_to[to] = con;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
435 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
436
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
437
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
438 CONTEXTP CONFIG::find_context(char *to) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
439 context_map::iterator i = env_to.find(to);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
440 if (i != env_to.end()) return (*i).second; // found user@domain.tld key
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
441 char *x = strchr(to, '@');
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
442 if (x) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
443 x++;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
444 i = env_to.find(x);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
445 if (i != env_to.end()) return (*i).second; // found domain.tld key
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
446 char y = *x;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
447 *x = '\0';
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
448 i = env_to.find(to);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
449 *x = y;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
450 if (i != env_to.end()) return (*i).second; // found user@ key
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
451 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
452 return default_context;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
453 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
454
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
455
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
456 void CONFIG::dump() {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
457 if (default_context) default_context->dump();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
458 for (context_list::iterator i=contexts.begin(); i!=contexts.end(); i++) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
459 CONTEXTP c = *i;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
460 CONTEXTP p = c->get_parent();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
461 if (!p && (c != default_context)) c->dump();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
462 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
463 char buf[maxlen];
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
464 for (context_map::iterator i=env_to.begin(); i!=env_to.end(); i++) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
465 char *to = (*i).first;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
466 CONTEXTP con = (*i).second;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
467 printf("// envelope to %s \t-> context %s \n", to, con->get_full_name(buf,maxlen));
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
468 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
469 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
470
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
471
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
472 CONTEXT::CONTEXT(CONTEXTP parent_, char *name_) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
473 parent = parent_;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
474 name = name_;
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
475 verify_host = NULL;
88
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
476 env_from_default = (parent) ? token_inherit : token_unknown;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
477 content_filtering = (parent) ? parent->content_filtering : false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
478 content_suffix = NULL;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
479 content_message = NULL;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
480 host_limit = (parent) ? parent->host_limit : 0;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
481 host_limit_message = NULL;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
482 host_random = (parent) ? parent->host_random : false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
483 tag_limit = (parent) ? parent->tag_limit : 0;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
484 tag_limit_message = NULL;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
485 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
486
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
487
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
488 CONTEXT::~CONTEXT() {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
489 for (dnsblp_map::iterator i=dnsbl_names.begin(); i!=dnsbl_names.end(); i++) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
490 DNSBLP d = (*i).second;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
491 // delete the underlying DNSBL objects.
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
492 delete d;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
493 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
494 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
495
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
496
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
497 bool CONTEXT::is_parent(CONTEXTP p) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
498 if (p == parent) return true;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
499 if (!parent) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
500 return parent->is_parent(p);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
501 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
502
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
503
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
504 char *CONTEXT::get_full_name(char *buffer, int size) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
505 if (!parent) return name;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
506 char buf[maxlen];
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
507 snprintf(buffer, size, "%s.%s", parent->get_full_name(buf, maxlen), name);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
508 return buffer;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
509 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
510
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
511
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
512 bool CONTEXT::cover_env_to(char *to) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
513 char buffer[maxlen];
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
514 char *x = strchr(to, '@');
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
515 if (x) x++;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
516 else x = to;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
517 if (*x == '\0') return true; // always allow covering addresses with no domain name, eg abuse@
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
518 string_set::iterator i = env_to.find(x);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
519 if (i != env_to.end()) return true;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
520 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
521 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
522
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
523
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
524 VERIFYP CONTEXT::find_verify(char *to) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
525 if (verify_host && (verify_host != token_myhostname) && cover_env_to(to)) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
526 verify_map::iterator i = verifiers.find(verify_host);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
527 if (i == verifiers.end()) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
528 if (debug_syslog) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
529 char buf[maxlen];
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
530 snprintf(buf, maxlen, "cannot find struc for %s", verify_host);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
531 my_syslog(buf);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
532 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
533 return NULL;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
534 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
535 VERIFYP v = (*i).second;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
536
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
537 return v;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
538 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
539 else if (parent) return parent->find_verify(to);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
540 else return NULL;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
541 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
542
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
543
88
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
544 char *CONTEXT::find_from(char *from) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
545 char *rc = token_inherit;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
546 string_map::iterator i = env_from.find(from);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
547 if (i != env_from.end()) rc = (*i).second; // found user@domain.tld key
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
548 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
549 char *x = strchr(from, '@');
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
550 if (x) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
551 x++;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
552 i = env_from.find(x);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
553 if (i != env_from.end()) rc = (*i).second; // found domain.tld key
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
554 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
555 char y = *x;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
556 *x = '\0';
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
557 i = env_from.find(from);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
558 *x = y;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
559 if (i != env_from.end()) rc = (*i).second; // found user@ key
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
560 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
561 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
562 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
563 if (rc == token_inherit) rc = env_from_default;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
564 if ((rc == token_inherit) && parent) return parent->find_from(from);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
565 return (rc == token_inherit) ? token_unknown : rc;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
566 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
567
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
568
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
569 CONTEXTP CONTEXT::find_context(char *from) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
570 context_map::iterator i = env_from_context.find(from);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
571 if (i != env_from_context.end()) return (*i).second; // found user@domain.tld key
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
572 char *x = strchr(from, '@');
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
573 if (x) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
574 x++;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
575 i = env_from_context.find(x);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
576 if (i != env_from_context.end()) return (*i).second; // found domain.tld key
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
577 char y = *x;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
578 *x = '\0';
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
579 i = env_from_context.find(from);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
580 *x = y;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
581 if (i != env_from_context.end()) return (*i).second; // found user@ key
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
582 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
583 return this;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
584 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
585
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
586
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
587 CONTEXTP CONTEXT::find_from_context_name(char *name) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
588 context_map::iterator i = children.find(name);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
589 if (i != children.end()) return (*i).second;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
590 return NULL;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
591 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
592
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
593
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
594 DNSBLP CONTEXT::find_dnsbl(char *name) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
595 dnsblp_map::iterator i = dnsbl_names.find(name);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
596 if (i != dnsbl_names.end()) return (*i).second;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
597 if (parent) return parent->find_dnsbl(name);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
598 return NULL;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
599 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
600
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
601
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
602 char* CONTEXT::get_content_suffix() {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
603 if (!content_suffix && parent) return parent->get_content_suffix();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
604 return content_suffix;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
605 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
606
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
607
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
608 char* CONTEXT::get_content_message() {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
609 if (!content_message && parent) return parent->get_content_message();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
610 return content_message;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
611 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
612
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
613
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
614 string_set& CONTEXT::get_content_host_ignore() {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
615 if (content_host_ignore.empty() && parent) return parent->get_content_host_ignore();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
616 return content_host_ignore;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
617 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
618
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
619
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
620 string_set& CONTEXT::get_content_tlds() {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
621 if (content_tlds.empty() && parent) return parent->get_content_tlds();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
622 return content_tlds;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
623 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
624
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
625
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
626 string_set& CONTEXT::get_html_tags() {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
627 if (html_tags.empty() && parent) return parent->get_html_tags();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
628 return html_tags;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
629 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
630
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
631
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
632 dnsblp_list& CONTEXT::get_dnsbl_list() {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
633 if (dnsbl_list.empty() && parent) return parent->get_dnsbl_list();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
634 return dnsbl_list;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
635 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
636
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
637
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
638 bool CONTEXT::acceptable_content(recorder &memory, char *&msg) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
639 if (memory.excessive_bad_tags(tag_limit)) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
640 msg = tag_limit_message;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
641 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
642 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
643 if (!host_random && memory.excessive_hosts(host_limit)) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
644 msg = host_limit_message;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
645 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
646 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
647 return true;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
648 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
649
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
650
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
651 void CONTEXT::dump(int level) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
652 char indent[maxlen];
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
653 int i = min(maxlen-1, level*4);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
654 memset(indent, ' ', i);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
655 indent[i] = '\0';
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
656 char buf[maxlen];
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
657 char *fullname = get_full_name(buf,maxlen);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
658 printf("%s context %s { \t// %s\n", indent, name, fullname);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
659
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
660 for (dnsblp_map::iterator i=dnsbl_names.begin(); i!=dnsbl_names.end(); i++) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
661 char *n = (*i).first;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
662 DNSBL &d = *(*i).second;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
663 printf("%s dnsbl %s %s \"%s\"; \n", indent, n, d.suffix, d.message);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
664 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
665
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
666 if (!dnsbl_list.empty()) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
667 printf("%s dnsbl_list", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
668 for (dnsblp_list::iterator i=dnsbl_list.begin(); i!=dnsbl_list.end(); i++) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
669 DNSBL &d = *(*i);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
670 printf(" %s", d.name);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
671 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
672 printf("; \n");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
673 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
674
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
675 if (content_filtering) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
676 printf("%s content on { \n", indent, env_from_default);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
677 if (content_suffix) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
678 printf("%s filter %s \"%s\"; \n", indent, content_suffix, content_message);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
679 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
680 if (!content_host_ignore.empty()) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
681 printf("%s ignore { \n", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
682 for (string_set::iterator i=content_host_ignore.begin(); i!=content_host_ignore.end(); i++) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
683 printf("%s %s; \n", indent, *i);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
684 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
685 printf("%s }; \n", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
686 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
687 if (!content_tlds.empty()) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
688 printf("%s tld { \n", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
689 printf("%s ", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
690 for (string_set::iterator i=content_tlds.begin(); i!=content_tlds.end(); i++) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
691 printf("%s; ", *i);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
692 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
693 printf("\n%s }; \n", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
694 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
695 if (!html_tags.empty()) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
696 printf("%s html_tags { \n", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
697 printf("%s ", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
698 for (string_set::iterator i=html_tags.begin(); i!=html_tags.end(); i++) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
699 printf("%s; ", *i);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
700 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
701 printf("\n%s }; \n", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
702 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
703 if (host_limit_message) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
704 printf("%s host_limit on %d \"%s\"; \n", indent, host_limit, host_limit_message);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
705 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
706 else if (host_random) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
707 printf("%s host_limit soft %d; \n", indent, host_limit);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
708 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
709 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
710 printf("%s host_limit off; \n", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
711 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
712 if (tag_limit_message) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
713 printf("%s html_limit on %d \"%s\"; \n", indent, tag_limit, tag_limit_message);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
714 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
715 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
716 printf("%s html_limit off; \n", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
717 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
718 printf("%s }; \n", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
719 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
720 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
721 printf("%s content off {}; \n", indent, env_from_default);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
722 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
723
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
724 printf("%s env_to { \t// %s\n", indent, fullname);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
725 for (string_set::iterator i=env_to.begin(); i!=env_to.end(); i++) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
726 printf("%s %s; \n", indent, *i);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
727 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
728 printf("%s }; \n", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
729
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
730 if (verify_host) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
731 printf("%s verify %s; \n", indent, verify_host);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
732 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
733
88
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
734 for (context_map::iterator i=children.begin(); i!=children.end(); i++) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
735 CONTEXTP c = (*i).second;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
736 c->dump(level+1);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
737 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
738
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
739 printf("%s env_from %s { \t// %s\n", indent, env_from_default, fullname);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
740 if (!env_from.empty()) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
741 printf("%s // white/black/unknown \n", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
742 for (string_map::iterator i=env_from.begin(); i!=env_from.end(); i++) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
743 char *f = (*i).first;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
744 char *t = (*i).second;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
745 printf("%s %s \t%s; \n", indent, f, t);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
746 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
747 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
748 if (!env_from_context.empty()) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
749 printf("%s // child contexts \n", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
750 for (context_map::iterator j=env_from_context.begin(); j!=env_from_context.end(); j++) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
751 char *f = (*j).first;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
752 CONTEXTP t = (*j).second;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
753 printf("%s %s \t%s; \n", indent, f, t->name);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
754 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
755 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
756 printf("%s }; \n", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
757
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
758 printf("%s }; \n", indent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
759 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
760
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
761
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
762 ////////////////////////////////////////////////
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
763 // helper to discard the strings held by a string_set
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
764 //
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
765 void discard(string_set &s) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
766 for (string_set::iterator i=s.begin(); i!=s.end(); i++) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
767 free(*i);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
768 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
769 s.clear();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
770 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
771
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
772
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
773 ////////////////////////////////////////////////
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
774 // helper to register a string in a string set
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
775 //
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
776 char* register_string(string_set &s, char *name) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
777 string_set::iterator i = s.find(name);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
778 if (i != s.end()) return *i;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
779 char *x = strdup(name);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
780 s.insert(x);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
781 return x;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
782 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
783
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
784
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
785 ////////////////////////////////////////////////
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
786 // register a global string
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
787 //
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
788 char* register_string(char *name) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
789 return register_string(all_strings, name);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
790 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
791
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
792
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
793 ////////////////////////////////////////////////
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
794 //
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
795 bool tsa(TOKEN &tok, char *token);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
796 bool tsa(TOKEN &tok, char *token) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
797 char *have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
798 if (have == token) return true;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
799 tok.token_error(token, have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
800 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
801 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
802
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
803
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
804 ////////////////////////////////////////////////
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
805 //
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
806 bool parse_dnsbl(TOKEN &tok, CONFIG &dc, CONTEXT &me);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
807 bool parse_dnsbl(TOKEN &tok, CONFIG &dc, CONTEXT &me) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
808 char *name = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
809 char *suf = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
810 char *msg = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
811 if (!tsa(tok, token_semi)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
812 DNSBLP dnsnew = new DNSBL(name, suf, msg);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
813 DNSBLP dnsold = me.find_dnsbl(name);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
814 if (dnsold && (*dnsold == *dnsnew)) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
815 // duplicate redefinition, ignore it
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
816 delete dnsnew;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
817 return true;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
818 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
819 me.add_dnsbl(name, dnsnew);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
820 return true;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
821 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
822
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
823
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
824 ////////////////////////////////////////////////
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
825 //
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
826 bool parse_dnsbll(TOKEN &tok, CONFIG &dc, CONTEXT &me);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
827 bool parse_dnsbll(TOKEN &tok, CONFIG &dc, CONTEXT &me) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
828 while (true) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
829 char *have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
830 if (!have) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
831 if (have == token_semi) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
832 DNSBLP dns = me.find_dnsbl(have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
833 if (dns) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
834 me.add_dnsbl(dns);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
835 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
836 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
837 tok.token_error("dnsbl name", have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
838 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
839 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
840 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
841 return true;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
842 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
843
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
844
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
845 ////////////////////////////////////////////////
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
846 //
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
847 bool parse_content(TOKEN &tok, CONFIG &dc, CONTEXT &me);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
848 bool parse_content(TOKEN &tok, CONFIG &dc, CONTEXT &me) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
849 char *setting = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
850 if (setting == token_on) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
851 me.set_content_filtering(true);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
852 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
853 else if (setting == token_off) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
854 me.set_content_filtering(false);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
855 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
856 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
857 tok.token_error("on/off", setting);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
858 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
859 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
860 if (!tsa(tok, token_lbrace)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
861 while (true) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
862 char *have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
863 if (!have) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
864 if (have == token_filter) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
865 char *suffix = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
866 char *messag = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
867 me.set_content_suffix(suffix);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
868 me.set_content_message(messag);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
869 if (!tsa(tok, token_semi)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
870 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
871 else if (have == token_ignore) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
872 if (!tsa(tok, token_lbrace)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
873 while (true) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
874 if (!have) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
875 char *have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
876 if (have == token_rbrace) break; // done
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
877 me.add_ignore(have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
878 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
879 if (!tsa(tok, token_semi)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
880 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
881 else if (have == token_tld) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
882 if (!tsa(tok, token_lbrace)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
883 while (true) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
884 char *have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
885 if (!have) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
886 if (have == token_rbrace) break; // done
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
887 me.add_tld(have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
888 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
889 if (!tsa(tok, token_semi)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
890 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
891 else if (have == token_html_limit) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
892 have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
893 if (have == token_on) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
894 me.set_tag_limit(tok.nextint());
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
895 me.set_tag_message(tok.next());
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
896 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
897 else if (have == token_off) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
898 me.set_tag_limit(0);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
899 me.set_tag_message(NULL);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
900 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
901 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
902 tok.token_error("on/off", have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
903 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
904 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
905 if (!tsa(tok, token_semi)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
906 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
907 else if (have == token_html_tags) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
908 if (!tsa(tok, token_lbrace)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
909 while (true) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
910 char *have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
911 if (!have) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
912 if (have == token_rbrace) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
913 break; // done
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
914 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
915 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
916 me.add_tag(have); // base version
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
917 char buf[200];
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
918 snprintf(buf, sizeof(buf), "/%s", have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
919 me.add_tag(register_string(buf)); // leading /
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
920 snprintf(buf, sizeof(buf), "%s/", have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
921 me.add_tag(register_string(buf)); // trailing /
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
922 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
923 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
924 if (!tsa(tok, token_semi)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
925 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
926 else if (have == token_host_limit) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
927 have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
928 if (have == token_on) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
929 me.set_host_limit(tok.nextint());
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
930 me.set_host_message(tok.next());
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
931 me.set_host_random(false);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
932 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
933 else if (have == token_off) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
934 me.set_host_limit(0);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
935 me.set_host_message(NULL);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
936 me.set_host_random(false);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
937 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
938 else if (have == token_soft) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
939 me.set_host_limit(tok.nextint());
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
940 me.set_host_message(NULL);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
941 me.set_host_random(true);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
942 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
943 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
944 tok.token_error("on/off/soft", have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
945 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
946 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
947 if (!tsa(tok, token_semi)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
948 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
949 else if (have == token_rbrace) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
950 break; // done
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
951 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
952 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
953 tok.token_error("content keyword", have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
954 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
955 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
956 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
957 return tsa(tok, token_semi);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
958 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
959
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
960
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
961 ////////////////////////////////////////////////
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
962 //
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
963 bool parse_envto(TOKEN &tok, CONFIG &dc, CONTEXT &me);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
964 bool parse_envto(TOKEN &tok, CONFIG &dc, CONTEXT &me) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
965 if (!tsa(tok, token_lbrace)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
966 while (true) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
967 char *have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
968 if (!have) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
969 if (have == token_rbrace) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
970 if (have == token_semi) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
971 // optional separators
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
972 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
973 else if (have == token_dccto) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
974 char *flavor = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
975 if (!tsa(tok, token_lbrace)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
976 bool keeping = false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
977 while (true) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
978 char *have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
979 if (!have) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
980 if (have == token_rbrace) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
981 if (have == flavor) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
982 keeping = true;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
983 continue;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
984 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
985 else if ((have == token_ok) || (have == token_ok2) || (have == token_many)) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
986 keeping = false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
987 continue;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
988 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
989 if (have == token_envto) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
990 have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
991 if (keeping) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
992 if (me.allow_env_to(have)) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
993 me.add_to(have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
994 dc.add_to(have, &me);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
995 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
996 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
997 }
91
ca46fafc6621 dcc_to should not look at substitute mail_host
carl
parents: 90
diff changeset
998 //else if (have == token_substitute) {
ca46fafc6621 dcc_to should not look at substitute mail_host
carl
parents: 90
diff changeset
999 // if (tok.next() == token_mailhost) {
ca46fafc6621 dcc_to should not look at substitute mail_host
carl
parents: 90
diff changeset
1000 // have = tok.next();
ca46fafc6621 dcc_to should not look at substitute mail_host
carl
parents: 90
diff changeset
1001 // if (keeping) {
ca46fafc6621 dcc_to should not look at substitute mail_host
carl
parents: 90
diff changeset
1002 // if (me.allow_env_to(have)) {
ca46fafc6621 dcc_to should not look at substitute mail_host
carl
parents: 90
diff changeset
1003 // me.add_to(have);
ca46fafc6621 dcc_to should not look at substitute mail_host
carl
parents: 90
diff changeset
1004 // dc.add_to(have, &me);
ca46fafc6621 dcc_to should not look at substitute mail_host
carl
parents: 90
diff changeset
1005 // }
ca46fafc6621 dcc_to should not look at substitute mail_host
carl
parents: 90
diff changeset
1006 // }
ca46fafc6621 dcc_to should not look at substitute mail_host
carl
parents: 90
diff changeset
1007 // }
ca46fafc6621 dcc_to should not look at substitute mail_host
carl
parents: 90
diff changeset
1008 //}
88
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1009 tok.skipeol();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1010 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1011 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1012 else if (me.allow_env_to(have)) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1013 me.add_to(have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1014 dc.add_to(have, &me);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1015 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1016 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1017 tok.token_error("user@ or user@domain.tld or domain.tld where domain.tld allowed by parent context", have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1018 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1019 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1020 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1021 return tsa(tok, token_semi);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1022 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1023
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1024
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1025 ////////////////////////////////////////////////
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1026 //
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1027 bool parse_verify(TOKEN &tok, CONFIG &dc, CONTEXT &me);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1028 bool parse_verify(TOKEN &tok, CONFIG &dc, CONTEXT &me) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1029 char *host = tok.next();
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1030 if (!tsa(tok, token_semi)) return false;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1031 me.set_verify(host);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1032 add_verify_host(host);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1033 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1034
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1035
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1036 ////////////////////////////////////////////////
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1037 //
88
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1038 bool parse_envfrom(TOKEN &tok, CONFIG &dc, CONTEXT &me);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1039 bool parse_envfrom(TOKEN &tok, CONFIG &dc, CONTEXT &me) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1040 char *st = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1041 if ((st == token_black) || (st == token_white) || (st == token_unknown) || (st == token_inherit)) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1042 me.set_from_default(st);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1043 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1044 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1045 tok.push(st);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1046 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1047 if (!tsa(tok, token_lbrace)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1048 while (true) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1049 char *have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1050 if (!have) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1051 if (have == token_rbrace) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1052 if (have == token_semi) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1053 // optional separators
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1054 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1055 else if (have == token_dccfrom) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1056 if (!tsa(tok, token_lbrace)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1057 bool keeping = false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1058 bool many = false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1059 while (true) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1060 char *have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1061 if (!have) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1062 if (have == token_rbrace) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1063 if (have == token_ok) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1064 keeping = true;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1065 many = false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1066 continue;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1067 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1068 else if (have == token_many) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1069 keeping = true;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1070 many = true;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1071 continue;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1072 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1073 else if (have == token_ok2) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1074 keeping = false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1075 continue;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1076 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1077 if (have == token_envfrom) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1078 have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1079 if (keeping) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1080 me.add_from(have, (many) ? token_black : token_white);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1081 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1082 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1083 else if (have == token_substitute) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1084 if (tok.next() == token_mailhost) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1085 have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1086 me.add_from(have, (many) ? token_black : token_white);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1087 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1088 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1089 tok.skipeol();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1090 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1091 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1092 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1093 // may be a valid email address or domain name
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1094 char *st = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1095 if ((st == token_black) || (st == token_white) || (st == token_unknown)) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1096 me.add_from(have, st);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1097 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1098 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1099 CONTEXTP con = me.find_from_context_name(st);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1100 if (con) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1101 me.add_from_context(have, con);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1102 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1103 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1104 tok.token_error("white/black/unknown or child context name", st);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1105 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1106 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1107 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1108 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1109 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1110 return tsa(tok, token_semi);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1111 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1112
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1113
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1114 ////////////////////////////////////////////////
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1115 //
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1116 bool parse_context(TOKEN &tok, CONFIG &dc, CONTEXTP parent);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1117 bool parse_context(TOKEN &tok, CONFIG &dc, CONTEXTP parent) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1118 char *name = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1119 if (!tsa(tok, token_lbrace)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1120 CONTEXTP con = new CONTEXT(parent, name);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1121
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1122 while (true) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1123 char *have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1124 if (!have) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1125 if (have == token_rbrace) break; // done
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1126 if (have == token_dnsbl) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1127 if (!parse_dnsbl(tok, dc, *con)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1128 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1129 else if (have == token_dnsbll) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1130 if (!parse_dnsbll(tok, dc, *con)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1131 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1132 else if (have == token_content) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1133 if (!parse_content(tok, dc, *con)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1134 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1135 else if (have == token_envto) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1136 if (!parse_envto(tok, dc, *con)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1137 }
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1138 else if (have == token_verify) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1139 if (!parse_verify(tok, dc, *con)) return false;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1140 }
88
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1141 else if (have == token_envfrom) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1142 if (!parse_envfrom(tok, dc, *con)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1143 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1144 else if (have == token_context) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1145 if (!parse_context(tok, dc, con)) return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1146 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1147 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1148 tok.token_error("context keyword", have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1149 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1150 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1151 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1152
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1153 if (!tsa(tok, token_semi)) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1154 delete con;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1155 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1156 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1157 dc.add_context(con);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1158 if (parent) parent->add_context(con);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1159 return true;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1160 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1161
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1162
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1163 ////////////////////////////////////////////////
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1164 // parse a config file
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1165 //
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1166 bool load_conf(CONFIG &dc, char *fn) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1167 TOKEN tok(fn, &dc.config_files);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1168 while (true) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1169 char *have = tok.next();
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1170 if (!have) break;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1171 if (have == token_context) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1172 if (!parse_context(tok, dc, NULL)) {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1173 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1174 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1175 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1176 else {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1177 tok.token_error(token_context, have);
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1178 return false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1179 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1180 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1181 return (dc.default_context) ? true : false;
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1182 }
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1183
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1184
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1185 ////////////////////////////////////////////////
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1186 // setup a new smtp verify host
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1187 //
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1188 void add_verify_host(char *host) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1189 verify_map::iterator i = verifiers.find(host);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1190 if (i == verifiers.end()) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1191 VERIFYP v = new VERIFY(host);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1192 verifiers[host] = v;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1193 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1194 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1195
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1196
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1197 ////////////////////////////////////////////////
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1198 // thread to check for verify hosts with old sockets that we can close
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1199 //
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1200 void* verify_closer(void *arg) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1201 while (true) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1202 sleep(maxage);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1203 for (verify_map::iterator i=verifiers.begin(); i!=verifiers.end(); i++) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1204 VERIFYP v = (*i).second;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1205 v->closer();
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1206 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1207 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1208 return NULL;
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1209 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1210
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1211
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1212 ////////////////////////////////////////////////
88
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1213 // init the tokens
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1214 //
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1215 void token_init() {
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1216 token_black = register_string("black");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1217 token_content = register_string("content");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1218 token_context = register_string("context");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1219 token_dccfrom = register_string("dcc_from");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1220 token_dccto = register_string("dcc_to");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1221 token_default = register_string("default");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1222 token_dnsbl = register_string("dnsbl");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1223 token_dnsbll = register_string("dnsbl_list");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1224 token_envfrom = register_string("env_from");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1225 token_envto = register_string("env_to");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1226 token_filter = register_string("filter");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1227 token_host_limit = register_string("host_limit");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1228 token_html_limit = register_string("html_limit");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1229 token_html_tags = register_string("html_tags");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1230 token_ignore = register_string("ignore");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1231 token_include = register_string("include");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1232 token_inherit = register_string("inherit");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1233 token_lbrace = register_string("{");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1234 token_mailhost = register_string("mail_host");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1235 token_many = register_string("many");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1236 token_off = register_string("off");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1237 token_ok = register_string("ok");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1238 token_ok2 = register_string("ok2");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1239 token_on = register_string("on");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1240 token_rbrace = register_string("}");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1241 token_semi = register_string(";");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1242 token_soft = register_string("soft");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1243 token_substitute = register_string("substitute");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1244 token_tld = register_string("tld");
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1245 token_unknown = register_string("unknown");
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1246 token_verify = register_string("verify");
88
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1247 token_white = register_string("white");
90
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1248
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1249 if (gethostname(myhostname, HOST_NAME_MAX+1) != 0) {
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1250 strncpy(myhostname, "localhost", HOST_NAME_MAX+1);
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1251 }
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1252 myhostname[HOST_NAME_MAX] = '\0'; // ensure null termination
962a1f8f1d9f add verify statement to verify addresses with better mx host
carl
parents: 88
diff changeset
1253 token_myhostname = register_string(myhostname);
88
7245c45cef7a fix for missing default return value in CONTEXT::acceptable_content()
carl
parents: 86
diff changeset
1254 }