git-svn: trunk@2102
Nigel Horne authored on 2006/07/19 18:44:06... | ... |
@@ -1,3 +1,9 @@ |
1 |
+Wed Jul 19 10:42:32 BST 2006 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * clamav-milter: Use LogClean from clamd.conf, removed --dont-log-clean |
|
4 |
+ Started to use logg() functions from output.o |
|
5 |
+ Improved load balancing |
|
6 |
+ |
|
1 | 7 |
Tue Jul 18 17:54:42 CEST 2006 (tk) |
2 | 8 |
---------------------------------- |
3 | 9 |
* sigtool/sigtool.c: automatically verify patches created with --diff; |
... | ... |
@@ -71,13 +71,15 @@ am__installdirs = "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)" |
71 | 71 |
sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM) |
72 | 72 |
PROGRAMS = $(sbin_PROGRAMS) |
73 | 73 |
am__clamav_milter_SOURCES_DIST = $(top_srcdir)/shared/cfgparser.c \ |
74 |
- $(top_srcdir)/shared/cfgparser.h $(top_srcdir)/shared/getopt.c \ |
|
74 |
+ $(top_srcdir)/shared/cfgparser.h $(top_srcdir)/shared/output.c \ |
|
75 |
+ $(top_srcdir)/shared/output.h $(top_srcdir)/shared/getopt.c \ |
|
75 | 76 |
$(top_srcdir)/shared/getopt.h $(top_srcdir)/shared/memory.c \ |
76 | 77 |
$(top_srcdir)/shared/memory.h $(top_srcdir)/shared/misc.c \ |
77 | 78 |
$(top_srcdir)/shared/misc.h $(top_srcdir)/shared/network.c \ |
78 | 79 |
$(top_srcdir)/shared/network.h clamav-milter.c |
79 | 80 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@am_clamav_milter_OBJECTS = \ |
80 | 81 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ cfgparser.$(OBJEXT) \ |
82 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ output.$(OBJEXT) \ |
|
81 | 83 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ getopt.$(OBJEXT) \ |
82 | 84 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ memory.$(OBJEXT) \ |
83 | 85 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ misc.$(OBJEXT) \ |
... | ... |
@@ -137,7 +139,6 @@ EGREP = @EGREP@ |
137 | 137 |
EXEEXT = @EXEEXT@ |
138 | 138 |
FRESHCLAM_LIBS = @FRESHCLAM_LIBS@ |
139 | 139 |
GETENT = @GETENT@ |
140 |
-GREP = @GREP@ |
|
141 | 140 |
HAVE_MILTER_FALSE = @HAVE_MILTER_FALSE@ |
142 | 141 |
HAVE_MILTER_TRUE = @HAVE_MILTER_TRUE@ |
143 | 142 |
INSTALL_DATA = @INSTALL_DATA@ |
... | ... |
@@ -171,6 +172,8 @@ STRIP = @STRIP@ |
171 | 171 |
TH_SAFE = @TH_SAFE@ |
172 | 172 |
VERSION = @VERSION@ |
173 | 173 |
ac_ct_CC = @ac_ct_CC@ |
174 |
+ac_ct_RANLIB = @ac_ct_RANLIB@ |
|
175 |
+ac_ct_STRIP = @ac_ct_STRIP@ |
|
174 | 176 |
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ |
175 | 177 |
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ |
176 | 178 |
am__include = @am__include@ |
... | ... |
@@ -186,29 +189,23 @@ build_os = @build_os@ |
186 | 186 |
build_vendor = @build_vendor@ |
187 | 187 |
datadir = @datadir@ |
188 | 188 |
datarootdir = @datarootdir@ |
189 |
-docdir = @docdir@ |
|
190 |
-dvidir = @dvidir@ |
|
191 | 189 |
exec_prefix = @exec_prefix@ |
192 | 190 |
host = @host@ |
193 | 191 |
host_alias = @host_alias@ |
194 | 192 |
host_cpu = @host_cpu@ |
195 | 193 |
host_os = @host_os@ |
196 | 194 |
host_vendor = @host_vendor@ |
197 |
-htmldir = @htmldir@ |
|
198 | 195 |
includedir = @includedir@ |
199 | 196 |
infodir = @infodir@ |
200 | 197 |
install_sh = @install_sh@ |
201 | 198 |
libdir = @libdir@ |
202 | 199 |
libexecdir = @libexecdir@ |
203 |
-localedir = @localedir@ |
|
204 | 200 |
localstatedir = @localstatedir@ |
205 | 201 |
mandir = @mandir@ |
206 | 202 |
mkdir_p = @mkdir_p@ |
207 | 203 |
oldincludedir = @oldincludedir@ |
208 |
-pdfdir = @pdfdir@ |
|
209 | 204 |
prefix = @prefix@ |
210 | 205 |
program_transform_name = @program_transform_name@ |
211 |
-psdir = @psdir@ |
|
212 | 206 |
sbindir = @sbindir@ |
213 | 207 |
sendmailprog = @sendmailprog@ |
214 | 208 |
sharedstatedir = @sharedstatedir@ |
... | ... |
@@ -221,6 +218,8 @@ target_vendor = @target_vendor@ |
221 | 221 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@clamav_milter_SOURCES = \ |
222 | 222 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ $(top_srcdir)/shared/cfgparser.c \ |
223 | 223 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ $(top_srcdir)/shared/cfgparser.h \ |
224 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ $(top_srcdir)/shared/output.c \ |
|
225 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ $(top_srcdir)/shared/output.h \ |
|
224 | 226 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ $(top_srcdir)/shared/getopt.c \ |
225 | 227 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ $(top_srcdir)/shared/getopt.h \ |
226 | 228 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ $(top_srcdir)/shared/memory.c \ |
... | ... |
@@ -311,6 +310,7 @@ distclean-compile: |
311 | 311 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Po@am__quote@ |
312 | 312 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Po@am__quote@ |
313 | 313 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/network.Po@am__quote@ |
314 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/output.Po@am__quote@ |
|
314 | 315 |
|
315 | 316 |
.c.o: |
316 | 317 |
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ |
... | ... |
@@ -347,6 +347,20 @@ cfgparser.obj: $(top_srcdir)/shared/cfgparser.c |
347 | 347 |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
348 | 348 |
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cfgparser.obj `if test -f '$(top_srcdir)/shared/cfgparser.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/cfgparser.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/cfgparser.c'; fi` |
349 | 349 |
|
350 |
+output.o: $(top_srcdir)/shared/output.c |
|
351 |
+@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT output.o -MD -MP -MF "$(DEPDIR)/output.Tpo" -c -o output.o `test -f '$(top_srcdir)/shared/output.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/output.c; \ |
|
352 |
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/output.Tpo" "$(DEPDIR)/output.Po"; else rm -f "$(DEPDIR)/output.Tpo"; exit 1; fi |
|
353 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/shared/output.c' object='output.o' libtool=no @AMDEPBACKSLASH@ |
|
354 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
355 |
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o output.o `test -f '$(top_srcdir)/shared/output.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/output.c |
|
356 |
+ |
|
357 |
+output.obj: $(top_srcdir)/shared/output.c |
|
358 |
+@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT output.obj -MD -MP -MF "$(DEPDIR)/output.Tpo" -c -o output.obj `if test -f '$(top_srcdir)/shared/output.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/output.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/output.c'; fi`; \ |
|
359 |
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/output.Tpo" "$(DEPDIR)/output.Po"; else rm -f "$(DEPDIR)/output.Tpo"; exit 1; fi |
|
360 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/shared/output.c' object='output.obj' libtool=no @AMDEPBACKSLASH@ |
|
361 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
362 |
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o output.obj `if test -f '$(top_srcdir)/shared/output.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/output.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/output.c'; fi` |
|
363 |
+ |
|
350 | 364 |
getopt.o: $(top_srcdir)/shared/getopt.c |
351 | 365 |
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT getopt.o -MD -MP -MF "$(DEPDIR)/getopt.Tpo" -c -o getopt.o `test -f '$(top_srcdir)/shared/getopt.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/getopt.c; \ |
352 | 366 |
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/getopt.Tpo" "$(DEPDIR)/getopt.Po"; else rm -f "$(DEPDIR)/getopt.Tpo"; exit 1; fi |
... | ... |
@@ -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.261 2006/07/18 08:29:02 njh Exp $"; |
|
26 |
+static char const rcsid[] = "$Id: clamav-milter.c,v 1.262 2006/07/19 09:44:06 njh Exp $"; |
|
27 | 27 |
|
28 |
-#define CM_VERSION "devel-170706" |
|
28 |
+#define CM_VERSION "devel-190706" |
|
29 | 29 |
|
30 | 30 |
#if HAVE_CONFIG_H |
31 | 31 |
#include "clamav-config.h" |
... | ... |
@@ -36,6 +36,7 @@ static char const rcsid[] = "$Id: clamav-milter.c,v 1.261 2006/07/18 08:29:02 nj |
36 | 36 |
#include "target.h" |
37 | 37 |
#include "str.h" |
38 | 38 |
#include "../libclamav/others.h" |
39 |
+#include "output.h" |
|
39 | 40 |
#include "clamav.h" |
40 | 41 |
#include "table.h" |
41 | 42 |
#include "network.h" |
... | ... |
@@ -292,7 +293,6 @@ static void clamdIsDown(void); |
292 | 292 |
static void *watchdog(void *a); |
293 | 293 |
static int check_and_reload_database(void); |
294 | 294 |
static void timeoutBlacklist(char *ip_address, int time_of_blacklist); |
295 |
-static int logg_facility(const char *name); |
|
296 | 295 |
static void quit(void); |
297 | 296 |
static void broadcast(const char *mess); |
298 | 297 |
static int loadDatabase(void); |
... | ... |
@@ -383,7 +383,7 @@ static int readTimeout = 0; /* |
383 | 383 |
* respond, see ReadTimeout in clamd.conf |
384 | 384 |
*/ |
385 | 385 |
static long streamMaxLength = -1; /* StreamMaxLength from clamd.conf */ |
386 |
-static int logClean = 1; /* |
|
386 |
+static int logClean = 0; /* |
|
387 | 387 |
* Add clean items to the log file |
388 | 388 |
*/ |
389 | 389 |
static char *signature = N_("-- \nScanned by ClamAv - http://www.clamav.net\n"); |
... | ... |
@@ -425,6 +425,13 @@ static int detect_forged_local_address; /* |
425 | 425 |
* Requires that -o, -l or -f are NOT given |
426 | 426 |
*/ |
427 | 427 |
static short use_syslog = 0; |
428 |
+ /* |
|
429 |
+ * NOTE: first character of strings to logg(): |
|
430 |
+ * ! Error |
|
431 |
+ * ^ Warning |
|
432 |
+ * * Debug |
|
433 |
+ * # or no special character Info |
|
434 |
+ */ |
|
428 | 435 |
static const char *pidFile; |
429 | 436 |
static int logVerbose = 0; |
430 | 437 |
static struct cfgstruct *copt; |
... | ... |
@@ -507,12 +514,11 @@ static void print_trace(void); |
507 | 507 |
static int verifyIncomingSocketName(const char *sockName); |
508 | 508 |
static int isWhitelisted(const char *emailaddress); |
509 | 509 |
static int isBlacklisted(const char *ip_address); |
510 |
-static void logger(const char *mess); |
|
511 | 510 |
static void mx(void); |
512 | 511 |
static void resolve(const char *host); |
513 | 512 |
static sfsistat black_hole(const struct privdata *privdata); |
514 | 513 |
|
515 |
-short logg_time, logg_lock, logok; |
|
514 |
+short logg_time, logg_lock; |
|
516 | 515 |
int logg_size; |
517 | 516 |
|
518 | 517 |
static void |
... | ... |
@@ -529,7 +535,6 @@ help(void) |
529 | 529 |
puts(_("\t--config-file=FILE\t-c FILE\tRead configuration from FILE.")); |
530 | 530 |
puts(_("\t--debug\t\t\t-D\tPrint debug messages.")); |
531 | 531 |
puts(_("\t--detect-forged-local-address\t-L\tReject mails that claim to be from us.")); |
532 |
- puts(_("\t--dont-log-clean\t-C\tDon't add an entry to syslog that a mail is clean.")); |
|
533 | 532 |
puts(_("\t--dont-scan-on-error\t-d\tPass e-mails through unscanned if a system error occurs.")); |
534 | 533 |
puts(_("\t--dont-wait\t\t\tAsk remote end to resend if max-children exceeded.")); |
535 | 534 |
puts(_("\t--external\t\t-e\tUse an external scanner (usually clamd).")); |
... | ... |
@@ -631,9 +636,9 @@ main(int argc, char **argv) |
631 | 631 |
struct cidr_net *net; |
632 | 632 |
struct in_addr ignoreIP; |
633 | 633 |
#ifdef CL_DEBUG |
634 |
- const char *args = "a:AbB:c:CdDefF:I:k:lLm:M:nNop:PqQ:hHs:St:T:U:VwW:x:0:1:2"; |
|
634 |
+ const char *args = "a:AbB:c:dDefF:I:k:lLm:M:nNop:PqQ:hHs:St:T:U:VwW:x:0:1:2"; |
|
635 | 635 |
#else |
636 |
- const char *args = "a:AbB:c:CdDefF:I:k:lLm:M:nNop:PqQ:hHs:St:T:U:VwW:0:1:2"; |
|
636 |
+ const char *args = "a:AbB:c:dDefF:I:k:lLm:M:nNop:PqQ:hHs:St:T:U:VwW:0:1:2"; |
|
637 | 637 |
#endif |
638 | 638 |
|
639 | 639 |
static struct option long_options[] = { |
... | ... |
@@ -656,9 +661,6 @@ main(int argc, char **argv) |
656 | 656 |
"detect-forged-local-address", 0, NULL, 'L' |
657 | 657 |
}, |
658 | 658 |
{ |
659 |
- "dont-log-clean", 0, NULL, 'C' |
|
660 |
- }, |
|
661 |
- { |
|
662 | 659 |
"dont-scan-on-error", 0, NULL, 'd' |
663 | 660 |
}, |
664 | 661 |
{ |
... | ... |
@@ -791,9 +793,6 @@ main(int argc, char **argv) |
791 | 791 |
case 'c': /* where is clamd.conf? */ |
792 | 792 |
cfgfile = optarg; |
793 | 793 |
break; |
794 |
- case 'C': /* dont log clean */ |
|
795 |
- logClean = 0; |
|
796 |
- break; |
|
797 | 794 |
case 'd': /* don't scan on error */ |
798 | 795 |
cl_error = SMFIS_ACCEPT; |
799 | 796 |
break; |
... | ... |
@@ -1193,13 +1192,15 @@ main(int argc, char **argv) |
1193 | 1193 |
if(cfgopt(copt, "LogSyslog")->enabled) { |
1194 | 1194 |
int fac = LOG_LOCAL6; |
1195 | 1195 |
|
1196 |
- if(cfgopt(copt, "LogVerbose")->enabled) { |
|
1196 |
+#ifdef CL_DEBUG |
|
1197 |
+ if((debug_level >= 15) && cfgopt(copt, "LogVerbose")->enabled) { |
|
1197 | 1198 |
logVerbose = 1; |
1198 | 1199 |
#if ((SENDMAIL_VERSION_A > 8) || ((SENDMAIL_VERSION_A == 8) && (SENDMAIL_VERSION_B >= 13))) |
1199 | 1200 |
smfi_setdbg(6); |
1200 | 1201 |
#endif |
1201 | 1202 |
} |
1202 |
- use_syslog = 1; |
|
1203 |
+#endif |
|
1204 |
+ logg_syslog = use_syslog = 1; |
|
1203 | 1205 |
|
1204 | 1206 |
if(((cpt = cfgopt(copt, "LogFacility")) != NULL) && cpt->enabled) |
1205 | 1207 |
if((fac = logg_facility(cpt->strarg)) == -1) { |
... | ... |
@@ -1212,7 +1213,7 @@ main(int argc, char **argv) |
1212 | 1212 |
if(qflag) |
1213 | 1213 |
fprintf(stderr, _("%s: (-q && !LogSyslog): warning - all interception message methods are off\n"), |
1214 | 1214 |
argv[0]); |
1215 |
- use_syslog = 0; |
|
1215 |
+ logg_syslog = use_syslog = 0; |
|
1216 | 1216 |
} |
1217 | 1217 |
/* |
1218 | 1218 |
* Get the outgoing socket details - the way to talk to clamd, unless |
... | ... |
@@ -1347,7 +1348,7 @@ main(int argc, char **argv) |
1347 | 1347 |
free(hostname); |
1348 | 1348 |
} |
1349 | 1349 |
|
1350 |
- cli_dbgmsg("numServers: %d\n", numServers); |
|
1350 |
+ logg("*numServers: %d\n", numServers); |
|
1351 | 1351 |
|
1352 | 1352 |
serverIPs = (long *)cli_malloc(numServers * sizeof(long)); |
1353 | 1353 |
activeServers = 0; |
... | ... |
@@ -1562,8 +1563,6 @@ main(int argc, char **argv) |
1562 | 1562 |
logg_time = 1; |
1563 | 1563 |
if(cfgopt(copt, "LogFileUnlock")->enabled) |
1564 | 1564 |
logg_lock = 0; |
1565 |
- if(cfgopt(copt, "LogClean")->enabled) |
|
1566 |
- logok = 1; |
|
1567 | 1565 |
if((cpt = cfgopt(copt, "LogFileMaxSize")) != NULL) |
1568 | 1566 |
logg_size = cpt->numarg; |
1569 | 1567 |
|
... | ... |
@@ -1580,6 +1579,9 @@ main(int argc, char **argv) |
1580 | 1580 |
#endif |
1581 | 1581 |
} |
1582 | 1582 |
|
1583 |
+ if(cfgopt(copt, "LogClean")->enabled) |
|
1584 |
+ logClean = 1; |
|
1585 |
+ |
|
1583 | 1586 |
atexit(quit); |
1584 | 1587 |
|
1585 | 1588 |
if(!external) { |
... | ... |
@@ -2055,7 +2057,7 @@ findServer(void) |
2055 | 2055 |
* Don't worry about no lock - it's doesn't matter if it's |
2056 | 2056 |
* not really accurate |
2057 | 2057 |
*/ |
2058 |
- j = n_children - 1; |
|
2058 |
+ j = n_children; /* look at the next free one */ |
|
2059 | 2059 |
} else |
2060 | 2060 |
/* |
2061 | 2061 |
* cli_rndnum returns 0..(max-1) - the max argument is not |
... | ... |
@@ -2067,27 +2069,25 @@ findServer(void) |
2067 | 2067 |
for(i = 0, server = servers; i < numServers; i++, server++) { |
2068 | 2068 |
int sock; |
2069 | 2069 |
|
2070 |
- if(((i + j) % numServers) >= numServers) |
|
2070 |
+ if(((i + j) % numServers) >= numServers) { |
|
2071 | 2071 |
/* |
2072 | 2072 |
* FIXME: "can't happen" but for some reason, the line |
2073 | 2073 |
* server->sin_addr.s_addr = |
2074 | 2074 |
* serverIPs[(i + j) % numServers]; |
2075 | 2075 |
* gives occasional valgrind errors |
2076 | 2076 |
*/ |
2077 |
- if(use_syslog) { |
|
2078 |
- syslog(LOG_ERR, "FindServer: looking for %d from %d - report to bugs@clamav.net\n", |
|
2079 |
- (i + j) % numServers, numServers); |
|
2080 |
- free(servers); |
|
2081 |
- free(socks); |
|
2082 |
- return 0; |
|
2083 |
- } |
|
2077 |
+ logg(_("!FindServer: looking for %1$d from %2$d - report to bugs@clamav.net\n"), |
|
2078 |
+ (i + j) % numServers, numServers); |
|
2079 |
+ free(servers); |
|
2080 |
+ free(socks); |
|
2081 |
+ return 0; |
|
2082 |
+ } |
|
2084 | 2083 |
|
2085 | 2084 |
server->sin_family = AF_INET; |
2086 | 2085 |
server->sin_port = (in_port_t)htons(tcpSocket); |
2087 | 2086 |
server->sin_addr.s_addr = serverIPs[(i + j) % numServers]; |
2088 | 2087 |
|
2089 |
- cli_dbgmsg("findServer: try server %d\n", |
|
2090 |
- (i + j) % numServers); |
|
2088 |
+ logg("*findServer: try server %d\n", (i + j) % numServers); |
|
2091 | 2089 |
|
2092 | 2090 |
sock = socks[i] = socket(AF_INET, SOCK_STREAM, 0); |
2093 | 2091 |
|
... | ... |
@@ -2113,11 +2113,7 @@ findServer(void) |
2113 | 2113 |
#else |
2114 | 2114 |
char *hostname = cli_strtok(serverHostNames, i, ":"); |
2115 | 2115 |
#endif |
2116 |
- cli_warnmsg(_("Check clamd server %s - it may be down\n"), hostname); |
|
2117 |
- if(use_syslog) |
|
2118 |
- syslog(LOG_WARNING, |
|
2119 |
- _("Check clamd server %s - it may be down"), |
|
2120 |
- hostname); |
|
2116 |
+ logg(_("^Check clamd server %s - it may be down\n"), hostname); |
|
2121 | 2117 |
close(sock); |
2122 | 2118 |
#ifndef MAXHOSTNAMELEN |
2123 | 2119 |
free(hostname); |
... | ... |
@@ -2418,10 +2414,7 @@ clamfi_envfrom(SMFICTX *ctx, char **argv) |
2418 | 2418 |
struct privdata *privdata; |
2419 | 2419 |
const char *mailaddr = argv[0]; |
2420 | 2420 |
|
2421 |
- if(logVerbose) |
|
2422 |
- syslog(LOG_DEBUG, "clamfi_envfrom: %s", argv[0]); |
|
2423 |
- |
|
2424 |
- cli_dbgmsg("clamfi_envfrom: %s\n", argv[0]); |
|
2421 |
+ logg("*clamfi_envfrom: %s", argv[0]); |
|
2425 | 2422 |
|
2426 | 2423 |
if(strcmp(argv[0], "<>") == 0) { |
2427 | 2424 |
mailaddr = smfi_getsymval(ctx, "{mail_addr}"); |
... | ... |
@@ -2575,11 +2568,9 @@ static sfsistat |
2575 | 2575 |
clamfi_envrcpt(SMFICTX *ctx, char **argv) |
2576 | 2576 |
{ |
2577 | 2577 |
struct privdata *privdata = (struct privdata *)smfi_getpriv(ctx); |
2578 |
+ const char *to; |
|
2578 | 2579 |
|
2579 |
- if(logVerbose) |
|
2580 |
- syslog(LOG_DEBUG, "clamfi_envrcpt: %s", argv[0]); |
|
2581 |
- |
|
2582 |
- cli_dbgmsg("clamfi_envrcpt: %s\n", argv[0]); |
|
2580 |
+ logg("*clamfi_envrcpt: %s\n", argv[0]); |
|
2583 | 2581 |
|
2584 | 2582 |
if(privdata->to == NULL) { |
2585 | 2583 |
privdata->to = cli_malloc(sizeof(char *) * 2); |
... | ... |
@@ -2591,7 +2582,11 @@ clamfi_envrcpt(SMFICTX *ctx, char **argv) |
2591 | 2591 |
if(privdata->to == NULL) |
2592 | 2592 |
return cl_error; |
2593 | 2593 |
|
2594 |
- privdata->to[privdata->numTo] = strdup(argv[0]); |
|
2594 |
+ to = smfi_getsymval(ctx, "{rcpt_addr}"); |
|
2595 |
+ if(to == NULL) |
|
2596 |
+ to = argv[0]; |
|
2597 |
+ |
|
2598 |
+ privdata->to[privdata->numTo] = strdup(to); |
|
2595 | 2599 |
privdata->to[++privdata->numTo] = NULL; |
2596 | 2600 |
|
2597 | 2601 |
return SMFIS_CONTINUE; |
... | ... |
@@ -2602,13 +2597,13 @@ clamfi_header(SMFICTX *ctx, char *headerf, char *headerv) |
2602 | 2602 |
{ |
2603 | 2603 |
struct privdata *privdata = (struct privdata *)smfi_getpriv(ctx); |
2604 | 2604 |
|
2605 |
- if(logVerbose) |
|
2606 |
- syslog(LOG_DEBUG, "clamfi_header: %s: %s", headerf, headerv); |
|
2607 | 2605 |
#ifdef CL_DEBUG |
2608 | 2606 |
if(debug_level >= 9) |
2609 |
- cli_dbgmsg("clamfi_header: %s: %s\n", headerf, headerv); |
|
2607 |
+ logg("*clamfi_header: %s: %s\n", headerf, headerv); |
|
2610 | 2608 |
else |
2611 |
- cli_dbgmsg("clamfi_header\n"); |
|
2609 |
+ logg("*clamfi_header\n"); |
|
2610 |
+#else |
|
2611 |
+ logg("*clamfi_header\n"); |
|
2612 | 2612 |
#endif |
2613 | 2613 |
|
2614 | 2614 |
/* |
... | ... |
@@ -2796,6 +2791,10 @@ clamfi_body(SMFICTX *ctx, u_char *bodyp, size_t len) |
2796 | 2796 |
*/ |
2797 | 2797 |
do { |
2798 | 2798 |
if(*ptr == '\n') { |
2799 |
+ /* |
|
2800 |
+ * FIXME: doesn't work if the \nFrom straddles |
|
2801 |
+ * multiple calls to clamfi_body |
|
2802 |
+ */ |
|
2799 | 2803 |
if(strncmp(ptr, "\nFrom ", 6) == 0) { |
2800 | 2804 |
nbytes += clamfi_send(privdata, 7, "\n>From "); |
2801 | 2805 |
ptr += 6; |
... | ... |
@@ -2915,19 +2914,15 @@ clamfi_eom(SMFICTX *ctx) |
2915 | 2915 |
} |
2916 | 2916 |
switch(cl_scanfile(privdata->filename, &virname, &scanned, privdata->root, &limits, options)) { |
2917 | 2917 |
case CL_CLEAN: |
2918 |
- if(logClean) { |
|
2919 |
- snprintf(mess, sizeof(mess), "%s: OK", privdata->filename); |
|
2920 |
- logger(mess); |
|
2921 |
- } |
|
2918 |
+ if(logClean) |
|
2919 |
+ logg("#%s: OK", privdata->filename); |
|
2922 | 2920 |
strcpy(mess, "OK"); |
2923 | 2921 |
break; |
2924 | 2922 |
case CL_VIRUS: |
2925 |
- snprintf(mess, sizeof(mess), "%s: %s FOUND", privdata->filename, virname); |
|
2926 |
- logger(mess); |
|
2923 |
+ logg("#%s: %s FOUND", privdata->filename, virname); |
|
2927 | 2924 |
break; |
2928 | 2925 |
default: |
2929 |
- snprintf(mess, sizeof(mess), "%s: %s ERROR", privdata->filename, cl_strerror(rc)); |
|
2930 |
- logger(mess); |
|
2926 |
+ logg("!%s: %s ERROR", privdata->filename, cl_strerror(rc)); |
|
2931 | 2927 |
break; |
2932 | 2928 |
} |
2933 | 2929 |
cl_free(privdata->root); |
... | ... |
@@ -3552,13 +3547,10 @@ clamfi_abort(SMFICTX *ctx) |
3552 | 3552 |
static sfsistat |
3553 | 3553 |
clamfi_close(SMFICTX *ctx) |
3554 | 3554 |
{ |
3555 |
- cli_dbgmsg("clamfi_close\n"); |
|
3555 |
+ logg("*clamfi_close\n"); |
|
3556 | 3556 |
|
3557 | 3557 |
clamfi_cleanup(ctx); |
3558 | 3558 |
|
3559 |
- if(logVerbose) |
|
3560 |
- syslog(LOG_DEBUG, "clamfi_close"); |
|
3561 |
- |
|
3562 | 3559 |
return SMFIS_CONTINUE; |
3563 | 3560 |
} |
3564 | 3561 |
|
... | ... |
@@ -4800,10 +4792,7 @@ clamdIsDown(void) |
4800 | 4800 |
time_t thistime, diff; |
4801 | 4801 |
static pthread_mutex_t time_mutex = PTHREAD_MUTEX_INITIALIZER; |
4802 | 4802 |
|
4803 |
- cli_errmsg(_("No response from any clamd server - your AV system is not scanning emails\n")); |
|
4804 |
- |
|
4805 |
- if(use_syslog) |
|
4806 |
- syslog(LOG_ERR, _("No response from any clamd server - your AV system is not scanning emails")); |
|
4803 |
+ logg(_("!No response from any clamd server - your AV system is not scanning emails\n")); |
|
4807 | 4804 |
|
4808 | 4805 |
time(&thistime); |
4809 | 4806 |
pthread_mutex_lock(&time_mutex); |
... | ... |
@@ -5090,88 +5079,6 @@ timeoutBlacklist(char *ip_address, int time_of_blacklist) |
5090 | 5090 |
tableRemove(blacklist, ip_address); |
5091 | 5091 |
} |
5092 | 5092 |
|
5093 |
-static const struct { |
|
5094 |
- const char *name; |
|
5095 |
- int code; |
|
5096 |
-} facilitymap[] = { |
|
5097 |
-#ifdef LOG_AUTH |
|
5098 |
- { "LOG_AUTH", LOG_AUTH }, |
|
5099 |
-#endif |
|
5100 |
-#ifdef LOG_AUTHPRIV |
|
5101 |
- { "LOG_AUTHPRIV", LOG_AUTHPRIV }, |
|
5102 |
-#endif |
|
5103 |
-#ifdef LOG_CRON |
|
5104 |
- { "LOG_CRON", LOG_CRON }, |
|
5105 |
-#endif |
|
5106 |
-#ifdef LOG_DAEMON |
|
5107 |
- { "LOG_DAEMON", LOG_DAEMON }, |
|
5108 |
-#endif |
|
5109 |
-#ifdef LOG_FTP |
|
5110 |
- { "LOG_FTP", LOG_FTP }, |
|
5111 |
-#endif |
|
5112 |
-#ifdef LOG_KERN |
|
5113 |
- { "LOG_KERN", LOG_KERN }, |
|
5114 |
-#endif |
|
5115 |
-#ifdef LOG_LPR |
|
5116 |
- { "LOG_LPR", LOG_LPR }, |
|
5117 |
-#endif |
|
5118 |
-#ifdef LOG_MAIL |
|
5119 |
- { "LOG_MAIL", LOG_MAIL }, |
|
5120 |
-#endif |
|
5121 |
-#ifdef LOG_NEWS |
|
5122 |
- { "LOG_NEWS", LOG_NEWS }, |
|
5123 |
-#endif |
|
5124 |
-#ifdef LOG_AUTH |
|
5125 |
- { "LOG_AUTH", LOG_AUTH }, |
|
5126 |
-#endif |
|
5127 |
-#ifdef LOG_SYSLOG |
|
5128 |
- { "LOG_SYSLOG", LOG_SYSLOG }, |
|
5129 |
-#endif |
|
5130 |
-#ifdef LOG_USER |
|
5131 |
- { "LOG_USER", LOG_USER }, |
|
5132 |
-#endif |
|
5133 |
-#ifdef LOG_UUCP |
|
5134 |
- { "LOG_UUCP", LOG_UUCP }, |
|
5135 |
-#endif |
|
5136 |
-#ifdef LOG_LOCAL0 |
|
5137 |
- { "LOG_LOCAL0", LOG_LOCAL0 }, |
|
5138 |
-#endif |
|
5139 |
-#ifdef LOG_LOCAL1 |
|
5140 |
- { "LOG_LOCAL1", LOG_LOCAL1 }, |
|
5141 |
-#endif |
|
5142 |
-#ifdef LOG_LOCAL2 |
|
5143 |
- { "LOG_LOCAL2", LOG_LOCAL2 }, |
|
5144 |
-#endif |
|
5145 |
-#ifdef LOG_LOCAL3 |
|
5146 |
- { "LOG_LOCAL3", LOG_LOCAL3 }, |
|
5147 |
-#endif |
|
5148 |
-#ifdef LOG_LOCAL4 |
|
5149 |
- { "LOG_LOCAL4", LOG_LOCAL4 }, |
|
5150 |
-#endif |
|
5151 |
-#ifdef LOG_LOCAL5 |
|
5152 |
- { "LOG_LOCAL5", LOG_LOCAL5 }, |
|
5153 |
-#endif |
|
5154 |
-#ifdef LOG_LOCAL6 |
|
5155 |
- { "LOG_LOCAL6", LOG_LOCAL6 }, |
|
5156 |
-#endif |
|
5157 |
-#ifdef LOG_LOCAL7 |
|
5158 |
- { "LOG_LOCAL7", LOG_LOCAL7 }, |
|
5159 |
-#endif |
|
5160 |
- { NULL, -1 } |
|
5161 |
-}; |
|
5162 |
- |
|
5163 |
-static int |
|
5164 |
-logg_facility(const char *name) |
|
5165 |
-{ |
|
5166 |
- int i; |
|
5167 |
- |
|
5168 |
- for(i = 0; facilitymap[i].name; i++) |
|
5169 |
- if(strcasecmp(facilitymap[i].name, name) == 0) |
|
5170 |
- return facilitymap[i].code; |
|
5171 |
- |
|
5172 |
- return -1; |
|
5173 |
-} |
|
5174 |
- |
|
5175 | 5093 |
static void |
5176 | 5094 |
quit(void) |
5177 | 5095 |
{ |
... | ... |
@@ -5365,12 +5272,8 @@ loadDatabase(void) |
5365 | 5365 |
syslog(LOG_INFO, _("ClamAV: Protecting against %u viruses"), signatures); |
5366 | 5366 |
} |
5367 | 5367 |
if(oldroot) { |
5368 |
- char mess[128]; |
|
5369 |
- |
|
5370 | 5368 |
cl_free(oldroot); |
5371 |
- sprintf(mess, "Database correctly reloaded (%u viruses)", signatures); |
|
5372 |
- logger(mess); |
|
5373 |
- cli_dbgmsg("Database updated\n"); |
|
5369 |
+ logg("#Database correctly reloaded (%u viruses)", signatures); |
|
5374 | 5370 |
} else |
5375 | 5371 |
cli_dbgmsg("Database loaded\n"); |
5376 | 5372 |
|
... | ... |
@@ -5612,6 +5515,7 @@ isBlacklisted(const char *ip_address) |
5612 | 5612 |
return 0; |
5613 | 5613 |
} |
5614 | 5614 |
|
5615 |
+#if 0 |
|
5615 | 5616 |
static void |
5616 | 5617 |
logger(const char *mess) |
5617 | 5618 |
{ |
... | ... |
@@ -5649,6 +5553,7 @@ logger(const char *mess) |
5649 | 5649 |
fclose(fout); |
5650 | 5650 |
#endif |
5651 | 5651 |
} |
5652 |
+#endif |
|
5652 | 5653 |
|
5653 | 5654 |
/* |
5654 | 5655 |
* Determine our MX peers, they must never be blacklisted |