annotate src/context.cpp @ 90:962a1f8f1d9f stable-5-4

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