68
72
char updtmpdir[512], dbdir[512];
69
73
int sigchld_wait = 1;
70
74
const char *pidfile = NULL;
77
void submit_host_info(struct optstruct *opts);
78
char *get_hostid(void *cbdata);
73
81
sighandler (int sig)
191
199
(" --list-mirrors print mirrors from mirrors.dat\n");
193
(" --submit-stats[=/path/clamd.conf] only submit detection statistics\n");
201
(" --enable-stats enable statistical information reporting\n");
203
(" --stats-host-id=UUID HostID in the form of an UUID to use when submitting statistical information\n");
195
205
(" --update-db=DBNAME only update database DBNAME\n");
344
/* Stats/intelligence gathering */
345
if (optget(opts, "stats-host-id")->enabled) {
346
char *p = optget(opts, "stats-host-id")->strarg;
348
if (strcmp(p, "default")) {
349
if (!strcmp(p, "anonymous")) {
350
strcpy(hostid, STATS_ANON_UUID);
352
if (strlen(p) > 36) {
353
logg("!Invalid HostID\n");
361
strcpy(hostid, "default");
364
submit_host_info(opts);
334
366
if (optget (opts, "HTTPProxyPassword")->enabled)
336
368
if (CLAMSTAT (cfgfile, &statbuf) == -1)
636
668
ret = download (opts, cfgfile);
640
if ((opt = optget (opts, "SubmitDetectionStats"))->enabled)
641
submitstats (opt->strarg, opts);
645
672
if ((opt = optget (opts, "OnErrorExecute"))->enabled)
646
673
arg = opt->strarg;
699
if ((opt = optget (opts, "submit-stats"))->active)
701
if (!optget (opts, "no-warnings")->enabled)
702
logg (" *** Virus databases are not updated in this mode ***\n");
703
ret = submitstats (opt->strarg, opts);
707
ret = download (opts, cfgfile);
709
if ((opt = optget (opts, "SubmitDetectionStats"))->enabled)
710
submitstats (opt->strarg, opts);
726
ret = download (opts, cfgfile);
747
void submit_host_info(struct optstruct *opts)
749
struct optstruct *opt;
750
struct cl_engine *engine;
753
if (!optget(opts, "enable-stats")->enabled)
756
engine = cl_engine_new();
760
if (optget (opts, "Debug")->enabled || optget (opts, "debug")->enabled)
763
if (optget (opts, "verbose")->enabled)
766
cl_engine_stats_enable(engine);
768
intel = engine->stats_data;
770
engine->cb_stats_submit = NULL;
771
cl_engine_free(engine);
775
intel->host_info = calloc(1, strlen(TARGET_OS_TYPE) + strlen(TARGET_ARCH_TYPE) + 2);
776
if (!(intel->host_info)) {
777
engine->cb_stats_submit = NULL;
778
cl_engine_free(engine);
782
sprintf(intel->host_info, "%s %s", TARGET_OS_TYPE, TARGET_ARCH_TYPE);
784
if (!strcmp(hostid, "none"))
785
cl_engine_set_clcb_stats_get_hostid(engine, NULL);
786
else if (strcmp(hostid, "default"))
787
cl_engine_set_clcb_stats_get_hostid(engine, get_hostid);
789
if (optget(opts, "stats-timeout")->enabled) {
790
cl_engine_set_num(engine, CL_ENGINE_STATS_TIMEOUT, optget(opts, "StatsTimeout")->numarg);
793
cl_engine_free(engine);
796
int is_valid_hostid(void)
800
if (strlen(hostid) != 36)
804
for (i=0; i < 36; i++)
805
if (hostid[i] == '-')
811
if (hostid[8] != '-' || hostid[13] != '-' || hostid[18] != '-' || hostid[23] != '-')
817
char *get_hostid(void *cbdata)
819
if (!strcmp(hostid, "none"))
822
if (!is_valid_hostid())
823
return strdup(STATS_ANON_UUID);
825
logg("HostID is valid: %s\n", hostid);
827
return strdup(hostid);