From 011b4f295abb497866cc2e043c384c1aab8c3882 Mon Sep 17 00:00:00 2001 From: Tomasz Kojm Date: Sun, 11 Feb 2007 10:21:16 +0000 Subject: [PATCH] add option ScriptedUpdates git-svn: trunk@2702 --- clamav-devel/ChangeLog | 4 ++++ clamav-devel/docs/man/freshclam.conf.5.in | 5 +++++ clamav-devel/etc/freshclam.conf | 4 ++++ clamav-devel/freshclam/manager.c | 14 +++++++++++--- clamav-devel/shared/cfgparser.c | 1 + 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/clamav-devel/ChangeLog b/clamav-devel/ChangeLog index b757fb8f2..cdb5f1762 100644 --- a/clamav-devel/ChangeLog +++ b/clamav-devel/ChangeLog @@ -1,3 +1,7 @@ +Sun Feb 11 11:19:57 CET 2007 (tk) +--------------------------------- + * freshclam: add option ScriptedUpdates, requested by Luca + Sun Feb 11 01:38:26 CET 2007 (tk) --------------------------------- * remove part of warnings from gcc, patch from Edwin diff --git a/clamav-devel/docs/man/freshclam.conf.5.in b/clamav-devel/docs/man/freshclam.conf.5.in index f5bf68fcc..f277e1496 100644 --- a/clamav-devel/docs/man/freshclam.conf.5.in +++ b/clamav-devel/docs/man/freshclam.conf.5.in @@ -84,6 +84,11 @@ Freshclam(1) tries every mirror this number of times before switching to the nex .br . Default: 3 (per mirror) .TP +\fBScriptedUpdates BOOL\fR +With this option you can control scripted updates. It's highly recommended to keep it enabled. +.br . +Default: enabled +.TP \fBHTTPProxyServer STR\fR, \fBHTTPProxyPort NUM\fR Use given proxy server and TCP port for database downloads. .TP diff --git a/clamav-devel/etc/freshclam.conf b/clamav-devel/etc/freshclam.conf index ef5412949..885d9ba78 100644 --- a/clamav-devel/etc/freshclam.conf +++ b/clamav-devel/etc/freshclam.conf @@ -64,6 +64,10 @@ DatabaseMirror database.clamav.net # Default: 3 (per mirror) #MaxAttempts 5 +# With this option you can control scripted updates. It's highly recommended +# to keep it enabled. +#ScriptedUpdates yes + # Number of database checks per day. # Default: 12 (every two hours) #Checks 24 diff --git a/clamav-devel/freshclam/manager.c b/clamav-devel/freshclam/manager.c index 8dca8153f..1ec2617a7 100644 --- a/clamav-devel/freshclam/manager.c +++ b/clamav-devel/freshclam/manager.c @@ -788,10 +788,12 @@ static struct cl_cvd *currentdb(const char *dbname, unsigned int *inc) snprintf(path, sizeof(path), "%s.inc", dbname); if(stat(path, &sb) != -1) { snprintf(path, sizeof(path), "%s.inc/%s.info", dbname, dbname); - *inc = 1; + if(inc) + *inc = 1; } else { snprintf(path, sizeof(path), "%s.cvd", dbname); - *inc = 0; + if(inc) + *inc = 0; } cvd = cl_cvdhead(path); @@ -953,6 +955,9 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig }; */ + if(!cfgopt(copt, "ScriptedUpdates")->enabled) + nodb = 1; + if(nodb) { ret = getcvd(dbfile, hostname, ip, localip, proxy, port, user, pass, uas, nodb, newver, ctimeout, rtimeout, mdat); if(ret) @@ -1012,12 +1017,15 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig } } - if(!(current = currentdb(dbname, &inc))) { + if(!(current = currentdb(dbname, NULL))) { /* should never be reached */ logg("!Can't parse new database\n"); return 55; /* FIXME */ } + if(nodb && inc) + rmdirs(dbinc); + logg("%s updated (version: %d, sigs: %d, f-level: %d, builder: %s)\n", inc ? dbinc : dbfile, current->version, current->sigs, current->fl, current->builder); if(flevel < current->fl) { diff --git a/clamav-devel/shared/cfgparser.c b/clamav-devel/shared/cfgparser.c index 36c3870a5..f03d272de 100644 --- a/clamav-devel/shared/cfgparser.c +++ b/clamav-devel/shared/cfgparser.c @@ -107,6 +107,7 @@ struct cfgoption cfg_options[] = { {"DNSDatabaseInfo", OPT_QUOTESTR, -1, "current.cvd.clamav.net", 0, OPT_FRESHCLAM}, {"DatabaseMirror", OPT_QUOTESTR, -1, NULL, 1, OPT_FRESHCLAM}, {"MaxAttempts", OPT_NUM, 3, NULL, 0, OPT_FRESHCLAM}, + {"ScriptedUpdates", OPT_BOOL, 1, NULL, 0, OPT_FRESHCLAM}, {"HTTPProxyServer", OPT_QUOTESTR, -1, NULL, 0, OPT_FRESHCLAM}, {"HTTPProxyPort", OPT_NUM, -1, NULL, 0, OPT_FRESHCLAM}, {"HTTPProxyUsername", OPT_QUOTESTR, -1, NULL, 0, OPT_FRESHCLAM},