Browse code

freshclam: fix again handling of relative db paths (bb#2240)

Tomasz Kojm authored on 2010/12/22 20:12:18
Showing 4 changed files
... ...
@@ -1,3 +1,7 @@
1
+Wed Dec 22 12:10:06 CET 2010 (tk)
2
+---------------------------------
3
+ * freshclam: fix again handling of relative db paths (bb#2240)
4
+
1 5
 Tue Dec 21 16:00:26 CET 2010 (acab)
2 6
 -----------------------------------
3 7
  * clamav-milter: add LogClean option (bb#2442)
... ...
@@ -63,7 +63,7 @@ static short terminate = 0;
63 63
 extern int active_children;
64 64
 
65 65
 static short foreground = 1;
66
-char updtmpdir[512];
66
+char updtmpdir[512], dbdir[512];
67 67
 int sigchld_wait = 1;
68 68
 
69 69
 static void sighandler(int sig) {
... ...
@@ -164,7 +164,7 @@ static void help(void)
164 164
     mprintf("\n");
165 165
 }
166 166
 
167
-static int download(const struct optstruct *opts, const char *datadir, const char *cfgfile)
167
+static int download(const struct optstruct *opts, const char *cfgfile)
168 168
 {
169 169
 	int ret = 0, try = 0, maxattempts = 0;
170 170
 	const struct optstruct *opt;
... ...
@@ -178,7 +178,7 @@ static int download(const struct optstruct *opts, const char *datadir, const cha
178 178
 	return 56;
179 179
     } else {
180 180
 	while(opt) {
181
-	    ret = downloadmanager(opts, opt->strarg, datadir, try == maxattempts - 1);
181
+	    ret = downloadmanager(opts, opt->strarg, try == maxattempts - 1);
182 182
 #ifndef _WIN32
183 183
 	    alarm(0);
184 184
 #endif
... ...
@@ -224,7 +224,7 @@ int main(int argc, char **argv)
224 224
 {
225 225
 	int ret = 52, retcl;
226 226
 	const char *cfgfile, *arg = NULL, *pidfile = NULL;
227
-	char *pt, dbdir[512];
227
+	char *pt;
228 228
 	struct optstruct *opts;
229 229
 	const struct optstruct *opt;
230 230
 #ifndef	_WIN32
... ...
@@ -471,7 +471,7 @@ int main(int argc, char **argv)
471 471
 	logg("#freshclam daemon %s (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n", get_version());
472 472
 
473 473
 	while(!terminate) {
474
-	    ret = download(opts, dbdir, cfgfile);
474
+	    ret = download(opts, cfgfile);
475 475
 
476 476
 	    if(ret <= 1) {
477 477
 		if((opt = optget(opts, "SubmitDetectionStats"))->enabled)
... ...
@@ -529,7 +529,7 @@ int main(int argc, char **argv)
529 529
 		logg(" *** Virus databases are not updated in this mode ***\n");
530 530
 	    ret = submitstats(opt->strarg, opts);
531 531
 	} else {
532
-	    ret = download(opts, dbdir, cfgfile);
532
+	    ret = download(opts, cfgfile);
533 533
 
534 534
 	    if((opt = optget(opts, "SubmitDetectionStats"))->enabled)
535 535
 		submitstats(opt->strarg, opts);
... ...
@@ -83,7 +83,7 @@
83 83
 #include "libclamav/cvd.h"
84 84
 #include "libclamav/regex_list.h"
85 85
 
86
-extern char updtmpdir[512];
86
+extern char updtmpdir[512], dbdir[512];
87 87
 
88 88
 #define CHDIR_ERR(x)				\
89 89
 	if(chdir(x) == -1)			\
... ...
@@ -1132,7 +1132,7 @@ static int getfile(const char *srcfile, const char *destfile, const char *hostna
1132 1132
 
1133 1133
     if(mdat) {
1134 1134
 	mirman_update_sf(mdat->currip, mdat->af, mdat, 0, 1);
1135
-	mirman_write("mirrors.dat", optget(opts, "DatabaseDirectory")->strarg, mdat);
1135
+	mirman_write("mirrors.dat", dbdir, mdat);
1136 1136
     }
1137 1137
 
1138 1138
     ret = getfile_mirman(srcfile, destfile, hostname, ip, localip, proxy, port, user, pass, uas, ctimeout, rtimeout, mdat, logerr, can_whitelist, ims, ipaddr, sd);
... ...
@@ -1140,7 +1140,7 @@ static int getfile(const char *srcfile, const char *destfile, const char *hostna
1140 1140
 
1141 1141
     if(mdat) {
1142 1142
 	mirman_update_sf(mdat->currip, mdat->af, mdat, 0, -1);
1143
-	mirman_write("mirrors.dat", optget(opts, "DatabaseDirectory")->strarg, mdat);
1143
+	mirman_write("mirrors.dat", dbdir, mdat);
1144 1144
     }
1145 1145
 
1146 1146
     return ret;
... ...
@@ -2047,7 +2047,7 @@ static int updatecustomdb(const char *url, int *signo, const struct optstruct *o
2047 2047
     return 0;
2048 2048
 }
2049 2049
 
2050
-int downloadmanager(const struct optstruct *opts, const char *hostname, const char *dbdir, int logerr)
2050
+int downloadmanager(const struct optstruct *opts, const char *hostname, int logerr)
2051 2051
 {
2052 2052
 	time_t currtime;
2053 2053
 	int ret, updated = 0, outdated = 0, signo = 0;
... ...
@@ -25,7 +25,7 @@
25 25
 
26 26
 #include "shared/optparser.h"
27 27
 
28
-int downloadmanager(const struct optstruct *opts, const char *hostname, const char *dbdir, int logerr);
28
+int downloadmanager(const struct optstruct *opts, const char *hostname, int logerr);
29 29
 
30 30
 int submitstats(const char *clamdcfg, const struct optstruct *opts);
31 31