comparison src/spamass.cpp.in @ 167:9b129ed78d7d stable-6-0-6

actually use spamassassin result, allow build without spam assassin, only call it if some recipient needs it.
author carl
date Mon, 27 Aug 2007 20:49:19 -0700
parents 5809bcdc325b
children 6bac960af6b4
comparison
equal deleted inserted replaced
166:7161d8451fcf 167:9b129ed78d7d
20 #include <unistd.h> 20 #include <unistd.h>
21 21
22 22
23 static const char Id[] = "$Id$"; 23 static const char Id[] = "$Id$";
24 24
25 bool warnedmacro = false; /* have we logged that we couldn't fetch a macro? */ 25 char *spamc = "@SPAMC@";
26 char *spamc_empty = "";
27 bool warnedmacro = false; /* have we logged that we couldn't fetch a macro? */
26 const int maxlen = 1000; // used for snprintf buffers 28 const int maxlen = 1000; // used for snprintf buffers
27 29
28 30
29 SpamAssassin::SpamAssassin() 31 SpamAssassin::SpamAssassin(mlfiPriv *priv_, int ip, char *helo_, char *from, char *qid)
30 { 32 {
31 error = false; 33 error = false;
32 running = false; 34 running = false;
33 first_recipient = true; 35 first_recipient = true;
36 priv = priv_;
37 ip4 = ip;
38 helo = helo_;
39 envfrom = from;
40 queueid = qid;
41 pid = 0;
42 pipe_io[0][0] = -1;
43 pipe_io[0][1] = -1;
44 pipe_io[1][0] = -1;
45 pipe_io[1][1] = -1;
34 } 46 }
35 47
36 48
37 SpamAssassin::~SpamAssassin() 49 SpamAssassin::~SpamAssassin()
38 { 50 {
53 } 65 }
54 } 66 }
55 } 67 }
56 68
57 69
58 void SpamAssassin::mlfi_connect(mlfiPriv *priv_, int ip)
59 {
60 priv = priv_;
61 ip4 = ip;
62 }
63
64
65 void SpamAssassin::mlfi_helo(char *helohost)
66 {
67 helo = helohost;
68 }
69
70
71 void SpamAssassin::mlfi_envfrom(char *from, char *qid)
72 {
73 envfrom = from;
74 queueid = qid;
75 }
76
77
78 void SpamAssassin::mlfi_envrcpt(SMFICTX *ctx, char *envrcpt) 70 void SpamAssassin::mlfi_envrcpt(SMFICTX *ctx, char *envrcpt)
79 { 71 {
80 if (first_recipient) { 72 if (first_recipient) {
81 /* Send the envelope headers as X-Envelope-From: and 73 /* Send the envelope headers as X-Envelope-From: and
82 X-Envelope-To: so that SpamAssassin can use them in its 74 X-Envelope-To: so that SpamAssassin can use them in its
225 217
226 closeall(3); 218 closeall(3);
227 219
228 // execute spamc 220 // execute spamc
229 char* argv[3]; 221 char* argv[3];
230 argv[0] = "@SPAMC@"; 222 argv[0] = spamc;
231 argv[1] = "-c"; 223 argv[1] = "-c";
232 argv[2] = NULL; 224 argv[2] = NULL;
233 execvp(argv[0] , argv); // does not return! 225 execvp(argv[0] , argv); // does not return!
234 _exit(1); // exec failed 226 _exit(1); // exec failed
235 break; 227 break;