Browse code

Turn stats into an opt-in feature rather than an opt-out feature for the 0.98.2 release

Shawn Webb authored on 2014/03/08 03:09:37
Showing 8 changed files
... ...
@@ -434,8 +434,8 @@ int main(int argc, char **argv)
434 434
             logg("#Not loading PUA signatures.\n");
435 435
         }
436 436
 
437
-        if (optget(opts, "StatsDisabled")->enabled) {
438
-            cl_engine_set_clcb_stats_add_sample(engine, NULL);
437
+        if (optget(opts, "StatsEnabled")->enabled) {
438
+            cl_engine_stats_enable(engine);
439 439
         }
440 440
 
441 441
         if (optget(opts, "StatsPEDisabled")->enabled) {
... ...
@@ -582,8 +582,8 @@ int scanmanager(const struct optstruct *opts)
582 582
         cl_engine_set_num(engine, CL_ENGINE_DISABLE_PE_STATS, 1);
583 583
     }
584 584
 
585
-    if (optget(opts, "disable-stats")->enabled) {
586
-        cl_engine_set_clcb_stats_add_sample(engine, NULL);
585
+    if (optget(opts, "enable-stats")->enabled) {
586
+        cl_engine_stats_enable(engine);
587 587
     }
588 588
 
589 589
     if (optget(opts, "stats-timeout")->enabled) {
... ...
@@ -742,6 +742,9 @@ void submit_host_info(struct optstruct *opts)
742 742
     struct cl_engine *engine;
743 743
     cli_intel_t *intel;
744 744
 
745
+    if (!optget(opts, "enable-stats")->enabled)
746
+        return;
747
+
745 748
     engine = cl_engine_new();
746 749
     if (!(engine))
747 750
         return;
... ...
@@ -398,6 +398,8 @@ extern void cl_engine_set_clcb_stats_get_size(struct cl_engine *engine, clcb_sta
398 398
 typedef char * (*clcb_stats_get_hostid)(void *cbdata);
399 399
 extern void cl_engine_set_clcb_stats_get_hostid(struct cl_engine *engine, clcb_stats_get_hostid callback);
400 400
 
401
+extern void cl_engine_stats_enable(struct cl_engine *engine);
402
+
401 403
 struct cl_stat {
402 404
     char *dir;
403 405
     STATBUF *stattab;
... ...
@@ -55,6 +55,7 @@ CLAMAV_PUBLIC {
55 55
     cl_update_hash;
56 56
     cl_finish_hash;
57 57
     cl_hash_destroy;
58
+    cl_engine_stats_enable;
58 59
 };
59 60
 CLAMAV_PRIVATE {
60 61
   global:
... ...
@@ -672,3 +672,9 @@ void cl_engine_set_clcb_stats_get_hostid(struct cl_engine *engine, clcb_stats_ge
672 672
 {
673 673
     engine->cb_stats_get_hostid = callback;
674 674
 }
675
+
676
+void cl_engine_stats_enable(struct cl_engine *engine)
677
+{
678
+    engine->cb_stats_add_sample = clamav_stats_add_sample;
679
+    engine->cb_stats_submit = clamav_stats_submit;
680
+}
... ...
@@ -186,7 +186,7 @@ const struct clam_option __clam_options[] = {
186 186
 
187 187
     { "StatsHostID", "stats-host-id", 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_FRESHCLAM | OPT_CLAMD | OPT_CLAMSCAN, "HostID in the form of an UUID to use when submitting statistical information. See the clamscan manpage for more information.", "default" },
188 188
 
189
-    { "StatsDisabled", "disable-stats", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_CLAMSCAN, "Disable submission of statistical data", "no" },
189
+    { "StatsEnabled", "enable-stats", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_CLAMSCAN, "Enable submission of statistical data", "yes" },
190 190
 
191 191
     { "StatsPEDisabled", "disable-pe-stats", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "Disable submission of PE section statistical data", "no" },
192 192
 
... ...
@@ -74,6 +74,7 @@ EXPORTS cl_hash_init @66
74 74
 EXPORTS cl_update_hash @67
75 75
 EXPORTS cl_finish_hash @68
76 76
 EXPORTS cl_hash_destroy @69
77
+EXPORTS cl_engine_stats_enable @70
77 78
 
78 79
 ; path variables
79 80
 ; --------------