Mercurial > dnsbl
comparison src/spamass.cpp.in @ 168:6bac960af6b4
add generic reverse dns filtering regex
author | carl |
---|---|
date | Thu, 30 Aug 2007 11:08:46 -0700 |
parents | 9b129ed78d7d |
children | bd33eaccfed8 |
comparison
equal
deleted
inserted
replaced
167:9b129ed78d7d | 168:6bac960af6b4 |
---|---|
91 time_t tval; | 91 time_t tval; |
92 time(&tval); | 92 time(&tval); |
93 strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", localtime(&tval)); | 93 strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", localtime(&tval)); |
94 macro_b = date; | 94 macro_b = date; |
95 | 95 |
96 /* queue ID */ | 96 // queue ID |
97 macro_i = queueid; | 97 macro_i = queueid; |
98 | 98 |
99 /* FQDN of this site */ | 99 // FQDN of this site |
100 macro_j = smfi_getsymval(ctx, "j"); | 100 macro_j = getorwarnmacro(ctx, "j", "localhost", "ENVRCPT"); |
101 if (!macro_j) { | 101 |
102 macro_j = "localhost"; | 102 // Protocol used to receive the message */ |
103 warnmacro("j", "ENVRCPT"); | 103 macro_r = getorwarnmacro(ctx, "r", "SMTP", "ENVRCPT"); |
104 } | |
105 | |
106 /* Protocol used to receive the message */ | |
107 macro_r = smfi_getsymval(ctx, "r"); | |
108 if (!macro_r) { | |
109 macro_r = "SMTP"; | |
110 warnmacro("r", "ENVRCPT"); | |
111 } | |
112 | 104 |
113 macro_s = helo; | 105 macro_s = helo; |
114 | 106 |
115 /* Sendmail binary version */ | 107 // Sendmail binary version |
116 macro_v = smfi_getsymval(ctx, "v"); | 108 macro_v = getorwarnmacro(ctx, "v", "8.13.0", "ENVRCPT"); |
117 if (!macro_v) { | 109 |
118 macro_v = "8.13.0"; | 110 // Sendmail .cf version |
119 warnmacro("v", "ENVRCPT"); | 111 macro_Z = getorwarnmacro(ctx, "Z", "8.13.0", "ENVRCPT"); |
120 } | 112 |
121 | 113 // Validated sending site's address |
122 /* Sendmail .cf version */ | 114 macro__ = getorwarnmacro(ctx, "_", "unknown", "ENVRCPT"); |
123 macro_Z = smfi_getsymval(ctx, "Z"); | |
124 if (!macro_Z) { | |
125 macro_Z = "8.13.0"; | |
126 warnmacro("Z", "ENVRCPT"); | |
127 } | |
128 | |
129 /* Validated sending site's address */ | |
130 macro__ = smfi_getsymval(ctx, "_"); | |
131 if (!macro__) { | |
132 macro__ = "unknown"; | |
133 warnmacro("_", "ENVRCPT"); | |
134 } | |
135 | 115 |
136 output(string("Received: from ") + macro_s + " (" + macro__+ ")\r\n\t" + | 116 output(string("Received: from ") + macro_s + " (" + macro__+ ")\r\n\t" + |
137 "by " + macro_j + " (" + macro_v + "/" + macro_Z + ") with " + macro_r + " id " + macro_i + "\r\n\t" + | 117 "by " + macro_j + " (" + macro_v + "/" + macro_Z + ") with " + macro_r + " id " + macro_i + "\r\n\t" + |
138 "for " + envfrom + ";\r\n\t" + | 118 "for " + envfrom + ";\r\n\t" + |
139 macro_b + "\r\n"); | 119 macro_b + "\r\n"); |
411 while (fd < fdlimit) | 391 while (fd < fdlimit) |
412 close(fd++); | 392 close(fd++); |
413 } | 393 } |
414 | 394 |
415 | 395 |
396 char *SpamAssassin::getorwarnmacro(SMFICTX *ctx, char *macro, char *def, char *scope) | |
397 { | |
398 char *rc = smfi_getsymval(ctx, macro); | |
399 if (!rc) { | |
400 rc = def; | |
401 warnmacro(macro, scope); | |
402 } | |
403 return rc; | |
404 } | |
405 | |
406 | |
416 void SpamAssassin::warnmacro(char *macro, char *scope) | 407 void SpamAssassin::warnmacro(char *macro, char *scope) |
417 { | 408 { |
418 if (warnedmacro) return; | 409 if (warnedmacro) return; |
419 char buf[maxlen]; | 410 char buf[maxlen]; |
420 snprintf(buf, sizeof(buf), "Could not retrieve sendmail macro %s. Add it to confMILTER_MACROS_%s for better results.", macro, scope); | 411 snprintf(buf, sizeof(buf), "Could not retrieve sendmail macro %s. Add it to confMILTER_MACROS_%s for better results.", macro, scope); |