Browse code

Honour DetectPhishing from clamd.conf

git-svn: trunk@2167

Nigel Horne authored on 2006/08/02 22:49:29
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Wed Aug  2 14:48:36 BST 2006 (njh)
2
+----------------------------------
3
+  * clamav-milter:	Honour DetectPhishing in clamd.conf
4
+
1 5
 Wed Aug  2 15:27:01 CEST 2006 (tk)
2 6
 ----------------------------------
3 7
   * freshclam/manager.c: fix call to getcvd()
... ...
@@ -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.272 2006/08/01 07:32:41 njh Exp $";
26
+static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.273 2006/08/02 13:48:05 njh Exp $";
27 27
 
28
-#define	CM_VERSION	"devel-010806"
28
+#define	CM_VERSION	"devel-020806"
29 29
 
30 30
 #if HAVE_CONFIG_H
31 31
 #include "clamav-config.h"
... ...
@@ -4900,8 +4900,11 @@ watchdog(void *a)
4900 4900
 		cli_dbgmsg("watchdog wakes\n");
4901 4901
 
4902 4902
 		if(check_and_reload_database() != 0) {
4903
-			smfi_stop();
4904
-			return NULL;
4903
+			if(cl_error != SMFIS_ACCEPT) {
4904
+				smfi_stop();
4905
+				return NULL;
4906
+			}
4907
+			logg(_("!No emails will be scanned"));
4905 4908
 		}
4906 4909
 
4907 4910
 		i = 0;
... ...
@@ -5044,8 +5047,11 @@ watchdog(void *a)
5044 5044
 		 * see, and there's no access to it via an approved method
5045 5045
 		 */
5046 5046
 		if(check_and_reload_database() != 0) {
5047
-			smfi_stop();
5048
-			return NULL;
5047
+			if(cl_error != SMFIS_ACCEPT) {
5048
+				smfi_stop();
5049
+				return NULL;
5050
+			}
5051
+			logg(_("!No emails will be scanned"));
5049 5052
 		}
5050 5053
 		/* Garbage collect IP addresses no longer blacklisted */
5051 5054
 		if(blacklist) {
... ...
@@ -5073,21 +5079,19 @@ check_and_reload_database(void)
5073 5073
 
5074 5074
 	switch(cl_statchkdir(&dbstat)) {
5075 5075
 		case 1:
5076
-			cli_dbgmsg("Database has changed\n");
5076
+			logg("^Database has changed, loading updated database\n");
5077 5077
 			cl_statfree(&dbstat);
5078
-			if(use_syslog)
5079
-				syslog(LOG_WARNING, _("Loading new database"));
5080 5078
 			rc = loadDatabase();
5081 5079
 			if(rc != 0) {
5082
-				cli_errmsg("Failed to load updated database\n");
5080
+				logg("!Failed to load updated database\n");
5083 5081
 				return rc;
5084 5082
 			}
5085 5083
 			break;
5086 5084
 		case 0:
5087
-			cli_dbgmsg("Database has not changed\n");
5085
+			logg("Database has not changed\n");
5088 5086
 			break;
5089 5087
 		default:
5090
-			cli_errmsg("Database error - %s is stopping\n", progname);
5088
+			logg("Database error - %s is stopping\n", progname);
5091 5089
 			return 1;
5092 5090
 	}
5093 5091
 	return 0;	/* all OK */
... ...
@@ -5197,7 +5201,7 @@ loadDatabase(void)
5197 5197
 {
5198 5198
 	/*extern const char *cl_retdbdir(void);	/* FIXME: should be included */
5199 5199
 	int ret, v;
5200
-	unsigned int signatures;
5200
+	unsigned int signatures, dboptions;
5201 5201
 	time_t t;
5202 5202
 	char *daily, *ptr;
5203 5203
 	struct cl_cvd *d;
... ...
@@ -5263,19 +5267,26 @@ loadDatabase(void)
5263 5263
 
5264 5264
 	signatures = 0;
5265 5265
 	newroot = NULL;
5266
-	ret = cl_loaddbdir(dbdir, &newroot, &signatures);
5266
+	dboptions = 0;
5267
+
5268
+	if(!cfgopt(copt, "DetectPhishing")->enabled) {
5269
+		dboptions |= CL_DB_NOPHISHING;
5270
+		logg("Not loading phishing signatures.\n");
5271
+	}
5272
+
5273
+	ret = cl_load(dbdir, &newroot, &signatures, dboptions);
5267 5274
 	if(ret != 0) {
5268
-		cli_errmsg("%s\n", cl_strerror(ret));
5275
+		logg("!%s\n", cl_strerror(ret));
5269 5276
 		return -1;
5270 5277
 	}
5271 5278
 	if(newroot == NULL) {
5272
-		cli_errmsg("Can't initialize the virus database.\n");
5279
+		logg("!Can't initialize the virus database.\n");
5273 5280
 		return -1;
5274 5281
 	}
5275 5282
 
5276 5283
 	ret = cl_build(newroot);
5277 5284
 	if(ret != 0) {
5278
-		cli_errmsg("Database initialization error: %s\n", cl_strerror(ret));
5285
+		logg("!Database initialization error: %s\n", cl_strerror(ret));
5279 5286
 		cl_free(newroot);
5280 5287
 		return -1;
5281 5288
 	}
... ...
@@ -5312,9 +5323,7 @@ sigsegv(int sig)
5312 5312
 	print_trace();
5313 5313
 #endif
5314 5314
 
5315
-	if(use_syslog)
5316
-		syslog(LOG_CRIT, "Segmentation fault :-( Bye..");
5317
-	cli_errmsg("Segmentation fault :-( Bye..\n");
5315
+	logg("!Segmentation fault :-( Bye..\n");
5318 5316
 
5319 5317
 	smfi_stop();
5320 5318
 }