Mercurial > dnsbl
comparison src/spamass.cpp.in @ 214:82886d4dd71f stable-6-0-19
Fixes to compile on Fedora 9 and for const correctness.
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 10 Jun 2008 08:58:42 -0700 |
parents | 92a5c866bdfa |
children | 3fee608becbc |
comparison
equal
deleted
inserted
replaced
213:44ffef730bc4 | 214:82886d4dd71f |
---|---|
17 #include <sys/types.h> | 17 #include <sys/types.h> |
18 #include <sys/wait.h> | 18 #include <sys/wait.h> |
19 #include <unistd.h> | 19 #include <unistd.h> |
20 | 20 |
21 | 21 |
22 char *spamc = "@SPAMC@"; | 22 const char *spamc = "@SPAMC@"; |
23 char *spamc_empty = ""; | 23 const char *spamc_empty = ""; |
24 static bool warnedmacro = false; // have we logged that we couldn't fetch a macro? | 24 static bool warnedmacro = false; // have we logged that we couldn't fetch a macro? |
25 const int maxlen = 1000; // used for snprintf buffers | 25 const int maxlen = 1000; // used for snprintf buffers |
26 | 26 |
27 | 27 |
28 SpamAssassin::SpamAssassin(mlfiPriv *priv_, int ip, char *helo_, char *from, char *qid) | 28 SpamAssassin::SpamAssassin(mlfiPriv *priv_, int ip, const char *helo_, const char *from, const char *qid) |
29 { | 29 { |
30 error = false; | 30 error = false; |
31 running = false; | 31 running = false; |
32 first_recipient = true; | 32 first_recipient = true; |
33 priv = priv_; | 33 priv = priv_; |
62 } | 62 } |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 | 66 |
67 void SpamAssassin::mlfi_envrcpt(SMFICTX *ctx, char *envrcpt) | 67 void SpamAssassin::mlfi_envrcpt(SMFICTX *ctx, const char *envrcpt) |
68 { | 68 { |
69 if (first_recipient) { | 69 if (first_recipient) { |
70 first_recipient = false; | 70 first_recipient = false; |
71 /* Send the envelope headers as X-Envelope-From: and | 71 /* Send the envelope headers as X-Envelope-From: and |
72 X-Envelope-To: so that SpamAssassin can use them in its | 72 X-Envelope-To: so that SpamAssassin can use them in its |
121 } | 121 } |
122 output(string("X-Envelope-To: ") + envrcpt + "\r\n"); | 122 output(string("X-Envelope-To: ") + envrcpt + "\r\n"); |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 void SpamAssassin::mlfi_header(char* headerf, char* headerv) | 126 void SpamAssassin::mlfi_header(const char* headerf, const char* headerv) |
127 { | 127 { |
128 if (!running) Connect(); | 128 if (!running) Connect(); |
129 if (running) { | 129 if (running) { |
130 output(spamc_input); | 130 output(spamc_input); |
131 spamc_input.empty(); | 131 spamc_input.empty(); |
142 { | 142 { |
143 output("\r\n"); | 143 output("\r\n"); |
144 } | 144 } |
145 | 145 |
146 | 146 |
147 void SpamAssassin::mlfi_body(u_char *bodyp, size_t bodylen) | 147 void SpamAssassin::mlfi_body(const u_char *bodyp, size_t bodylen) |
148 { | 148 { |
149 output((char *)bodyp, bodylen); | 149 output((const char *)bodyp, bodylen); |
150 } | 150 } |
151 | 151 |
152 | 152 |
153 int SpamAssassin::mlfi_eom() | 153 int SpamAssassin::mlfi_eom() |
154 { | 154 { |
198 | 198 |
199 closeall(3); | 199 closeall(3); |
200 | 200 |
201 // execute spamc | 201 // execute spamc |
202 char* argv[3]; | 202 char* argv[3]; |
203 argv[0] = spamc; | 203 argv[0] = (char*)spamc; |
204 argv[1] = "-c"; | 204 argv[1] = (char*)"-c"; |
205 argv[2] = NULL; | 205 argv[2] = NULL; |
206 execvp(argv[0] , argv); // does not return! | 206 execvp(argv[0] , argv); // does not return! |
207 _exit(1); // exec failed | 207 _exit(1); // exec failed |
208 break; | 208 break; |
209 } | 209 } |
239 spamc_input.append(buffer, size); | 239 spamc_input.append(buffer, size); |
240 return; | 240 return; |
241 } | 241 } |
242 | 242 |
243 // send to SpamAssassin | 243 // send to SpamAssassin |
244 long total = 0; | 244 size_t total = 0; |
245 long wsize = 0; | 245 size_t wsize = 0; |
246 string reason; | 246 string reason; |
247 int status; | 247 int status; |
248 do { | 248 do { |
249 struct pollfd fds[2]; | 249 struct pollfd fds[2]; |
250 int nfds = 2, nready; | 250 int nfds = 2, nready; |
392 while (fd < fdlimit) | 392 while (fd < fdlimit) |
393 close(fd++); | 393 close(fd++); |
394 } | 394 } |
395 | 395 |
396 | 396 |
397 char *SpamAssassin::getorwarnmacro(SMFICTX *ctx, char *macro, char *def, char *scope) | 397 const char *SpamAssassin::getorwarnmacro(SMFICTX *ctx, const char *macro, const char *def, const char *scope) |
398 { | 398 { |
399 char *rc = smfi_getsymval(ctx, macro); | 399 const char *rc = smfi_getsymval(ctx, (char*)macro); |
400 if (!rc) { | 400 if (!rc) { |
401 rc = def; | 401 rc = def; |
402 warnmacro(macro, scope); | 402 warnmacro(macro, scope); |
403 } | 403 } |
404 return rc; | 404 return rc; |
405 } | 405 } |
406 | 406 |
407 | 407 |
408 void SpamAssassin::warnmacro(char *macro, char *scope) | 408 void SpamAssassin::warnmacro(const char *macro, const char *scope) |
409 { | 409 { |
410 if (warnedmacro) return; | 410 if (warnedmacro) return; |
411 char buf[maxlen]; | 411 char buf[maxlen]; |
412 snprintf(buf, sizeof(buf), "Could not retrieve sendmail macro %s. Add it to confMILTER_MACROS_%s for better results.", macro, scope); | 412 snprintf(buf, sizeof(buf), "Could not retrieve sendmail macro %s. Add it to confMILTER_MACROS_%s for better results.", macro, scope); |
413 my_syslog(priv, buf); | 413 my_syslog(priv, buf); |