git-svn: trunk@2108
Nigel Horne authored on 2006/07/22 20:07:01... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Sat Jul 22 12:05:26 BST 2006 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * clamav-milter: More consistent use of ReadTimeout in the load balancing |
|
4 |
+ code |
|
5 |
+ |
|
1 | 6 |
Fri Jul 21 19:18:08 BST 2006 (njh) |
2 | 7 |
---------------------------------- |
3 | 8 |
* libclamav/tnef.c: Handle trailing newline at the end of winmail.dat, |
... | ... |
@@ -554,7 +559,7 @@ Wed Mar 22 13:14:52 CET 2006 (tk) |
554 | 554 |
Mon Mar 20 21:56:38 CET 2006 (acab) |
555 | 555 |
----------------------------------- |
556 | 556 |
* libclamav/fsg.c: fix wrong write size calculation (reported by Andrey J. |
557 |
- Melnikoff (TEMHOTA) <temnota*kmv.ru>) |
|
557 |
+ Melnikoff (TEMHOTA) <temnota*kmv.ru>) |
|
558 | 558 |
|
559 | 559 |
Sun Mar 19 21:49:19 CET 2006 (tk) |
560 | 560 |
--------------------------------- |
... | ... |
@@ -653,7 +658,7 @@ Tue Jan 24 16:52:21 CET 2006 (tk) |
653 | 653 |
Mon Jan 23 17:09:26 CET 2006 (acab) |
654 | 654 |
----------------------------------- |
655 | 655 |
* libclamav: Fixed more warnings |
656 |
- Wrapped write() |
|
656 |
+ Wrapped write() |
|
657 | 657 |
Finalized yc emulator |
658 | 658 |
|
659 | 659 |
Mon Jan 23 12:12:07 CET 2006 (acab) |
... | ... |
@@ -680,7 +685,7 @@ Sun Jan 15 16:43:36 CET 2006 (tk) |
680 | 680 |
Fri Jan 14 14:51:01 CET 2006 (acab) |
681 | 681 |
--------------------------------- |
682 | 682 |
* libclamav: added yC support |
683 |
- thanks a lot to Ivan Zlatev <pumqara*gmail.com> |
|
683 |
+ thanks a lot to Ivan Zlatev <pumqara*gmail.com> |
|
684 | 684 |
|
685 | 685 |
Fri Jan 13 14:53:45 CET 2006 (tk) |
686 | 686 |
--------------------------------- |
... | ... |
@@ -23,9 +23,9 @@ |
23 | 23 |
* |
24 | 24 |
* For installation instructions see the file INSTALL that came with this file |
25 | 25 |
*/ |
26 |
-static char const rcsid[] = "$Id: clamav-milter.c,v 1.264 2006/07/20 00:41:11 njh Exp $"; |
|
26 |
+static char const rcsid[] = "$Id: clamav-milter.c,v 1.265 2006/07/22 11:07:01 njh Exp $"; |
|
27 | 27 |
|
28 |
-#define CM_VERSION "devel-190706" |
|
28 |
+#define CM_VERSION "devel-220706" |
|
29 | 29 |
|
30 | 30 |
#if HAVE_CONFIG_H |
31 | 31 |
#include "clamav-config.h" |
... | ... |
@@ -149,9 +149,13 @@ typedef unsigned int in_addr_t; |
149 | 149 |
#endif |
150 | 150 |
|
151 | 151 |
#define VERSION_LENGTH 128 |
152 |
+#define DEFAULT_TIMEOUT 120 |
|
152 | 153 |
|
153 | 154 |
/* DO NOT ENABLE THIS, it is for my research only */ |
154 | 155 |
/*#define REPORT_PHISHING "reportphishing@antiphishing.org"*/ |
156 |
+/*#define REPORT_PHISHING "reportphishing" /* use aliases to forward to |
|
157 |
+ * antiphishing.org |
|
158 |
+ */ |
|
155 | 159 |
|
156 | 160 |
/*#define SESSION /* |
157 | 161 |
* Keep one command connection open to clamd, otherwise a new |
... | ... |
@@ -378,7 +382,7 @@ static int cl_error = SMFIS_TEMPFAIL; /* |
378 | 378 |
* an error. Patch from |
379 | 379 |
* Joe Talbott <josepht@cstone.net> |
380 | 380 |
*/ |
381 |
-static int readTimeout = 0; /* |
|
381 |
+static int readTimeout = DEFAULT_TIMEOUT; /* |
|
382 | 382 |
* number of seconds to wait for clamd to |
383 | 383 |
* respond, see ReadTimeout in clamd.conf |
384 | 384 |
*/ |
... | ... |
@@ -1183,7 +1187,7 @@ main(int argc, char **argv) |
1183 | 1183 |
return EX_CONFIG; |
1184 | 1184 |
} |
1185 | 1185 |
} else |
1186 |
- readTimeout = 0; |
|
1186 |
+ readTimeout = DEFAULT_TIMEOUT; |
|
1187 | 1187 |
|
1188 | 1188 |
if(((cpt = cfgopt(copt, "StreamMaxLength")) != NULL) && cpt->enabled) { |
1189 | 1189 |
if(cpt->numarg < 0) { |
... | ... |
@@ -2057,7 +2061,6 @@ findServer(void) |
2057 | 2057 |
struct sockaddr_in *servers, *server; |
2058 | 2058 |
int *socks, maxsock = 0, i, j; |
2059 | 2059 |
fd_set rfds; |
2060 |
- struct timeval tv; |
|
2061 | 2060 |
int retval; |
2062 | 2061 |
|
2063 | 2062 |
assert(tcpSocket != 0); |
... | ... |
@@ -2141,13 +2144,16 @@ findServer(void) |
2141 | 2141 |
|
2142 | 2142 |
free(servers); |
2143 | 2143 |
|
2144 |
- tv.tv_sec = readTimeout; |
|
2145 |
- tv.tv_usec = 0; |
|
2146 |
- |
|
2147 | 2144 |
if(maxsock == 0) |
2148 | 2145 |
retval = 0; |
2149 |
- else |
|
2146 |
+ else { |
|
2147 |
+ struct timeval tv; |
|
2148 |
+ |
|
2149 |
+ tv.tv_sec = readTimeout ? readTimeout : DEFAULT_TIMEOUT; |
|
2150 |
+ tv.tv_usec = 0; |
|
2151 |
+ |
|
2150 | 2152 |
retval = select(maxsock + 1, &rfds, NULL, NULL, &tv); |
2153 |
+ } |
|
2151 | 2154 |
|
2152 | 2155 |
if(retval < 0) |
2153 | 2156 |
perror("select"); |
... | ... |
@@ -3396,10 +3402,7 @@ clamfi_eom(SMFICTX *ctx) |
3396 | 3396 |
for(to = privdata->to; *to; to++) { |
3397 | 3397 |
smfi_delrcpt(ctx, *to); |
3398 | 3398 |
smfi_addheader(ctx, "X-Original-To", *to); |
3399 |
- free(*to); |
|
3400 | 3399 |
} |
3401 |
- free(privdata->to); |
|
3402 |
- privdata->to = NULL; |
|
3403 | 3400 |
if(smfi_addrcpt(ctx, REPORT_PHISHING) == MI_FAILURE) { |
3404 | 3401 |
/* It's a remote site */ |
3405 | 3402 |
if(privdata->filename) { |
... | ... |
@@ -3410,18 +3413,14 @@ clamfi_eom(SMFICTX *ctx) |
3410 | 3410 |
if(use_syslog) |
3411 | 3411 |
syslog(LOG_INFO, _("Reported phishing to %s"), REPORT_PHISHING); |
3412 | 3412 |
|
3413 |
+ } else { |
|
3414 |
+ logg(_("^Can't set anti-phish header\n")); |
|
3415 |
+ rc = (privdata->discard) ? SMFIS_DISCARD : SMFIS_REJECT; |
|
3413 | 3416 |
} |
3414 |
- if(use_syslog) |
|
3415 |
- syslog(LOG_ERR, _("Can't set anti-phish header")); |
|
3416 |
- else |
|
3417 |
- cli_warnmsg(_("Can't set anti-phish header\n")); |
|
3418 |
- rc = (privdata->discard) ? SMFIS_DISCARD : SMFIS_REJECT; |
|
3419 | 3417 |
} else { |
3420 |
- setsubject(ctx, "Phishing attempt trapped and redirected"); |
|
3418 |
+ setsubject(ctx, "Phishing attempt trapped by ClamAV and redirected"); |
|
3421 | 3419 |
|
3422 |
- if(use_syslog) |
|
3423 |
- syslog(LOG_DEBUG, "Redirected phish to %s", REPORT_PHISHING); |
|
3424 |
- cli_dbgmsg("Redirected phish to %s\n", REPORT_PHISHING); |
|
3420 |
+ logg("Redirected phish to %s\n", REPORT_PHISHING); |
|
3425 | 3421 |
} |
3426 | 3422 |
} else |
3427 | 3423 |
#endif |
... | ... |
@@ -3430,19 +3429,13 @@ clamfi_eom(SMFICTX *ctx) |
3430 | 3430 |
for(to = privdata->to; *to; to++) { |
3431 | 3431 |
smfi_delrcpt(ctx, *to); |
3432 | 3432 |
smfi_addheader(ctx, "X-Original-To", *to); |
3433 |
- free(*to); |
|
3434 | 3433 |
} |
3435 |
- free(privdata->to); |
|
3436 |
- privdata->to = NULL; |
|
3437 | 3434 |
/* |
3438 | 3435 |
* NOTE: on a closed relay this will not work |
3439 | 3436 |
* if the recipient is a remote address |
3440 | 3437 |
*/ |
3441 | 3438 |
if(smfi_addrcpt(ctx, quarantine) == MI_FAILURE) { |
3442 |
- if(use_syslog) |
|
3443 |
- syslog(LOG_ERR, _("Can't set quarantine user %s"), quarantine); |
|
3444 |
- else |
|
3445 |
- cli_warnmsg(_("Can't set quarantine user %s\n"), quarantine); |
|
3439 |
+ logg(_("^Can't set quarantine user %s"), quarantine); |
|
3446 | 3440 |
rc = (privdata->discard) ? SMFIS_DISCARD : SMFIS_REJECT; |
3447 | 3441 |
} else { |
3448 | 3442 |
#ifdef REPORT_PHISHING |
... | ... |
@@ -3453,9 +3446,7 @@ clamfi_eom(SMFICTX *ctx) |
3453 | 3453 |
#endif |
3454 | 3454 |
setsubject(ctx, virusname); |
3455 | 3455 |
|
3456 |
- if(use_syslog) |
|
3457 |
- syslog(LOG_DEBUG, "Redirected virus to %s", quarantine); |
|
3458 |
- cli_dbgmsg("Redirected virus to %s\n", quarantine); |
|
3456 |
+ logg("Redirected virus to %s", quarantine); |
|
3459 | 3457 |
} |
3460 | 3458 |
} else if(advisory) |
3461 | 3459 |
setsubject(ctx, virusname); |