Browse code

enable DNSDatabaseInfo by default; add --no-dns option

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@817 77e5149b-7576-45b1-b177-96237e5ba77b

Tomasz Kojm authored on 2004/09/01 09:25:22
Showing 7 changed files
... ...
@@ -1,3 +1,8 @@
1
+Wed Sep  1 02:21:41 CEST 2004 (tk)
2
+----------------------------------
3
+  * etc/freshclam.conf: enable DNSDatabaseInfo by default
4
+  * freshclam: add --no-dns option
5
+
1 6
 Tue Aug 31 20:39:34 CEST 2004 (tk)
2 7
 ----------------------------------
3 8
   * sigtool: add support for *.hdb files in -l; include creation time in
... ...
@@ -1,5 +1,5 @@
1 1
 .\" Manual page created by Tomasz Kojm, 20020415
2
-.TH "freshclam" "1" "March 14, 2004" "Tomasz Kojm" "Clam AntiVirus"
2
+.TH "freshclam" "1" "September 1, 2004" "Tomasz Kojm" "Clam AntiVirus"
3 3
 .SH "NAME"
4 4
 .LP 
5 5
 freshclam \- update virus databases
... ...
@@ -43,6 +43,9 @@ Run in a daemon mode. This option requires \-\-checks.
43 43
 \fB\-p FILE, \-\-pid=FILE\fR
44 44
 Save daemon's pid in FILE.
45 45
 .TP 
46
+\fB\-\-no\-dns\fR
47
+This option forces old non\-DNS verification method (without a TTL delay).
48
+.TP 
46 49
 \fB\-c #n, \-\-checks=#n\fR
47 50
 Check #n times per day for a new database. #n must be between 1 and 50.
48 51
 .TP 
... ...
@@ -29,7 +29,7 @@
29 29
 #DatabaseOwner clamav
30 30
 
31 31
 # Use DNS to verify virus database version.
32
-#DNSDatabaseInfo current.cvd.clamav.net
32
+DNSDatabaseInfo current.cvd.clamav.net
33 33
 
34 34
 # The main database mirror is database.clamav.net (this is a round-robin
35 35
 # DNS that points to many mirrors on the world) and in most cases you
... ...
@@ -425,6 +425,7 @@ void help(void)
425 425
     mprintf("    --daemon             -d              run in daemon mode\n");
426 426
     mprintf("    --pid=FILE           -p FILE         save daemon's pid in FILE\n");
427 427
     mprintf("    --user=USER          -u USER         run as USER\n");
428
+    mprintf("    --no-dns                             force old non-DNS verification method\n");
428 429
     mprintf("    --checks=#n          -c #n           number of checks per day, 1 <= n <= 50\n");
429 430
     mprintf("    --datadir=DIRECTORY                  download new databases into DIRECTORY\n");
430 431
 #ifdef BUILD_CLAMD
... ...
@@ -53,7 +53,7 @@
53 53
 int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, const char *hostname)
54 54
 {
55 55
 	time_t currtime;
56
-	int ret, updated = 0, signo = 0;
56
+	int ret, updated = 0, signo = 0, usedns;
57 57
 	char ipaddr[16];
58 58
 	struct cfgstruct *cpt;
59 59
 
... ...
@@ -67,15 +67,17 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c
67 67
     logg("SECURITY WARNING: NO SUPPORT FOR DIGITAL SIGNATURES\n");
68 68
 #endif
69 69
 
70
+    optl(opt, "no-dns") ? (usedns = 0) : (usedns = 1);
71
+
70 72
     memset(ipaddr, 0, sizeof(ipaddr));
71 73
 
72
-    if((ret = downloaddb(DB1NAME, "main.cvd", hostname, ipaddr, &signo, copt)) > 50)
74
+    if((ret = downloaddb(DB1NAME, "main.cvd", hostname, ipaddr, &signo, copt, usedns)) > 50)
73 75
 	return ret;
74 76
     else if(ret == 0)
75 77
 	updated = 1;
76 78
 
77 79
     /* if ipaddr[0] != 0 it will use it to connect to the web host */
78
-    if((ret = downloaddb(DB2NAME, "daily.cvd", hostname, ipaddr, &signo, copt)) > 50)
80
+    if((ret = downloaddb(DB2NAME, "daily.cvd", hostname, ipaddr, &signo, copt, usedns)) > 50)
79 81
 	return ret;
80 82
     else if(ret == 0)
81 83
 	updated = 1;
... ...
@@ -127,7 +129,7 @@ static int isnumb(const char *str)
127 127
     return 1;
128 128
 }
129 129
 
130
-int downloaddb(const char *localname, const char *remotename, const char *hostname, char *ip, int *signo, const struct cfgstruct *copt)
130
+int downloaddb(const char *localname, const char *remotename, const char *hostname, char *ip, int *signo, const struct cfgstruct *copt, int usedns)
131 131
 {
132 132
 	struct cl_cvd *current, *remote;
133 133
 	struct cfgstruct *cpt;
... ...
@@ -140,7 +142,8 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna
140 140
     if((current = cl_cvdhead(localname)) == NULL)
141 141
 	nodb = 1;
142 142
 
143
-    if(!nodb && (cpt = cfgopt(copt, "DNSDatabaseInfo"))) {
143
+
144
+    if(!nodb && usedns && (cpt = cfgopt(copt, "DNSDatabaseInfo"))) {
144 145
 	if((dnsreply = txtquery(cpt->strarg, &ttl))) {
145 146
 		int field = 0;
146 147
 
... ...
@@ -249,11 +252,14 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna
249 249
     if(current)
250 250
 	cl_cvdfree(current);
251 251
 
252
-    if(ipaddr[0])
252
+    if(ipaddr[0]) {
253 253
 	/* use ipaddr in order to connect to the same mirror */
254 254
 	hostfd = wwwconnect(ipaddr, proxy, port, NULL);
255
-    else
256
-	hostfd = wwwconnect(hostname, proxy, port, NULL);
255
+    } else {
256
+	hostfd = wwwconnect(hostname, proxy, port, ipaddr);
257
+	if(!ip[0])
258
+	    strcpy(ip, ipaddr);
259
+    }
257 260
 
258 261
     if(hostfd < 0) {
259 262
 	if(ipaddr[0])
... ...
@@ -24,7 +24,7 @@
24 24
 
25 25
 int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, const char *hostname);
26 26
 
27
-int downloaddb(const char *localname, const char *remotename, const char *hostname, char *ip, int *signo, const struct cfgstruct *copt);
27
+int downloaddb(const char *localname, const char *remotename, const char *hostname, char *ip, int *signo, const struct cfgstruct *copt, int usedns);
28 28
 
29 29
 int wwwconnect(const char *server, const char *proxy, int pport, char *ip);
30 30
 
... ...
@@ -58,6 +58,7 @@ int main(int argc, char **argv)
58 58
 	    {"pid", 1, 0, 'p'},
59 59
 	    {"user", 1, 0, 'u'}, /* not used */
60 60
 	    {"config-file", 1, 0, 0},
61
+	    {"no-dns", 0, 0, 0},
61 62
 	    {"checks", 1, 0, 'c'},
62 63
 	    {"http-proxy", 1, 0, 0},
63 64
 	    {"proxy-user", 1, 0, 0},