Browse code

add option ScriptedUpdates

git-svn: trunk@2702

Tomasz Kojm authored on 2007/02/11 19:21:16
Showing 5 changed files
... ...
@@ -1,3 +1,7 @@
1
+Sun Feb 11 11:19:57 CET 2007 (tk)
2
+---------------------------------
3
+  * freshclam: add option ScriptedUpdates, requested by Luca
4
+
1 5
 Sun Feb 11 01:38:26 CET 2007 (tk)
2 6
 ---------------------------------
3 7
   * remove part of warnings from gcc, patch from Edwin
... ...
@@ -84,6 +84,11 @@ Freshclam(1) tries every mirror this number of times before switching to the nex
84 84
 .br .
85 85
 Default: 3 (per mirror)
86 86
 .TP 
87
+\fBScriptedUpdates BOOL\fR
88
+With this option you can control scripted updates. It's highly recommended to keep it enabled.
89
+.br .
90
+Default: enabled
91
+.TP 
87 92
 \fBHTTPProxyServer STR\fR, \fBHTTPProxyPort NUM\fR
88 93
 Use given proxy server and TCP port for database downloads.
89 94
 .TP 
... ...
@@ -64,6 +64,10 @@ DatabaseMirror database.clamav.net
64 64
 # Default: 3 (per mirror)
65 65
 #MaxAttempts 5
66 66
 
67
+# With this option you can control scripted updates. It's highly recommended
68
+# to keep it enabled.
69
+#ScriptedUpdates yes
70
+
67 71
 # Number of database checks per day.
68 72
 # Default: 12 (every two hours)
69 73
 #Checks 24
... ...
@@ -788,10 +788,12 @@ static struct cl_cvd *currentdb(const char *dbname, unsigned int *inc)
788 788
     snprintf(path, sizeof(path), "%s.inc", dbname);
789 789
     if(stat(path, &sb) != -1) {
790 790
 	snprintf(path, sizeof(path), "%s.inc/%s.info", dbname, dbname);
791
-	*inc = 1;
791
+	if(inc)
792
+	    *inc = 1;
792 793
     } else {
793 794
 	snprintf(path, sizeof(path), "%s.cvd", dbname);
794
-	*inc = 0;
795
+	if(inc)
796
+	    *inc = 0;
795 797
     }
796 798
 
797 799
     cvd = cl_cvdhead(path);
... ...
@@ -953,6 +955,9 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig
953 953
     };
954 954
     */
955 955
 
956
+    if(!cfgopt(copt, "ScriptedUpdates")->enabled)
957
+	nodb = 1;
958
+
956 959
     if(nodb) {
957 960
 	ret = getcvd(dbfile, hostname, ip, localip, proxy, port, user, pass, uas, nodb, newver, ctimeout, rtimeout, mdat);
958 961
 	if(ret)
... ...
@@ -1012,12 +1017,15 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig
1012 1012
 	}
1013 1013
     }
1014 1014
 
1015
-    if(!(current = currentdb(dbname, &inc))) {
1015
+    if(!(current = currentdb(dbname, NULL))) {
1016 1016
 	/* should never be reached */
1017 1017
 	logg("!Can't parse new database\n");
1018 1018
 	return 55; /* FIXME */
1019 1019
     }
1020 1020
 
1021
+    if(nodb && inc)
1022
+	rmdirs(dbinc);
1023
+
1021 1024
     logg("%s updated (version: %d, sigs: %d, f-level: %d, builder: %s)\n", inc ? dbinc : dbfile, current->version, current->sigs, current->fl, current->builder);
1022 1025
 
1023 1026
     if(flevel < current->fl) {
... ...
@@ -107,6 +107,7 @@ struct cfgoption cfg_options[] = {
107 107
     {"DNSDatabaseInfo", OPT_QUOTESTR, -1, "current.cvd.clamav.net", 0, OPT_FRESHCLAM},
108 108
     {"DatabaseMirror", OPT_QUOTESTR, -1, NULL, 1, OPT_FRESHCLAM},
109 109
     {"MaxAttempts", OPT_NUM, 3, NULL, 0, OPT_FRESHCLAM},
110
+    {"ScriptedUpdates", OPT_BOOL, 1, NULL, 0, OPT_FRESHCLAM},
110 111
     {"HTTPProxyServer", OPT_QUOTESTR, -1, NULL, 0, OPT_FRESHCLAM},
111 112
     {"HTTPProxyPort", OPT_NUM, -1, NULL, 0, OPT_FRESHCLAM},
112 113
     {"HTTPProxyUsername", OPT_QUOTESTR, -1, NULL, 0, OPT_FRESHCLAM},