Browse code

load daily.cfg before any other files

git-svn: trunk@2916

Tomasz Kojm authored on 2007/03/07 08:24:28
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Tue Mar  6 22:24:37 CET 2007 (tk)
2
+---------------------------------
3
+  * libclamav/readdb.c: load daily.cfg before any other files (when loading
4
+			daily.cvd/inc) and display dconf status only once
5
+
1 6
 Tue Mar  6 16:10:52 CET 2007 (tk)
2 7
 ---------------------------------
3 8
   * clamscan: fix gcc -W* warnings
... ...
@@ -1251,17 +1251,32 @@ static int cli_loaddbdir_l(const char *dirname, struct cl_engine **engine, unsig
1251 1251
 	    char b[offsetof(struct dirent, d_name) + NAME_MAX + 1];
1252 1252
 	} result;
1253 1253
 #endif
1254
+	struct stat sb;
1254 1255
 	char *dbfile;
1255 1256
 	int ret = CL_ESUPPORT;
1256 1257
 
1257 1258
 
1259
+    cli_dbgmsg("Loading databases from %s\n", dirname);
1260
+
1261
+    /* check for and load daily.cfg */
1262
+    dbfile = (char *) cli_malloc(strlen(dirname) + 11);
1263
+    if(!dbfile)
1264
+	return CL_EMEM;
1265
+    sprintf(dbfile, "%s/daily.cfg", dirname);
1266
+    if(stat(dbfile, &sb) != -1) {
1267
+	if((ret = cli_load(dbfile, engine, signo, options))) {
1268
+	    free(dbfile);
1269
+	    return ret;
1270
+	}
1271
+	cli_dconf_print((*engine)->dconf);
1272
+    }
1273
+    free(dbfile);
1274
+
1258 1275
     if((dd = opendir(dirname)) == NULL) {
1259 1276
         cli_errmsg("cli_loaddbdir(): Can't open directory %s\n", dirname);
1260 1277
         return CL_EOPEN;
1261 1278
     }
1262 1279
 
1263
-    cli_dbgmsg("Loading databases from %s\n", dirname);
1264
-
1265 1280
 #ifdef HAVE_READDIR_R_3
1266 1281
     while(!readdir_r(dd, &result.d, &dent) && dent) {
1267 1282
 #elif defined(HAVE_READDIR_R_2)
... ...
@@ -1284,7 +1299,6 @@ static int cli_loaddbdir_l(const char *dirname, struct cl_engine **engine, unsig
1284 1284
 	     cli_strbcasestr(dent->d_name, ".sdb")  ||
1285 1285
 	     cli_strbcasestr(dent->d_name, ".zmd")  ||
1286 1286
 	     cli_strbcasestr(dent->d_name, ".rmd")  ||
1287
-	     cli_strbcasestr(dent->d_name, ".cfg")  ||
1288 1287
 #ifdef CL_EXPERIMENTAL
1289 1288
 	     cli_strbcasestr(dent->d_name, ".pdb")  ||
1290 1289
 	     cli_strbcasestr(dent->d_name, ".wdb")  ||
... ...
@@ -1293,7 +1307,7 @@ static int cli_loaddbdir_l(const char *dirname, struct cl_engine **engine, unsig
1293 1293
 	     cli_strbcasestr(dent->d_name, ".inc")  ||
1294 1294
 	     cli_strbcasestr(dent->d_name, ".cvd"))) {
1295 1295
 
1296
-		dbfile = (char *) cli_calloc(strlen(dent->d_name) + strlen(dirname) + 2, sizeof(char));
1296
+		dbfile = (char *) cli_malloc(strlen(dent->d_name) + strlen(dirname) + 2);
1297 1297
 
1298 1298
 		if(!dbfile) {
1299 1299
 		    cli_dbgmsg("cli_loaddbdir(): dbfile == NULL\n");
... ...
@@ -1380,9 +1394,6 @@ int cl_load(const char *path, struct cl_engine **engine, unsigned int *signo, un
1380 1380
 	    return CL_EOPEN;
1381 1381
     }
1382 1382
 
1383
-    if(ret == CL_SUCCESS)
1384
-	cli_dconf_print((*engine)->dconf);
1385
-
1386 1383
     return ret;
1387 1384
 }
1388 1385
 
... ...
@@ -1474,7 +1485,7 @@ int cl_statinidir(const char *dirname, struct cl_stat *dbstat)
1474 1474
 		}
1475 1475
 #endif
1476 1476
 
1477
-                fname = cli_calloc(strlen(dirname) + strlen(dent->d_name) + 32, sizeof(char));
1477
+                fname = cli_malloc(strlen(dirname) + strlen(dent->d_name) + 32);
1478 1478
 		if(!fname) {
1479 1479
 		    cl_statfree(dbstat);
1480 1480
 		    closedir(dd);
... ...
@@ -1490,7 +1501,7 @@ int cl_statinidir(const char *dirname, struct cl_stat *dbstat)
1490 1490
 		    sprintf(fname, "%s/%s", dirname, dent->d_name);
1491 1491
 		}
1492 1492
 #if defined(C_INTERIX) || defined(C_OS2)
1493
-		dbstat->statdname[dbstat->entries - 1] = (char *) cli_calloc(strlen(dent->d_name) + 1, sizeof(char));
1493
+		dbstat->statdname[dbstat->entries - 1] = (char *) cli_malloc(strlen(dent->d_name) + 1);
1494 1494
 		if(!dbstat->statdname[dbstat->entries - 1]) {
1495 1495
 		    cl_statfree(dbstat);
1496 1496
 		    closedir(dd);
... ...
@@ -1567,7 +1578,7 @@ int cl_statchkdir(const struct cl_stat *dbstat)
1567 1567
 	    cli_strbcasestr(dent->d_name, ".inc")   ||
1568 1568
 	    cli_strbcasestr(dent->d_name, ".cvd"))) {
1569 1569
 
1570
-                fname = cli_calloc(strlen(dbstat->dir) + strlen(dent->d_name) + 32, sizeof(char));
1570
+                fname = cli_malloc(strlen(dbstat->dir) + strlen(dent->d_name) + 32);
1571 1571
 		if(!fname) {
1572 1572
 		    closedir(dd);
1573 1573
 		    return CL_EMEM;