Browse code

freshclam: add support for DetectionStatsHostID (bb#1503)

Tomasz Kojm authored on 2009/11/06 20:44:19
Showing 3 changed files
... ...
@@ -1,3 +1,7 @@
1
+Fri Nov  6 12:22:33 CET 2009 (tk)
2
+---------------------------------
3
+ * freshclam: add support for DetectionStatsHostID (bb#1503)
4
+
1 5
 Tue Nov  3 22:50:30 CET 2009 (tk)
2 6
 ---------------------------------
3 7
  * libclamav, freshclam: fix handling of dbs when both daily.cvd and daily.cld
... ...
@@ -525,7 +525,7 @@ int submitstats(const char *clamdcfg, const struct optstruct *opts)
525 525
 	char buff[512], statsdat[512], newstatsdat[512], uastr[128];
526 526
 	char logfile[256], fbuff[FILEBUFF];
527 527
 	char *pt, *pt2, *auth = NULL;
528
-	const char *line, *country = NULL, *user, *proxy = NULL;
528
+	const char *line, *country = NULL, *user, *proxy = NULL, *hostid = NULL;
529 529
 	struct optstruct *clamdopt;
530 530
 	const struct optstruct *opt;
531 531
 	struct stat sb;
... ...
@@ -534,6 +534,11 @@ int submitstats(const char *clamdcfg, const struct optstruct *opts)
534 534
 	unsigned int qcnt, entries, submitted = 0, permfail = 0, port = 0;
535 535
 
536 536
 
537
+    if(optget(opts, "HTTPUserAgent")->enabled) {
538
+	logg("!SubmitDetectionStats: HTTPUserAgent must be disabled for SubmitDetectionStats to work\n");
539
+	return 56;
540
+    }
541
+
537 542
     if((opt = optget(opts, "DetectionStatsCountry"))->enabled) {
538 543
 	if(strlen(opt->strarg) != 2 || !isalpha(opt->strarg[0]) || !isalpha(opt->strarg[1])) {
539 544
 	    logg("!SubmitDetectionStats: DetectionStatsCountry requires a two-letter country code\n");
... ...
@@ -542,6 +547,14 @@ int submitstats(const char *clamdcfg, const struct optstruct *opts)
542 542
 	country = opt->strarg;
543 543
     }
544 544
 
545
+    if((opt = optget(opts, "DetectionStatsHostID"))->enabled) {
546
+	if(strlen(opt->strarg) != 32) {
547
+	    logg("!SubmitDetectionStats: The unique ID must be 32 characters long\n");
548
+	    return 56;
549
+	}
550
+	hostid = opt->strarg;
551
+    }
552
+
545 553
     if(!(clamdopt = optparse(clamdcfg, 0, NULL, 1, OPT_CLAMD, 0, NULL))) {
546 554
 	logg("!SubmitDetectionStats: Can't open or parse configuration file %s\n", clamdcfg);
547 555
 	return 56;
... ...
@@ -602,10 +615,7 @@ int submitstats(const char *clamdcfg, const struct optstruct *opts)
602 602
 	strncpy(newstatsdat, line, sizeof(newstatsdat));
603 603
     }
604 604
 
605
-    if((opt = optget(opts, "HTTPUserAgent"))->enabled)
606
-	strncpy(uastr, opt->strarg, sizeof(uastr));
607
-    else
608
-	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 : "");
605
+    snprintf(uastr, sizeof(uastr), PACKAGE"/%s (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE"):%s:%s", get_version(), country ? country : "", hostid ? hostid : "");
609 606
     uastr[sizeof(uastr) - 1] = 0;
610 607
 
611 608
     if((opt = optget(opts, "HTTPProxyServer"))->enabled) {
... ...
@@ -356,6 +356,8 @@ const struct clam_option __clam_options[] = {
356 356
 
357 357
     { "DetectionStatsCountry", NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_FRESHCLAM, "Country of origin of malware/detection statistics (for statistical\npurposes only). The statistics collector at ClamAV.net will look up\nyour IP address to determine the geographical origin of the malware\nreported by your installation. If this installation is mainly used to\nscan data which comes from a different location, please enable this\noption and enter a two-letter code (see http://www.iana.org/domains/root/db/)\nof the country of origin.", "country-code" },
358 358
 
359
+    { "DetectionStatsHostID", NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_FRESHCLAM, "FIXME: Add description", "unique-id" },
360
+
359 361
     { "SafeBrowsing", NULL, 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM, "This option enables support for Google Safe Browsing. When activated for\nthe first time, freshclam will download a new database file (safebrowsing.cvd)\nwhich will be automatically loaded by clamd and clamscan during the next\nreload, provided that the heuristic phishing detection is turned on. This\ndatabase includes information about websites that may be phishing sites or\npossible sources of malware. When using this option, it's mandatory to run\nfreshclam at least every 30 minutes.\nFreshclam uses the ClamAV's mirror infrastructure to distribute the\ndatabase and its updates but all the contents are provided under Google's\nterms of use. See http://code.google.com/support/bin/answer.py?answer=70015\nand http://safebrowsing.clamav.net for more information.", "yes" },
360 362
 
361 363
     /* Deprecated options */