Browse code

freshclam: add new config option DetectionStatsCountry

git-svn: trunk@4297

Tomasz Kojm authored on 2008/10/29 04:10:48
Showing 5 changed files
... ...
@@ -1,3 +1,7 @@
1
+Tue Oct 28 20:37:35 CET 2008 (tk)
2
+---------------------------------
3
+  * freshclam: add new config option DetectionStatsCountry
4
+
1 5
 Tue Oct 28 10:52:41 CET 2008 (tk)
2 6
 ---------------------------------
3 7
   * freshclam: re-enable --submit-stats (bb#1235)
... ...
@@ -148,6 +148,11 @@ Default: 30
148 148
 When enabled freshclam will submit statistics to the ClamAV Project about the latest virus detections in your environment. The ClamAV maintainers will then use this data to determine what types of malware are the most detected in the field and in what geographic area they are. This feature requires LogTime and LogFile to be enabled in clamd.conf. The path for clamd.conf file must be provided.
149 149
 .br
150 150
 Default: disabled
151
+.TP
152
+\fBDetectionStatsCountry STRING\fR
153
+Country of origin of malware/detection statistics (for statistical purposes only). The statistics collector at ClamAV.net will look up your IP address to determine the geographical origin of the malware reported by your installation. If this installation is mainly used to scan data which comes from a different location, please enable this option and enter a two-letter code (see http://www.iana.org/domains/root/db/) of the country of origin.
154
+.br
155
+Default: disabled
151 156
 .SH "FILES"
152 157
 .LP 
153 158
 @CFGDIR@/freshclam.conf
... ...
@@ -149,3 +149,13 @@ DatabaseMirror database.clamav.net
149 149
 # This feature requires LogTime and LogFile to be enabled in clamd.conf.
150 150
 # Default: no
151 151
 #SubmitDetectionStats /path/to/clamd.conf
152
+
153
+# Country of origin of malware/detection statistics (for statistical
154
+# purposes only). The statistics collector at ClamAV.net will look up
155
+# your IP address to determine the geographical origin of the malware
156
+# reported by your installation. If this installation is mainly used to
157
+# scan data which comes from a different location, please enable this
158
+# option and enter a two-letter code (see http://www.iana.org/domains/root/db/)
159
+# of the country of origin.
160
+# Default: disabled
161
+#DetectionStatsCountry country-code
... ...
@@ -475,7 +475,7 @@ int submitstats(const char *clamdcfg, const struct cfgstruct *copt)
475 475
 	char buff[512], statsdat[512], newstatsdat[512], uastr[128];
476 476
 	char logfile[256], fbuff[FILEBUFF];
477 477
 	char *pt, *pt2;
478
-	const char *line;
478
+	const char *line, *country = NULL;
479 479
 	struct cfgstruct *clamdopt;
480 480
 	const struct cfgstruct *cpt;
481 481
 	struct stat sb;
... ...
@@ -484,6 +484,14 @@ int submitstats(const char *clamdcfg, const struct cfgstruct *copt)
484 484
 	unsigned int qcnt, entries, submitted = 0, permfail = 0;
485 485
 
486 486
 
487
+    if((cpt = cfgopt(copt, "DetectionStatsCountry"))->enabled) {
488
+	if(strlen(cpt->strarg) != 2 || !isalpha(cpt->strarg[0]) || !isalpha(cpt->strarg[1])) {
489
+	    logg("!SubmitDetectionStats: DetectionStatsCountry requires a two-letter country code\n");
490
+	    return 56;
491
+	}
492
+	country = cpt->strarg;
493
+    }
494
+
487 495
     if(!(clamdopt = getcfg(clamdcfg, 1))) {
488 496
 	logg("!SubmitDetectionStats: Can't open or parse configuration file %s\n", clamdcfg);
489 497
 	return 56;
... ...
@@ -547,7 +555,7 @@ int submitstats(const char *clamdcfg, const struct cfgstruct *copt)
547 547
     if((cpt = cfgopt(copt, "HTTPUserAgent"))->enabled)
548 548
 	strncpy(uastr, cpt->strarg, sizeof(uastr));
549 549
     else
550
-	snprintf(uastr, sizeof(uastr), PACKAGE"/%s (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")", get_version());
550
+	snprintf(uastr, sizeof(uastr), PACKAGE"/%s (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")%s%s", get_version(), country ? ":" : "", country ? country : "");
551 551
     uastr[sizeof(uastr) - 1] = 0;
552 552
 
553 553
     ret = 0;
... ...
@@ -129,6 +129,7 @@ struct cfgoption cfg_options[] = {
129 129
     {"ConnectTimeout", OPT_NUM, 30, NULL, 0, OPT_FRESHCLAM},
130 130
     {"ReceiveTimeout", OPT_NUM, 30, NULL, 0, OPT_FRESHCLAM},
131 131
     {"SubmitDetectionStats", OPT_QUOTESTR, -1, NULL, 0, OPT_FRESHCLAM},
132
+    {"DetectionStatsCountry", OPT_QUOTESTR, -1, NULL, 0, OPT_FRESHCLAM},
132 133
 
133 134
     {"DevACOnly", OPT_BOOL, -1, NULL, 0, OPT_CLAMD},
134 135
     {"DevACDepth", OPT_NUM, -1, NULL, 0, OPT_CLAMD},